summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dbus-hci.c16
-rw-r--r--src/dbus-hci.h5
-rw-r--r--src/security.c18
3 files changed, 26 insertions, 13 deletions
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index e7d2c78e..562609e0 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -896,14 +896,22 @@ proceed:
adapter_set_state(adapter, state);
}
-void hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
- uint8_t key_type, uint8_t old_key_type)
+int hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
+ uint8_t *key, uint8_t key_type,
+ int pin_length, uint8_t old_key_type)
{
struct btd_device *device;
struct btd_adapter *adapter;
+ int err;
if (!get_adapter_and_device(local, peer, &adapter, &device, TRUE))
- return;
+ return -ENODEV;
+
+ err = write_link_key(local, peer, key, key_type, pin_length);
+ if (err < 0) {
+ error("write_link_key: %s (%d)", strerror(-err), -err);
+ return err;
+ }
/* If this is not the first link key set a flag so a subsequent auth
* complete event doesn't trigger SDP */
@@ -916,6 +924,8 @@ void hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
device_set_secmode3_conn(device, TRUE);
else if (!device_is_bonding(device, NULL) && old_key_type == 0xFF)
hcid_dbus_bonding_process_complete(local, peer, 0);
+
+ return 0;
}
void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle,
diff --git a/src/dbus-hci.h b/src/dbus-hci.h
index b930e893..c7e0dca0 100644
--- a/src/dbus-hci.h
+++ b/src/dbus-hci.h
@@ -46,8 +46,9 @@ int hcid_dbus_set_io_cap(bdaddr_t *local, bdaddr_t *remote,
int hcid_dbus_user_confirm(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey);
int hcid_dbus_user_passkey(bdaddr_t *sba, bdaddr_t *dba);
int hcid_dbus_user_notify(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey);
-void hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
- uint8_t key_type, uint8_t old_key_type);
+int hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
+ uint8_t *key, uint8_t key_type,
+ int pin_length, uint8_t old_key_type);
DBusMessage *new_authentication_return(DBusMessage *msg, uint8_t status);
diff --git a/src/security.c b/src/security.c
index 6a7a8a2c..f2c24d2b 100644
--- a/src/security.c
+++ b/src/security.c
@@ -361,14 +361,18 @@ static void link_key_notify(int dev, bdaddr_t *sba, void *ptr)
dev_id = hci_devid(sa);
- err = write_link_key(sba, dba, evt->link_key, new_key_type,
- io_data[dev_id].pin_length);
+ err = hcid_dbus_link_key_notify(sba, dba, evt->link_key, evt->key_type,
+ io_data[dev_id].pin_length,
+ old_key_type);
if (err < 0) {
uint16_t handle;
- error("write_link_key: %s (%d)", strerror(-err), -err);
-
- hcid_dbus_bonding_process_complete(sba, dba, HCI_MEMORY_FULL);
+ if (err == -ENODEV)
+ hcid_dbus_bonding_process_complete(sba, dba,
+ HCI_OE_LOW_RESOURCES);
+ else
+ hcid_dbus_bonding_process_complete(sba, dba,
+ HCI_MEMORY_FULL);
if (get_handle(dev, sba, dba, &handle) == 0) {
disconnect_cp cp;
@@ -380,9 +384,7 @@ static void link_key_notify(int dev, bdaddr_t *sba, void *ptr)
hci_send_cmd(dev, OGF_LINK_CTL, OCF_DISCONNECT,
DISCONNECT_CP_SIZE, &cp);
}
- } else
- hcid_dbus_link_key_notify(sba, dba, evt->key_type,
- old_key_type);
+ }
io_data[dev_id].pin_length = -1;
}