Move link key removal from controller to hciops

This commit is contained in:
Johan Hedberg 2010-10-01 15:02:40 +03:00
parent 06dcf6ada5
commit 1bf7ec6b5c
4 changed files with 29 additions and 11 deletions

View File

@ -1048,6 +1048,25 @@ static int hciops_disconnect(int index, uint16_t handle)
return err;
}
static int hciops_remove_bonding(int index, bdaddr_t *bdaddr)
{
int dd, err;
dd = hci_open_dev(index);
if (dd < 0)
return -errno;
/* Delete the link key from the Bluetooth chip */
if (hci_delete_stored_link_key(dd, bdaddr, 0, HCI_REQ_TIMEOUT) < 0)
err = -errno;
else
err = 0;
hci_close_dev(dd);
return err;
}
static struct btd_adapter_ops hci_ops = {
.setup = hciops_setup,
.cleanup = hciops_cleanup,
@ -1080,6 +1099,7 @@ static struct btd_adapter_ops hci_ops = {
.init_ssp_mode = hciops_init_ssp_mode,
.read_link_policy = hciops_read_link_policy,
.disconnect = hciops_disconnect,
.remove_bonding = hciops_remove_bonding,
};
static int hciops_init(void)

View File

@ -3486,3 +3486,8 @@ int btd_adapter_disconnect_device(struct btd_adapter *adapter, uint16_t handle)
{
return adapter_ops->disconnect(adapter->dev_id, handle);
}
int btd_adapter_remove_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr)
{
return adapter_ops->remove_bonding(adapter->dev_id, bdaddr);
}

View File

@ -205,6 +205,7 @@ struct btd_adapter_ops {
int (*init_ssp_mode) (int index, uint8_t *ssp_mode);
int (*read_link_policy) (int index);
int (*disconnect) (int index, uint16_t handle);
int (*remove_bonding) (int index, bdaddr_t *bdaddr);
};
int btd_register_adapter_ops(struct btd_adapter_ops *btd_adapter_ops);
@ -235,3 +236,5 @@ int btd_adapter_unblock_address(struct btd_adapter *adapter, bdaddr_t *bdaddr);
int btd_adapter_disconnect_device(struct btd_adapter *adapter,
uint16_t handle);
int btd_adapter_remove_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr);

View File

@ -1037,7 +1037,6 @@ void device_remove_bonding(struct btd_device *device)
{
char filename[PATH_MAX + 1];
char srcaddr[18], dstaddr[18];
int dd, dev_id;
bdaddr_t bdaddr;
adapter_get_address(device->adapter, &bdaddr);
@ -1050,16 +1049,7 @@ void device_remove_bonding(struct btd_device *device)
/* Delete the link key from storage */
textfile_casedel(filename, dstaddr);
dev_id = adapter_get_dev_id(device->adapter);
dd = hci_open_dev(dev_id);
if (dd < 0)
return;
/* Delete the link key from the Bluetooth chip */
hci_delete_stored_link_key(dd, &device->bdaddr, 0, HCI_REQ_TIMEOUT);
hci_close_dev(dd);
btd_adapter_remove_bonding(device->adapter, &device->bdaddr);
}
static void device_remove_stored(struct btd_device *device)