static void smp_notify_keys(struct l2cap_conn *conn) { struct smp_chan *smp = conn->smp_chan; struct hci_conn *hcon = conn->hcon; struct hci_dev *hdev = hcon->hdev; struct smp_cmd_pairing *req = (void *) &smp->preq[1]; struct smp_cmd_pairing *rsp = (void *) &smp->prsp[1]; bool persistent; if (smp->remote_irk) { mgmt_new_irk(hdev, smp->remote_irk); /* Now that user space can be considered to know the * identity address track the connection based on it * from now on. */ bacpy(&hcon->dst, &smp->remote_irk->bdaddr); hcon->dst_type = smp->remote_irk->addr_type; l2cap_conn_update_id_addr(hcon); } /* The LTKs and CSRKs should be persistent only if both sides * had the bonding bit set in their authentication requests. */ persistent = !!((req->auth_req & rsp->auth_req) & SMP_AUTH_BONDING); if (smp->csrk) { smp->csrk->bdaddr_type = hcon->dst_type; bacpy(&smp->csrk->bdaddr, &hcon->dst); mgmt_new_csrk(hdev, smp->csrk, persistent); } if (smp->slave_csrk) { smp->slave_csrk->bdaddr_type = hcon->dst_type; bacpy(&smp->slave_csrk->bdaddr, &hcon->dst); mgmt_new_csrk(hdev, smp->slave_csrk, persistent); } if (smp->ltk) { smp->ltk->bdaddr_type = hcon->dst_type; bacpy(&smp->ltk->bdaddr, &hcon->dst); mgmt_new_ltk(hdev, smp->ltk, persistent); } if (smp->slave_ltk) { smp->slave_ltk->bdaddr_type = hcon->dst_type; bacpy(&smp->slave_ltk->bdaddr, &hcon->dst); mgmt_new_ltk(hdev, smp->slave_ltk, persistent); } }
void control_message(uint16_t opcode, const void *data, uint16_t size) { if (!decode_control) return; switch (opcode) { case MGMT_EV_INDEX_ADDED: mgmt_index_added(size, data); break; case MGMT_EV_INDEX_REMOVED: mgmt_index_removed(size, data); break; case MGMT_EV_CONTROLLER_ERROR: mgmt_controller_error(size, data); break; case MGMT_EV_NEW_SETTINGS: mgmt_new_settings(size, data); break; case MGMT_EV_CLASS_OF_DEV_CHANGED: mgmt_class_of_dev_changed(size, data); break; case MGMT_EV_LOCAL_NAME_CHANGED: mgmt_local_name_changed(size, data); break; case MGMT_EV_NEW_LINK_KEY: mgmt_new_link_key(size, data); break; case MGMT_EV_NEW_LONG_TERM_KEY: mgmt_new_long_term_key(size, data); break; case MGMT_EV_DEVICE_CONNECTED: mgmt_device_connected(size, data); break; case MGMT_EV_DEVICE_DISCONNECTED: mgmt_device_disconnected(size, data); break; case MGMT_EV_CONNECT_FAILED: mgmt_connect_failed(size, data); break; case MGMT_EV_PIN_CODE_REQUEST: mgmt_pin_code_request(size, data); break; case MGMT_EV_USER_CONFIRM_REQUEST: mgmt_user_confirm_request(size, data); break; case MGMT_EV_USER_PASSKEY_REQUEST: mgmt_user_passkey_request(size, data); break; case MGMT_EV_AUTH_FAILED: mgmt_auth_failed(size, data); break; case MGMT_EV_DEVICE_FOUND: mgmt_device_found(size, data); break; case MGMT_EV_DISCOVERING: mgmt_discovering(size, data); break; case MGMT_EV_DEVICE_BLOCKED: mgmt_device_blocked(size, data); break; case MGMT_EV_DEVICE_UNBLOCKED: mgmt_device_unblocked(size, data); break; case MGMT_EV_DEVICE_UNPAIRED: mgmt_device_unpaired(size, data); break; case MGMT_EV_PASSKEY_NOTIFY: mgmt_passkey_notify(size, data); break; case MGMT_EV_NEW_IRK: mgmt_new_irk(size, data); break; case MGMT_EV_NEW_CSRK: mgmt_new_csrk(size, data); break; case MGMT_EV_DEVICE_ADDED: mgmt_device_added(size, data); break; case MGMT_EV_DEVICE_REMOVED: mgmt_device_removed(size, data); break; case MGMT_EV_NEW_CONN_PARAM: mgmt_new_conn_param(size, data); break; case MGMT_EV_UNCONF_INDEX_ADDED: mgmt_unconf_index_added(size, data); break; case MGMT_EV_UNCONF_INDEX_REMOVED: mgmt_unconf_index_removed(size, data); break; case MGMT_EV_NEW_CONFIG_OPTIONS: mgmt_new_config_options(size, data); break; case MGMT_EV_EXT_INDEX_ADDED: mgmt_ext_index_added(size, data); break; case MGMT_EV_EXT_INDEX_REMOVED: mgmt_ext_index_removed(size, data); break; case MGMT_EV_ADVERTISING_ADDED: mgmt_advertising_added(size, data); break; case MGMT_EV_ADVERTISING_REMOVED: mgmt_advertising_removed(size, data); break; default: printf("* Unknown control (code %d len %d)\n", opcode, size); packet_hexdump(data, size); break; } }