diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2004-11-17 08:28:52 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2004-11-17 08:28:52 +0000 |
commit | 52d36be0bf2610739f04786d18df80db23e9cf6b (patch) | |
tree | ebdf47f821c695d20d4066be8b79ac2f14c282db /test | |
parent | 23b788ad7e8009445323f65b3fb94bb6b11717d0 (diff) |
Add parameter for activating secure mode
Diffstat (limited to 'test')
-rw-r--r-- | test/l2test.c | 34 | ||||
-rw-r--r-- | test/rctest.c | 45 |
2 files changed, 45 insertions, 34 deletions
diff --git a/test/l2test.c b/test/l2test.c index f98e5109..eedf4b70 100644 --- a/test/l2test.c +++ b/test/l2test.c @@ -51,6 +51,8 @@ #include <sys/socket.h> #include <bluetooth/bluetooth.h> +#include <bluetooth/hci.h> +#include <bluetooth/hci_lib.h> #include <bluetooth/l2cap.h> #define NIBBLE_TO_ASCII(c) ((c) < 0x0a ? (c) + 0x30 : (c) + 0x57) @@ -88,6 +90,7 @@ int num_frames = -1; // Infinite int master = 0; int auth = 0; int encrypt = 0; +int secure = 0; int socktype = SOCK_SEQPACKET; int linger = 0; int reliable = 0; @@ -270,15 +273,14 @@ void do_listen(void (*handler)(int sk)) opt = 0; if (reliable) opt |= L2CAP_LM_RELIABLE; - if (master) - opt |= L2CAP_LM_MASTER; - + opt |= L2CAP_LM_MASTER; if (auth) - opt |= L2CAP_LM_AUTH; - + opt |= L2CAP_LM_AUTH; if (encrypt) - opt |= L2CAP_LM_ENCRYPT; + opt |= L2CAP_LM_ENCRYPT; + if (secure) + opt |= L2CAP_LM_SECURE; if (setsockopt(s, SOL_L2CAP, L2CAP_LM, &opt, sizeof(opt)) < 0) { syslog(LOG_ERR, "Can't set L2CAP link mode. %s(%d)", strerror(errno), errno); @@ -570,7 +572,7 @@ void usage(void) "\t-m multiple connects\n"); printf("Options:\n" - "\t[-b bytes] [-S bdaddr] [-P psm]\n" + "\t[-b bytes] [-i device] [-P psm]\n" "\t[-I imtu] [-O omtu]\n" "\t[-N num] send num frames (default = infinite)\n" "\t[-L seconds] enable SO_LINGER\n" @@ -578,6 +580,7 @@ void usage(void) "\t[-D] use connectionless channel (datagram)\n" "\t[-A] request authentication\n" "\t[-E] request encryption\n" + "\t[-S] secure connection\n" "\t[-M] become master\n"); } @@ -590,8 +593,10 @@ int main(int argc ,char *argv[]) struct sigaction sa; mode = RECV; need_addr = 0; - - while ((opt=getopt(argc,argv,"rdscuwmnxyb:P:I:O:S:N:RMAEDL:")) != EOF) { + + bacpy(&bdaddr, BDADDR_ANY); + + while ((opt=getopt(argc,argv,"rdscuwmnxyb:i:P:I:O:N:RMAESL:D")) != EOF) { switch(opt) { case 'r': mode = RECV; @@ -642,8 +647,11 @@ int main(int argc ,char *argv[]) mode = SENDDUMP; break; - case 'S': - baswap(&bdaddr, strtoba(optarg)); + case 'i': + if (!strncasecmp(optarg, "hci", 3)) + hci_devba(atoi(optarg + 3), &bdaddr); + else + str2ba(optarg, &bdaddr); break; case 'P': @@ -678,6 +686,10 @@ int main(int argc ,char *argv[]) encrypt = 1; break; + case 'S': + secure = 1; + break; + case 'D': socktype = SOCK_DGRAM; break; diff --git a/test/rctest.c b/test/rctest.c index 31ecae57..6e5fba27 100644 --- a/test/rctest.c +++ b/test/rctest.c @@ -49,6 +49,8 @@ #include <sys/socket.h> #include <bluetooth/bluetooth.h> +#include <bluetooth/hci.h> +#include <bluetooth/hci_lib.h> #include <bluetooth/rfcomm.h> /* Test modes */ @@ -65,10 +67,6 @@ enum { unsigned char *buf; -/* Default mtu */ -int imtu = 672; -int omtu = 0; - /* Default data size */ long data_size = 127; long num_frames = -1; @@ -80,6 +78,7 @@ uint8_t channel = 10; int master = 0; int auth = 0; int encrypt = 0; +int secure = 0; int socktype = SOCK_STREAM; int linger = 0; @@ -153,13 +152,13 @@ void do_listen( void (*handler)(int sk) ) /* Set link mode */ opt = 0; if (master) - opt |= RFCOMM_LM_MASTER; - + opt |= RFCOMM_LM_MASTER; if (auth) - opt |= RFCOMM_LM_AUTH; - + opt |= RFCOMM_LM_AUTH; if (encrypt) - opt |= RFCOMM_LM_ENCRYPT; + opt |= RFCOMM_LM_ENCRYPT; + if (secure) + opt |= RFCOMM_LM_SECURE; if (setsockopt(s, SOL_RFCOMM, RFCOMM_LM, &opt, sizeof(opt)) < 0) { syslog(LOG_ERR, "Can't set L2CAP link mode. %s(%d)", strerror(errno), errno); @@ -343,8 +342,7 @@ void usage(void) "\t-m multiple connects\n"); printf("Options:\n" - "\t[-b bytes] [-S bdaddr] [-P channel]\n" - "\t[-I imtu] [-O omtu]\n" + "\t[-b bytes] [-i device] [-P channel]\n" "\t[-L seconds] enabled SO_LINGER option\n" "\t[-N num] number of frames to send\n" "\t[-A] request authentication\n" @@ -361,8 +359,10 @@ int main(int argc ,char *argv[]) struct sigaction sa; mode = RECV; need_addr = 0; - - while ((opt=getopt(argc,argv,"rdscuwmnb:P:I:O:S:MAEL:N:")) != EOF) { + + bacpy(&bdaddr, BDADDR_ANY); + + while ((opt=getopt(argc,argv,"rdscuwmnb:i:P:N:MAESL:")) != EOF) { switch(opt) { case 'r': mode = RECV; @@ -405,22 +405,17 @@ int main(int argc ,char *argv[]) data_size = atoi(optarg); break; - case 'S': - baswap(&bdaddr, strtoba(optarg)); + case 'i': + if (!strncasecmp(optarg, "hci", 3)) + hci_devba(atoi(optarg + 3), &bdaddr); + else + str2ba(optarg, &bdaddr); break; case 'P': channel = atoi(optarg); break; - case 'I': - imtu = atoi(optarg); - break; - - case 'O': - omtu = atoi(optarg); - break; - case 'M': master = 1; break; @@ -433,6 +428,10 @@ int main(int argc ,char *argv[]) encrypt = 1; break; + case 'S': + secure = 1; + break; + case 'L': linger = atoi(optarg); break; |