aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/bluetooth
diff options
context:
space:
mode:
authorTakanori Watanabe <takawata@FreeBSD.org>2017-04-27 15:03:24 +0000
committerTakanori Watanabe <takawata@FreeBSD.org>2017-04-27 15:03:24 +0000
commit4aa92fe2f385fa66a86878dd38e29cde6c28ece7 (patch)
tree118a668c3443572267cfcc3b5b43a326489a5a7b /usr.sbin/bluetooth
parent791c9d7848b38e9ef3f8f1b78d0e00a2fbafa542 (diff)
Notes
Diffstat (limited to 'usr.sbin/bluetooth')
-rw-r--r--usr.sbin/bluetooth/hccontrol/node.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/usr.sbin/bluetooth/hccontrol/node.c b/usr.sbin/bluetooth/hccontrol/node.c
index f1f2694a22859..2a08e0e89cbe4 100644
--- a/usr.sbin/bluetooth/hccontrol/node.c
+++ b/usr.sbin/bluetooth/hccontrol/node.c
@@ -208,12 +208,59 @@ hci_flush_neighbor_cache(int s, int argc, char **argv)
return (OK);
} /* hci_flush_neighbor_cache */
+#define MIN(a,b) (((a)>(b)) ? (b) :(a) )
+
+static int hci_dump_adv(uint8_t *data, int length)
+{
+ int elemlen;
+ int type;
+ int i;
+
+ while(length>0){
+ elemlen = *data;
+ data++;
+ length --;
+ elemlen--;
+ if(length<=0)
+ break;
+ type = *data;
+ data++;
+ length --;
+ elemlen--;
+ if(length<=0)
+ break;
+ switch(type){
+ case 0x1:
+ printf("NDflag:%x\n", *data);
+ break;
+ case 0x9:
+ printf("LocalName:");
+ for(i = 0; i < MIN(length,elemlen); i++){
+ putchar(data[i]);
+ }
+ printf("\n");
+ break;
+ default:
+ printf("Type%d:", type);
+ for(i=0; i < MIN(length,elemlen); i++){
+ printf("%02x ",data[i]);
+ }
+ printf("\n");
+ break;
+ }
+ data += elemlen;
+ length -= elemlen;
+ }
+ return 0;
+}
+#undef MIN
/* Send Read_Neighbor_Cache command to the node */
static int
hci_read_neighbor_cache(int s, int argc, char **argv)
{
struct ng_btsocket_hci_raw_node_neighbor_cache r;
int n, error = OK;
+ const char *addrtype2str[] = {"B", "P", "R", "E"};
memset(&r, 0, sizeof(r));
r.num_entries = NG_HCI_MAX_NEIGHBOR_NUM;
@@ -231,6 +278,7 @@ hci_read_neighbor_cache(int s, int argc, char **argv)
}
fprintf(stdout,
+"T " \
"BD_ADDR " \
"Features " \
"Clock offset " \
@@ -238,12 +286,16 @@ hci_read_neighbor_cache(int s, int argc, char **argv)
"Rep. scan\n");
for (n = 0; n < r.num_entries; n++) {
+ uint8_t addrtype = r.entries[n].addrtype;
+ if(addrtype >= sizeof(addrtype2str)/sizeof(addrtype2str[0]))
+ addrtype = sizeof(addrtype2str)/sizeof(addrtype2str[0]) - 1;
fprintf(stdout,
-"%-17.17s " \
+"%1s %-17.17s " \
"%02x %02x %02x %02x %02x %02x %02x %02x " \
"%#12x " \
"%#9x " \
"%#9x\n",
+ addrtype2str[addrtype],
hci_bdaddr2str(&r.entries[n].bdaddr),
r.entries[n].features[0], r.entries[n].features[1],
r.entries[n].features[2], r.entries[n].features[3],
@@ -251,6 +303,9 @@ hci_read_neighbor_cache(int s, int argc, char **argv)
r.entries[n].features[6], r.entries[n].features[7],
r.entries[n].clock_offset, r.entries[n].page_scan_mode,
r.entries[n].page_scan_rep_mode);
+ hci_dump_adv(r.entries[n].extinq_data,
+ r.entries[n].extinq_size);
+ fprintf(stdout,"\n");
}
out:
free(r.entries);