--- android/bluetooth.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/android/bluetooth.c b/android/bluetooth.c index 201238b..a703148 100644 --- a/android/bluetooth.c +++ b/android/bluetooth.c @@ -1804,6 +1804,39 @@ static void new_long_term_key_event(uint16_t index, uint16_t length, /* TODO browse services here? */ } +static void new_csrk_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_ev_new_csrk *ev = param; + struct device *dev; + char dst[18]; + + if (length < sizeof(*ev)) { + error("Too small csrk event (%u bytes)", length); + return; + } + + ba2str(&ev->key.addr.bdaddr, dst); + dev = find_device(&ev->key.addr.bdaddr); + if (!dev) + return; + + if (ev->key.master == 0x01) { + memcpy(dev->remote_csrk, ev->key.val, 16); + dev->remote_sign_cnt = 0; + dev->valid_remote_csrk = true; + } else if (ev->key.master == 0x00) { + memcpy(dev->local_csrk, ev->key.val, 16); + dev->local_sign_cnt = 0; + dev->valid_local_csrk = true; + } else { + error("Unknown key type 02%02x", ev->key.master); + return; + } + + /*TODO: Store it. Remember about Sign Counter*/ +} + static void register_mgmt_handlers(void) { mgmt_register(mgmt_if, MGMT_EV_NEW_SETTINGS, adapter.index, @@ -1853,6 +1886,10 @@ static void register_mgmt_handlers(void) mgmt_register(mgmt_if, MGMT_EV_NEW_LONG_TERM_KEY, adapter.index, new_long_term_key_event, NULL, NULL); + + mgmt_register(mgmt_if, MGMT_EV_NEW_CSRK, adapter.index, + new_csrk_callback, NULL, NULL); + } static void load_link_keys_complete(uint8_t status, uint16_t length, -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html