diff --git a/tools/oobtest.c b/tools/oobtest.c
index 67aafc2..5215c12 100644
--- a/tools/oobtest.c
+++ b/tools/oobtest.c
static bool use_bredr = false;
static bool use_le = false;
+static bool use_sc = false;
+static bool use_sconly = false;
static bool provide_p192 = false;
static bool provide_p256 = false;
fprintf(stderr, "Reading OOB data for index %u failed: %s\n",
index, mgmt_errstr(status));
mainloop_quit();
+ return;
}
printf("[Index %u]\n", index);
fprintf(stderr, "Reading info for index %u failed: %s\n",
index, mgmt_errstr(status));
mainloop_quit();
+ return;
}
ba2str(&rp->bdaddr, str);
else if (index == index2)
bacpy(&bdaddr2, &rp->bdaddr);
+ supported_settings = le32_to_cpu(rp->supported_settings);
+
+ if (use_bredr && !(supported_settings & MGMT_SETTING_BREDR)) {
+ fprintf(stderr, "BR/EDR support missing\n");
+ mainloop_quit();
+ return;
+ }
+
+ if (use_bredr && !(supported_settings & MGMT_SETTING_SSP)) {
+ fprintf(stderr, "Secure Simple Pairing support missing\n");
+ mainloop_quit();
+ return;
+ }
+
+ if (use_le && !(supported_settings & MGMT_SETTING_LE)) {
+ fprintf(stderr, "Low Energy support missing\n");
+ mainloop_quit();
+ return;
+ }
+
+ if (use_sc && !(supported_settings & MGMT_SETTING_SECURE_CONN)) {
+ fprintf(stderr, "Secure Connections support missing\n");
+ mainloop_quit();
+ return;
+ }
+
+ if (use_sconly && !(supported_settings & MGMT_SETTING_SECURE_CONN)) {
+ fprintf(stderr, "Secure Connections Only support missing\n");
+ mainloop_quit();
+ return;
+ }
+
mgmt_register(mgmt, MGMT_EV_NEW_LINK_KEY, index,
new_link_key_event,
UINT_TO_PTR(index), NULL);
new_long_term_key_event,
UINT_TO_PTR(index), NULL);
- supported_settings = le32_to_cpu(rp->supported_settings);
-
-
val = 0x00;
mgmt_send(mgmt, MGMT_OP_SET_POWERED, index, 1, &val,
NULL, NULL, NULL);
+ clear_link_keys(index);
+ clear_long_term_keys(index);
+ clear_remote_oob_data(index);
+
if (use_bredr) {
val = 0x01;
mgmt_send(mgmt, MGMT_OP_SET_BREDR, index, 1, &val,
val = 0x01;
mgmt_send(mgmt, MGMT_OP_SET_SSP, index, 1, &val,
NULL, NULL, NULL);
-
- clear_link_keys(index);
- } else {
+ } else if (use_le) {
val = 0x01;
mgmt_send(mgmt, MGMT_OP_SET_LE, index, 1, &val,
NULL, NULL, NULL);
val = 0x00;
mgmt_send(mgmt, MGMT_OP_SET_BREDR, index, 1, &val,
NULL, NULL, NULL);
-
- clear_long_term_keys(index);
+ } else {
+ fprintf(stderr, "Invalid transport for pairing\n");
+ mainloop_quit();
+ return;
}
- if (supported_settings & MGMT_SETTING_SECURE_CONN) {
+ if (use_sc) {
val = 0x01;
mgmt_send(mgmt, MGMT_OP_SET_SECURE_CONN, index, 1, &val,
NULL, NULL, NULL);
+ } else if (use_sconly) {
+ val = 0x02;
+ mgmt_send(mgmt, MGMT_OP_SET_SECURE_CONN, index, 1, &val,
+ NULL, NULL, NULL);
+ } else {
+ val = 0x00;
+ mgmt_send(mgmt, MGMT_OP_SET_SECURE_CONN, index, 1, &val,
+ NULL, NULL, NULL);
}
val = 0x01;
mgmt_send(mgmt, MGMT_OP_SET_POWERED, index, 1, &val,
NULL, NULL, NULL);
- clear_remote_oob_data(index);
-
- if (use_bredr) {
+ if (use_bredr && (provide_p192 || provide_p256)) {
mgmt_send(mgmt, MGMT_OP_READ_LOCAL_OOB_DATA, index, 0, NULL,
read_oob_data_complete,
UINT_TO_PTR(index), NULL);
fprintf(stderr, "Reading index list failed: %s\n",
mgmt_errstr(status));
mainloop_quit();
+ return;
}
count = le16_to_cpu(rp->num_controllers);
if (count < 2) {
fprintf(stderr, "At least 2 controllers are required\n");
mainloop_quit();
+ return;
}
for (i = 0; i < count; i++) {
printf("options:\n"
"\t-B, --bredr Use BR/EDR transport\n"
"\t-L, --le Use LE transport\n"
+ "\t-S, --sc Use Secure Connections\n"
+ "\t-O, --sconly Use Secure Connections Only\n"
+ "\t-1, --p192 Provide P-192 OOB data\n"
+ "\t-2, --p256 Provide P-256 OOB data\n"
"\t-h, --help Show help options\n");
}
static const struct option main_options[] = {
{ "bredr", no_argument, NULL, 'B' },
{ "le", no_argument, NULL, 'L' },
+ { "sc", no_argument, NULL, 'S' },
+ { "sconly", no_argument, NULL, 'O' },
{ "p192", no_argument, NULL, '1' },
{ "p256", no_argument, NULL, '2' },
{ "version", no_argument, NULL, 'v' },
for (;;) {
int opt;
- opt = getopt_long(argc, argv, "BL12vh", main_options, NULL);
+ opt = getopt_long(argc, argv, "BLSO12vh", main_options, NULL);
if (opt < 0)
break;
case 'L':
use_le = true;
break;
+ case 'S':
+ use_sc = true;
+ break;
+ case 'O':
+ use_sconly = true;
+ break;
case '1':
provide_p192 = true;
break;
return EXIT_FAILURE;
}
- if (!use_bredr && !use_le) {
- fprintf(stderr, "Missing transport option\n");
+ if (use_bredr == use_le) {
+ fprintf(stderr, "Specify either --bredr or --le\n");
return EXIT_FAILURE;
}
- if (!provide_p192 && !provide_p256) {
- provide_p192 = true;
- provide_p256 = true;
+ if (use_sc && use_sconly) {
+ fprintf(stderr, "Only --sc or --sconly can be used\n");
+ return EXIT_FAILURE;
}
mainloop_init();