Lines Matching refs:conn

123 	struct hci_conn *conn;  in hci_cc_role_discovery()  local
132 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
133 if (conn) in hci_cc_role_discovery()
134 conn->role = rp->role; in hci_cc_role_discovery()
142 struct hci_conn *conn; in hci_cc_read_link_policy() local
151 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
152 if (conn) in hci_cc_read_link_policy()
153 conn->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_link_policy()
161 struct hci_conn *conn; in hci_cc_write_link_policy() local
175 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
176 if (conn) in hci_cc_write_link_policy()
177 conn->link_policy = get_unaligned_le16(sent + 2); in hci_cc_write_link_policy()
628 struct hci_conn *conn; in hci_cc_read_auth_payload_timeout() local
637 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
638 if (conn) in hci_cc_read_auth_payload_timeout()
639 conn->auth_payload_timeout = __le16_to_cpu(rp->timeout); in hci_cc_read_auth_payload_timeout()
648 struct hci_conn *conn; in hci_cc_write_auth_payload_timeout() local
662 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
663 if (conn) in hci_cc_write_auth_payload_timeout()
664 conn->auth_payload_timeout = get_unaligned_le16(sent + 2); in hci_cc_write_auth_payload_timeout()
897 struct hci_conn *conn; in hci_cc_read_clock() local
918 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
919 if (conn) { in hci_cc_read_clock()
920 conn->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
921 conn->clock_accuracy = le16_to_cpu(rp->accuracy); in hci_cc_read_clock()
998 struct hci_conn *conn; in hci_cc_pin_code_reply() local
1014 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
1015 if (conn) in hci_cc_pin_code_reply()
1016 conn->pin_length = cp->pin_len; in hci_cc_pin_code_reply()
1275 struct hci_conn *conn; in hci_cc_le_set_adv_enable() local
1279 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_adv_enable()
1280 if (conn) in hci_cc_le_set_adv_enable()
1282 &conn->le_conn_timeout, in hci_cc_le_set_adv_enable()
1283 conn->conn_timeout); in hci_cc_le_set_adv_enable()
1316 struct hci_conn *conn; in hci_cc_le_set_ext_adv_enable() local
1323 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_ext_adv_enable()
1324 if (conn) in hci_cc_le_set_ext_adv_enable()
1326 &conn->le_conn_timeout, in hci_cc_le_set_ext_adv_enable()
1327 conn->conn_timeout); in hci_cc_le_set_ext_adv_enable()
1840 struct hci_conn *conn; in hci_cc_read_rssi() local
1849 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
1850 if (conn) in hci_cc_read_rssi()
1851 conn->rssi = rp->rssi; in hci_cc_read_rssi()
1860 struct hci_conn *conn; in hci_cc_read_tx_power() local
1873 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
1874 if (!conn) in hci_cc_read_tx_power()
1879 conn->tx_power = rp->tx_power; in hci_cc_read_tx_power()
1882 conn->max_tx_power = rp->tx_power; in hci_cc_read_tx_power()
1920 struct hci_conn *conn; in hci_cs_create_conn() local
1930 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
1932 BT_DBG("%s bdaddr %pMR hcon %p", hdev->name, &cp->bdaddr, conn); in hci_cs_create_conn()
1935 if (conn && conn->state == BT_CONNECT) { in hci_cs_create_conn()
1936 if (status != 0x0c || conn->attempt > 2) { in hci_cs_create_conn()
1937 conn->state = BT_CLOSED; in hci_cs_create_conn()
1938 hci_connect_cfm(conn, status); in hci_cs_create_conn()
1939 hci_conn_del(conn); in hci_cs_create_conn()
1941 conn->state = BT_CONNECT2; in hci_cs_create_conn()
1944 if (!conn) { in hci_cs_create_conn()
1945 conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
1947 if (!conn) in hci_cs_create_conn()
1993 struct hci_conn *conn; in hci_cs_auth_requested() local
2006 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
2007 if (conn) { in hci_cs_auth_requested()
2008 if (conn->state == BT_CONFIG) { in hci_cs_auth_requested()
2009 hci_connect_cfm(conn, status); in hci_cs_auth_requested()
2010 hci_conn_drop(conn); in hci_cs_auth_requested()
2020 struct hci_conn *conn; in hci_cs_set_conn_encrypt() local
2033 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
2034 if (conn) { in hci_cs_set_conn_encrypt()
2035 if (conn->state == BT_CONFIG) { in hci_cs_set_conn_encrypt()
2036 hci_connect_cfm(conn, status); in hci_cs_set_conn_encrypt()
2037 hci_conn_drop(conn); in hci_cs_set_conn_encrypt()
2045 struct hci_conn *conn) in hci_outgoing_auth_needed() argument
2047 if (conn->state != BT_CONFIG || !conn->out) in hci_outgoing_auth_needed()
2050 if (conn->pending_sec_level == BT_SECURITY_SDP) in hci_outgoing_auth_needed()
2057 if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) && in hci_outgoing_auth_needed()
2058 conn->pending_sec_level != BT_SECURITY_FIPS && in hci_outgoing_auth_needed()
2059 conn->pending_sec_level != BT_SECURITY_HIGH && in hci_outgoing_auth_needed()
2060 conn->pending_sec_level != BT_SECURITY_MEDIUM) in hci_outgoing_auth_needed()
2101 static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, in hci_check_pending_name() argument
2112 if (conn && in hci_check_pending_name()
2113 (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) && in hci_check_pending_name()
2114 !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_check_pending_name()
2115 mgmt_device_connected(hdev, conn, name, name_len); in hci_check_pending_name()
2153 struct hci_conn *conn; in hci_cs_remote_name_req() local
2168 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2171 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2173 if (!conn) in hci_cs_remote_name_req()
2176 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_cs_remote_name_req()
2179 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_cs_remote_name_req()
2182 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_cs_remote_name_req()
2184 auth_cp.handle = __cpu_to_le16(conn->handle); in hci_cs_remote_name_req()
2196 struct hci_conn *conn; in hci_cs_read_remote_features() local
2209 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2210 if (conn) { in hci_cs_read_remote_features()
2211 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_features()
2212 hci_connect_cfm(conn, status); in hci_cs_read_remote_features()
2213 hci_conn_drop(conn); in hci_cs_read_remote_features()
2223 struct hci_conn *conn; in hci_cs_read_remote_ext_features() local
2236 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2237 if (conn) { in hci_cs_read_remote_ext_features()
2238 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_ext_features()
2239 hci_connect_cfm(conn, status); in hci_cs_read_remote_ext_features()
2240 hci_conn_drop(conn); in hci_cs_read_remote_ext_features()
2320 struct hci_conn *conn; in hci_cs_sniff_mode() local
2333 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2334 if (conn) { in hci_cs_sniff_mode()
2335 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_sniff_mode()
2337 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_sniff_mode()
2338 hci_sco_setup(conn, status); in hci_cs_sniff_mode()
2347 struct hci_conn *conn; in hci_cs_exit_sniff_mode() local
2360 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2361 if (conn) { in hci_cs_exit_sniff_mode()
2362 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_exit_sniff_mode()
2364 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_exit_sniff_mode()
2365 hci_sco_setup(conn, status); in hci_cs_exit_sniff_mode()
2374 struct hci_conn *conn; in hci_cs_disconnect() local
2385 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2386 if (conn) { in hci_cs_disconnect()
2387 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2388 conn->dst_type, status); in hci_cs_disconnect()
2390 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_cs_disconnect()
2391 hdev->cur_adv_instance = conn->adv_instance; in hci_cs_disconnect()
2400 hci_conn_del(conn); in hci_cs_disconnect()
2432 struct hci_conn *conn; in cs_le_create_conn() local
2434 conn = hci_conn_hash_lookup_le(hdev, peer_addr, in cs_le_create_conn()
2436 if (!conn) in cs_le_create_conn()
2445 conn->init_addr_type = own_address_type; in cs_le_create_conn()
2447 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2449 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2451 conn->resp_addr_type = peer_addr_type; in cs_le_create_conn()
2452 bacpy(&conn->resp_addr, peer_addr); in cs_le_create_conn()
2460 queue_delayed_work(conn->hdev->workqueue, in cs_le_create_conn()
2461 &conn->le_conn_timeout, in cs_le_create_conn()
2462 conn->conn_timeout); in cs_le_create_conn()
2518 struct hci_conn *conn; in hci_cs_le_read_remote_features() local
2531 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2532 if (conn) { in hci_cs_le_read_remote_features()
2533 if (conn->state == BT_CONFIG) { in hci_cs_le_read_remote_features()
2534 hci_connect_cfm(conn, status); in hci_cs_le_read_remote_features()
2535 hci_conn_drop(conn); in hci_cs_le_read_remote_features()
2545 struct hci_conn *conn; in hci_cs_le_start_enc() local
2558 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2559 if (!conn) in hci_cs_le_start_enc()
2562 if (conn->state != BT_CONNECTED) in hci_cs_le_start_enc()
2565 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_cs_le_start_enc()
2566 hci_conn_drop(conn); in hci_cs_le_start_enc()
2575 struct hci_conn *conn; in hci_cs_switch_role() local
2588 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
2589 if (conn) in hci_cs_switch_role()
2590 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_cs_switch_role()
2695 struct hci_conn *conn; in hci_conn_complete_evt() local
2701 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
2702 if (!conn) { in hci_conn_complete_evt()
2716 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_complete_evt()
2718 if (!conn) { in hci_conn_complete_evt()
2726 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, in hci_conn_complete_evt()
2728 if (!conn) in hci_conn_complete_evt()
2731 conn->type = SCO_LINK; in hci_conn_complete_evt()
2736 conn->handle = __le16_to_cpu(ev->handle); in hci_conn_complete_evt()
2738 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
2739 conn->state = BT_CONFIG; in hci_conn_complete_evt()
2740 hci_conn_hold(conn); in hci_conn_complete_evt()
2742 if (!conn->out && !hci_conn_ssp_enabled(conn) && in hci_conn_complete_evt()
2744 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_conn_complete_evt()
2746 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_conn_complete_evt()
2748 conn->state = BT_CONNECTED; in hci_conn_complete_evt()
2750 hci_debugfs_create_conn(conn); in hci_conn_complete_evt()
2751 hci_conn_add_sysfs(conn); in hci_conn_complete_evt()
2754 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_conn_complete_evt()
2757 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
2760 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
2770 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
2773 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_complete_evt()
2778 conn->state = BT_CLOSED; in hci_conn_complete_evt()
2779 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
2780 mgmt_connect_failed(hdev, &conn->dst, conn->type, in hci_conn_complete_evt()
2781 conn->dst_type, ev->status); in hci_conn_complete_evt()
2784 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
2785 hci_sco_setup(conn, ev->status); in hci_conn_complete_evt()
2788 hci_connect_cfm(conn, ev->status); in hci_conn_complete_evt()
2789 hci_conn_del(conn); in hci_conn_complete_evt()
2791 switch (conn->setting & SCO_AIRMODE_MASK) { in hci_conn_complete_evt()
2798 hci_connect_cfm(conn, ev->status); in hci_conn_complete_evt()
2821 struct hci_conn *conn; in hci_conn_request_evt() local
2861 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
2863 if (!conn) { in hci_conn_request_evt()
2864 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
2866 if (!conn) { in hci_conn_request_evt()
2873 memcpy(conn->dev_class, ev->dev_class, 3); in hci_conn_request_evt()
2880 conn->state = BT_CONNECT; in hci_conn_request_evt()
2892 conn->state = BT_CONNECT; in hci_conn_request_evt()
2895 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_request_evt()
2906 conn->state = BT_CONNECT2; in hci_conn_request_evt()
2907 hci_connect_cfm(conn, 0); in hci_conn_request_evt()
2932 struct hci_conn *conn; in hci_disconn_complete_evt() local
2939 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
2940 if (!conn) in hci_disconn_complete_evt()
2944 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
2945 conn->dst_type, ev->status); in hci_disconn_complete_evt()
2949 conn->state = BT_CLOSED; in hci_disconn_complete_evt()
2951 mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_disconn_complete_evt()
2953 if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags)) in hci_disconn_complete_evt()
2958 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
2961 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
2962 if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
2963 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
2968 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
2988 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
3008 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_disconn_complete_evt()
3009 hdev->cur_adv_instance = conn->adv_instance; in hci_disconn_complete_evt()
3013 hci_conn_del(conn); in hci_disconn_complete_evt()
3022 struct hci_conn *conn; in hci_auth_complete_evt() local
3028 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
3029 if (!conn) in hci_auth_complete_evt()
3033 clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3035 if (!hci_conn_ssp_enabled(conn) && in hci_auth_complete_evt()
3036 test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { in hci_auth_complete_evt()
3039 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
3040 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
3044 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3046 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
3049 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3050 clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3052 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
3053 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
3060 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
3061 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
3062 hci_conn_drop(conn); in hci_auth_complete_evt()
3065 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
3067 hci_conn_hold(conn); in hci_auth_complete_evt()
3068 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
3069 hci_conn_drop(conn); in hci_auth_complete_evt()
3072 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
3080 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
3081 hci_encrypt_cfm(conn, ev->status); in hci_auth_complete_evt()
3092 struct hci_conn *conn; in hci_remote_name_evt() local
3100 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
3106 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
3109 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
3112 if (!conn) in hci_remote_name_evt()
3115 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_remote_name_evt()
3118 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
3121 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
3123 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
3135 struct hci_conn *conn; in read_enc_key_size_complete() local
3150 conn = hci_conn_hash_lookup_handle(hdev, handle); in read_enc_key_size_complete()
3151 if (!conn) in read_enc_key_size_complete()
3161 conn->enc_key_size = 0; in read_enc_key_size_complete()
3163 conn->enc_key_size = rp->key_size; in read_enc_key_size_complete()
3166 hci_encrypt_cfm(conn, 0); in read_enc_key_size_complete()
3175 struct hci_conn *conn; in hci_encrypt_change_evt() local
3181 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3182 if (!conn) in hci_encrypt_change_evt()
3188 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
3189 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3190 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
3193 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
3194 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
3196 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
3197 conn->type == LE_LINK) in hci_encrypt_change_evt()
3198 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3200 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3201 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3208 if (ev->status && conn->type == LE_LINK) { in hci_encrypt_change_evt()
3213 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
3216 if (!hci_conn_check_link_mode(conn)) in hci_encrypt_change_evt()
3219 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
3221 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_encrypt_change_evt()
3226 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3227 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_encrypt_change_evt()
3228 hci_conn_drop(conn); in hci_encrypt_change_evt()
3233 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
3242 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3248 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3253 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3267 if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_encrypt_change_evt()
3268 test_bit(HCI_CONN_AES_CCM, &conn->flags) && in hci_encrypt_change_evt()
3269 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3270 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3273 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3275 hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3280 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3290 struct hci_conn *conn; in hci_change_link_key_complete_evt() local
3296 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3297 if (conn) { in hci_change_link_key_complete_evt()
3299 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
3301 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
3303 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
3313 struct hci_conn *conn; in hci_remote_features_evt() local
3319 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3320 if (!conn) in hci_remote_features_evt()
3324 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
3326 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
3330 lmp_ext_feat_capable(conn)) { in hci_remote_features_evt()
3339 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_features_evt()
3342 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
3345 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_features_evt()
3346 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_features_evt()
3348 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_features_evt()
3349 conn->state = BT_CONNECTED; in hci_remote_features_evt()
3350 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
3351 hci_conn_drop(conn); in hci_remote_features_evt()
3875 struct hci_conn *conn; in hci_role_change_evt() local
3881 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
3882 if (conn) { in hci_role_change_evt()
3884 conn->role = ev->role; in hci_role_change_evt()
3886 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
3888 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
3914 struct hci_conn *conn; in hci_num_comp_pkts_evt() local
3920 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_num_comp_pkts_evt()
3921 if (!conn) in hci_num_comp_pkts_evt()
3924 conn->sent -= count; in hci_num_comp_pkts_evt()
3926 switch (conn->type) { in hci_num_comp_pkts_evt()
3953 conn->type, conn); in hci_num_comp_pkts_evt()
3972 return chan->conn; in __hci_conn_lookup_handle()
4003 struct hci_conn *conn = NULL; in hci_num_comp_blocks_evt() local
4009 conn = __hci_conn_lookup_handle(hdev, handle); in hci_num_comp_blocks_evt()
4010 if (!conn) in hci_num_comp_blocks_evt()
4013 conn->sent -= block_count; in hci_num_comp_blocks_evt()
4015 switch (conn->type) { in hci_num_comp_blocks_evt()
4025 conn->type, conn); in hci_num_comp_blocks_evt()
4036 struct hci_conn *conn; in hci_mode_change_evt() local
4042 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4043 if (conn) { in hci_mode_change_evt()
4044 conn->mode = ev->mode; in hci_mode_change_evt()
4047 &conn->flags)) { in hci_mode_change_evt()
4048 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
4049 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4051 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4054 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
4055 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
4064 struct hci_conn *conn; in hci_pin_code_request_evt() local
4070 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4071 if (!conn) in hci_pin_code_request_evt()
4074 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
4075 hci_conn_hold(conn); in hci_pin_code_request_evt()
4076 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
4077 hci_conn_drop(conn); in hci_pin_code_request_evt()
4081 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
4087 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
4099 static void conn_set_key(struct hci_conn *conn, u8 key_type, u8 pin_len) in conn_set_key() argument
4104 conn->pin_length = pin_len; in conn_set_key()
4105 conn->key_type = key_type; in conn_set_key()
4114 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4116 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4120 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4123 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4126 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
4135 struct hci_conn *conn; in hci_link_key_request_evt() local
4155 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4156 if (conn) { in hci_link_key_request_evt()
4157 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
4161 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
4167 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
4168 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
4174 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
4194 struct hci_conn *conn; in hci_link_key_notify_evt() local
4203 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4204 if (!conn) in hci_link_key_notify_evt()
4207 hci_conn_hold(conn); in hci_link_key_notify_evt()
4208 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
4209 hci_conn_drop(conn); in hci_link_key_notify_evt()
4211 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
4212 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
4217 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4226 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
4243 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4245 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4254 struct hci_conn *conn; in hci_clock_offset_evt() local
4260 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4261 if (conn && !ev->status) { in hci_clock_offset_evt()
4264 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4277 struct hci_conn *conn; in hci_pkt_type_change_evt() local
4283 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4284 if (conn && !ev->status) in hci_pkt_type_change_evt()
4285 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
4383 struct hci_conn *conn; in hci_remote_ext_features_evt() local
4389 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4390 if (!conn) in hci_remote_ext_features_evt()
4394 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
4399 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4404 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4414 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4418 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4421 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
4424 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
4427 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
4430 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_ext_features_evt()
4431 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_ext_features_evt()
4433 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_ext_features_evt()
4434 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
4435 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
4436 hci_conn_drop(conn); in hci_remote_ext_features_evt()
4447 struct hci_conn *conn; in hci_sync_conn_complete_evt() local
4454 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
4455 if (!conn) { in hci_sync_conn_complete_evt()
4468 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
4469 if (!conn) in hci_sync_conn_complete_evt()
4485 if (conn->state == BT_CONNECTED) { in hci_sync_conn_complete_evt()
4490 conn->handle = __le16_to_cpu(ev->handle); in hci_sync_conn_complete_evt()
4491 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
4492 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
4494 hci_debugfs_create_conn(conn); in hci_sync_conn_complete_evt()
4495 hci_conn_add_sysfs(conn); in hci_sync_conn_complete_evt()
4506 if (conn->out) { in hci_sync_conn_complete_evt()
4507 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
4509 if (hci_setup_sync(conn, conn->link->handle)) in hci_sync_conn_complete_evt()
4515 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
4533 if (conn->codec.data_path == 0) { in hci_sync_conn_complete_evt()
4538 hci_connect_cfm(conn, ev->status); in hci_sync_conn_complete_evt()
4540 hci_conn_del(conn); in hci_sync_conn_complete_evt()
4617 struct hci_conn *conn; in hci_key_refresh_complete_evt() local
4624 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
4625 if (!conn) in hci_key_refresh_complete_evt()
4631 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
4635 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
4637 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
4639 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
4640 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_key_refresh_complete_evt()
4641 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
4645 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
4647 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
4649 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
4650 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
4652 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
4654 hci_conn_hold(conn); in hci_key_refresh_complete_evt()
4655 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
4656 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
4663 static u8 hci_get_auth_req(struct hci_conn *conn) in hci_get_auth_req() argument
4666 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
4667 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
4668 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
4673 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
4674 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
4675 return conn->remote_auth | 0x01; in hci_get_auth_req()
4678 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
4681 static u8 bredr_oob_data_present(struct hci_conn *conn) in bredr_oob_data_present() argument
4683 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
4686 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
4726 struct hci_conn *conn; in hci_io_capa_request_evt() local
4732 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
4733 if (!conn) in hci_io_capa_request_evt()
4736 hci_conn_hold(conn); in hci_io_capa_request_evt()
4745 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
4746 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
4752 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
4753 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
4756 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
4760 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
4761 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
4762 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
4764 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
4771 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
4773 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
4774 cp.oob_data = bredr_oob_data_present(conn); in hci_io_capa_request_evt()
4795 struct hci_conn *conn; in hci_io_capa_reply_evt() local
4801 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
4802 if (!conn) in hci_io_capa_reply_evt()
4805 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
4806 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
4817 struct hci_conn *conn; in hci_user_confirm_request_evt() local
4826 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
4827 if (!conn) in hci_user_confirm_request_evt()
4830 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
4831 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
4838 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
4839 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
4847 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
4848 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
4856 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
4857 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_user_confirm_request_evt()
4879 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
4880 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
4912 struct hci_conn *conn; in hci_user_passkey_notify_evt() local
4916 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
4917 if (!conn) in hci_user_passkey_notify_evt()
4920 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
4921 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
4924 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
4925 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
4926 conn->passkey_entered); in hci_user_passkey_notify_evt()
4932 struct hci_conn *conn; in hci_keypress_notify_evt() local
4936 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
4937 if (!conn) in hci_keypress_notify_evt()
4942 conn->passkey_entered = 0; in hci_keypress_notify_evt()
4946 conn->passkey_entered++; in hci_keypress_notify_evt()
4950 conn->passkey_entered--; in hci_keypress_notify_evt()
4954 conn->passkey_entered = 0; in hci_keypress_notify_evt()
4962 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
4963 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
4964 conn->passkey_entered); in hci_keypress_notify_evt()
4971 struct hci_conn *conn; in hci_simple_pair_complete_evt() local
4977 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
4978 if (!conn) in hci_simple_pair_complete_evt()
4982 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
4989 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
4990 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
4992 hci_conn_drop(conn); in hci_simple_pair_complete_evt()
5003 struct hci_conn *conn; in hci_remote_host_features_evt() local
5009 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5010 if (conn) in hci_remote_host_features_evt()
5011 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
5163 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
5218 static void le_conn_update_addr(struct hci_conn *conn, bdaddr_t *bdaddr, in le_conn_update_addr() argument
5221 if (conn->out) { in le_conn_update_addr()
5222 conn->dst_type = bdaddr_type; in le_conn_update_addr()
5223 conn->resp_addr_type = bdaddr_type; in le_conn_update_addr()
5224 bacpy(&conn->resp_addr, bdaddr); in le_conn_update_addr()
5230 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5231 bacpy(&conn->init_addr, local_rpa); in le_conn_update_addr()
5232 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5233 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5234 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5236 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5237 &conn->init_addr_type); in le_conn_update_addr()
5240 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5245 conn->resp_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5246 bacpy(&conn->resp_addr, local_rpa); in le_conn_update_addr()
5247 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5251 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5252 bacpy(&conn->resp_addr, in le_conn_update_addr()
5253 &conn->hdev->random_addr); in le_conn_update_addr()
5255 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5258 conn->init_addr_type = bdaddr_type; in le_conn_update_addr()
5259 bacpy(&conn->init_addr, bdaddr); in le_conn_update_addr()
5266 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5267 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5278 struct hci_conn *conn; in le_conn_complete_evt() local
5289 conn = hci_lookup_le_connect(hdev); in le_conn_complete_evt()
5290 if (!conn) { in le_conn_complete_evt()
5291 conn = hci_conn_add(hdev, LE_LINK, bdaddr, role); in le_conn_complete_evt()
5292 if (!conn) { in le_conn_complete_evt()
5297 conn->dst_type = bdaddr_type; in le_conn_complete_evt()
5307 if (conn->out) { in le_conn_complete_evt()
5308 conn->resp_addr_type = bdaddr_type; in le_conn_complete_evt()
5309 bacpy(&conn->resp_addr, bdaddr); in le_conn_complete_evt()
5311 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_complete_evt()
5312 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5315 &conn->init_addr, in le_conn_complete_evt()
5316 &conn->init_addr_type); in le_conn_complete_evt()
5320 cancel_delayed_work(&conn->le_conn_timeout); in le_conn_complete_evt()
5323 le_conn_update_addr(conn, bdaddr, bdaddr_type, local_rpa); in le_conn_complete_evt()
5334 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5336 bacpy(&conn->dst, &irk->bdaddr); in le_conn_complete_evt()
5337 conn->dst_type = irk->addr_type; in le_conn_complete_evt()
5340 conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL); in le_conn_complete_evt()
5343 hci_le_conn_failed(conn, status); in le_conn_complete_evt()
5347 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in le_conn_complete_evt()
5353 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5354 hci_conn_drop(conn); in le_conn_complete_evt()
5358 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in le_conn_complete_evt()
5359 mgmt_device_connected(hdev, conn, NULL, 0); in le_conn_complete_evt()
5361 conn->sec_level = BT_SECURITY_LOW; in le_conn_complete_evt()
5362 conn->handle = handle; in le_conn_complete_evt()
5363 conn->state = BT_CONFIG; in le_conn_complete_evt()
5370 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
5372 conn->le_conn_interval = interval; in le_conn_complete_evt()
5373 conn->le_conn_latency = latency; in le_conn_complete_evt()
5374 conn->le_supv_timeout = supervision_timeout; in le_conn_complete_evt()
5376 hci_debugfs_create_conn(conn); in le_conn_complete_evt()
5377 hci_conn_add_sysfs(conn); in le_conn_complete_evt()
5388 if (conn->out || in le_conn_complete_evt()
5392 cp.handle = __cpu_to_le16(conn->handle); in le_conn_complete_evt()
5397 hci_conn_hold(conn); in le_conn_complete_evt()
5399 conn->state = BT_CONNECTED; in le_conn_complete_evt()
5400 hci_connect_cfm(conn, status); in le_conn_complete_evt()
5403 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
5404 conn->dst_type); in le_conn_complete_evt()
5407 if (params->conn) { in le_conn_complete_evt()
5408 hci_conn_drop(params->conn); in le_conn_complete_evt()
5409 hci_conn_put(params->conn); in le_conn_complete_evt()
5410 params->conn = NULL; in le_conn_complete_evt()
5454 struct hci_conn *conn; in hci_le_ext_adv_term_evt() local
5475 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
5476 if (conn) { in hci_le_ext_adv_term_evt()
5480 conn->adv_instance = ev->handle; in hci_le_ext_adv_term_evt()
5483 bacmp(&conn->resp_addr, BDADDR_ANY)) in hci_le_ext_adv_term_evt()
5487 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
5492 bacpy(&conn->resp_addr, &adv->random_addr); in hci_le_ext_adv_term_evt()
5500 struct hci_conn *conn; in hci_le_conn_update_complete_evt() local
5509 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
5510 if (conn) { in hci_le_conn_update_complete_evt()
5511 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
5512 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
5513 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
5525 struct hci_conn *conn; in check_pending_le_conn() local
5575 conn = hci_connect_le(hdev, addr, addr_type, addr_resolved, in check_pending_le_conn()
5578 if (!IS_ERR(conn)) { in check_pending_le_conn()
5589 params->conn = hci_conn_get(conn); in check_pending_le_conn()
5591 return conn; in check_pending_le_conn()
5594 switch (PTR_ERR(conn)) { in check_pending_le_conn()
5603 BT_DBG("Failed to connect: err %ld", PTR_ERR(conn)); in check_pending_le_conn()
5617 struct hci_conn *conn; in process_adv_report() local
5699 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, bdaddr_resolved, in process_adv_report()
5701 if (!ext_adv && conn && type == LE_ADV_IND && len <= HCI_MAX_AD_LENGTH) { in process_adv_report()
5705 memcpy(conn->le_adv_data, data, len); in process_adv_report()
5706 conn->le_adv_data_len = len; in process_adv_report()
5918 struct hci_conn *conn; in hci_le_remote_feat_complete_evt() local
5924 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
5925 if (conn) { in hci_le_remote_feat_complete_evt()
5927 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
5929 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
5941 if (!conn->out && ev->status == 0x1a && in hci_le_remote_feat_complete_evt()
5947 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
5948 hci_connect_cfm(conn, status); in hci_le_remote_feat_complete_evt()
5949 hci_conn_drop(conn); in hci_le_remote_feat_complete_evt()
5961 struct hci_conn *conn; in hci_le_ltk_request_evt() local
5968 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
5969 if (conn == NULL) in hci_le_ltk_request_evt()
5972 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
5988 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
5990 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
5992 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
6003 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6007 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6113 struct hci_conn *conn; in hci_le_phy_update_evt() local
6122 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
6123 if (!conn) in hci_le_phy_update_evt()
6126 conn->le_tx_phy = ev->tx_phy; in hci_le_phy_update_evt()
6127 conn->le_rx_phy = ev->rx_phy; in hci_le_phy_update_evt()