FreeBSD/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c
/* Send Delete_Stored_Link_Key command to the unit */
Send Delete_Stored_Link_Key command to the unit
Send Delete_Stored_Link_Key command to the unit
static int
hci_delete_stored_link_key(int s, int argc, char **argv)
{
	ng_hci_delete_stored_link_key_cp	cp;
	ng_hci_delete_stored_link_key_rp	rp;
	int32_t					n;
	memset(&cp, 0, sizeof(cp));
	switch (argc) {
	case 1:
		if (!bt_aton(argv[0], &cp.bdaddr)) {
			struct hostent	*he = NULL;
			if ((he = bt_gethostbyname(argv[0])) == NULL)
				return (USAGE);
			memcpy(&cp.bdaddr, he->h_addr, sizeof(cp.bdaddr));
		}
		break;
	default:
		cp.delete_all = 1;
		break;
	}
	n = sizeof(cp);
	if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, 
			NG_HCI_OCF_DELETE_STORED_LINK_KEY),
			(char const *) &cp, sizeof(cp),
			(char *) &rp, &n) == ERROR)
		return (ERROR);
	if (rp.status != 0x00) {
		fprintf(stdout, "Status: %s [%#02x]\n", 
			hci_status2str(rp.status), rp.status);
		return (FAILED);
	}
	fprintf(stdout, "Number of keys deleted: %d\n", rp.num_keys_deleted);
	return (OK);
}
static int hci_delete_stored_link_key ( int s , int argc , char * * argv ) { ng_hci_delete_stored_link_key_cp cp ; ng_hci_delete_stored_link_key_rp rp ; int32_t n ; memset ( & cp , 0 , sizeof ( cp ) ) ; switch ( argc ) { case 1 : if ( ! bt_aton ( argv [ 0 ] , & cp . bdaddr ) ) { struct hostent * he = NULL ; if ( ( he = bt_gethostbyname ( argv [ 0 ] ) ) == NULL ) return ( USAGE ) ; memcpy ( & cp . bdaddr , he -> h_addr , sizeof ( cp . bdaddr ) ) ; } break ; default : cp . delete_all = 1 ; break ; } n = sizeof ( cp ) ; if ( hci_request ( s , NG_HCI_OPCODE ( NG_HCI_OGF_HC_BASEBAND , NG_HCI_OCF_DELETE_STORED_LINK_KEY ) , ( char const * ) & cp , sizeof ( cp ) , ( char * ) & rp , & n ) == ERROR ) return ( ERROR ) ; if ( rp . status != 0x00 ) { fprintf ( stdout , " \n " , hci_status2str ( rp . status ) , rp . status ) ; return ( FAILED ) ; } fprintf ( stdout , " \n " , rp . num_keys_deleted ) ; return ( OK ) ; }
Send Delete_Stored_Link_Key command to the unit
Send Delete_Stored_Link_Key command to the unit
/* parse BD_ADDR */ /* send command */