Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/bluetooth/hccontrol/node.c
Show All 34 Lines | |||||
#define L2CAP_SOCKET_CHECKED | #define L2CAP_SOCKET_CHECKED | ||||
#include <bluetooth.h> | #include <bluetooth.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <netgraph/ng_message.h> | #include <netgraph/ng_message.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <uuid.h> | |||||
#include "hccontrol.h" | #include "hccontrol.h" | ||||
/* Send Read_Node_State command to the node */ | /* Send Read_Node_State command to the node */ | ||||
static int | static int | ||||
hci_read_node_state(int s, int argc, char **argv) | hci_read_node_state(int s, int argc, char **argv) | ||||
{ | { | ||||
struct ng_btsocket_hci_raw_node_state r; | struct ng_btsocket_hci_raw_node_state r; | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | static int hci_dump_adv(uint8_t *data, int length) | ||||
int elemlen; | int elemlen; | ||||
int type; | int type; | ||||
int i; | int i; | ||||
while(length>0){ | while(length>0){ | ||||
elemlen = *data; | elemlen = *data; | ||||
data++; | data++; | ||||
length --; | length --; | ||||
elemlen--; | |||||
if(length<=0) | if(length<=0) | ||||
break; | break; | ||||
type = *data; | type = *data; | ||||
data++; | data++; | ||||
length --; | length --; | ||||
elemlen--; | elemlen--; | ||||
if(length<=0) | if(length <= 0) | ||||
break; | break; | ||||
switch(type){ | switch(type){ | ||||
case 0x1: | case 0x1: | ||||
printf("NDflag:%x\n", *data); | printf("NDflag:%x\n", *data); | ||||
break; | break; | ||||
case 0x8: | |||||
case 0x9: | case 0x9: | ||||
printf("LocalName:"); | printf("LocalName:"); | ||||
for(i = 0; i < MIN(length,elemlen); i++){ | for(i = 0; i < MIN(length,elemlen); i++){ | ||||
putchar(data[i]); | putchar(data[i]); | ||||
} | |||||
printf("\n"); | |||||
break; | |||||
case 0x6: | |||||
case 0x7: | |||||
{ | |||||
uuid_t uuid; | |||||
char *uuidstr; | |||||
uint32_t ustatus; | |||||
if (elemlen < 16) | |||||
break; | |||||
uuid.time_low = le32dec(data+12); | |||||
uuid.time_mid = le16dec(data+10); | |||||
uuid.time_hi_and_version = le16dec(data+8); | |||||
uuid.clock_seq_hi_and_reserved = data[7]; | |||||
uuid.clock_seq_low = data[6]; | |||||
for(i = 0; i < _UUID_NODE_LEN; i++){ | |||||
uuid.node[i] = data[5 - i]; | |||||
} | |||||
uuid_to_string(&uuid, &uuidstr, &ustatus); | |||||
printf("ServiceUUID: %s\n", uuidstr); | |||||
break; | |||||
} | |||||
case 0xff: | |||||
if (elemlen < 2) | |||||
break; | |||||
printf("Vendor:%04x:", data[0]|data[1]<<8); | |||||
for (i = 2; i < MIN(length,elemlen); i++) { | |||||
printf("%02x ",data[i]); | |||||
} | } | ||||
printf("\n"); | printf("\n"); | ||||
break; | break; | ||||
default: | default: | ||||
printf("Type%d:", type); | printf("Type%d:", type); | ||||
for(i=0; i < MIN(length,elemlen); i++){ | for(i=0; i < MIN(length,elemlen); i++){ | ||||
printf("%02x ",data[i]); | printf("%02x ",data[i]); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 416 Lines • Show Last 20 Lines |