l2test: add option to use SOCK_STREAM
Subsystems (2)
PATCH 1/4 l2test: add option to use SOCK_STREAM
--- test/l2test.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
test/l2test.c +6 -1
@@ -1046,6 +1046,7 @@ static void usage(void)"\t[-F fcs] use CRC16 check (default = 1)\n" "\t[-R] reliable mode\n" "\t[-G] use connectionless channel (datagram)\n" +"\t[-U] use sock stream\n" "\t[-A] request authentication\n" "\t[-E] request encryption\n" "\t[-S] secure connection\n"
@@ -1060,7 +1061,7 @@ int main(int argc, char *argv[])bacpy (&bdaddr,BDADDR_ANY ); -while ((opt=getopt (argc,argv,"rdscuwmnxyzpb:i:P:I:O:B:N:L:W:C:D:X:F:RGAESMT" )) !=EOF ) { +while ((opt=getopt (argc,argv,"rdscuwmnxyzpb:i:P:I:O:B:N:L:W:C:D:X:F:RGUAESMT" )) !=EOF ) {switch (opt) {case 'r' : mode =RECV ;
@@ -1199,6 +1200,10 @@ int main(int argc, char *argv[]) socktype =SOCK_DGRAM ;break ; +case 'U' : + socktype =SOCK_STREAM ; +break ; +case 'T' : timestamp =1 ;break ;
Signature · 1 line
1.6.4.4
PATCH 2/4 Add duplex test case to l2test
Use a SOCK_NONBLOCK to send and receive at the same time.
--- test/l2test.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 42 insertions(+), 1 deletions(-)
test/l2test.c +42 -1
@@ -60,6 +60,8 @@ enum {LSEND ,SENDDUMP ,LSENDDUMP , +LSENDRECV , +CSENDRECV ,INFOREQ , PAIRING, };
@@ -775,6 +777,22 @@ static void senddump_mode(int sk)dump_mode (sk); } +static void send_and_recv_mode (int sk) +{ +int flags; + +if ((flags =fcntl (sk,F_GETFL ,0 )) <0 ) + flags =0 ; +fcntl (sk,F_SETFL , flags |O_NONBLOCK ); + +/* fork for duplex channel */ +if (fork ()) +send_mode (sk); +else +recv_mode (sk); +return ; +} +static void reconnect_mode (char *svr) {while (1 ) {
@@ -1024,6 +1042,8 @@ static void usage(void)"\t-w listen and send\n" "\t-d listen and dump incoming data\n" "\t-x listen, then send, then dump incoming data\n" +"\t-t listen, then send and receive at the same time\n" +"\t-q connect, then send and receive at the same time\n" "\t-s connect and send\n" "\t-u connect and receive\n" "\t-n connect and be silent\n"
@@ -1061,7 +1081,7 @@ int main(int argc, char *argv[])bacpy (&bdaddr,BDADDR_ANY ); -while ((opt=getopt (argc,argv,"rdscuwmnxyzpb:i:P:I:O:B:N:L:W:C:D:X:F:RGUAESMT" )) !=EOF ) { +while ((opt=getopt (argc,argv,"rdscuwmntqxyzpb:i:P:I:O:B:N:L:W:C:D:X:F:RUGAESMT" )) !=EOF ) {switch (opt) {case 'r' : mode =RECV ;
@@ -1100,6 +1120,15 @@ int main(int argc, char *argv[]) need_addr =1 ;break ; +case 't' : + mode =LSENDRECV ; +break ; + +case 'q' : + mode =CSENDRECV ; + need_addr =1 ; +break ; +case 'x' : mode =LSENDDUMP ;break ;
@@ -1286,6 +1315,18 @@ int main(int argc, char *argv[])do_listen (senddump_mode);break ; +case LSENDRECV : +do_listen (send_and_recv_mode); +break ; + +case CSENDRECV : + sk =do_connect (argv[optind]); +if (sk <0 ) +exit (1 ); + +send_and_recv_mode (sk); +break ; +case INFOREQ :info_request (argv[optind]);exit (0 );
Signature · 1 line
1.6.4.4
PATCH 3/4 Add txWindow and MaxTt to l2cap_options
--- lib/l2cap.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
lib/l2cap.h +2 -0
@@ -52,6 +52,8 @@ struct l2cap_options {uint16_t flush_to;uint8_t mode;uint8_t fcs; +uint8_t max_tx; +uint16_t txwin_size; };#define L2CAP_CONNINFO 0x02
Signature · 1 line
1.6.4.4
PATCH 4/4 Add options to test MaxTx and TxWindow
--- test/l2test.c | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-)
test/l2test.c +21 -1
@@ -75,6 +75,12 @@ static int omtu = 0;/* Default FCS option */ static int fcs =0x01 ; +/* Default Transmission Window */ +static int txwin_size =63 ; + +/* Default Max Transmission */ +static int max_transmit =3 ; +/* Default data size */ static long data_size =-1 ;static long buffer_size =2048 ;
@@ -226,6 +232,8 @@ static int do_connect(char *svr) opts.mode = rfcmode; opts.fcs = fcs; + opts.txwin_size = txwin_size; + opts.max_tx = max_transmit;if (setsockopt (sk,SOL_L2CAP ,L2CAP_OPTIONS , &opts,sizeof (opts)) <0 ) { syslog(LOG_ERR, "Can't set L2CAP options: %s (%d)",
@@ -388,6 +396,8 @@ static void do_listen(void (*handler)(int sk)) opts.mode = rfcmode; opts.fcs = fcs; + opts.txwin_size = txwin_size; + opts.max_tx = max_transmit;if (setsockopt (sk,SOL_L2CAP ,L2CAP_OPTIONS , &opts,sizeof (opts)) <0 ) { syslog(LOG_ERR, "Can't set L2CAP options: %s (%d)",
@@ -1064,6 +1074,8 @@ static void usage(void)"\t[-D milliseconds] delay after sending num frames (default = 0)\n" "\t[-X mode] select retransmission/flow-control mode\n" "\t[-F fcs] use CRC16 check (default = 1)\n" +"\t[-Q num] Max Transmit value (default = 3)\n" +"\t[-Z size] Transmission Window size (default = 63)\n" "\t[-R] reliable mode\n" "\t[-G] use connectionless channel (datagram)\n" "\t[-U] use sock stream\n"
@@ -1081,7 +1093,7 @@ int main(int argc, char *argv[])bacpy (&bdaddr,BDADDR_ANY ); -while ((opt=getopt (argc,argv,"rdscuwmntqxyzpb:i:P:I:O:B:N:L:W:C:D:X:F:RUGAESMT" )) !=EOF ) { +while ((opt=getopt (argc,argv,"rdscuwmntqxyzpb:i:P:I:O:B:N:L:W:C:D:X:F:Q:Z:RUGAESMT" )) !=EOF ) {switch (opt) {case 'r' : mode =RECV ;
@@ -1237,6 +1249,14 @@ int main(int argc, char *argv[]) timestamp =1 ;break ; +case 'Q' : + max_transmit =atoi (optarg); +break ; + +case 'Z' : + txwin_size =atoi (optarg); +break ; +default :usage ();exit (1 );
Signature · 1 line
1.6.4.4
Hi,
Quoted 3 lines · Gustavo F. Padovan
--- test/l2test.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
All four patches have now been pushed upstream. Thanks.
Johan