FreeBSD/usr.sbin/bluetooth/hccontrol/node.c
/* Send Read_Connection_List command to the node */
Send Read_Connection_List command to the node
Send Read_Connection_List command to the node
static int
hci_read_connection_list(int s, int argc, char **argv)
{
	struct ng_btsocket_hci_raw_con_list	r;
	int					n, error = OK;
	memset(&r, 0, sizeof(r));
	r.num_connections = NG_HCI_MAX_CON_NUM;
	r.connections = calloc(NG_HCI_MAX_CON_NUM, sizeof(ng_hci_node_con_ep));
	if (r.connections == NULL) {
		errno = ENOMEM;
		return (ERROR);
	}
	if (ioctl(s, SIOC_HCI_RAW_NODE_GET_CON_LIST, &r, sizeof(r)) < 0) {
		error = ERROR;
		goto out;
	}
	fprintf(stdout,
"Remote BD_ADDR    " \
"Handle " \
"Type " \
"Mode " \
"Role " \
"Encrypt " \
"Pending " \
"Queue " \
"State\n");
	for (n = 0; n < r.num_connections; n++) {
		fprintf(stdout,
"%-17.17s " \
"%6d " \
"%4.4s " \
"%4d " \
"%4.4s " \
"%7.7s " \
"%7d " \
"%5d " \
"%s\n",
			hci_bdaddr2str(&r.connections[n].bdaddr),
			r.connections[n].con_handle,
			(r.connections[n].link_type == NG_HCI_LINK_ACL)?
				"ACL" : "SCO",
			r.connections[n].mode,
			(r.connections[n].role == NG_HCI_ROLE_MASTER)?
				"MAST" : "SLAV",
			hci_encrypt2str(r.connections[n].encryption_mode, 1),
			r.connections[n].pending,
			r.connections[n].queue_len,
			hci_con_state2str(r.connections[n].state));
	}
out:
	free(r.connections);
	return (error);
}
static int hci_read_connection_list ( int s , int argc , char * * argv ) { struct ng_btsocket_hci_raw_con_list r ; int n , error = OK ; memset ( & r , 0 , sizeof ( r ) ) ; r . num_connections = NG_HCI_MAX_CON_NUM ; r . connections = calloc ( NG_HCI_MAX_CON_NUM , sizeof ( ng_hci_node_con_ep ) ) ; if ( r . connections == NULL ) { errno = ENOMEM ; return ( ERROR ) ; } if ( ioctl ( s , SIOC_HCI_RAW_NODE_GET_CON_LIST , & r , sizeof ( r ) ) < 0 ) { error = ERROR ; goto out ; } fprintf ( stdout , " " " " " " " " " " " " " " " " " \n " ) ; for ( n = 0 ; n < r . num_connections ; n ++ ) { fprintf ( stdout , " " " " " " " " " " " " " " " " " \n " , hci_bdaddr2str ( & r . connections [ n ] . bdaddr ) , r . connections [ n ] . con_handle , ( r . connections [ n ] . link_type == NG_HCI_LINK_ACL ) ? " " : " " , r . connections [ n ] . mode , ( r . connections [ n ] . role == NG_HCI_ROLE_MASTER ) ? " " : " " , hci_encrypt2str ( r . connections [ n ] . encryption_mode , 1 ) , r . connections [ n ] . pending , r . connections [ n ] . queue_len , hci_con_state2str ( r . connections [ n ] . state ) ) ; } out : free ( r . connections ) ; return ( error ) ; }
Send Read_Connection_List command to the node
Send Read_Connection_List command to the node