FreeBSD/usr.sbin/bluetooth/hccontrol/node.c
/* Send Read_Neighbor_Cache command to the node */
Send Read_Neighbor_Cache command to the node
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;
	memset(&r, 0, sizeof(r));
	r.num_entries = NG_HCI_MAX_NEIGHBOR_NUM;
	r.entries = calloc(NG_HCI_MAX_NEIGHBOR_NUM,
				sizeof(ng_hci_node_neighbor_cache_entry_ep));
	if (r.entries == NULL) {
		errno = ENOMEM;
		return (ERROR);
	}
	if (ioctl(s, SIOC_HCI_RAW_NODE_GET_NEIGHBOR_CACHE, &r,
			sizeof(r)) < 0) {
		error = ERROR;
		goto out;
	}
	fprintf(stdout,
"BD_ADDR           " \
"Features                " \
"Clock offset " \
"Page scan " \
"Rep. scan\n");
	for (n = 0; n < r.num_entries; n++) {
		fprintf(stdout, 
"%-17.17s " \
"%02x %02x %02x %02x %02x %02x %02x %02x " \
"%#12x " \
"%#9x " \
"%#9x\n",
			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],
			r.entries[n].features[4], r.entries[n].features[5],
			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);
	}
out:
	free(r.entries);
	return (error);
}
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 ; memset ( & r , 0 , sizeof ( r ) ) ; r . num_entries = NG_HCI_MAX_NEIGHBOR_NUM ; r . entries = calloc ( NG_HCI_MAX_NEIGHBOR_NUM , sizeof ( ng_hci_node_neighbor_cache_entry_ep ) ) ; if ( r . entries == NULL ) { errno = ENOMEM ; return ( ERROR ) ; } if ( ioctl ( s , SIOC_HCI_RAW_NODE_GET_NEIGHBOR_CACHE , & r , sizeof ( r ) ) < 0 ) { error = ERROR ; goto out ; } fprintf ( stdout , " " " " " " " " " \n " ) ; for ( n = 0 ; n < r . num_entries ; n ++ ) { fprintf ( stdout , " " " " " " " " " \n " , 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 ] , r . entries [ n ] . features [ 4 ] , r . entries [ n ] . features [ 5 ] , 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 ) ; } out : free ( r . entries ) ; return ( error ) ; }
Send Read_Neighbor_Cache command to the node
Send Read_Neighbor_Cache command to the node