Lines Matching full:conn
170 struct hci_conn *conn; in hci_cc_role_discovery() local
179 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
180 if (conn) in hci_cc_role_discovery()
181 conn->role = rp->role; in hci_cc_role_discovery()
192 struct hci_conn *conn; in hci_cc_read_link_policy() local
201 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
202 if (conn) in hci_cc_read_link_policy()
203 conn->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_link_policy()
214 struct hci_conn *conn; in hci_cc_write_link_policy() local
228 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
229 if (conn) in hci_cc_write_link_policy()
230 conn->link_policy = get_unaligned_le16(sent + 2); in hci_cc_write_link_policy()
719 struct hci_conn *conn; in hci_cc_read_enc_key_size() local
729 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_cc_read_enc_key_size()
730 if (!conn) { in hci_cc_read_enc_key_size()
742 conn->enc_key_size = 0; in hci_cc_read_enc_key_size()
744 conn->enc_key_size = rp->key_size; in hci_cc_read_enc_key_size()
748 hci_encrypt_cfm(conn, 0); in hci_cc_read_enc_key_size()
777 struct hci_conn *conn; in hci_cc_read_auth_payload_timeout() local
786 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
787 if (conn) in hci_cc_read_auth_payload_timeout()
788 conn->auth_payload_timeout = __le16_to_cpu(rp->timeout); in hci_cc_read_auth_payload_timeout()
799 struct hci_conn *conn; in hci_cc_write_auth_payload_timeout() local
813 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
814 if (conn) in hci_cc_write_auth_payload_timeout()
815 conn->auth_payload_timeout = get_unaligned_le16(sent + 2); in hci_cc_write_auth_payload_timeout()
1075 struct hci_conn *conn; in hci_cc_read_clock() local
1093 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
1094 if (conn) { in hci_cc_read_clock()
1095 conn->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1096 conn->clock_accuracy = le16_to_cpu(rp->accuracy); in hci_cc_read_clock()
1183 struct hci_conn *conn; in hci_cc_pin_code_reply() local
1199 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
1200 if (conn) in hci_cc_pin_code_reply()
1201 conn->pin_length = cp->pin_len; in hci_cc_pin_code_reply()
1584 struct hci_conn *conn; in hci_cc_le_set_adv_enable() local
1588 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_adv_enable()
1589 if (conn) in hci_cc_le_set_adv_enable()
1591 &conn->le_conn_timeout, in hci_cc_le_set_adv_enable()
1592 conn->conn_timeout); in hci_cc_le_set_adv_enable()
1627 struct hci_conn *conn; in hci_cc_le_set_ext_adv_enable() local
1634 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_ext_adv_enable()
1635 if (conn) in hci_cc_le_set_ext_adv_enable()
1637 &conn->le_conn_timeout, in hci_cc_le_set_ext_adv_enable()
1638 conn->conn_timeout); in hci_cc_le_set_ext_adv_enable()
2212 struct hci_conn *conn; in hci_cc_read_rssi() local
2221 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
2222 if (conn) in hci_cc_read_rssi()
2223 conn->rssi = rp->rssi; in hci_cc_read_rssi()
2235 struct hci_conn *conn; in hci_cc_read_tx_power() local
2248 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
2249 if (!conn) in hci_cc_read_tx_power()
2254 conn->tx_power = rp->tx_power; in hci_cc_read_tx_power()
2257 conn->max_tx_power = rp->tx_power; in hci_cc_read_tx_power()
2299 struct hci_conn *conn; in hci_cs_create_conn() local
2309 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
2311 bt_dev_dbg(hdev, "bdaddr %pMR hcon %p", &cp->bdaddr, conn); in hci_cs_create_conn()
2314 if (conn && conn->state == BT_CONNECT) { in hci_cs_create_conn()
2315 if (status != 0x0c || conn->attempt > 2) { in hci_cs_create_conn()
2316 conn->state = BT_CLOSED; in hci_cs_create_conn()
2317 hci_connect_cfm(conn, status); in hci_cs_create_conn()
2318 hci_conn_del(conn); in hci_cs_create_conn()
2320 conn->state = BT_CONNECT2; in hci_cs_create_conn()
2323 if (!conn) { in hci_cs_create_conn()
2324 conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
2326 if (!conn) in hci_cs_create_conn()
2372 struct hci_conn *conn; in hci_cs_auth_requested() local
2385 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
2386 if (conn) { in hci_cs_auth_requested()
2387 if (conn->state == BT_CONFIG) { in hci_cs_auth_requested()
2388 hci_connect_cfm(conn, status); in hci_cs_auth_requested()
2389 hci_conn_drop(conn); in hci_cs_auth_requested()
2399 struct hci_conn *conn; in hci_cs_set_conn_encrypt() local
2412 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
2413 if (conn) { in hci_cs_set_conn_encrypt()
2414 if (conn->state == BT_CONFIG) { in hci_cs_set_conn_encrypt()
2415 hci_connect_cfm(conn, status); in hci_cs_set_conn_encrypt()
2416 hci_conn_drop(conn); in hci_cs_set_conn_encrypt()
2424 struct hci_conn *conn) in hci_outgoing_auth_needed() argument
2426 if (conn->state != BT_CONFIG || !conn->out) in hci_outgoing_auth_needed()
2429 if (conn->pending_sec_level == BT_SECURITY_SDP) in hci_outgoing_auth_needed()
2436 if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) && in hci_outgoing_auth_needed()
2437 conn->pending_sec_level != BT_SECURITY_FIPS && in hci_outgoing_auth_needed()
2438 conn->pending_sec_level != BT_SECURITY_HIGH && in hci_outgoing_auth_needed()
2439 conn->pending_sec_level != BT_SECURITY_MEDIUM) in hci_outgoing_auth_needed()
2486 static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, in hci_check_pending_name() argument
2493 * conn objects that exist but are not (yet) connected however. in hci_check_pending_name()
2497 if (conn && in hci_check_pending_name()
2498 (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) && in hci_check_pending_name()
2499 !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_check_pending_name()
2500 mgmt_device_connected(hdev, conn, name, name_len); in hci_check_pending_name()
2535 struct hci_conn *conn; in hci_cs_remote_name_req() local
2550 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2553 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2555 if (!conn) in hci_cs_remote_name_req()
2558 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_cs_remote_name_req()
2561 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_cs_remote_name_req()
2564 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_cs_remote_name_req()
2566 auth_cp.handle = __cpu_to_le16(conn->handle); in hci_cs_remote_name_req()
2578 struct hci_conn *conn; in hci_cs_read_remote_features() local
2591 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2592 if (conn) { in hci_cs_read_remote_features()
2593 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_features()
2594 hci_connect_cfm(conn, status); in hci_cs_read_remote_features()
2595 hci_conn_drop(conn); in hci_cs_read_remote_features()
2605 struct hci_conn *conn; in hci_cs_read_remote_ext_features() local
2618 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2619 if (conn) { in hci_cs_read_remote_ext_features()
2620 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_ext_features()
2621 hci_connect_cfm(conn, status); in hci_cs_read_remote_ext_features()
2622 hci_conn_drop(conn); in hci_cs_read_remote_ext_features()
2702 struct hci_conn *conn; in hci_cs_sniff_mode() local
2715 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2716 if (conn) { in hci_cs_sniff_mode()
2717 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_sniff_mode()
2719 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_sniff_mode()
2720 hci_sco_setup(conn, status); in hci_cs_sniff_mode()
2729 struct hci_conn *conn; in hci_cs_exit_sniff_mode() local
2742 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2743 if (conn) { in hci_cs_exit_sniff_mode()
2744 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_exit_sniff_mode()
2746 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_exit_sniff_mode()
2747 hci_sco_setup(conn, status); in hci_cs_exit_sniff_mode()
2757 struct hci_conn *conn; in hci_cs_disconnect() local
2774 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2775 if (!conn) in hci_cs_disconnect()
2779 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2780 conn->dst_type, status); in hci_cs_disconnect()
2782 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_cs_disconnect()
2783 hdev->cur_adv_instance = conn->adv_instance; in hci_cs_disconnect()
2790 mgmt_conn = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_cs_disconnect()
2792 if (conn->type == ACL_LINK) { in hci_cs_disconnect()
2793 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_cs_disconnect()
2794 hci_remove_link_key(hdev, &conn->dst); in hci_cs_disconnect()
2797 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_cs_disconnect()
2816 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_cs_disconnect()
2819 hci_disconn_cfm(conn, cp->reason); in hci_cs_disconnect()
2827 hci_conn_del(conn); in hci_cs_disconnect()
2858 struct hci_conn *conn; in cs_le_create_conn() local
2860 conn = hci_conn_hash_lookup_le(hdev, peer_addr, in cs_le_create_conn()
2862 if (!conn) in cs_le_create_conn()
2871 conn->init_addr_type = own_address_type; in cs_le_create_conn()
2873 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2875 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2877 conn->resp_addr_type = peer_addr_type; in cs_le_create_conn()
2878 bacpy(&conn->resp_addr, peer_addr); in cs_le_create_conn()
2886 queue_delayed_work(conn->hdev->workqueue, in cs_le_create_conn()
2887 &conn->le_conn_timeout, in cs_le_create_conn()
2888 conn->conn_timeout); in cs_le_create_conn()
2944 struct hci_conn *conn; in hci_cs_le_read_remote_features() local
2957 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2958 if (conn) { in hci_cs_le_read_remote_features()
2959 if (conn->state == BT_CONFIG) { in hci_cs_le_read_remote_features()
2960 hci_connect_cfm(conn, status); in hci_cs_le_read_remote_features()
2961 hci_conn_drop(conn); in hci_cs_le_read_remote_features()
2971 struct hci_conn *conn; in hci_cs_le_start_enc() local
2984 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2985 if (!conn) in hci_cs_le_start_enc()
2988 if (conn->state != BT_CONNECTED) in hci_cs_le_start_enc()
2991 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_cs_le_start_enc()
2992 hci_conn_drop(conn); in hci_cs_le_start_enc()
3001 struct hci_conn *conn; in hci_cs_switch_role() local
3014 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
3015 if (conn) in hci_cs_switch_role()
3016 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_cs_switch_role()
3130 struct hci_conn *conn; in hci_conn_complete_evt() local
3137 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
3138 if (!conn) { in hci_conn_complete_evt()
3158 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_complete_evt()
3160 if (!conn) { in hci_conn_complete_evt()
3161 bt_dev_err(hdev, "no memory for new conn"); in hci_conn_complete_evt()
3168 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, in hci_conn_complete_evt()
3170 if (!conn) in hci_conn_complete_evt()
3173 conn->type = SCO_LINK; in hci_conn_complete_evt()
3183 if (conn->handle != HCI_CONN_HANDLE_UNSET) { in hci_conn_complete_evt()
3189 conn->handle = __le16_to_cpu(ev->handle); in hci_conn_complete_evt()
3190 if (conn->handle > HCI_CONN_HANDLE_MAX) { in hci_conn_complete_evt()
3192 conn->handle, HCI_CONN_HANDLE_MAX); in hci_conn_complete_evt()
3197 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3198 conn->state = BT_CONFIG; in hci_conn_complete_evt()
3199 hci_conn_hold(conn); in hci_conn_complete_evt()
3201 if (!conn->out && !hci_conn_ssp_enabled(conn) && in hci_conn_complete_evt()
3203 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_conn_complete_evt()
3205 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_conn_complete_evt()
3207 conn->state = BT_CONNECTED; in hci_conn_complete_evt()
3209 hci_debugfs_create_conn(conn); in hci_conn_complete_evt()
3210 hci_conn_add_sysfs(conn); in hci_conn_complete_evt()
3213 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_conn_complete_evt()
3216 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
3219 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3229 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
3232 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_complete_evt()
3238 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
3239 hci_sco_setup(conn, ev->status); in hci_conn_complete_evt()
3243 hci_conn_failed(conn, status); in hci_conn_complete_evt()
3245 switch (conn->setting & SCO_AIRMODE_MASK) { in hci_conn_complete_evt()
3252 hci_connect_cfm(conn, status); in hci_conn_complete_evt()
3276 struct hci_conn *conn; in hci_conn_request_evt() local
3315 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
3317 if (!conn) { in hci_conn_request_evt()
3318 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
3320 if (!conn) { in hci_conn_request_evt()
3326 memcpy(conn->dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3333 conn->state = BT_CONNECT; in hci_conn_request_evt()
3345 conn->state = BT_CONNECT; in hci_conn_request_evt()
3348 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_request_evt()
3359 conn->state = BT_CONNECT2; in hci_conn_request_evt()
3360 hci_connect_cfm(conn, 0); in hci_conn_request_evt()
3390 struct hci_conn *conn; in hci_disconn_complete_evt() local
3397 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
3398 if (!conn) in hci_disconn_complete_evt()
3402 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
3403 conn->dst_type, ev->status); in hci_disconn_complete_evt()
3407 conn->state = BT_CLOSED; in hci_disconn_complete_evt()
3409 mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_disconn_complete_evt()
3411 if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags)) in hci_disconn_complete_evt()
3416 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
3419 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
3420 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
3421 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
3426 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
3446 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
3458 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_disconn_complete_evt()
3459 hdev->cur_adv_instance = conn->adv_instance; in hci_disconn_complete_evt()
3463 hci_conn_del(conn); in hci_disconn_complete_evt()
3473 struct hci_conn *conn; in hci_auth_complete_evt() local
3479 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
3480 if (!conn) in hci_auth_complete_evt()
3484 clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3486 if (!hci_conn_ssp_enabled(conn) && in hci_auth_complete_evt()
3487 test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { in hci_auth_complete_evt()
3490 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
3491 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
3495 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3497 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
3500 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3501 clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3503 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
3504 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
3511 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
3512 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
3513 hci_conn_drop(conn); in hci_auth_complete_evt()
3516 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
3518 hci_conn_hold(conn); in hci_auth_complete_evt()
3519 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
3520 hci_conn_drop(conn); in hci_auth_complete_evt()
3523 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
3531 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
3532 hci_encrypt_cfm(conn, ev->status); in hci_auth_complete_evt()
3544 struct hci_conn *conn; in hci_remote_name_evt() local
3552 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
3558 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
3561 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
3564 if (!conn) in hci_remote_name_evt()
3567 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_remote_name_evt()
3570 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
3573 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
3575 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
3587 struct hci_conn *conn; in hci_encrypt_change_evt() local
3593 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3594 if (!conn) in hci_encrypt_change_evt()
3600 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
3601 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3602 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
3605 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
3606 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
3608 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
3609 conn->type == LE_LINK) in hci_encrypt_change_evt()
3610 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3612 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3613 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3620 if (ev->status && conn->type == LE_LINK) { in hci_encrypt_change_evt()
3625 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
3628 if (!hci_conn_check_link_mode(conn)) in hci_encrypt_change_evt()
3631 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
3633 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_encrypt_change_evt()
3638 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3639 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_encrypt_change_evt()
3640 hci_conn_drop(conn); in hci_encrypt_change_evt()
3645 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
3653 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3657 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3661 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3671 * sent when the link is active and Encryption is enabled, the conn in hci_encrypt_change_evt()
3675 if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_encrypt_change_evt()
3676 test_bit(HCI_CONN_AES_CCM, &conn->flags) && in hci_encrypt_change_evt()
3677 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3678 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3681 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3683 hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3688 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3698 struct hci_conn *conn; in hci_change_link_key_complete_evt() local
3704 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3705 if (conn) { in hci_change_link_key_complete_evt()
3707 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
3709 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
3711 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
3721 struct hci_conn *conn; in hci_remote_features_evt() local
3727 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3728 if (!conn) in hci_remote_features_evt()
3732 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
3734 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
3738 lmp_ext_feat_capable(conn)) { in hci_remote_features_evt()
3747 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_features_evt()
3750 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
3753 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_features_evt()
3754 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_features_evt()
3756 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_features_evt()
3757 conn->state = BT_CONNECTED; in hci_remote_features_evt()
3758 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
3759 hci_conn_drop(conn); in hci_remote_features_evt()
3812 struct hci_conn *conn; in hci_cc_le_set_cig_params() local
3820 while ((conn = hci_conn_hash_lookup_cig(hdev, rp->cig_id))) { in hci_cc_le_set_cig_params()
3821 conn->state = BT_CLOSED; in hci_cc_le_set_cig_params()
3822 hci_connect_cfm(conn, rp->status); in hci_cc_le_set_cig_params()
3823 hci_conn_del(conn); in hci_cc_le_set_cig_params()
3830 list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { in hci_cc_le_set_cig_params()
3831 if (conn->type != ISO_LINK || conn->iso_qos.cig != rp->cig_id || in hci_cc_le_set_cig_params()
3832 conn->state == BT_CONNECTED) in hci_cc_le_set_cig_params()
3835 conn->handle = __le16_to_cpu(rp->handle[i++]); in hci_cc_le_set_cig_params()
3837 bt_dev_dbg(hdev, "%p handle 0x%4.4x link %p", conn, in hci_cc_le_set_cig_params()
3838 conn->handle, conn->link); in hci_cc_le_set_cig_params()
3841 if (conn->link && conn->link->state == BT_CONNECTED) in hci_cc_le_set_cig_params()
3842 hci_le_create_cis(conn->link); in hci_cc_le_set_cig_params()
3861 struct hci_conn *conn; in hci_cc_le_setup_iso_path() local
3871 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cc_le_setup_iso_path()
3872 if (!conn) in hci_cc_le_setup_iso_path()
3876 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3877 hci_conn_del(conn); in hci_cc_le_setup_iso_path()
3885 if (conn->iso_qos.out.sdu && !conn->iso_qos.in.sdu) in hci_cc_le_setup_iso_path()
3886 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3890 /* Confirm connection since conn->iso_qos is always configured in hci_cc_le_setup_iso_path()
3893 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3922 /* TODO: set the conn state */ in hci_cc_set_per_adv_param()
4231 struct hci_conn *conn; in hci_cs_le_create_cis() local
4236 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_le_create_cis()
4237 if (conn) { in hci_cs_le_create_cis()
4238 conn->state = BT_CLOSED; in hci_cs_le_create_cis()
4239 hci_connect_cfm(conn, status); in hci_cs_le_create_cis()
4240 hci_conn_del(conn); in hci_cs_le_create_cis()
4339 struct hci_conn *conn; in hci_role_change_evt() local
4345 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
4346 if (conn) { in hci_role_change_evt()
4348 conn->role = ev->role; in hci_role_change_evt()
4350 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
4352 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
4377 struct hci_conn *conn; in hci_num_comp_pkts_evt() local
4383 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_num_comp_pkts_evt()
4384 if (!conn) in hci_num_comp_pkts_evt()
4387 conn->sent -= count; in hci_num_comp_pkts_evt()
4389 switch (conn->type) { in hci_num_comp_pkts_evt()
4431 bt_dev_err(hdev, "unknown type %d conn %p", in hci_num_comp_pkts_evt()
4432 conn->type, conn); in hci_num_comp_pkts_evt()
4451 return chan->conn; in __hci_conn_lookup_handle()
4482 struct hci_conn *conn = NULL; in hci_num_comp_blocks_evt() local
4488 conn = __hci_conn_lookup_handle(hdev, handle); in hci_num_comp_blocks_evt()
4489 if (!conn) in hci_num_comp_blocks_evt()
4492 conn->sent -= block_count; in hci_num_comp_blocks_evt()
4494 switch (conn->type) { in hci_num_comp_blocks_evt()
4503 bt_dev_err(hdev, "unknown type %d conn %p", in hci_num_comp_blocks_evt()
4504 conn->type, conn); in hci_num_comp_blocks_evt()
4516 struct hci_conn *conn; in hci_mode_change_evt() local
4522 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4523 if (conn) { in hci_mode_change_evt()
4524 conn->mode = ev->mode; in hci_mode_change_evt()
4527 &conn->flags)) { in hci_mode_change_evt()
4528 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
4529 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4531 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4534 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
4535 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
4545 struct hci_conn *conn; in hci_pin_code_request_evt() local
4551 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4552 if (!conn) in hci_pin_code_request_evt()
4555 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
4556 hci_conn_hold(conn); in hci_pin_code_request_evt()
4557 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
4558 hci_conn_drop(conn); in hci_pin_code_request_evt()
4562 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
4568 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
4580 static void conn_set_key(struct hci_conn *conn, u8 key_type, u8 pin_len) in conn_set_key() argument
4585 conn->pin_length = pin_len; in conn_set_key()
4586 conn->key_type = key_type; in conn_set_key()
4595 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4597 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4601 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4604 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4607 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
4617 struct hci_conn *conn; in hci_link_key_request_evt() local
4635 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4636 if (conn) { in hci_link_key_request_evt()
4637 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
4641 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
4647 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
4648 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
4653 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
4674 struct hci_conn *conn; in hci_link_key_notify_evt() local
4683 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4684 if (!conn) in hci_link_key_notify_evt()
4687 hci_conn_hold(conn); in hci_link_key_notify_evt()
4688 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
4689 hci_conn_drop(conn); in hci_link_key_notify_evt()
4691 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
4692 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
4697 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4706 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
4723 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4725 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4735 struct hci_conn *conn; in hci_clock_offset_evt() local
4741 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4742 if (conn && !ev->status) { in hci_clock_offset_evt()
4745 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4759 struct hci_conn *conn; in hci_pkt_type_change_evt() local
4765 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4766 if (conn && !ev->status) in hci_pkt_type_change_evt()
4767 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
4882 struct hci_conn *conn; in hci_remote_ext_features_evt() local
4888 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4889 if (!conn) in hci_remote_ext_features_evt()
4893 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
4898 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4903 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4913 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4917 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4920 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
4923 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
4926 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
4929 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_ext_features_evt()
4930 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_ext_features_evt()
4932 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_ext_features_evt()
4933 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
4934 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
4935 hci_conn_drop(conn); in hci_remote_ext_features_evt()
4946 struct hci_conn *conn; in hci_sync_conn_complete_evt() local
4966 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
4967 if (!conn) { in hci_sync_conn_complete_evt()
4980 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
4981 if (!conn) in hci_sync_conn_complete_evt()
4991 if (conn->handle != HCI_CONN_HANDLE_UNSET) { in hci_sync_conn_complete_evt()
4998 conn->handle = __le16_to_cpu(ev->handle); in hci_sync_conn_complete_evt()
4999 if (conn->handle > HCI_CONN_HANDLE_MAX) { in hci_sync_conn_complete_evt()
5001 conn->handle, HCI_CONN_HANDLE_MAX); in hci_sync_conn_complete_evt()
5003 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5007 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
5008 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
5010 hci_debugfs_create_conn(conn); in hci_sync_conn_complete_evt()
5011 hci_conn_add_sysfs(conn); in hci_sync_conn_complete_evt()
5022 if (conn->out) { in hci_sync_conn_complete_evt()
5023 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
5025 if (hci_setup_sync(conn, conn->link->handle)) in hci_sync_conn_complete_evt()
5031 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5039 if (conn->codec.data_path == 0 && hdev->notify) { in hci_sync_conn_complete_evt()
5050 hci_connect_cfm(conn, status); in hci_sync_conn_complete_evt()
5052 hci_conn_del(conn); in hci_sync_conn_complete_evt()
5134 struct hci_conn *conn; in hci_key_refresh_complete_evt() local
5141 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5142 if (!conn) in hci_key_refresh_complete_evt()
5148 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
5152 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
5154 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
5156 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
5157 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_key_refresh_complete_evt()
5158 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
5162 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
5164 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
5166 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5167 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
5169 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5171 hci_conn_hold(conn); in hci_key_refresh_complete_evt()
5172 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
5173 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
5180 static u8 hci_get_auth_req(struct hci_conn *conn) in hci_get_auth_req() argument
5183 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
5184 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
5185 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
5190 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
5191 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
5192 return conn->remote_auth | 0x01; in hci_get_auth_req()
5195 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
5198 static u8 bredr_oob_data_present(struct hci_conn *conn) in bredr_oob_data_present() argument
5200 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
5203 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
5244 struct hci_conn *conn; in hci_io_capa_request_evt() local
5250 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
5251 if (!conn) in hci_io_capa_request_evt()
5254 hci_conn_hold(conn); in hci_io_capa_request_evt()
5263 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
5264 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
5270 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
5271 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
5274 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
5278 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
5279 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
5280 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
5282 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
5289 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
5291 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
5292 cp.oob_data = bredr_oob_data_present(conn); in hci_io_capa_request_evt()
5314 struct hci_conn *conn; in hci_io_capa_reply_evt() local
5320 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
5321 if (!conn) in hci_io_capa_reply_evt()
5324 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
5325 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
5336 struct hci_conn *conn; in hci_user_confirm_request_evt() local
5345 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
5346 if (!conn) in hci_user_confirm_request_evt()
5349 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
5350 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
5355 * necessarily match conn->auth_type. in hci_user_confirm_request_evt()
5357 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
5358 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
5366 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
5367 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
5375 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
5376 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_user_confirm_request_evt()
5398 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
5399 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
5431 struct hci_conn *conn; in hci_user_passkey_notify_evt() local
5435 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
5436 if (!conn) in hci_user_passkey_notify_evt()
5439 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
5440 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
5443 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
5444 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
5445 conn->passkey_entered); in hci_user_passkey_notify_evt()
5452 struct hci_conn *conn; in hci_keypress_notify_evt() local
5456 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
5457 if (!conn) in hci_keypress_notify_evt()
5462 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5466 conn->passkey_entered++; in hci_keypress_notify_evt()
5470 conn->passkey_entered--; in hci_keypress_notify_evt()
5474 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5482 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
5483 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
5484 conn->passkey_entered); in hci_keypress_notify_evt()
5491 struct hci_conn *conn; in hci_simple_pair_complete_evt() local
5497 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
5498 if (!conn) in hci_simple_pair_complete_evt()
5502 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
5509 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
5510 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
5512 hci_conn_drop(conn); in hci_simple_pair_complete_evt()
5523 struct hci_conn *conn; in hci_remote_host_features_evt() local
5529 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5530 if (conn) in hci_remote_host_features_evt()
5531 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
5682 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
5738 static void le_conn_update_addr(struct hci_conn *conn, bdaddr_t *bdaddr, in le_conn_update_addr() argument
5741 if (conn->out) { in le_conn_update_addr()
5742 conn->dst_type = bdaddr_type; in le_conn_update_addr()
5743 conn->resp_addr_type = bdaddr_type; in le_conn_update_addr()
5744 bacpy(&conn->resp_addr, bdaddr); in le_conn_update_addr()
5750 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5751 bacpy(&conn->init_addr, local_rpa); in le_conn_update_addr()
5752 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5753 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5754 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5756 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5757 &conn->init_addr_type); in le_conn_update_addr()
5760 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5765 conn->resp_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5766 bacpy(&conn->resp_addr, local_rpa); in le_conn_update_addr()
5767 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5771 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5772 bacpy(&conn->resp_addr, in le_conn_update_addr()
5773 &conn->hdev->random_addr); in le_conn_update_addr()
5775 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5778 conn->init_addr_type = bdaddr_type; in le_conn_update_addr()
5779 bacpy(&conn->init_addr, bdaddr); in le_conn_update_addr()
5786 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5787 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5798 struct hci_conn *conn; in le_conn_complete_evt() local
5809 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr); in le_conn_complete_evt()
5810 if (!conn) { in le_conn_complete_evt()
5817 conn = hci_conn_add(hdev, LE_LINK, bdaddr, role); in le_conn_complete_evt()
5818 if (!conn) { in le_conn_complete_evt()
5823 conn->dst_type = bdaddr_type; in le_conn_complete_evt()
5833 if (conn->out) { in le_conn_complete_evt()
5834 conn->resp_addr_type = bdaddr_type; in le_conn_complete_evt()
5835 bacpy(&conn->resp_addr, bdaddr); in le_conn_complete_evt()
5837 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_complete_evt()
5838 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5841 &conn->init_addr, in le_conn_complete_evt()
5842 &conn->init_addr_type); in le_conn_complete_evt()
5846 cancel_delayed_work(&conn->le_conn_timeout); in le_conn_complete_evt()
5855 if (conn->handle != HCI_CONN_HANDLE_UNSET) { in le_conn_complete_evt()
5860 le_conn_update_addr(conn, bdaddr, bdaddr_type, local_rpa); in le_conn_complete_evt()
5871 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5873 bacpy(&conn->dst, &irk->bdaddr); in le_conn_complete_evt()
5874 conn->dst_type = irk->addr_type; in le_conn_complete_evt()
5877 conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL); in le_conn_complete_evt()
5892 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in le_conn_complete_evt()
5898 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5899 hci_conn_drop(conn); in le_conn_complete_evt()
5903 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in le_conn_complete_evt()
5904 mgmt_device_connected(hdev, conn, NULL, 0); in le_conn_complete_evt()
5906 conn->sec_level = BT_SECURITY_LOW; in le_conn_complete_evt()
5907 conn->handle = handle; in le_conn_complete_evt()
5908 conn->state = BT_CONFIG; in le_conn_complete_evt()
5915 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
5917 conn->le_conn_interval = interval; in le_conn_complete_evt()
5918 conn->le_conn_latency = latency; in le_conn_complete_evt()
5919 conn->le_supv_timeout = supervision_timeout; in le_conn_complete_evt()
5921 hci_debugfs_create_conn(conn); in le_conn_complete_evt()
5922 hci_conn_add_sysfs(conn); in le_conn_complete_evt()
5933 if (conn->out || in le_conn_complete_evt()
5937 cp.handle = __cpu_to_le16(conn->handle); in le_conn_complete_evt()
5942 hci_conn_hold(conn); in le_conn_complete_evt()
5944 conn->state = BT_CONNECTED; in le_conn_complete_evt()
5945 hci_connect_cfm(conn, status); in le_conn_complete_evt()
5948 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
5949 conn->dst_type); in le_conn_complete_evt()
5952 if (params->conn) { in le_conn_complete_evt()
5953 hci_conn_drop(params->conn); in le_conn_complete_evt()
5954 hci_conn_put(params->conn); in le_conn_complete_evt()
5955 params->conn = NULL; in le_conn_complete_evt()
5996 struct hci_conn *conn; in hci_le_ext_adv_term_evt() local
6038 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
6039 if (conn) { in hci_le_ext_adv_term_evt()
6043 conn->adv_instance = ev->handle; in hci_le_ext_adv_term_evt()
6046 bacmp(&conn->resp_addr, BDADDR_ANY)) in hci_le_ext_adv_term_evt()
6050 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
6055 bacpy(&conn->resp_addr, &adv->random_addr); in hci_le_ext_adv_term_evt()
6066 struct hci_conn *conn; in hci_le_conn_update_complete_evt() local
6075 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
6076 if (conn) { in hci_le_conn_update_complete_evt()
6077 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
6078 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
6079 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
6091 struct hci_conn *conn; in check_pending_le_conn() local
6142 conn = hci_connect_le(hdev, addr, addr_type, addr_resolved, in check_pending_le_conn()
6145 if (!IS_ERR(conn)) { in check_pending_le_conn()
6146 /* If HCI_AUTO_CONN_EXPLICIT is set, conn is already owned in check_pending_le_conn()
6156 params->conn = hci_conn_get(conn); in check_pending_le_conn()
6158 return conn; in check_pending_le_conn()
6161 switch (PTR_ERR(conn)) { in check_pending_le_conn()
6170 BT_DBG("Failed to connect: err %ld", PTR_ERR(conn)); in check_pending_le_conn()
6184 struct hci_conn *conn; in process_adv_report() local
6266 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, bdaddr_resolved, in process_adv_report()
6268 if (!ext_adv && conn && type == LE_ADV_IND && len <= HCI_MAX_AD_LENGTH) { in process_adv_report()
6272 memcpy(conn->le_adv_data, data, len); in process_adv_report()
6273 conn->le_adv_data_len = len; in process_adv_report()
6548 struct hci_conn *conn; in hci_le_remote_feat_complete_evt() local
6554 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
6555 if (conn) { in hci_le_remote_feat_complete_evt()
6557 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
6559 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
6571 if (!conn->out && ev->status == 0x1a && in hci_le_remote_feat_complete_evt()
6577 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
6578 hci_connect_cfm(conn, status); in hci_le_remote_feat_complete_evt()
6579 hci_conn_drop(conn); in hci_le_remote_feat_complete_evt()
6592 struct hci_conn *conn; in hci_le_ltk_request_evt() local
6599 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6600 if (conn == NULL) in hci_le_ltk_request_evt()
6603 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
6619 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
6621 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
6623 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
6634 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6638 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6755 struct hci_conn *conn; in hci_le_phy_update_evt() local
6764 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
6765 if (!conn) in hci_le_phy_update_evt()
6768 conn->le_tx_phy = ev->tx_phy; in hci_le_phy_update_evt()
6769 conn->le_rx_phy = ev->rx_phy; in hci_le_phy_update_evt()
6779 struct hci_conn *conn; in hci_le_cis_estabilished_evt() local
6786 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_cis_estabilished_evt()
6787 if (!conn) { in hci_le_cis_estabilished_evt()
6794 if (conn->type != ISO_LINK) { in hci_le_cis_estabilished_evt()
6801 if (conn->role == HCI_ROLE_SLAVE) { in hci_le_cis_estabilished_evt()
6807 conn->iso_qos.in.interval = le32_to_cpu(interval); in hci_le_cis_estabilished_evt()
6809 conn->iso_qos.out.interval = le32_to_cpu(interval); in hci_le_cis_estabilished_evt()
6810 conn->iso_qos.in.latency = le16_to_cpu(ev->interval); in hci_le_cis_estabilished_evt()
6811 conn->iso_qos.out.latency = le16_to_cpu(ev->interval); in hci_le_cis_estabilished_evt()
6812 conn->iso_qos.in.sdu = le16_to_cpu(ev->c_mtu); in hci_le_cis_estabilished_evt()
6813 conn->iso_qos.out.sdu = le16_to_cpu(ev->p_mtu); in hci_le_cis_estabilished_evt()
6814 conn->iso_qos.in.phy = ev->c_phy; in hci_le_cis_estabilished_evt()
6815 conn->iso_qos.out.phy = ev->p_phy; in hci_le_cis_estabilished_evt()
6819 conn->state = BT_CONNECTED; in hci_le_cis_estabilished_evt()
6820 hci_debugfs_create_conn(conn); in hci_le_cis_estabilished_evt()
6821 hci_conn_add_sysfs(conn); in hci_le_cis_estabilished_evt()
6822 hci_iso_setup_path(conn); in hci_le_cis_estabilished_evt()
6826 hci_connect_cfm(conn, ev->status); in hci_le_cis_estabilished_evt()
6827 hci_conn_del(conn); in hci_le_cis_estabilished_evt()
6907 struct hci_conn *conn; in hci_le_create_big_complete_evt() local
6917 conn = hci_conn_hash_lookup_big(hdev, ev->handle); in hci_le_create_big_complete_evt()
6918 if (!conn) in hci_le_create_big_complete_evt()
6921 if (conn->type != ISO_LINK) { in hci_le_create_big_complete_evt()
6929 conn->handle = __le16_to_cpu(ev->bis_handle[0]); in hci_le_create_big_complete_evt()
6932 conn->state = BT_CONNECTED; in hci_le_create_big_complete_evt()
6933 hci_debugfs_create_conn(conn); in hci_le_create_big_complete_evt()
6934 hci_conn_add_sysfs(conn); in hci_le_create_big_complete_evt()
6935 hci_iso_setup_path(conn); in hci_le_create_big_complete_evt()
6939 hci_connect_cfm(conn, ev->status); in hci_le_create_big_complete_evt()
6940 hci_conn_del(conn); in hci_le_create_big_complete_evt()