Page MenuHomeFreeBSD

D10362.id27466.diff
No OneTemporary

D10362.id27466.diff

Index: lib/libbluetooth/bluetooth.h
===================================================================
--- lib/libbluetooth/bluetooth.h
+++ lib/libbluetooth/bluetooth.h
@@ -46,6 +46,7 @@
#include <bitstring.h>
#include <netgraph/ng_message.h>
+#include <netgraph/bluetooth/include/ng_bluetooth.h>
#include <netgraph/bluetooth/include/ng_hci.h>
#include <netgraph/bluetooth/include/ng_l2cap.h>
#include <netgraph/bluetooth/include/ng_btsocket.h>
Index: sys/netgraph/bluetooth/hci/ng_hci_evnt.c
===================================================================
--- sys/netgraph/bluetooth/hci/ng_hci_evnt.c
+++ sys/netgraph/bluetooth/hci/ng_hci_evnt.c
@@ -417,7 +417,6 @@
} else
getmicrotime(&n->updated);
-#if 0
{
/*
* TODO: Make these information
@@ -425,21 +424,36 @@
*/
u_int8_t length_data;
- char *rssi;
-
NG_HCI_M_PULLUP(event, sizeof(u_int8_t));
+ if(event == NULL){
+ NG_HCI_WARN("%s: Event datasize Pullup Failed\n", __func__);
+ goto out;
+ }
length_data = *mtod(event, u_int8_t *);
m_adj(event, sizeof(u_int8_t));
+ n->extinq_size = (length_data < NG_HCI_EXTINQ_MAX)?
+ length_data : NG_HCI_EXTINQ_MAX;
+
/*Advertizement data*/
- NG_HCI_M_PULLUP(event, length_data);
- m_adj(event, length_data);
+ NG_HCI_M_PULLUP(event, n->extinq_size);
+ if(event == NULL){
+ NG_HCI_WARN("%s: Event data pullup Failed\n", __func__);
+ goto out;
+ }
+ m_copydata(event, 0, n->extinq_size, n->extinq_data);
+ m_adj(event, n->extinq_size);
NG_HCI_M_PULLUP(event, sizeof(char ));
/*Get RSSI*/
- rssi = mtod(event, char *);
+ if(event == NULL){
+ NG_HCI_WARN("%s: Event rssi pull up Failed\n", __func__);
+
+ goto out;
+ }
+ n->page_scan_mode = *mtod(event, char *);
m_adj(event, sizeof(u_int8_t));
}
-#endif
}
+ out:
NG_FREE_M(event);
return (error);
Index: sys/netgraph/bluetooth/hci/ng_hci_main.c
===================================================================
--- sys/netgraph/bluetooth/hci/ng_hci_main.c
+++ sys/netgraph/bluetooth/hci/ng_hci_main.c
@@ -93,7 +93,22 @@
MODULE_VERSION(ng_hci, NG_BLUETOOTH_VERSION);
MODULE_DEPEND(ng_hci, ng_bluetooth, NG_BLUETOOTH_VERSION,
NG_BLUETOOTH_VERSION, NG_BLUETOOTH_VERSION);
+static int ng_hci_linktype_to_addrtype(int linktype);
+static int ng_hci_linktype_to_addrtype(int linktype)
+{
+ switch(linktype){
+ case NG_HCI_LINK_LE_PUBLIC:
+ return BDADDR_LE_PUBLIC;
+ case NG_HCI_LINK_LE_RANDOM:
+ return BDADDR_LE_RANDOM;
+ case NG_HCI_LINK_ACL:
+ /*FALLTHROUGH*/
+ default:
+ return BDADDR_BREDR;
+ }
+ return BDADDR_BREDR;
+}
/*****************************************************************************
*****************************************************************************
** Netgraph methods implementation
@@ -481,11 +496,15 @@
e2->page_scan_rep_mode = n->page_scan_rep_mode;
e2->page_scan_mode = n->page_scan_mode;
e2->clock_offset = n->clock_offset;
+ e2->addrtype =
+ ng_hci_linktype_to_addrtype(n->addrtype);
+ e2->extinq_size = n->extinq_size;
bcopy(&n->bdaddr, &e2->bdaddr,
sizeof(e2->bdaddr));
bcopy(&n->features, &e2->features,
sizeof(e2->features));
-
+ bcopy(&n->extinq_data, &e2->extinq_data,
+ n->extinq_size);
e2 ++;
if (--s <= 0)
break;
Index: sys/netgraph/bluetooth/hci/ng_hci_var.h
===================================================================
--- sys/netgraph/bluetooth/hci/ng_hci_var.h
+++ sys/netgraph/bluetooth/hci/ng_hci_var.h
@@ -210,7 +210,8 @@
u_int8_t page_scan_rep_mode; /* PS rep. mode */
u_int8_t page_scan_mode; /* page scan mode */
u_int16_t clock_offset; /* clock offset */
-
+ uint8_t extinq_size;
+ uint8_t extinq_data[NG_HCI_EXTINQ_MAX];
LIST_ENTRY(ng_hci_neighbor) next;
} ng_hci_neighbor_t;
typedef ng_hci_neighbor_t * ng_hci_neighbor_p;
Index: sys/netgraph/bluetooth/include/ng_bluetooth.h
===================================================================
--- sys/netgraph/bluetooth/include/ng_bluetooth.h
+++ sys/netgraph/bluetooth/include/ng_bluetooth.h
@@ -224,5 +224,9 @@
u_int32_t bluetooth_l2cap_ertx_timeout (void);
u_int32_t bluetooth_sco_rtx_timeout (void);
+#define BDADDR_BREDR 0
+#define BDADDR_LE_PUBLIC 1
+#define BDADDR_LE_RANDOM 2
+
#endif /* _NETGRAPH_BLUETOOTH_H_ */
Index: sys/netgraph/bluetooth/include/ng_btsocket.h
===================================================================
--- sys/netgraph/bluetooth/include/ng_btsocket.h
+++ sys/netgraph/bluetooth/include/ng_btsocket.h
@@ -228,10 +228,6 @@
bdaddr_t l2cap_bdaddr; /* address */
};
-#define BDADDR_BREDR 0
-#define BDADDR_LE_PUBLIC 1
-#define BDADDR_LE_RANDOM 2
-
struct sockaddr_l2cap {
u_char l2cap_len; /* total length */
u_char l2cap_family; /* address family */
Index: sys/netgraph/bluetooth/include/ng_hci.h
===================================================================
--- sys/netgraph/bluetooth/include/ng_hci.h
+++ sys/netgraph/bluetooth/include/ng_hci.h
@@ -80,6 +80,7 @@
#define NG_HCI_FEATURES_SIZE 8 /* LMP features */
#define NG_HCI_UNIT_NAME_SIZE 248 /* unit name size */
#define NG_HCI_COMMANDS_SIZE 64 /*Command list BMP size*/
+#define NG_HCI_EXTINQ_MAX 240 /**/
/* HCI specification */
#define NG_HCI_SPEC_V10 0x00 /* v1.0 */
#define NG_HCI_SPEC_V11 0x01 /* v1.1 */
@@ -561,6 +562,9 @@
u_int16_t clock_offset; /* clock offset */
bdaddr_t bdaddr; /* bdaddr */
u_int8_t features[NG_HCI_FEATURES_SIZE]; /* features */
+ uint8_t addrtype;
+ uint8_t extinq_size; /* MAX 240*/
+ uint8_t extinq_data[NG_HCI_EXTINQ_MAX];
} ng_hci_node_neighbor_cache_entry_ep;
#define NG_HCI_MAX_NEIGHBOR_NUM \
Index: usr.sbin/bluetooth/hccontrol/node.c
===================================================================
--- usr.sbin/bluetooth/hccontrol/node.c
+++ usr.sbin/bluetooth/hccontrol/node.c
@@ -208,12 +208,59 @@
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 @@
}
fprintf(stdout,
+"T " \
"BD_ADDR " \
"Features " \
"Clock offset " \
@@ -238,12 +286,16 @@
"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 @@
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);

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 26, 10:50 AM (11 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15603959
Default Alt Text
D10362.id27466.diff (7 KB)

Event Timeline