diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2005-04-20 17:49:43 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2005-04-20 17:49:43 +0000 |
commit | cdd3dd5576a585f61674a3346c6598b907e97e9d (patch) | |
tree | 86b823c1c07834c523252178f6b02ba41d82480f /hcid | |
parent | 7cc4137b299169997e45e07614966adc55f6f5eb (diff) |
Take care of return link keys event
Diffstat (limited to 'hcid')
-rw-r--r-- | hcid/security.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/hcid/security.c b/hcid/security.c index 8f5c69bc..5b2dc285 100644 --- a/hcid/security.c +++ b/hcid/security.c @@ -225,10 +225,10 @@ static void link_key_notify(int dev, bdaddr_t *sba, void *ptr) evt_link_key_notify *evt = ptr; bdaddr_t *dba = &evt->bdaddr; struct link_key key; - char sa[18]; + char sa[18], da[18]; - ba2str(sba, sa); - syslog(LOG_INFO, "link_key_notify (sba=%s)", sa); + ba2str(sba, sa); ba2str(dba, da); + syslog(LOG_INFO, "link_key_notify (sba=%s, dba=%s)", sa, da); memcpy(key.key, evt->link_key, 16); bacpy(&key.sba, sba); @@ -243,6 +243,28 @@ static void link_key_notify(int dev, bdaddr_t *sba, void *ptr) write_link_key(sba, dba, evt->link_key, evt->key_type); } +static void return_link_keys(int dev, bdaddr_t *sba, void *ptr) +{ + evt_return_link_keys *evt = ptr; + uint8_t num = evt->num_keys; + unsigned char key[16]; + char sa[18], da[18]; + bdaddr_t dba; + int i; + + ba2str(sba, sa); + ptr++; + + for (i = 0; i < num; i++) { + bacpy(&dba, ptr); ba2str(&dba, da); + memcpy(key, ptr + 6, 16); + + syslog(LOG_INFO, "return_link_keys (sba=%s, dba=%s)", sa, da); + + ptr += 22; + } +} + /* PIN code handling */ static int read_default_pin_code(void) @@ -548,6 +570,10 @@ static gboolean io_security_event(GIOChannel *chan, GIOCondition cond, gpointer case EVT_LINK_KEY_NOTIFY: link_key_notify(dev, &di->bdaddr, ptr); break; + + case EVT_RETURN_LINK_KEYS: + return_link_keys(dev, &di->bdaddr, ptr); + break; } return TRUE; @@ -577,6 +603,7 @@ void start_security_manager(int hdev) hci_filter_set_event(EVT_PIN_CODE_REQ, &flt); hci_filter_set_event(EVT_LINK_KEY_REQ, &flt); hci_filter_set_event(EVT_LINK_KEY_NOTIFY, &flt); + hci_filter_set_event(EVT_RETURN_LINK_KEYS, &flt); hci_filter_set_event(EVT_REMOTE_NAME_REQ_COMPLETE, &flt); hci_filter_set_event(EVT_READ_REMOTE_VERSION_COMPLETE, &flt); hci_filter_set_event(EVT_READ_REMOTE_FEATURES_COMPLETE, &flt); |