Lines Matching refs:conn
120 struct hci_conn *conn; in hci_cc_role_discovery() local
129 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
130 if (conn) in hci_cc_role_discovery()
131 conn->role = rp->role; in hci_cc_role_discovery()
139 struct hci_conn *conn; in hci_cc_read_link_policy() local
148 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
149 if (conn) in hci_cc_read_link_policy()
150 conn->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_link_policy()
158 struct hci_conn *conn; in hci_cc_write_link_policy() local
172 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
173 if (conn) in hci_cc_write_link_policy()
174 conn->link_policy = get_unaligned_le16(sent + 2); in hci_cc_write_link_policy()
602 struct hci_conn *conn; in hci_cc_read_auth_payload_timeout() local
611 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
612 if (conn) in hci_cc_read_auth_payload_timeout()
613 conn->auth_payload_timeout = __le16_to_cpu(rp->timeout); in hci_cc_read_auth_payload_timeout()
622 struct hci_conn *conn; in hci_cc_write_auth_payload_timeout() local
636 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
637 if (conn) in hci_cc_write_auth_payload_timeout()
638 conn->auth_payload_timeout = get_unaligned_le16(sent + 2); in hci_cc_write_auth_payload_timeout()
871 struct hci_conn *conn; in hci_cc_read_clock() local
892 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
893 if (conn) { in hci_cc_read_clock()
894 conn->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
895 conn->clock_accuracy = le16_to_cpu(rp->accuracy); in hci_cc_read_clock()
972 struct hci_conn *conn; in hci_cc_pin_code_reply() local
988 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
989 if (conn) in hci_cc_pin_code_reply()
990 conn->pin_length = cp->pin_len; in hci_cc_pin_code_reply()
1224 struct hci_conn *conn; in hci_cc_le_set_adv_enable() local
1228 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_adv_enable()
1229 if (conn) in hci_cc_le_set_adv_enable()
1231 &conn->le_conn_timeout, in hci_cc_le_set_adv_enable()
1232 conn->conn_timeout); in hci_cc_le_set_adv_enable()
1258 struct hci_conn *conn; in hci_cc_le_set_ext_adv_enable() local
1262 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_ext_adv_enable()
1263 if (conn) in hci_cc_le_set_ext_adv_enable()
1265 &conn->le_conn_timeout, in hci_cc_le_set_ext_adv_enable()
1266 conn->conn_timeout); in hci_cc_le_set_ext_adv_enable()
1761 struct hci_conn *conn; in hci_cc_read_rssi() local
1770 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
1771 if (conn) in hci_cc_read_rssi()
1772 conn->rssi = rp->rssi; in hci_cc_read_rssi()
1781 struct hci_conn *conn; in hci_cc_read_tx_power() local
1794 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
1795 if (!conn) in hci_cc_read_tx_power()
1800 conn->tx_power = rp->tx_power; in hci_cc_read_tx_power()
1803 conn->max_tx_power = rp->tx_power; in hci_cc_read_tx_power()
1841 struct hci_conn *conn; in hci_cs_create_conn() local
1851 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
1853 BT_DBG("%s bdaddr %pMR hcon %p", hdev->name, &cp->bdaddr, conn); in hci_cs_create_conn()
1856 if (conn && conn->state == BT_CONNECT) { in hci_cs_create_conn()
1857 if (status != 0x0c || conn->attempt > 2) { in hci_cs_create_conn()
1858 conn->state = BT_CLOSED; in hci_cs_create_conn()
1859 hci_connect_cfm(conn, status); in hci_cs_create_conn()
1860 hci_conn_del(conn); in hci_cs_create_conn()
1862 conn->state = BT_CONNECT2; in hci_cs_create_conn()
1865 if (!conn) { in hci_cs_create_conn()
1866 conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
1868 if (!conn) in hci_cs_create_conn()
1914 struct hci_conn *conn; in hci_cs_auth_requested() local
1927 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
1928 if (conn) { in hci_cs_auth_requested()
1929 if (conn->state == BT_CONFIG) { in hci_cs_auth_requested()
1930 hci_connect_cfm(conn, status); in hci_cs_auth_requested()
1931 hci_conn_drop(conn); in hci_cs_auth_requested()
1941 struct hci_conn *conn; in hci_cs_set_conn_encrypt() local
1954 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
1955 if (conn) { in hci_cs_set_conn_encrypt()
1956 if (conn->state == BT_CONFIG) { in hci_cs_set_conn_encrypt()
1957 hci_connect_cfm(conn, status); in hci_cs_set_conn_encrypt()
1958 hci_conn_drop(conn); in hci_cs_set_conn_encrypt()
1966 struct hci_conn *conn) in hci_outgoing_auth_needed() argument
1968 if (conn->state != BT_CONFIG || !conn->out) in hci_outgoing_auth_needed()
1971 if (conn->pending_sec_level == BT_SECURITY_SDP) in hci_outgoing_auth_needed()
1978 if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) && in hci_outgoing_auth_needed()
1979 conn->pending_sec_level != BT_SECURITY_FIPS && in hci_outgoing_auth_needed()
1980 conn->pending_sec_level != BT_SECURITY_HIGH && in hci_outgoing_auth_needed()
1981 conn->pending_sec_level != BT_SECURITY_MEDIUM) in hci_outgoing_auth_needed()
2022 static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, in hci_check_pending_name() argument
2033 if (conn && in hci_check_pending_name()
2034 (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) && in hci_check_pending_name()
2035 !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_check_pending_name()
2036 mgmt_device_connected(hdev, conn, 0, name, name_len); in hci_check_pending_name()
2074 struct hci_conn *conn; in hci_cs_remote_name_req() local
2089 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2092 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2094 if (!conn) in hci_cs_remote_name_req()
2097 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_cs_remote_name_req()
2100 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_cs_remote_name_req()
2103 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_cs_remote_name_req()
2105 auth_cp.handle = __cpu_to_le16(conn->handle); in hci_cs_remote_name_req()
2117 struct hci_conn *conn; in hci_cs_read_remote_features() local
2130 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2131 if (conn) { in hci_cs_read_remote_features()
2132 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_features()
2133 hci_connect_cfm(conn, status); in hci_cs_read_remote_features()
2134 hci_conn_drop(conn); in hci_cs_read_remote_features()
2144 struct hci_conn *conn; in hci_cs_read_remote_ext_features() local
2157 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2158 if (conn) { in hci_cs_read_remote_ext_features()
2159 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_ext_features()
2160 hci_connect_cfm(conn, status); in hci_cs_read_remote_ext_features()
2161 hci_conn_drop(conn); in hci_cs_read_remote_ext_features()
2206 struct hci_conn *conn; in hci_cs_sniff_mode() local
2219 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2220 if (conn) { in hci_cs_sniff_mode()
2221 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_sniff_mode()
2223 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_sniff_mode()
2224 hci_sco_setup(conn, status); in hci_cs_sniff_mode()
2233 struct hci_conn *conn; in hci_cs_exit_sniff_mode() local
2246 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2247 if (conn) { in hci_cs_exit_sniff_mode()
2248 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_exit_sniff_mode()
2250 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_exit_sniff_mode()
2251 hci_sco_setup(conn, status); in hci_cs_exit_sniff_mode()
2260 struct hci_conn *conn; in hci_cs_disconnect() local
2271 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2272 if (conn) { in hci_cs_disconnect()
2273 u8 type = conn->type; in hci_cs_disconnect()
2275 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2276 conn->dst_type, status); in hci_cs_disconnect()
2283 hci_conn_del(conn); in hci_cs_disconnect()
2295 struct hci_conn *conn; in cs_le_create_conn() local
2297 conn = hci_conn_hash_lookup_le(hdev, peer_addr, in cs_le_create_conn()
2299 if (!conn) in cs_le_create_conn()
2322 conn->init_addr_type = own_address_type; in cs_le_create_conn()
2324 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2326 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2328 conn->resp_addr_type = peer_addr_type; in cs_le_create_conn()
2329 bacpy(&conn->resp_addr, peer_addr); in cs_le_create_conn()
2337 queue_delayed_work(conn->hdev->workqueue, in cs_le_create_conn()
2338 &conn->le_conn_timeout, in cs_le_create_conn()
2339 conn->conn_timeout); in cs_le_create_conn()
2395 struct hci_conn *conn; in hci_cs_le_read_remote_features() local
2408 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2409 if (conn) { in hci_cs_le_read_remote_features()
2410 if (conn->state == BT_CONFIG) { in hci_cs_le_read_remote_features()
2411 hci_connect_cfm(conn, status); in hci_cs_le_read_remote_features()
2412 hci_conn_drop(conn); in hci_cs_le_read_remote_features()
2422 struct hci_conn *conn; in hci_cs_le_start_enc() local
2435 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2436 if (!conn) in hci_cs_le_start_enc()
2439 if (conn->state != BT_CONNECTED) in hci_cs_le_start_enc()
2442 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_cs_le_start_enc()
2443 hci_conn_drop(conn); in hci_cs_le_start_enc()
2452 struct hci_conn *conn; in hci_cs_switch_role() local
2465 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
2466 if (conn) in hci_cs_switch_role()
2467 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_cs_switch_role()
2572 struct hci_conn *conn; in hci_conn_complete_evt() local
2578 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
2579 if (!conn) { in hci_conn_complete_evt()
2593 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_complete_evt()
2595 if (!conn) { in hci_conn_complete_evt()
2603 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, in hci_conn_complete_evt()
2605 if (!conn) in hci_conn_complete_evt()
2608 conn->type = SCO_LINK; in hci_conn_complete_evt()
2613 conn->handle = __le16_to_cpu(ev->handle); in hci_conn_complete_evt()
2615 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
2616 conn->state = BT_CONFIG; in hci_conn_complete_evt()
2617 hci_conn_hold(conn); in hci_conn_complete_evt()
2619 if (!conn->out && !hci_conn_ssp_enabled(conn) && in hci_conn_complete_evt()
2621 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_conn_complete_evt()
2623 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_conn_complete_evt()
2625 conn->state = BT_CONNECTED; in hci_conn_complete_evt()
2627 hci_debugfs_create_conn(conn); in hci_conn_complete_evt()
2628 hci_conn_add_sysfs(conn); in hci_conn_complete_evt()
2631 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_conn_complete_evt()
2634 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
2637 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
2647 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
2650 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_complete_evt()
2655 conn->state = BT_CLOSED; in hci_conn_complete_evt()
2656 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
2657 mgmt_connect_failed(hdev, &conn->dst, conn->type, in hci_conn_complete_evt()
2658 conn->dst_type, ev->status); in hci_conn_complete_evt()
2661 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
2662 hci_sco_setup(conn, ev->status); in hci_conn_complete_evt()
2665 hci_connect_cfm(conn, ev->status); in hci_conn_complete_evt()
2666 hci_conn_del(conn); in hci_conn_complete_evt()
2668 switch (conn->setting & SCO_AIRMODE_MASK) { in hci_conn_complete_evt()
2675 hci_connect_cfm(conn, ev->status); in hci_conn_complete_evt()
2698 struct hci_conn *conn; in hci_conn_request_evt() local
2738 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
2740 if (!conn) { in hci_conn_request_evt()
2741 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
2743 if (!conn) { in hci_conn_request_evt()
2750 memcpy(conn->dev_class, ev->dev_class, 3); in hci_conn_request_evt()
2757 conn->state = BT_CONNECT; in hci_conn_request_evt()
2769 conn->state = BT_CONNECT; in hci_conn_request_evt()
2772 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_request_evt()
2783 conn->state = BT_CONNECT2; in hci_conn_request_evt()
2784 hci_connect_cfm(conn, 0); in hci_conn_request_evt()
2809 struct hci_conn *conn; in hci_disconn_complete_evt() local
2817 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
2818 if (!conn) in hci_disconn_complete_evt()
2822 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
2823 conn->dst_type, ev->status); in hci_disconn_complete_evt()
2827 conn->state = BT_CLOSED; in hci_disconn_complete_evt()
2829 mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_disconn_complete_evt()
2831 if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags)) in hci_disconn_complete_evt()
2836 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
2839 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
2840 if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
2841 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
2846 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
2866 type = conn->type; in hci_disconn_complete_evt()
2868 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
2869 hci_conn_del(conn); in hci_disconn_complete_evt()
2899 struct hci_conn *conn; in hci_auth_complete_evt() local
2905 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
2906 if (!conn) in hci_auth_complete_evt()
2910 clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
2912 if (!hci_conn_ssp_enabled(conn) && in hci_auth_complete_evt()
2913 test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { in hci_auth_complete_evt()
2916 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
2917 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
2921 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
2923 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
2926 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
2927 clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags); in hci_auth_complete_evt()
2929 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
2930 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
2937 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
2938 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
2939 hci_conn_drop(conn); in hci_auth_complete_evt()
2942 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
2944 hci_conn_hold(conn); in hci_auth_complete_evt()
2945 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
2946 hci_conn_drop(conn); in hci_auth_complete_evt()
2949 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
2957 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
2958 hci_encrypt_cfm(conn, ev->status); in hci_auth_complete_evt()
2969 struct hci_conn *conn; in hci_remote_name_evt() local
2977 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
2983 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
2986 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
2989 if (!conn) in hci_remote_name_evt()
2992 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_remote_name_evt()
2995 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
2998 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
3000 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
3012 struct hci_conn *conn; in read_enc_key_size_complete() local
3027 conn = hci_conn_hash_lookup_handle(hdev, handle); in read_enc_key_size_complete()
3028 if (!conn) in read_enc_key_size_complete()
3038 conn->enc_key_size = 0; in read_enc_key_size_complete()
3040 conn->enc_key_size = rp->key_size; in read_enc_key_size_complete()
3043 hci_encrypt_cfm(conn, 0); in read_enc_key_size_complete()
3052 struct hci_conn *conn; in hci_encrypt_change_evt() local
3058 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3059 if (!conn) in hci_encrypt_change_evt()
3065 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
3066 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3067 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
3070 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
3071 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
3073 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
3074 conn->type == LE_LINK) in hci_encrypt_change_evt()
3075 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3077 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3078 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3085 if (ev->status && conn->type == LE_LINK) { in hci_encrypt_change_evt()
3090 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
3093 if (!hci_conn_check_link_mode(conn)) in hci_encrypt_change_evt()
3096 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
3098 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_encrypt_change_evt()
3103 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3104 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_encrypt_change_evt()
3105 hci_conn_drop(conn); in hci_encrypt_change_evt()
3110 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
3119 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3125 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3130 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3144 if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_encrypt_change_evt()
3145 test_bit(HCI_CONN_AES_CCM, &conn->flags) && in hci_encrypt_change_evt()
3146 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3147 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3150 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3152 hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3157 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3167 struct hci_conn *conn; in hci_change_link_key_complete_evt() local
3173 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3174 if (conn) { in hci_change_link_key_complete_evt()
3176 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
3178 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
3180 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
3190 struct hci_conn *conn; in hci_remote_features_evt() local
3196 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3197 if (!conn) in hci_remote_features_evt()
3201 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
3203 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
3207 lmp_ext_feat_capable(conn)) { in hci_remote_features_evt()
3216 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_features_evt()
3219 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
3222 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_features_evt()
3223 mgmt_device_connected(hdev, conn, 0, NULL, 0); in hci_remote_features_evt()
3225 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_features_evt()
3226 conn->state = BT_CONNECTED; in hci_remote_features_evt()
3227 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
3228 hci_conn_drop(conn); in hci_remote_features_evt()
3733 struct hci_conn *conn; in hci_role_change_evt() local
3739 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
3740 if (conn) { in hci_role_change_evt()
3742 conn->role = ev->role; in hci_role_change_evt()
3744 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
3746 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
3772 struct hci_conn *conn; in hci_num_comp_pkts_evt() local
3778 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_num_comp_pkts_evt()
3779 if (!conn) in hci_num_comp_pkts_evt()
3782 conn->sent -= count; in hci_num_comp_pkts_evt()
3784 switch (conn->type) { in hci_num_comp_pkts_evt()
3811 conn->type, conn); in hci_num_comp_pkts_evt()
3830 return chan->conn; in __hci_conn_lookup_handle()
3861 struct hci_conn *conn = NULL; in hci_num_comp_blocks_evt() local
3867 conn = __hci_conn_lookup_handle(hdev, handle); in hci_num_comp_blocks_evt()
3868 if (!conn) in hci_num_comp_blocks_evt()
3871 conn->sent -= block_count; in hci_num_comp_blocks_evt()
3873 switch (conn->type) { in hci_num_comp_blocks_evt()
3883 conn->type, conn); in hci_num_comp_blocks_evt()
3894 struct hci_conn *conn; in hci_mode_change_evt() local
3900 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
3901 if (conn) { in hci_mode_change_evt()
3902 conn->mode = ev->mode; in hci_mode_change_evt()
3905 &conn->flags)) { in hci_mode_change_evt()
3906 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
3907 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
3909 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
3912 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
3913 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
3922 struct hci_conn *conn; in hci_pin_code_request_evt() local
3928 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
3929 if (!conn) in hci_pin_code_request_evt()
3932 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
3933 hci_conn_hold(conn); in hci_pin_code_request_evt()
3934 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
3935 hci_conn_drop(conn); in hci_pin_code_request_evt()
3939 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
3945 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
3957 static void conn_set_key(struct hci_conn *conn, u8 key_type, u8 pin_len) in conn_set_key() argument
3962 conn->pin_length = pin_len; in conn_set_key()
3963 conn->key_type = key_type; in conn_set_key()
3972 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
3974 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
3978 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
3981 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
3984 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
3993 struct hci_conn *conn; in hci_link_key_request_evt() local
4013 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4014 if (conn) { in hci_link_key_request_evt()
4015 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
4019 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
4025 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
4026 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
4032 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
4052 struct hci_conn *conn; in hci_link_key_notify_evt() local
4061 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4062 if (!conn) in hci_link_key_notify_evt()
4065 hci_conn_hold(conn); in hci_link_key_notify_evt()
4066 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
4067 hci_conn_drop(conn); in hci_link_key_notify_evt()
4069 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
4070 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
4075 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4084 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
4101 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4103 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4112 struct hci_conn *conn; in hci_clock_offset_evt() local
4118 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4119 if (conn && !ev->status) { in hci_clock_offset_evt()
4122 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4135 struct hci_conn *conn; in hci_pkt_type_change_evt() local
4141 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4142 if (conn && !ev->status) in hci_pkt_type_change_evt()
4143 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
4241 struct hci_conn *conn; in hci_remote_ext_features_evt() local
4247 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4248 if (!conn) in hci_remote_ext_features_evt()
4252 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
4257 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4262 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4272 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4276 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4279 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
4282 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
4285 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
4288 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_ext_features_evt()
4289 mgmt_device_connected(hdev, conn, 0, NULL, 0); in hci_remote_ext_features_evt()
4291 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_ext_features_evt()
4292 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
4293 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
4294 hci_conn_drop(conn); in hci_remote_ext_features_evt()
4305 struct hci_conn *conn; in hci_sync_conn_complete_evt() local
4311 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
4312 if (!conn) { in hci_sync_conn_complete_evt()
4325 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
4326 if (!conn) in hci_sync_conn_complete_evt()
4342 if (conn->state == BT_CONNECTED) { in hci_sync_conn_complete_evt()
4347 conn->handle = __le16_to_cpu(ev->handle); in hci_sync_conn_complete_evt()
4348 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
4349 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
4351 hci_debugfs_create_conn(conn); in hci_sync_conn_complete_evt()
4352 hci_conn_add_sysfs(conn); in hci_sync_conn_complete_evt()
4363 if (conn->out) { in hci_sync_conn_complete_evt()
4364 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
4366 if (hci_setup_sync(conn, conn->link->handle)) in hci_sync_conn_complete_evt()
4372 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
4389 hci_connect_cfm(conn, ev->status); in hci_sync_conn_complete_evt()
4391 hci_conn_del(conn); in hci_sync_conn_complete_evt()
4468 struct hci_conn *conn; in hci_key_refresh_complete_evt() local
4475 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
4476 if (!conn) in hci_key_refresh_complete_evt()
4482 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
4486 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
4488 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
4490 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
4491 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_key_refresh_complete_evt()
4492 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
4496 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
4498 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
4500 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
4501 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
4503 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
4505 hci_conn_hold(conn); in hci_key_refresh_complete_evt()
4506 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
4507 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
4514 static u8 hci_get_auth_req(struct hci_conn *conn) in hci_get_auth_req() argument
4517 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
4518 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
4519 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
4524 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
4525 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
4526 return conn->remote_auth | 0x01; in hci_get_auth_req()
4529 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
4532 static u8 bredr_oob_data_present(struct hci_conn *conn) in bredr_oob_data_present() argument
4534 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
4537 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
4577 struct hci_conn *conn; in hci_io_capa_request_evt() local
4583 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
4584 if (!conn) in hci_io_capa_request_evt()
4587 hci_conn_hold(conn); in hci_io_capa_request_evt()
4596 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
4597 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
4603 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
4604 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
4607 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
4611 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
4612 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
4613 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
4615 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
4622 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
4624 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
4625 cp.oob_data = bredr_oob_data_present(conn); in hci_io_capa_request_evt()
4646 struct hci_conn *conn; in hci_io_capa_reply_evt() local
4652 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
4653 if (!conn) in hci_io_capa_reply_evt()
4656 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
4657 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
4668 struct hci_conn *conn; in hci_user_confirm_request_evt() local
4677 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
4678 if (!conn) in hci_user_confirm_request_evt()
4681 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
4682 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
4689 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
4690 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
4698 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
4699 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
4707 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
4708 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_user_confirm_request_evt()
4730 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
4731 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
4763 struct hci_conn *conn; in hci_user_passkey_notify_evt() local
4767 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
4768 if (!conn) in hci_user_passkey_notify_evt()
4771 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
4772 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
4775 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
4776 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
4777 conn->passkey_entered); in hci_user_passkey_notify_evt()
4783 struct hci_conn *conn; in hci_keypress_notify_evt() local
4787 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
4788 if (!conn) in hci_keypress_notify_evt()
4793 conn->passkey_entered = 0; in hci_keypress_notify_evt()
4797 conn->passkey_entered++; in hci_keypress_notify_evt()
4801 conn->passkey_entered--; in hci_keypress_notify_evt()
4805 conn->passkey_entered = 0; in hci_keypress_notify_evt()
4813 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
4814 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
4815 conn->passkey_entered); in hci_keypress_notify_evt()
4822 struct hci_conn *conn; in hci_simple_pair_complete_evt() local
4828 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
4829 if (!conn) in hci_simple_pair_complete_evt()
4833 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
4840 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
4841 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
4843 hci_conn_drop(conn); in hci_simple_pair_complete_evt()
4854 struct hci_conn *conn; in hci_remote_host_features_evt() local
4860 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
4861 if (conn) in hci_remote_host_features_evt()
4862 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
5018 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
5073 static void le_conn_update_addr(struct hci_conn *conn, bdaddr_t *bdaddr, in le_conn_update_addr() argument
5076 if (conn->out) { in le_conn_update_addr()
5077 conn->dst_type = bdaddr_type; in le_conn_update_addr()
5078 conn->resp_addr_type = bdaddr_type; in le_conn_update_addr()
5079 bacpy(&conn->resp_addr, bdaddr); in le_conn_update_addr()
5085 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5086 bacpy(&conn->init_addr, local_rpa); in le_conn_update_addr()
5087 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5088 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5089 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5091 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5092 &conn->init_addr_type); in le_conn_update_addr()
5095 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5100 conn->resp_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5101 bacpy(&conn->resp_addr, local_rpa); in le_conn_update_addr()
5102 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5106 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5107 bacpy(&conn->resp_addr, in le_conn_update_addr()
5108 &conn->hdev->random_addr); in le_conn_update_addr()
5110 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5113 conn->init_addr_type = bdaddr_type; in le_conn_update_addr()
5114 bacpy(&conn->init_addr, bdaddr); in le_conn_update_addr()
5121 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5122 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5133 struct hci_conn *conn; in le_conn_complete_evt() local
5144 conn = hci_lookup_le_connect(hdev); in le_conn_complete_evt()
5145 if (!conn) { in le_conn_complete_evt()
5146 conn = hci_conn_add(hdev, LE_LINK, bdaddr, role); in le_conn_complete_evt()
5147 if (!conn) { in le_conn_complete_evt()
5152 conn->dst_type = bdaddr_type; in le_conn_complete_evt()
5162 if (conn->out) { in le_conn_complete_evt()
5163 conn->resp_addr_type = bdaddr_type; in le_conn_complete_evt()
5164 bacpy(&conn->resp_addr, bdaddr); in le_conn_complete_evt()
5166 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_complete_evt()
5167 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5170 &conn->init_addr, in le_conn_complete_evt()
5171 &conn->init_addr_type); in le_conn_complete_evt()
5175 cancel_delayed_work(&conn->le_conn_timeout); in le_conn_complete_evt()
5178 le_conn_update_addr(conn, bdaddr, bdaddr_type, local_rpa); in le_conn_complete_evt()
5189 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5191 bacpy(&conn->dst, &irk->bdaddr); in le_conn_complete_evt()
5192 conn->dst_type = irk->addr_type; in le_conn_complete_evt()
5196 hci_le_conn_failed(conn, status); in le_conn_complete_evt()
5200 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in le_conn_complete_evt()
5206 if (hci_bdaddr_list_lookup(&hdev->blacklist, &conn->dst, addr_type)) { in le_conn_complete_evt()
5207 hci_conn_drop(conn); in le_conn_complete_evt()
5211 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in le_conn_complete_evt()
5212 mgmt_device_connected(hdev, conn, 0, NULL, 0); in le_conn_complete_evt()
5214 conn->sec_level = BT_SECURITY_LOW; in le_conn_complete_evt()
5215 conn->handle = handle; in le_conn_complete_evt()
5216 conn->state = BT_CONFIG; in le_conn_complete_evt()
5218 conn->le_conn_interval = interval; in le_conn_complete_evt()
5219 conn->le_conn_latency = latency; in le_conn_complete_evt()
5220 conn->le_supv_timeout = supervision_timeout; in le_conn_complete_evt()
5222 hci_debugfs_create_conn(conn); in le_conn_complete_evt()
5223 hci_conn_add_sysfs(conn); in le_conn_complete_evt()
5234 if (conn->out || in le_conn_complete_evt()
5238 cp.handle = __cpu_to_le16(conn->handle); in le_conn_complete_evt()
5243 hci_conn_hold(conn); in le_conn_complete_evt()
5245 conn->state = BT_CONNECTED; in le_conn_complete_evt()
5246 hci_connect_cfm(conn, status); in le_conn_complete_evt()
5249 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
5250 conn->dst_type); in le_conn_complete_evt()
5253 if (params->conn) { in le_conn_complete_evt()
5254 hci_conn_drop(params->conn); in le_conn_complete_evt()
5255 hci_conn_put(params->conn); in le_conn_complete_evt()
5256 params->conn = NULL; in le_conn_complete_evt()
5300 struct hci_conn *conn; in hci_le_ext_adv_term_evt() local
5318 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
5319 if (conn) { in hci_le_ext_adv_term_evt()
5323 bacmp(&conn->resp_addr, BDADDR_ANY)) in hci_le_ext_adv_term_evt()
5327 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
5333 bacpy(&conn->resp_addr, &adv_instance->random_addr); in hci_le_ext_adv_term_evt()
5341 struct hci_conn *conn; in hci_le_conn_update_complete_evt() local
5350 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
5351 if (conn) { in hci_le_conn_update_complete_evt()
5352 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
5353 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
5354 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
5366 struct hci_conn *conn; in check_pending_le_conn() local
5416 conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW, in check_pending_le_conn()
5419 if (!IS_ERR(conn)) { in check_pending_le_conn()
5430 params->conn = hci_conn_get(conn); in check_pending_le_conn()
5432 return conn; in check_pending_le_conn()
5435 switch (PTR_ERR(conn)) { in check_pending_le_conn()
5444 BT_DBG("Failed to connect: err %ld", PTR_ERR(conn)); in check_pending_le_conn()
5458 struct hci_conn *conn; in process_adv_report() local
5535 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type, in process_adv_report()
5537 if (!ext_adv && conn && type == LE_ADV_IND && len <= HCI_MAX_AD_LENGTH) { in process_adv_report()
5541 memcpy(conn->le_adv_data, data, len); in process_adv_report()
5542 conn->le_adv_data_len = len; in process_adv_report()
5760 struct hci_conn *conn; in hci_le_remote_feat_complete_evt() local
5766 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
5767 if (conn) { in hci_le_remote_feat_complete_evt()
5769 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
5771 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
5784 !conn->out && ev->status == 0x1a) in hci_le_remote_feat_complete_evt()
5789 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
5790 hci_connect_cfm(conn, status); in hci_le_remote_feat_complete_evt()
5791 hci_conn_drop(conn); in hci_le_remote_feat_complete_evt()
5803 struct hci_conn *conn; in hci_le_ltk_request_evt() local
5810 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
5811 if (conn == NULL) in hci_le_ltk_request_evt()
5814 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
5830 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
5832 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
5834 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
5845 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
5849 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
5955 struct hci_conn *conn; in hci_le_phy_update_evt() local
5964 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
5965 if (!conn) in hci_le_phy_update_evt()
5968 conn->le_tx_phy = ev->tx_phy; in hci_le_phy_update_evt()
5969 conn->le_rx_phy = ev->rx_phy; in hci_le_phy_update_evt()