diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-08-01 08:07:42 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-08-01 08:07:42 +0000 |
commit | b42e7c67689f7c93e2eb7a54dd677a5c5e23df59 (patch) | |
tree | 486650ce67aea836200e641340d3bb5558d4270d | |
parent | 6b73e8982c860eb59784458b9c10d0ef6b375099 (diff) |
Add commands for Simple Pairing
-rw-r--r-- | tools/hciconfig.8 | 9 | ||||
-rw-r--r-- | tools/hciconfig.c | 65 | ||||
-rw-r--r-- | tools/hcisecfilter.c | 13 |
3 files changed, 82 insertions, 5 deletions
diff --git a/tools/hciconfig.8 b/tools/hciconfig.8 index da39a40c..fc8d69bf 100644 --- a/tools/hciconfig.8 +++ b/tools/hciconfig.8 @@ -183,6 +183,12 @@ With no prints out the current AFH mode. Otherwise, sets AFH mode to .IR mode . .TP +.BI sspmode " [mode]" +With no +.IR mode , +prints out the current Simple Pairing mode. Otherwise, sets Simple Pairing mode to +.IR mode . +.TP \fBaclmtu\fP \fImtu\fP:\fIpkt\fP Sets ACL MTU to to @@ -208,6 +214,9 @@ This command deletes the stored link key for .I bdaddr from the device. .TP +.BI oobdata +Display local OOB data. +.TP .BI commands Display supported commands. .TP diff --git a/tools/hciconfig.c b/tools/hciconfig.c index 430cd0c3..998b6145 100644 --- a/tools/hciconfig.c +++ b/tools/hciconfig.c @@ -885,6 +885,36 @@ static void cmd_delkey(int ctl, int hdev, char *opt) hci_close_dev(dd); } +static void cmd_oob_data(int ctl, int hdev, char *opt) +{ + uint8_t hash[16], randomizer[16]; + int i, dd; + + dd = hci_open_dev(hdev); + if (dd < 0) { + fprintf(stderr, "Can't open device hci%d: %s (%d)\n", + hdev, strerror(errno), errno); + exit(1); + } + + if (hci_read_local_oob_data(dd, hash, randomizer, 1000) < 0) { + fprintf(stderr, "Can't read local OOB data on hci%d: %s (%d)\n", + hdev, strerror(errno), errno); + exit(1); + } + + print_dev_hdr(&di); + printf("\tOOB Hash: "); + for (i = 0; i < 16; i++) + printf(" %02x", hash[i]); + printf("\n\tRandomizer:"); + for (i = 0; i < 16; i++) + printf(" %02x", randomizer[i]); + printf("\n"); + + hci_close_dev(dd); +} + static void cmd_commands(int ctl, int hdev, char *opt) { uint8_t cmds[64]; @@ -1365,6 +1395,39 @@ static void cmd_afh_mode(int ctl, int hdev, char *opt) } } +static void cmd_ssp_mode(int ctl, int hdev, char *opt) +{ + int dd; + + dd = hci_open_dev(hdev); + if (dd < 0) { + fprintf(stderr, "Can't open device hci%d: %s (%d)\n", + hdev, strerror(errno), errno); + exit(1); + } + + if (opt) { + uint8_t mode = atoi(opt); + + if (hci_write_simple_pairing_mode(dd, mode, 2000) < 0) { + fprintf(stderr, "Can't set Simple Pairing mode on hci%d: %s (%d)\n", + hdev, strerror(errno), errno); + exit(1); + } + } else { + uint8_t mode; + + if (hci_read_simple_pairing_mode(dd, &mode, 1000) < 0) { + fprintf(stderr, "Can't read Simple Pairing mode on hci%d: %s (%d)\n", + hdev, strerror(errno), errno); + exit(1); + } + + print_dev_hdr(&di); + printf("\tSimple Pairing mode: %s\n", mode == 1 ? "Enabled" : "Disabled"); + } +} + static void print_rev_ericsson(int dd) { struct hci_request rq; @@ -1571,10 +1634,12 @@ static struct { { "pageparms", cmd_page_parms, "[win:int]", "Get/Set page scan window and interval" }, { "pageto", cmd_page_to, "[to]", "Get/Set page timeout" }, { "afhmode", cmd_afh_mode, "[mode]", "Get/Set AFH mode" }, + { "sspmode", cmd_ssp_mode, "[mode]", "Get/Set Simple Pairing Mode" }, { "aclmtu", cmd_aclmtu, "<mtu:pkt>", "Set ACL MTU and number of packets" }, { "scomtu", cmd_scomtu, "<mtu:pkt>", "Set SCO MTU and number of packets" }, { "putkey", cmd_putkey, "<bdaddr>", "Store link key on the device" }, { "delkey", cmd_delkey, "<bdaddr>", "Delete link key from the device" }, + { "oobdata", cmd_oob_data, 0, "Display local OOB data" }, { "commands", cmd_commands, 0, "Display supported commands" }, { "features", cmd_features, 0, "Display device features" }, { "version", cmd_version, 0, "Display version information" }, diff --git a/tools/hcisecfilter.c b/tools/hcisecfilter.c index 6a4f897b..5bab6389 100644 --- a/tools/hcisecfilter.c +++ b/tools/hcisecfilter.c @@ -81,7 +81,7 @@ int main(void) hci_set_bit(OCF_READ_CLOCK_OFFSET, ocf_mask); hci_set_bit(OCF_READ_LMP_HANDLE, ocf_mask); - printf("OGF_LINK_CTL: { 0x%08x, 0x%08x, 0x%06x, 0x%02x }\n", + printf("OGF_LINK_CTL: { 0x%08x, 0x%08x, 0x%08x, 0x%02x }\n", ocf_mask[0], ocf_mask[1], ocf_mask[2], ocf_mask[3]); /* OGF_LINK_POLICY */ @@ -90,7 +90,7 @@ int main(void) hci_set_bit(OCF_READ_LINK_POLICY, ocf_mask); hci_set_bit(OCF_READ_DEFAULT_LINK_POLICY, ocf_mask); - printf("OGF_LINK_POLICY: { 0x%08x, 0x%08x, 0x%06x, 0x%02x }\n", + printf("OGF_LINK_POLICY: { 0x%08x, 0x%08x, 0x%08x, 0x%02x }\n", ocf_mask[0], ocf_mask[1], ocf_mask[2], ocf_mask[3]); /* OGF_HOST_CTL */ @@ -120,8 +120,11 @@ int main(void) hci_set_bit(OCF_READ_PAGE_SCAN_TYPE, ocf_mask); hci_set_bit(OCF_READ_AFH_MODE, ocf_mask); hci_set_bit(OCF_READ_EXT_INQUIRY_RESPONSE, ocf_mask); + hci_set_bit(OCF_READ_SIMPLE_PAIRING_MODE, ocf_mask); + hci_set_bit(OCF_READ_INQUIRY_TRANSMIT_POWER_LEVEL, ocf_mask); + hci_set_bit(OCF_READ_DEFAULT_ERROR_DATA_REPORTING, ocf_mask); - printf("OGF_HOST_CTL: { 0x%08x, 0x%08x, 0x%06x, 0x%02x }\n", + printf("OGF_HOST_CTL: { 0x%08x, 0x%08x, 0x%08x, 0x%02x }\n", ocf_mask[0], ocf_mask[1], ocf_mask[2], ocf_mask[3]); /* OGF_INFO_PARAM */ @@ -134,7 +137,7 @@ int main(void) hci_set_bit(OCF_READ_COUNTRY_CODE, ocf_mask); hci_set_bit(OCF_READ_BD_ADDR, ocf_mask); - printf("OGF_INFO_PARAM: { 0x%08x, 0x%08x, 0x%06x, 0x%02x }\n", + printf("OGF_INFO_PARAM: { 0x%08x, 0x%08x, 0x%08x, 0x%02x }\n", ocf_mask[0], ocf_mask[1], ocf_mask[2], ocf_mask[3]); /* OGF_STATUS_PARAM */ @@ -145,7 +148,7 @@ int main(void) hci_set_bit(OCF_READ_AFH_MAP, ocf_mask); hci_set_bit(OCF_READ_CLOCK, ocf_mask); - printf("OGF_STATUS_PARAM: { 0x%08x, 0x%08x, 0x%06x, 0x%02x }\n", + printf("OGF_STATUS_PARAM: { 0x%08x, 0x%08x, 0x%08x, 0x%02x }\n", ocf_mask[0], ocf_mask[1], ocf_mask[2], ocf_mask[3]); return 0; |