Lines Matching refs:conn
104 struct hci_conn *conn; in hci_cc_role_discovery() local
113 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
114 if (conn) in hci_cc_role_discovery()
115 conn->role = rp->role; in hci_cc_role_discovery()
123 struct hci_conn *conn; in hci_cc_read_link_policy() local
132 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
133 if (conn) in hci_cc_read_link_policy()
134 conn->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_link_policy()
142 struct hci_conn *conn; in hci_cc_write_link_policy() local
156 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
157 if (conn) in hci_cc_write_link_policy()
158 conn->link_policy = get_unaligned_le16(sent + 2); in hci_cc_write_link_policy()
586 struct hci_conn *conn; in hci_cc_read_auth_payload_timeout() local
595 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
596 if (conn) in hci_cc_read_auth_payload_timeout()
597 conn->auth_payload_timeout = __le16_to_cpu(rp->timeout); in hci_cc_read_auth_payload_timeout()
606 struct hci_conn *conn; in hci_cc_write_auth_payload_timeout() local
620 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
621 if (conn) in hci_cc_write_auth_payload_timeout()
622 conn->auth_payload_timeout = get_unaligned_le16(sent + 2); in hci_cc_write_auth_payload_timeout()
838 struct hci_conn *conn; in hci_cc_read_clock() local
859 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
860 if (conn) { in hci_cc_read_clock()
861 conn->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
862 conn->clock_accuracy = le16_to_cpu(rp->accuracy); in hci_cc_read_clock()
908 struct hci_conn *conn; in hci_cc_pin_code_reply() local
924 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
925 if (conn) in hci_cc_pin_code_reply()
926 conn->pin_length = cp->pin_len; in hci_cc_pin_code_reply()
1160 struct hci_conn *conn; in hci_cc_le_set_adv_enable() local
1164 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_adv_enable()
1165 if (conn) in hci_cc_le_set_adv_enable()
1167 &conn->le_conn_timeout, in hci_cc_le_set_adv_enable()
1168 conn->conn_timeout); in hci_cc_le_set_adv_enable()
1194 struct hci_conn *conn; in hci_cc_le_set_ext_adv_enable() local
1198 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_ext_adv_enable()
1199 if (conn) in hci_cc_le_set_ext_adv_enable()
1201 &conn->le_conn_timeout, in hci_cc_le_set_ext_adv_enable()
1202 conn->conn_timeout); in hci_cc_le_set_ext_adv_enable()
1694 struct hci_conn *conn; in hci_cc_read_rssi() local
1703 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
1704 if (conn) in hci_cc_read_rssi()
1705 conn->rssi = rp->rssi; in hci_cc_read_rssi()
1714 struct hci_conn *conn; in hci_cc_read_tx_power() local
1727 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
1728 if (!conn) in hci_cc_read_tx_power()
1733 conn->tx_power = rp->tx_power; in hci_cc_read_tx_power()
1736 conn->max_tx_power = rp->tx_power; in hci_cc_read_tx_power()
1774 struct hci_conn *conn; in hci_cs_create_conn() local
1784 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
1786 BT_DBG("%s bdaddr %pMR hcon %p", hdev->name, &cp->bdaddr, conn); in hci_cs_create_conn()
1789 if (conn && conn->state == BT_CONNECT) { in hci_cs_create_conn()
1790 if (status != 0x0c || conn->attempt > 2) { in hci_cs_create_conn()
1791 conn->state = BT_CLOSED; in hci_cs_create_conn()
1792 hci_connect_cfm(conn, status); in hci_cs_create_conn()
1793 hci_conn_del(conn); in hci_cs_create_conn()
1795 conn->state = BT_CONNECT2; in hci_cs_create_conn()
1798 if (!conn) { in hci_cs_create_conn()
1799 conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
1801 if (!conn) in hci_cs_create_conn()
1847 struct hci_conn *conn; in hci_cs_auth_requested() local
1860 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
1861 if (conn) { in hci_cs_auth_requested()
1862 if (conn->state == BT_CONFIG) { in hci_cs_auth_requested()
1863 hci_connect_cfm(conn, status); in hci_cs_auth_requested()
1864 hci_conn_drop(conn); in hci_cs_auth_requested()
1874 struct hci_conn *conn; in hci_cs_set_conn_encrypt() local
1887 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
1888 if (conn) { in hci_cs_set_conn_encrypt()
1889 if (conn->state == BT_CONFIG) { in hci_cs_set_conn_encrypt()
1890 hci_connect_cfm(conn, status); in hci_cs_set_conn_encrypt()
1891 hci_conn_drop(conn); in hci_cs_set_conn_encrypt()
1899 struct hci_conn *conn) in hci_outgoing_auth_needed() argument
1901 if (conn->state != BT_CONFIG || !conn->out) in hci_outgoing_auth_needed()
1904 if (conn->pending_sec_level == BT_SECURITY_SDP) in hci_outgoing_auth_needed()
1911 if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) && in hci_outgoing_auth_needed()
1912 conn->pending_sec_level != BT_SECURITY_FIPS && in hci_outgoing_auth_needed()
1913 conn->pending_sec_level != BT_SECURITY_HIGH && in hci_outgoing_auth_needed()
1914 conn->pending_sec_level != BT_SECURITY_MEDIUM) in hci_outgoing_auth_needed()
1955 static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, in hci_check_pending_name() argument
1966 if (conn && in hci_check_pending_name()
1967 (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) && in hci_check_pending_name()
1968 !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_check_pending_name()
1969 mgmt_device_connected(hdev, conn, 0, name, name_len); in hci_check_pending_name()
2007 struct hci_conn *conn; in hci_cs_remote_name_req() local
2022 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2025 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2027 if (!conn) in hci_cs_remote_name_req()
2030 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_cs_remote_name_req()
2033 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_cs_remote_name_req()
2036 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_cs_remote_name_req()
2038 auth_cp.handle = __cpu_to_le16(conn->handle); in hci_cs_remote_name_req()
2050 struct hci_conn *conn; in hci_cs_read_remote_features() local
2063 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2064 if (conn) { in hci_cs_read_remote_features()
2065 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_features()
2066 hci_connect_cfm(conn, status); in hci_cs_read_remote_features()
2067 hci_conn_drop(conn); in hci_cs_read_remote_features()
2077 struct hci_conn *conn; in hci_cs_read_remote_ext_features() local
2090 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2091 if (conn) { in hci_cs_read_remote_ext_features()
2092 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_ext_features()
2093 hci_connect_cfm(conn, status); in hci_cs_read_remote_ext_features()
2094 hci_conn_drop(conn); in hci_cs_read_remote_ext_features()
2139 struct hci_conn *conn; in hci_cs_sniff_mode() local
2152 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2153 if (conn) { in hci_cs_sniff_mode()
2154 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_sniff_mode()
2156 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_sniff_mode()
2157 hci_sco_setup(conn, status); in hci_cs_sniff_mode()
2166 struct hci_conn *conn; in hci_cs_exit_sniff_mode() local
2179 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2180 if (conn) { in hci_cs_exit_sniff_mode()
2181 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_exit_sniff_mode()
2183 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_exit_sniff_mode()
2184 hci_sco_setup(conn, status); in hci_cs_exit_sniff_mode()
2193 struct hci_conn *conn; in hci_cs_disconnect() local
2204 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2205 if (conn) in hci_cs_disconnect()
2206 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2207 conn->dst_type, status); in hci_cs_disconnect()
2216 struct hci_conn *conn; in cs_le_create_conn() local
2218 conn = hci_conn_hash_lookup_le(hdev, peer_addr, in cs_le_create_conn()
2220 if (!conn) in cs_le_create_conn()
2227 conn->init_addr_type = own_address_type; in cs_le_create_conn()
2229 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2231 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2233 conn->resp_addr_type = peer_addr_type; in cs_le_create_conn()
2234 bacpy(&conn->resp_addr, peer_addr); in cs_le_create_conn()
2242 queue_delayed_work(conn->hdev->workqueue, in cs_le_create_conn()
2243 &conn->le_conn_timeout, in cs_le_create_conn()
2244 conn->conn_timeout); in cs_le_create_conn()
2300 struct hci_conn *conn; in hci_cs_le_read_remote_features() local
2313 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2314 if (conn) { in hci_cs_le_read_remote_features()
2315 if (conn->state == BT_CONFIG) { in hci_cs_le_read_remote_features()
2316 hci_connect_cfm(conn, status); in hci_cs_le_read_remote_features()
2317 hci_conn_drop(conn); in hci_cs_le_read_remote_features()
2327 struct hci_conn *conn; in hci_cs_le_start_enc() local
2340 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2341 if (!conn) in hci_cs_le_start_enc()
2344 if (conn->state != BT_CONNECTED) in hci_cs_le_start_enc()
2347 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_cs_le_start_enc()
2348 hci_conn_drop(conn); in hci_cs_le_start_enc()
2357 struct hci_conn *conn; in hci_cs_switch_role() local
2370 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
2371 if (conn) in hci_cs_switch_role()
2372 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_cs_switch_role()
2477 struct hci_conn *conn; in hci_conn_complete_evt() local
2483 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
2484 if (!conn) { in hci_conn_complete_evt()
2488 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_conn_complete_evt()
2489 if (!conn) in hci_conn_complete_evt()
2492 conn->type = SCO_LINK; in hci_conn_complete_evt()
2496 conn->handle = __le16_to_cpu(ev->handle); in hci_conn_complete_evt()
2498 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
2499 conn->state = BT_CONFIG; in hci_conn_complete_evt()
2500 hci_conn_hold(conn); in hci_conn_complete_evt()
2502 if (!conn->out && !hci_conn_ssp_enabled(conn) && in hci_conn_complete_evt()
2504 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_conn_complete_evt()
2506 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_conn_complete_evt()
2508 conn->state = BT_CONNECTED; in hci_conn_complete_evt()
2510 hci_debugfs_create_conn(conn); in hci_conn_complete_evt()
2511 hci_conn_add_sysfs(conn); in hci_conn_complete_evt()
2514 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_conn_complete_evt()
2517 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
2520 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
2530 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
2533 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_complete_evt()
2538 conn->state = BT_CLOSED; in hci_conn_complete_evt()
2539 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
2540 mgmt_connect_failed(hdev, &conn->dst, conn->type, in hci_conn_complete_evt()
2541 conn->dst_type, ev->status); in hci_conn_complete_evt()
2544 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
2545 hci_sco_setup(conn, ev->status); in hci_conn_complete_evt()
2548 hci_connect_cfm(conn, ev->status); in hci_conn_complete_evt()
2549 hci_conn_del(conn); in hci_conn_complete_evt()
2551 hci_connect_cfm(conn, ev->status); in hci_conn_complete_evt()
2573 struct hci_conn *conn; in hci_conn_request_evt() local
2613 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
2615 if (!conn) { in hci_conn_request_evt()
2616 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
2618 if (!conn) { in hci_conn_request_evt()
2625 memcpy(conn->dev_class, ev->dev_class, 3); in hci_conn_request_evt()
2632 conn->state = BT_CONNECT; in hci_conn_request_evt()
2644 conn->state = BT_CONNECT; in hci_conn_request_evt()
2647 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_request_evt()
2658 conn->state = BT_CONNECT2; in hci_conn_request_evt()
2659 hci_connect_cfm(conn, 0); in hci_conn_request_evt()
2684 struct hci_conn *conn; in hci_disconn_complete_evt() local
2692 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
2693 if (!conn) in hci_disconn_complete_evt()
2697 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
2698 conn->dst_type, ev->status); in hci_disconn_complete_evt()
2702 conn->state = BT_CLOSED; in hci_disconn_complete_evt()
2704 mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_disconn_complete_evt()
2706 if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags)) in hci_disconn_complete_evt()
2711 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
2714 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
2715 if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
2716 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
2721 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
2741 type = conn->type; in hci_disconn_complete_evt()
2743 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
2744 hci_conn_del(conn); in hci_disconn_complete_evt()
2766 struct hci_conn *conn; in hci_auth_complete_evt() local
2772 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
2773 if (!conn) in hci_auth_complete_evt()
2777 clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
2779 if (!hci_conn_ssp_enabled(conn) && in hci_auth_complete_evt()
2780 test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { in hci_auth_complete_evt()
2783 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
2784 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
2788 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
2790 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
2793 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
2794 clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags); in hci_auth_complete_evt()
2796 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
2797 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
2804 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
2805 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
2806 hci_conn_drop(conn); in hci_auth_complete_evt()
2809 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
2811 hci_conn_hold(conn); in hci_auth_complete_evt()
2812 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
2813 hci_conn_drop(conn); in hci_auth_complete_evt()
2816 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
2824 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
2825 hci_encrypt_cfm(conn, ev->status, 0x00); in hci_auth_complete_evt()
2836 struct hci_conn *conn; in hci_remote_name_evt() local
2844 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
2850 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
2853 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
2856 if (!conn) in hci_remote_name_evt()
2859 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_remote_name_evt()
2862 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
2865 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
2867 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
2879 struct hci_conn *conn; in read_enc_key_size_complete() local
2894 conn = hci_conn_hash_lookup_handle(hdev, handle); in read_enc_key_size_complete()
2895 if (!conn) in read_enc_key_size_complete()
2905 conn->enc_key_size = HCI_LINK_KEY_SIZE; in read_enc_key_size_complete()
2907 conn->enc_key_size = rp->key_size; in read_enc_key_size_complete()
2910 if (conn->state == BT_CONFIG) { in read_enc_key_size_complete()
2911 conn->state = BT_CONNECTED; in read_enc_key_size_complete()
2912 hci_connect_cfm(conn, 0); in read_enc_key_size_complete()
2913 hci_conn_drop(conn); in read_enc_key_size_complete()
2917 if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags)) in read_enc_key_size_complete()
2919 else if (test_bit(HCI_CONN_AES_CCM, &conn->flags)) in read_enc_key_size_complete()
2924 hci_encrypt_cfm(conn, 0, encrypt); in read_enc_key_size_complete()
2934 struct hci_conn *conn; in hci_encrypt_change_evt() local
2940 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
2941 if (!conn) in hci_encrypt_change_evt()
2947 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
2948 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
2949 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
2952 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
2953 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
2955 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
2956 conn->type == LE_LINK) in hci_encrypt_change_evt()
2957 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
2959 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
2960 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
2967 if (ev->status && conn->type == LE_LINK) { in hci_encrypt_change_evt()
2972 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
2974 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
2976 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_encrypt_change_evt()
2978 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_encrypt_change_evt()
2979 hci_conn_drop(conn); in hci_encrypt_change_evt()
2988 (!test_bit(HCI_CONN_AES_CCM, &conn->flags) || in hci_encrypt_change_evt()
2989 conn->key_type != HCI_LK_AUTH_COMBINATION_P256)) { in hci_encrypt_change_evt()
2990 hci_connect_cfm(conn, HCI_ERROR_AUTH_FAILURE); in hci_encrypt_change_evt()
2991 hci_conn_drop(conn); in hci_encrypt_change_evt()
2996 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
3005 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3011 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3016 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3030 if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_encrypt_change_evt()
3031 test_bit(HCI_CONN_AES_CCM, &conn->flags) && in hci_encrypt_change_evt()
3032 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3033 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3036 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3038 hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3043 if (conn->state == BT_CONFIG) { in hci_encrypt_change_evt()
3045 conn->state = BT_CONNECTED; in hci_encrypt_change_evt()
3047 hci_connect_cfm(conn, ev->status); in hci_encrypt_change_evt()
3048 hci_conn_drop(conn); in hci_encrypt_change_evt()
3050 hci_encrypt_cfm(conn, ev->status, ev->encrypt); in hci_encrypt_change_evt()
3060 struct hci_conn *conn; in hci_change_link_key_complete_evt() local
3066 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3067 if (conn) { in hci_change_link_key_complete_evt()
3069 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
3071 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
3073 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
3083 struct hci_conn *conn; in hci_remote_features_evt() local
3089 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3090 if (!conn) in hci_remote_features_evt()
3094 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
3096 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
3100 lmp_ext_feat_capable(conn)) { in hci_remote_features_evt()
3109 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_features_evt()
3112 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
3115 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_features_evt()
3116 mgmt_device_connected(hdev, conn, 0, NULL, 0); in hci_remote_features_evt()
3118 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_features_evt()
3119 conn->state = BT_CONNECTED; in hci_remote_features_evt()
3120 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
3121 hci_conn_drop(conn); in hci_remote_features_evt()
3614 struct hci_conn *conn; in hci_role_change_evt() local
3620 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
3621 if (conn) { in hci_role_change_evt()
3623 conn->role = ev->role; in hci_role_change_evt()
3625 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
3627 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
3653 struct hci_conn *conn; in hci_num_comp_pkts_evt() local
3659 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_num_comp_pkts_evt()
3660 if (!conn) in hci_num_comp_pkts_evt()
3663 conn->sent -= count; in hci_num_comp_pkts_evt()
3665 switch (conn->type) { in hci_num_comp_pkts_evt()
3692 conn->type, conn); in hci_num_comp_pkts_evt()
3711 return chan->conn; in __hci_conn_lookup_handle()
3742 struct hci_conn *conn = NULL; in hci_num_comp_blocks_evt() local
3748 conn = __hci_conn_lookup_handle(hdev, handle); in hci_num_comp_blocks_evt()
3749 if (!conn) in hci_num_comp_blocks_evt()
3752 conn->sent -= block_count; in hci_num_comp_blocks_evt()
3754 switch (conn->type) { in hci_num_comp_blocks_evt()
3764 conn->type, conn); in hci_num_comp_blocks_evt()
3775 struct hci_conn *conn; in hci_mode_change_evt() local
3781 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
3782 if (conn) { in hci_mode_change_evt()
3783 conn->mode = ev->mode; in hci_mode_change_evt()
3786 &conn->flags)) { in hci_mode_change_evt()
3787 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
3788 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
3790 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
3793 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
3794 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
3803 struct hci_conn *conn; in hci_pin_code_request_evt() local
3809 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
3810 if (!conn) in hci_pin_code_request_evt()
3813 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
3814 hci_conn_hold(conn); in hci_pin_code_request_evt()
3815 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
3816 hci_conn_drop(conn); in hci_pin_code_request_evt()
3820 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
3826 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
3838 static void conn_set_key(struct hci_conn *conn, u8 key_type, u8 pin_len) in conn_set_key() argument
3843 conn->pin_length = pin_len; in conn_set_key()
3844 conn->key_type = key_type; in conn_set_key()
3853 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
3855 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
3859 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
3862 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
3865 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
3874 struct hci_conn *conn; in hci_link_key_request_evt() local
3894 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
3895 if (conn) { in hci_link_key_request_evt()
3896 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
3900 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
3906 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
3907 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
3913 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
3933 struct hci_conn *conn; in hci_link_key_notify_evt() local
3942 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
3943 if (!conn) in hci_link_key_notify_evt()
3946 hci_conn_hold(conn); in hci_link_key_notify_evt()
3947 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
3948 hci_conn_drop(conn); in hci_link_key_notify_evt()
3950 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
3951 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
3956 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
3965 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
3982 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
3984 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
3993 struct hci_conn *conn; in hci_clock_offset_evt() local
3999 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4000 if (conn && !ev->status) { in hci_clock_offset_evt()
4003 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4016 struct hci_conn *conn; in hci_pkt_type_change_evt() local
4022 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4023 if (conn && !ev->status) in hci_pkt_type_change_evt()
4024 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
4115 struct hci_conn *conn; in hci_remote_ext_features_evt() local
4121 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4122 if (!conn) in hci_remote_ext_features_evt()
4126 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
4131 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4136 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4146 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4150 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4153 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
4156 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
4159 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
4162 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_ext_features_evt()
4163 mgmt_device_connected(hdev, conn, 0, NULL, 0); in hci_remote_ext_features_evt()
4165 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_ext_features_evt()
4166 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
4167 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
4168 hci_conn_drop(conn); in hci_remote_ext_features_evt()
4179 struct hci_conn *conn; in hci_sync_conn_complete_evt() local
4185 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
4186 if (!conn) { in hci_sync_conn_complete_evt()
4199 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
4200 if (!conn) in hci_sync_conn_complete_evt()
4206 conn->handle = __le16_to_cpu(ev->handle); in hci_sync_conn_complete_evt()
4207 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
4208 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
4210 hci_debugfs_create_conn(conn); in hci_sync_conn_complete_evt()
4211 hci_conn_add_sysfs(conn); in hci_sync_conn_complete_evt()
4221 if (conn->out) { in hci_sync_conn_complete_evt()
4222 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
4224 if (hci_setup_sync(conn, conn->link->handle)) in hci_sync_conn_complete_evt()
4230 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
4234 hci_connect_cfm(conn, ev->status); in hci_sync_conn_complete_evt()
4236 hci_conn_del(conn); in hci_sync_conn_complete_evt()
4313 struct hci_conn *conn; in hci_key_refresh_complete_evt() local
4320 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
4321 if (!conn) in hci_key_refresh_complete_evt()
4327 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
4331 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
4333 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
4335 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
4336 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_key_refresh_complete_evt()
4337 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
4341 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
4343 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
4345 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
4346 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
4348 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
4350 hci_conn_hold(conn); in hci_key_refresh_complete_evt()
4351 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
4352 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
4359 static u8 hci_get_auth_req(struct hci_conn *conn) in hci_get_auth_req() argument
4362 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
4363 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
4364 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
4369 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
4370 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
4371 return conn->remote_auth | 0x01; in hci_get_auth_req()
4374 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
4377 static u8 bredr_oob_data_present(struct hci_conn *conn) in bredr_oob_data_present() argument
4379 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
4382 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
4422 struct hci_conn *conn; in hci_io_capa_request_evt() local
4428 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
4429 if (!conn) in hci_io_capa_request_evt()
4432 hci_conn_hold(conn); in hci_io_capa_request_evt()
4441 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
4442 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
4448 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
4449 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
4452 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
4456 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
4457 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
4458 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
4460 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
4467 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
4469 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
4470 cp.oob_data = bredr_oob_data_present(conn); in hci_io_capa_request_evt()
4491 struct hci_conn *conn; in hci_io_capa_reply_evt() local
4497 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
4498 if (!conn) in hci_io_capa_reply_evt()
4501 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
4502 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
4513 struct hci_conn *conn; in hci_user_confirm_request_evt() local
4522 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
4523 if (!conn) in hci_user_confirm_request_evt()
4526 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
4527 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
4534 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
4535 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
4543 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
4544 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
4552 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
4553 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_user_confirm_request_evt()
4565 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
4566 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
4598 struct hci_conn *conn; in hci_user_passkey_notify_evt() local
4602 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
4603 if (!conn) in hci_user_passkey_notify_evt()
4606 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
4607 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
4610 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
4611 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
4612 conn->passkey_entered); in hci_user_passkey_notify_evt()
4618 struct hci_conn *conn; in hci_keypress_notify_evt() local
4622 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
4623 if (!conn) in hci_keypress_notify_evt()
4628 conn->passkey_entered = 0; in hci_keypress_notify_evt()
4632 conn->passkey_entered++; in hci_keypress_notify_evt()
4636 conn->passkey_entered--; in hci_keypress_notify_evt()
4640 conn->passkey_entered = 0; in hci_keypress_notify_evt()
4648 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
4649 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
4650 conn->passkey_entered); in hci_keypress_notify_evt()
4657 struct hci_conn *conn; in hci_simple_pair_complete_evt() local
4663 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
4664 if (!conn) in hci_simple_pair_complete_evt()
4668 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
4675 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
4676 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
4678 hci_conn_drop(conn); in hci_simple_pair_complete_evt()
4689 struct hci_conn *conn; in hci_remote_host_features_evt() local
4695 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
4696 if (conn) in hci_remote_host_features_evt()
4697 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
4847 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
4907 struct hci_conn *conn; in le_conn_complete_evt() local
4918 conn = hci_lookup_le_connect(hdev); in le_conn_complete_evt()
4919 if (!conn) { in le_conn_complete_evt()
4920 conn = hci_conn_add(hdev, LE_LINK, bdaddr, role); in le_conn_complete_evt()
4921 if (!conn) { in le_conn_complete_evt()
4926 conn->dst_type = bdaddr_type; in le_conn_complete_evt()
4936 if (conn->out) { in le_conn_complete_evt()
4937 conn->resp_addr_type = bdaddr_type; in le_conn_complete_evt()
4938 bacpy(&conn->resp_addr, bdaddr); in le_conn_complete_evt()
4940 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_complete_evt()
4941 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
4944 &conn->init_addr, in le_conn_complete_evt()
4945 &conn->init_addr_type); in le_conn_complete_evt()
4949 cancel_delayed_work(&conn->le_conn_timeout); in le_conn_complete_evt()
4952 if (!conn->out) { in le_conn_complete_evt()
4956 conn->resp_addr_type = hdev->adv_addr_type; in le_conn_complete_evt()
4962 bacpy(&conn->resp_addr, &hdev->random_addr); in le_conn_complete_evt()
4964 bacpy(&conn->resp_addr, &hdev->bdaddr); in le_conn_complete_evt()
4967 conn->init_addr_type = bdaddr_type; in le_conn_complete_evt()
4968 bacpy(&conn->init_addr, bdaddr); in le_conn_complete_evt()
4975 conn->le_conn_min_interval = hdev->le_conn_min_interval; in le_conn_complete_evt()
4976 conn->le_conn_max_interval = hdev->le_conn_max_interval; in le_conn_complete_evt()
4988 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
4990 bacpy(&conn->dst, &irk->bdaddr); in le_conn_complete_evt()
4991 conn->dst_type = irk->addr_type; in le_conn_complete_evt()
4995 hci_le_conn_failed(conn, status); in le_conn_complete_evt()
4999 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in le_conn_complete_evt()
5005 if (hci_bdaddr_list_lookup(&hdev->blacklist, &conn->dst, addr_type)) { in le_conn_complete_evt()
5006 hci_conn_drop(conn); in le_conn_complete_evt()
5010 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in le_conn_complete_evt()
5011 mgmt_device_connected(hdev, conn, 0, NULL, 0); in le_conn_complete_evt()
5013 conn->sec_level = BT_SECURITY_LOW; in le_conn_complete_evt()
5014 conn->handle = handle; in le_conn_complete_evt()
5015 conn->state = BT_CONFIG; in le_conn_complete_evt()
5017 conn->le_conn_interval = interval; in le_conn_complete_evt()
5018 conn->le_conn_latency = latency; in le_conn_complete_evt()
5019 conn->le_supv_timeout = supervision_timeout; in le_conn_complete_evt()
5021 hci_debugfs_create_conn(conn); in le_conn_complete_evt()
5022 hci_conn_add_sysfs(conn); in le_conn_complete_evt()
5033 if (conn->out || in le_conn_complete_evt()
5037 cp.handle = __cpu_to_le16(conn->handle); in le_conn_complete_evt()
5042 hci_conn_hold(conn); in le_conn_complete_evt()
5044 conn->state = BT_CONNECTED; in le_conn_complete_evt()
5045 hci_connect_cfm(conn, status); in le_conn_complete_evt()
5048 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
5049 conn->dst_type); in le_conn_complete_evt()
5052 if (params->conn) { in le_conn_complete_evt()
5053 hci_conn_drop(params->conn); in le_conn_complete_evt()
5054 hci_conn_put(params->conn); in le_conn_complete_evt()
5055 params->conn = NULL; in le_conn_complete_evt()
5094 struct hci_conn *conn; in hci_le_ext_adv_term_evt() local
5101 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
5102 if (conn) { in hci_le_ext_adv_term_evt()
5109 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
5115 bacpy(&conn->resp_addr, &adv_instance->random_addr); in hci_le_ext_adv_term_evt()
5123 struct hci_conn *conn; in hci_le_conn_update_complete_evt() local
5132 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
5133 if (conn) { in hci_le_conn_update_complete_evt()
5134 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
5135 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
5136 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
5148 struct hci_conn *conn; in check_pending_le_conn() local
5196 conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW, in check_pending_le_conn()
5199 if (!IS_ERR(conn)) { in check_pending_le_conn()
5210 params->conn = hci_conn_get(conn); in check_pending_le_conn()
5212 return conn; in check_pending_le_conn()
5215 switch (PTR_ERR(conn)) { in check_pending_le_conn()
5224 BT_DBG("Failed to connect: err %ld", PTR_ERR(conn)); in check_pending_le_conn()
5237 struct hci_conn *conn; in process_adv_report() local
5312 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type, in process_adv_report()
5314 if (conn && type == LE_ADV_IND) { in process_adv_report()
5318 memcpy(conn->le_adv_data, data, len); in process_adv_report()
5319 conn->le_adv_data_len = len; in process_adv_report()
5530 struct hci_conn *conn; in hci_le_remote_feat_complete_evt() local
5536 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
5537 if (conn) { in hci_le_remote_feat_complete_evt()
5539 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
5541 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
5554 !conn->out && ev->status == 0x1a) in hci_le_remote_feat_complete_evt()
5559 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
5560 hci_connect_cfm(conn, status); in hci_le_remote_feat_complete_evt()
5561 hci_conn_drop(conn); in hci_le_remote_feat_complete_evt()
5573 struct hci_conn *conn; in hci_le_ltk_request_evt() local
5580 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
5581 if (conn == NULL) in hci_le_ltk_request_evt()
5584 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
5600 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
5602 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
5604 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
5615 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
5619 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()