Lines Matching full:conn

165 	struct hci_conn *conn;  in hci_cc_role_discovery()  local
174 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
175 if (conn) in hci_cc_role_discovery()
176 conn->role = rp->role; in hci_cc_role_discovery()
187 struct hci_conn *conn; in hci_cc_read_link_policy() local
196 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
197 if (conn) in hci_cc_read_link_policy()
198 conn->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_link_policy()
209 struct hci_conn *conn; in hci_cc_write_link_policy() local
223 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
224 if (conn) in hci_cc_write_link_policy()
225 conn->link_policy = get_unaligned_le16(sent + 2); in hci_cc_write_link_policy()
717 struct hci_conn *conn; in hci_cc_read_enc_key_size() local
727 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_cc_read_enc_key_size()
728 if (!conn) { in hci_cc_read_enc_key_size()
740 conn->enc_key_size = 0; in hci_cc_read_enc_key_size()
742 conn->enc_key_size = rp->key_size; in hci_cc_read_enc_key_size()
745 if (conn->enc_key_size < hdev->min_enc_key_size) { in hci_cc_read_enc_key_size()
746 /* As slave role, the conn->state has been set to in hci_cc_read_enc_key_size()
747 * BT_CONNECTED and l2cap conn req might not be received in hci_cc_read_enc_key_size()
751 * handler of l2cap conn req will get the right secure in hci_cc_read_enc_key_size()
755 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_cc_read_enc_key_size()
756 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_cc_read_enc_key_size()
760 hci_encrypt_cfm(conn, status); in hci_cc_read_enc_key_size()
789 struct hci_conn *conn; in hci_cc_read_auth_payload_timeout() local
798 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
799 if (conn) in hci_cc_read_auth_payload_timeout()
800 conn->auth_payload_timeout = __le16_to_cpu(rp->timeout); in hci_cc_read_auth_payload_timeout()
811 struct hci_conn *conn; in hci_cc_write_auth_payload_timeout() local
822 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
823 if (!conn) { in hci_cc_write_auth_payload_timeout()
829 conn->auth_payload_timeout = get_unaligned_le16(sent + 2); in hci_cc_write_auth_payload_timeout()
1061 struct hci_conn *conn; in hci_cc_read_clock() local
1079 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
1080 if (conn) { in hci_cc_read_clock()
1081 conn->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1082 conn->clock_accuracy = le16_to_cpu(rp->accuracy); in hci_cc_read_clock()
1145 struct hci_conn *conn; in hci_cc_pin_code_reply() local
1161 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
1162 if (conn) in hci_cc_pin_code_reply()
1163 conn->pin_length = cp->pin_len; in hci_cc_pin_code_reply()
1549 struct hci_conn *conn; in hci_cc_le_set_adv_enable() local
1553 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_adv_enable()
1554 if (conn) in hci_cc_le_set_adv_enable()
1556 &conn->le_conn_timeout, in hci_cc_le_set_adv_enable()
1557 conn->conn_timeout); in hci_cc_le_set_adv_enable()
1592 struct hci_conn *conn; in hci_cc_le_set_ext_adv_enable() local
1599 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_ext_adv_enable()
1600 if (conn) in hci_cc_le_set_ext_adv_enable()
1602 &conn->le_conn_timeout, in hci_cc_le_set_ext_adv_enable()
1603 conn->conn_timeout); in hci_cc_le_set_ext_adv_enable()
2177 struct hci_conn *conn; in hci_cc_read_rssi() local
2186 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
2187 if (conn) in hci_cc_read_rssi()
2188 conn->rssi = rp->rssi; in hci_cc_read_rssi()
2200 struct hci_conn *conn; in hci_cc_read_tx_power() local
2213 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
2214 if (!conn) in hci_cc_read_tx_power()
2219 conn->tx_power = rp->tx_power; in hci_cc_read_tx_power()
2222 conn->max_tx_power = rp->tx_power; in hci_cc_read_tx_power()
2263 struct hci_conn *conn; in hci_cs_create_conn() local
2273 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
2275 bt_dev_dbg(hdev, "bdaddr %pMR hcon %p", &cp->bdaddr, conn); in hci_cs_create_conn()
2278 if (conn && conn->state == BT_CONNECT) { in hci_cs_create_conn()
2279 conn->state = BT_CLOSED; in hci_cs_create_conn()
2280 hci_connect_cfm(conn, status); in hci_cs_create_conn()
2281 hci_conn_del(conn); in hci_cs_create_conn()
2284 if (!conn) { in hci_cs_create_conn()
2285 conn = hci_conn_add_unset(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
2287 if (IS_ERR(conn)) in hci_cs_create_conn()
2288 bt_dev_err(hdev, "connection err: %ld", PTR_ERR(conn)); in hci_cs_create_conn()
2321 if (link && link->conn) { in hci_cs_add_sco()
2322 link->conn->state = BT_CLOSED; in hci_cs_add_sco()
2324 hci_connect_cfm(link->conn, status); in hci_cs_add_sco()
2325 hci_conn_del(link->conn); in hci_cs_add_sco()
2335 struct hci_conn *conn; in hci_cs_auth_requested() local
2348 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
2349 if (conn) { in hci_cs_auth_requested()
2350 if (conn->state == BT_CONFIG) { in hci_cs_auth_requested()
2351 hci_connect_cfm(conn, status); in hci_cs_auth_requested()
2352 hci_conn_drop(conn); in hci_cs_auth_requested()
2362 struct hci_conn *conn; in hci_cs_set_conn_encrypt() local
2375 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
2376 if (conn) { in hci_cs_set_conn_encrypt()
2377 if (conn->state == BT_CONFIG) { in hci_cs_set_conn_encrypt()
2378 hci_connect_cfm(conn, status); in hci_cs_set_conn_encrypt()
2379 hci_conn_drop(conn); in hci_cs_set_conn_encrypt()
2387 struct hci_conn *conn) in hci_outgoing_auth_needed() argument
2389 if (conn->state != BT_CONFIG || !conn->out) in hci_outgoing_auth_needed()
2392 if (conn->pending_sec_level == BT_SECURITY_SDP) in hci_outgoing_auth_needed()
2399 if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) && in hci_outgoing_auth_needed()
2400 conn->pending_sec_level != BT_SECURITY_FIPS && in hci_outgoing_auth_needed()
2401 conn->pending_sec_level != BT_SECURITY_HIGH && in hci_outgoing_auth_needed()
2402 conn->pending_sec_level != BT_SECURITY_MEDIUM) in hci_outgoing_auth_needed()
2449 static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, in hci_check_pending_name() argument
2456 * conn objects that exist but are not (yet) connected however. in hci_check_pending_name()
2460 if (conn && (conn->state == BT_CONFIG || conn->state == BT_CONNECTED)) in hci_check_pending_name()
2461 mgmt_device_connected(hdev, conn, name, name_len); in hci_check_pending_name()
2496 struct hci_conn *conn; in hci_cs_remote_name_req() local
2511 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2514 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2516 if (!conn) in hci_cs_remote_name_req()
2519 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_cs_remote_name_req()
2522 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_cs_remote_name_req()
2525 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_cs_remote_name_req()
2527 auth_cp.handle = __cpu_to_le16(conn->handle); in hci_cs_remote_name_req()
2539 struct hci_conn *conn; in hci_cs_read_remote_features() local
2552 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2553 if (conn) { in hci_cs_read_remote_features()
2554 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_features()
2555 hci_connect_cfm(conn, status); in hci_cs_read_remote_features()
2556 hci_conn_drop(conn); in hci_cs_read_remote_features()
2566 struct hci_conn *conn; in hci_cs_read_remote_ext_features() local
2579 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2580 if (conn) { in hci_cs_read_remote_ext_features()
2581 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_ext_features()
2582 hci_connect_cfm(conn, status); in hci_cs_read_remote_ext_features()
2583 hci_conn_drop(conn); in hci_cs_read_remote_ext_features()
2604 if (link && link->conn) { in hci_setup_sync_conn_status()
2605 link->conn->state = BT_CLOSED; in hci_setup_sync_conn_status()
2607 hci_connect_cfm(link->conn, status); in hci_setup_sync_conn_status()
2608 hci_conn_del(link->conn); in hci_setup_sync_conn_status()
2650 struct hci_conn *conn; in hci_cs_sniff_mode() local
2663 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2664 if (conn) { in hci_cs_sniff_mode()
2665 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_sniff_mode()
2667 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_sniff_mode()
2668 hci_sco_setup(conn, status); in hci_cs_sniff_mode()
2677 struct hci_conn *conn; in hci_cs_exit_sniff_mode() local
2690 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2691 if (conn) { in hci_cs_exit_sniff_mode()
2692 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_exit_sniff_mode()
2694 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_exit_sniff_mode()
2695 hci_sco_setup(conn, status); in hci_cs_exit_sniff_mode()
2705 struct hci_conn *conn; in hci_cs_disconnect() local
2722 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2723 if (!conn) in hci_cs_disconnect()
2727 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2728 conn->dst_type, status); in hci_cs_disconnect()
2730 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_cs_disconnect()
2731 hdev->cur_adv_instance = conn->adv_instance; in hci_cs_disconnect()
2735 /* Inform sockets conn is gone before we delete it */ in hci_cs_disconnect()
2736 hci_disconn_cfm(conn, HCI_ERROR_UNSPECIFIED); in hci_cs_disconnect()
2741 mgmt_conn = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_cs_disconnect()
2743 if (conn->type == ACL_LINK) { in hci_cs_disconnect()
2744 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_cs_disconnect()
2745 hci_remove_link_key(hdev, &conn->dst); in hci_cs_disconnect()
2748 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_cs_disconnect()
2767 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_cs_disconnect()
2770 hci_disconn_cfm(conn, cp->reason); in hci_cs_disconnect()
2778 hci_conn_del(conn); in hci_cs_disconnect()
2809 struct hci_conn *conn; in cs_le_create_conn() local
2811 conn = hci_conn_hash_lookup_le(hdev, peer_addr, in cs_le_create_conn()
2813 if (!conn) in cs_le_create_conn()
2822 conn->init_addr_type = own_address_type; in cs_le_create_conn()
2824 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2826 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2828 conn->resp_addr_type = peer_addr_type; in cs_le_create_conn()
2829 bacpy(&conn->resp_addr, peer_addr); in cs_le_create_conn()
2885 struct hci_conn *conn; in hci_cs_le_read_remote_features() local
2898 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2899 if (conn) { in hci_cs_le_read_remote_features()
2900 if (conn->state == BT_CONFIG) { in hci_cs_le_read_remote_features()
2901 hci_connect_cfm(conn, status); in hci_cs_le_read_remote_features()
2902 hci_conn_drop(conn); in hci_cs_le_read_remote_features()
2912 struct hci_conn *conn; in hci_cs_le_start_enc() local
2925 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2926 if (!conn) in hci_cs_le_start_enc()
2929 if (conn->state != BT_CONNECTED) in hci_cs_le_start_enc()
2932 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_cs_le_start_enc()
2933 hci_conn_drop(conn); in hci_cs_le_start_enc()
2942 struct hci_conn *conn; in hci_cs_switch_role() local
2955 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
2956 if (conn) in hci_cs_switch_role()
2957 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_cs_switch_role()
3069 struct hci_conn *conn; in hci_conn_complete_evt() local
3076 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
3077 if (!conn) { in hci_conn_complete_evt()
3097 conn = hci_conn_add_unset(hdev, ev->link_type, in hci_conn_complete_evt()
3099 if (IS_ERR(conn)) { in hci_conn_complete_evt()
3100 bt_dev_err(hdev, "connection err: %ld", PTR_ERR(conn)); in hci_conn_complete_evt()
3107 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, in hci_conn_complete_evt()
3109 if (!conn) in hci_conn_complete_evt()
3112 conn->type = SCO_LINK; in hci_conn_complete_evt()
3122 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in hci_conn_complete_evt()
3128 status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle)); in hci_conn_complete_evt()
3132 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3133 conn->state = BT_CONFIG; in hci_conn_complete_evt()
3134 hci_conn_hold(conn); in hci_conn_complete_evt()
3136 if (!conn->out && !hci_conn_ssp_enabled(conn) && in hci_conn_complete_evt()
3138 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_conn_complete_evt()
3140 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_conn_complete_evt()
3142 conn->state = BT_CONNECTED; in hci_conn_complete_evt()
3144 hci_debugfs_create_conn(conn); in hci_conn_complete_evt()
3145 hci_conn_add_sysfs(conn); in hci_conn_complete_evt()
3148 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_conn_complete_evt()
3151 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
3154 if (ev->encr_mode == 1 && !test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_conn_complete_evt()
3161 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
3164 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_conn_complete_evt()
3166 cp.handle = cpu_to_le16(conn->handle); in hci_conn_complete_evt()
3170 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_conn_complete_evt()
3174 hci_encrypt_cfm(conn, ev->status); in hci_conn_complete_evt()
3179 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3189 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
3192 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_complete_evt()
3198 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
3199 hci_sco_setup(conn, ev->status); in hci_conn_complete_evt()
3203 hci_conn_failed(conn, status); in hci_conn_complete_evt()
3205 switch (conn->setting & SCO_AIRMODE_MASK) { in hci_conn_complete_evt()
3212 hci_connect_cfm(conn, status); in hci_conn_complete_evt()
3234 struct hci_conn *conn; in hci_conn_request_evt() local
3283 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
3285 if (!conn) { in hci_conn_request_evt()
3286 conn = hci_conn_add_unset(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
3288 if (IS_ERR(conn)) { in hci_conn_request_evt()
3289 bt_dev_err(hdev, "connection err: %ld", PTR_ERR(conn)); in hci_conn_request_evt()
3294 memcpy(conn->dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3301 conn->state = BT_CONNECT; in hci_conn_request_evt()
3313 conn->state = BT_CONNECT; in hci_conn_request_evt()
3316 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_request_evt()
3327 conn->state = BT_CONNECT2; in hci_conn_request_evt()
3328 hci_connect_cfm(conn, 0); in hci_conn_request_evt()
3358 struct hci_conn *conn; in hci_disconn_complete_evt() local
3365 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
3366 if (!conn) in hci_disconn_complete_evt()
3370 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
3371 conn->dst_type, ev->status); in hci_disconn_complete_evt()
3375 conn->state = BT_CLOSED; in hci_disconn_complete_evt()
3377 mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_disconn_complete_evt()
3379 if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags)) in hci_disconn_complete_evt()
3384 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
3387 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
3388 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
3389 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
3397 if (conn->type == LE_LINK) { in hci_disconn_complete_evt()
3398 params = hci_conn_params_lookup(hdev, &conn->dst, in hci_disconn_complete_evt()
3399 conn->dst_type); in hci_disconn_complete_evt()
3421 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
3433 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_disconn_complete_evt()
3434 hdev->cur_adv_instance = conn->adv_instance; in hci_disconn_complete_evt()
3438 hci_conn_del(conn); in hci_disconn_complete_evt()
3448 struct hci_conn *conn; in hci_auth_complete_evt() local
3454 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
3455 if (!conn) in hci_auth_complete_evt()
3459 clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3460 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
3461 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
3464 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3466 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
3469 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3471 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
3472 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
3479 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
3480 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
3481 hci_conn_drop(conn); in hci_auth_complete_evt()
3484 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
3486 hci_conn_hold(conn); in hci_auth_complete_evt()
3487 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
3488 hci_conn_drop(conn); in hci_auth_complete_evt()
3491 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
3499 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
3500 hci_encrypt_cfm(conn, ev->status); in hci_auth_complete_evt()
3512 struct hci_conn *conn; in hci_remote_name_evt() local
3518 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
3524 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
3527 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
3530 if (!conn) in hci_remote_name_evt()
3533 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_remote_name_evt()
3536 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
3539 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
3541 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
3553 struct hci_conn *conn; in hci_encrypt_change_evt() local
3559 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3560 if (!conn) in hci_encrypt_change_evt()
3566 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
3567 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3568 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
3571 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
3572 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
3574 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
3575 conn->type == LE_LINK) in hci_encrypt_change_evt()
3576 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3578 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3579 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3586 if (ev->status && conn->type == LE_LINK) { in hci_encrypt_change_evt()
3591 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
3594 if (!hci_conn_check_link_mode(conn)) in hci_encrypt_change_evt()
3597 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
3599 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_encrypt_change_evt()
3604 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3605 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_encrypt_change_evt()
3606 hci_conn_drop(conn); in hci_encrypt_change_evt()
3611 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
3619 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3623 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3627 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3644 * sent when the link is active and Encryption is enabled, the conn in hci_encrypt_change_evt()
3648 if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_encrypt_change_evt()
3649 test_bit(HCI_CONN_AES_CCM, &conn->flags) && in hci_encrypt_change_evt()
3650 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3651 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3654 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3656 if (hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3662 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3672 struct hci_conn *conn; in hci_change_link_key_complete_evt() local
3678 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3679 if (conn) { in hci_change_link_key_complete_evt()
3681 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
3683 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
3685 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
3695 struct hci_conn *conn; in hci_remote_features_evt() local
3701 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3702 if (!conn) in hci_remote_features_evt()
3706 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
3708 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
3712 lmp_ext_feat_capable(conn)) { in hci_remote_features_evt()
3724 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
3728 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_features_evt()
3731 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_features_evt()
3732 conn->state = BT_CONNECTED; in hci_remote_features_evt()
3733 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
3734 hci_conn_drop(conn); in hci_remote_features_evt()
3788 struct hci_conn *conn, *tmp; in hci_unbound_cis_failed() local
3792 list_for_each_entry_safe(conn, tmp, &hdev->conn_hash.list, list) { in hci_unbound_cis_failed()
3793 if (conn->type != ISO_LINK || !bacmp(&conn->dst, BDADDR_ANY) || in hci_unbound_cis_failed()
3794 conn->state == BT_OPEN || conn->iso_qos.ucast.cig != cig) in hci_unbound_cis_failed()
3797 if (HCI_CONN_HANDLE_UNSET(conn->handle)) in hci_unbound_cis_failed()
3798 hci_conn_failed(conn, status); in hci_unbound_cis_failed()
3807 struct hci_conn *conn; in hci_cc_le_set_cig_params() local
3843 conn = hci_conn_hash_lookup_cis(hdev, NULL, 0, rp->cig_id, in hci_cc_le_set_cig_params()
3845 if (!conn || !bacmp(&conn->dst, BDADDR_ANY)) in hci_cc_le_set_cig_params()
3848 if (conn->state != BT_BOUND && conn->state != BT_CONNECT) in hci_cc_le_set_cig_params()
3851 if (hci_conn_set_handle(conn, __le16_to_cpu(rp->handle[i]))) in hci_cc_le_set_cig_params()
3854 if (conn->state == BT_CONNECT) in hci_cc_le_set_cig_params()
3872 struct hci_conn *conn; in hci_cc_le_setup_iso_path() local
3882 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cc_le_setup_iso_path()
3883 if (!conn) in hci_cc_le_setup_iso_path()
3887 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3888 hci_conn_del(conn); in hci_cc_le_setup_iso_path()
3896 if (conn->iso_qos.ucast.out.sdu && !conn->iso_qos.ucast.in.sdu) in hci_cc_le_setup_iso_path()
3897 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3901 /* Confirm connection since conn->iso_qos is always configured in hci_cc_le_setup_iso_path()
3904 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3907 if (!rp->status && test_bit(HCI_CONN_BIG_SYNC, &conn->flags)) in hci_cc_le_setup_iso_path()
3908 mgmt_device_connected(hdev, conn, NULL, 0); in hci_cc_le_setup_iso_path()
3938 /* TODO: set the conn state */ in hci_cc_set_per_adv_param()
4265 struct hci_conn *conn; in hci_cs_le_create_cis() local
4270 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_le_create_cis()
4271 if (conn) { in hci_cs_le_create_cis()
4273 &conn->flags)) in hci_cs_le_create_cis()
4275 conn->state = BT_CLOSED; in hci_cs_le_create_cis()
4276 hci_connect_cfm(conn, status); in hci_cs_le_create_cis()
4277 hci_conn_del(conn); in hci_cs_le_create_cis()
4380 struct hci_conn *conn; in hci_role_change_evt() local
4386 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
4387 if (conn) { in hci_role_change_evt()
4389 conn->role = ev->role; in hci_role_change_evt()
4391 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
4393 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
4413 struct hci_conn *conn; in hci_num_comp_pkts_evt() local
4419 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_num_comp_pkts_evt()
4420 if (!conn) in hci_num_comp_pkts_evt()
4423 conn->sent -= count; in hci_num_comp_pkts_evt()
4425 switch (conn->type) { in hci_num_comp_pkts_evt()
4469 bt_dev_err(hdev, "unknown type %d conn %p", in hci_num_comp_pkts_evt()
4470 conn->type, conn); in hci_num_comp_pkts_evt()
4482 struct hci_conn *conn; in hci_mode_change_evt() local
4488 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4489 if (conn) { in hci_mode_change_evt()
4490 conn->mode = ev->mode; in hci_mode_change_evt()
4493 &conn->flags)) { in hci_mode_change_evt()
4494 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
4495 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4497 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4500 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
4501 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
4511 struct hci_conn *conn; in hci_pin_code_request_evt() local
4517 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4518 if (!conn) in hci_pin_code_request_evt()
4521 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
4522 hci_conn_hold(conn); in hci_pin_code_request_evt()
4523 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
4524 hci_conn_drop(conn); in hci_pin_code_request_evt()
4528 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
4534 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
4546 static void conn_set_key(struct hci_conn *conn, u8 key_type, u8 pin_len) in conn_set_key() argument
4551 conn->pin_length = pin_len; in conn_set_key()
4552 conn->key_type = key_type; in conn_set_key()
4561 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4563 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4567 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4570 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4573 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
4583 struct hci_conn *conn; in hci_link_key_request_evt() local
4601 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4602 if (conn) { in hci_link_key_request_evt()
4603 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
4607 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
4613 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
4614 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
4619 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
4640 struct hci_conn *conn; in hci_link_key_notify_evt() local
4649 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4650 if (!conn) in hci_link_key_notify_evt()
4657 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_link_key_notify_evt()
4658 hci_conn_drop(conn); in hci_link_key_notify_evt()
4662 hci_conn_hold(conn); in hci_link_key_notify_evt()
4663 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
4664 hci_conn_drop(conn); in hci_link_key_notify_evt()
4666 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
4667 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
4672 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4681 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
4698 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4700 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4710 struct hci_conn *conn; in hci_clock_offset_evt() local
4716 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4717 if (conn && !ev->status) { in hci_clock_offset_evt()
4720 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4734 struct hci_conn *conn; in hci_pkt_type_change_evt() local
4740 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4741 if (conn && !ev->status) in hci_pkt_type_change_evt()
4742 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
4857 struct hci_conn *conn; in hci_remote_ext_features_evt() local
4863 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4864 if (!conn) in hci_remote_ext_features_evt()
4868 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
4873 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4878 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4888 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4892 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4895 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
4898 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
4901 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
4905 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_ext_features_evt()
4908 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_ext_features_evt()
4909 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
4910 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
4911 hci_conn_drop(conn); in hci_remote_ext_features_evt()
4922 struct hci_conn *conn; in hci_sync_conn_complete_evt() local
4942 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
4943 if (!conn) { in hci_sync_conn_complete_evt()
4956 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
4957 if (!conn) in hci_sync_conn_complete_evt()
4967 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in hci_sync_conn_complete_evt()
4974 status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle)); in hci_sync_conn_complete_evt()
4976 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
4980 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
4981 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
4983 hci_debugfs_create_conn(conn); in hci_sync_conn_complete_evt()
4984 hci_conn_add_sysfs(conn); in hci_sync_conn_complete_evt()
4995 if (conn->out) { in hci_sync_conn_complete_evt()
4996 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
4998 if (hci_setup_sync(conn, conn->parent->handle)) in hci_sync_conn_complete_evt()
5004 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5012 if (conn->codec.data_path == 0 && hdev->notify) { in hci_sync_conn_complete_evt()
5023 hci_connect_cfm(conn, status); in hci_sync_conn_complete_evt()
5025 hci_conn_del(conn); in hci_sync_conn_complete_evt()
5107 struct hci_conn *conn; in hci_key_refresh_complete_evt() local
5114 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5115 if (!conn) in hci_key_refresh_complete_evt()
5121 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
5125 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
5127 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
5129 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
5130 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_key_refresh_complete_evt()
5131 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
5135 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
5137 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
5139 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5140 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
5142 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5144 hci_conn_hold(conn); in hci_key_refresh_complete_evt()
5145 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
5146 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
5153 static u8 hci_get_auth_req(struct hci_conn *conn) in hci_get_auth_req() argument
5156 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
5157 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
5158 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
5163 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
5164 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
5165 return conn->remote_auth | 0x01; in hci_get_auth_req()
5168 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
5171 static u8 bredr_oob_data_present(struct hci_conn *conn) in bredr_oob_data_present() argument
5173 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
5176 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
5217 struct hci_conn *conn; in hci_io_capa_request_evt() local
5223 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
5224 if (!conn || !hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) in hci_io_capa_request_evt()
5228 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_io_capa_request_evt()
5230 hci_conn_hold(conn); in hci_io_capa_request_evt()
5239 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
5240 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
5246 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
5247 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
5250 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
5254 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
5255 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
5256 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
5258 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
5265 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
5267 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
5268 cp.oob_data = bredr_oob_data_present(conn); in hci_io_capa_request_evt()
5290 struct hci_conn *conn; in hci_io_capa_reply_evt() local
5296 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
5297 if (!conn) in hci_io_capa_reply_evt()
5300 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
5301 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
5312 struct hci_conn *conn; in hci_user_confirm_request_evt() local
5321 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
5322 if (!conn) in hci_user_confirm_request_evt()
5325 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
5326 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
5331 * necessarily match conn->auth_type. in hci_user_confirm_request_evt()
5333 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
5334 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
5342 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
5343 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
5349 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
5350 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
5371 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
5372 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
5404 struct hci_conn *conn; in hci_user_passkey_notify_evt() local
5408 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
5409 if (!conn) in hci_user_passkey_notify_evt()
5412 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
5413 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
5416 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
5417 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
5418 conn->passkey_entered); in hci_user_passkey_notify_evt()
5425 struct hci_conn *conn; in hci_keypress_notify_evt() local
5429 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
5430 if (!conn) in hci_keypress_notify_evt()
5435 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5439 conn->passkey_entered++; in hci_keypress_notify_evt()
5443 conn->passkey_entered--; in hci_keypress_notify_evt()
5447 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5455 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
5456 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
5457 conn->passkey_entered); in hci_keypress_notify_evt()
5464 struct hci_conn *conn; in hci_simple_pair_complete_evt() local
5470 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
5471 if (!conn || !hci_conn_ssp_enabled(conn)) in hci_simple_pair_complete_evt()
5475 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
5482 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
5483 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
5485 hci_conn_drop(conn); in hci_simple_pair_complete_evt()
5496 struct hci_conn *conn; in hci_remote_host_features_evt() local
5502 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5503 if (conn) in hci_remote_host_features_evt()
5504 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
5567 static void le_conn_update_addr(struct hci_conn *conn, bdaddr_t *bdaddr, in le_conn_update_addr() argument
5570 if (conn->out) { in le_conn_update_addr()
5571 conn->dst_type = bdaddr_type; in le_conn_update_addr()
5572 conn->resp_addr_type = bdaddr_type; in le_conn_update_addr()
5573 bacpy(&conn->resp_addr, bdaddr); in le_conn_update_addr()
5579 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5580 bacpy(&conn->init_addr, local_rpa); in le_conn_update_addr()
5581 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5582 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5583 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5585 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5586 &conn->init_addr_type); in le_conn_update_addr()
5589 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5594 conn->resp_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5595 bacpy(&conn->resp_addr, local_rpa); in le_conn_update_addr()
5596 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5600 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5601 bacpy(&conn->resp_addr, in le_conn_update_addr()
5602 &conn->hdev->random_addr); in le_conn_update_addr()
5604 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5607 conn->init_addr_type = bdaddr_type; in le_conn_update_addr()
5608 bacpy(&conn->init_addr, bdaddr); in le_conn_update_addr()
5615 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5616 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5627 struct hci_conn *conn; in le_conn_complete_evt() local
5638 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr); in le_conn_complete_evt()
5639 if (!conn) { in le_conn_complete_evt()
5646 conn = hci_conn_add_unset(hdev, LE_LINK, bdaddr, role); in le_conn_complete_evt()
5647 if (IS_ERR(conn)) { in le_conn_complete_evt()
5648 bt_dev_err(hdev, "connection err: %ld", PTR_ERR(conn)); in le_conn_complete_evt()
5652 conn->dst_type = bdaddr_type; in le_conn_complete_evt()
5662 if (conn->out) { in le_conn_complete_evt()
5663 conn->resp_addr_type = bdaddr_type; in le_conn_complete_evt()
5664 bacpy(&conn->resp_addr, bdaddr); in le_conn_complete_evt()
5666 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_complete_evt()
5667 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5670 &conn->init_addr, in le_conn_complete_evt()
5671 &conn->init_addr_type); in le_conn_complete_evt()
5675 cancel_delayed_work(&conn->le_conn_timeout); in le_conn_complete_evt()
5684 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in le_conn_complete_evt()
5689 le_conn_update_addr(conn, bdaddr, bdaddr_type, local_rpa); in le_conn_complete_evt()
5700 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5702 bacpy(&conn->dst, &irk->bdaddr); in le_conn_complete_evt()
5703 conn->dst_type = irk->addr_type; in le_conn_complete_evt()
5706 conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL); in le_conn_complete_evt()
5712 if (status || hci_conn_set_handle(conn, handle)) in le_conn_complete_evt()
5716 if (test_bit(HCI_CONN_CANCEL, &conn->flags)) { in le_conn_complete_evt()
5717 hci_conn_drop(conn); in le_conn_complete_evt()
5721 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in le_conn_complete_evt()
5727 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5728 hci_conn_drop(conn); in le_conn_complete_evt()
5732 mgmt_device_connected(hdev, conn, NULL, 0); in le_conn_complete_evt()
5734 conn->sec_level = BT_SECURITY_LOW; in le_conn_complete_evt()
5735 conn->state = BT_CONFIG; in le_conn_complete_evt()
5742 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
5744 conn->le_conn_interval = interval; in le_conn_complete_evt()
5745 conn->le_conn_latency = latency; in le_conn_complete_evt()
5746 conn->le_supv_timeout = supervision_timeout; in le_conn_complete_evt()
5748 hci_debugfs_create_conn(conn); in le_conn_complete_evt()
5749 hci_conn_add_sysfs(conn); in le_conn_complete_evt()
5760 if (conn->out || in le_conn_complete_evt()
5764 cp.handle = __cpu_to_le16(conn->handle); in le_conn_complete_evt()
5769 hci_conn_hold(conn); in le_conn_complete_evt()
5771 conn->state = BT_CONNECTED; in le_conn_complete_evt()
5772 hci_connect_cfm(conn, status); in le_conn_complete_evt()
5775 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
5776 conn->dst_type); in le_conn_complete_evt()
5779 if (params->conn) { in le_conn_complete_evt()
5780 hci_conn_drop(params->conn); in le_conn_complete_evt()
5781 hci_conn_put(params->conn); in le_conn_complete_evt()
5782 params->conn = NULL; in le_conn_complete_evt()
5823 struct hci_conn *conn; in hci_le_ext_adv_term_evt() local
5865 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
5866 if (conn) { in hci_le_ext_adv_term_evt()
5870 conn->adv_instance = ev->handle; in hci_le_ext_adv_term_evt()
5873 bacmp(&conn->resp_addr, BDADDR_ANY)) in hci_le_ext_adv_term_evt()
5877 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
5882 bacpy(&conn->resp_addr, &adv->random_addr); in hci_le_ext_adv_term_evt()
5893 struct hci_conn *conn; in hci_le_conn_update_complete_evt() local
5902 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
5903 if (conn) { in hci_le_conn_update_complete_evt()
5904 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
5905 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
5906 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
5918 struct hci_conn *conn; in check_pending_le_conn() local
5969 conn = hci_connect_le(hdev, addr, addr_type, addr_resolved, in check_pending_le_conn()
5972 if (!IS_ERR(conn)) { in check_pending_le_conn()
5973 /* If HCI_AUTO_CONN_EXPLICIT is set, conn is already owned in check_pending_le_conn()
5983 params->conn = hci_conn_get(conn); in check_pending_le_conn()
5985 return conn; in check_pending_le_conn()
5988 switch (PTR_ERR(conn)) { in check_pending_le_conn()
5997 BT_DBG("Failed to connect: err %ld", PTR_ERR(conn)); in check_pending_le_conn()
6012 struct hci_conn *conn; in process_adv_report() local
6098 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, bdaddr_resolved, in process_adv_report()
6100 if (!ext_adv && conn && type == LE_ADV_IND && in process_adv_report()
6105 memcpy(conn->le_adv_data, data, len); in process_adv_report()
6106 conn->le_adv_data_len = len; in process_adv_report()
6366 struct hci_conn *pa_sync, *conn; in hci_le_pa_sync_estabilished_evt() local
6374 conn = hci_conn_hash_lookup_sid(hdev, ev->sid, &ev->bdaddr, in hci_le_pa_sync_estabilished_evt()
6376 if (!conn) { in hci_le_pa_sync_estabilished_evt()
6383 clear_bit(HCI_CONN_CREATE_PA_SYNC, &conn->flags); in hci_le_pa_sync_estabilished_evt()
6385 conn->sync_handle = le16_to_cpu(ev->handle); in hci_le_pa_sync_estabilished_evt()
6386 conn->sid = HCI_SID_INVALID; in hci_le_pa_sync_estabilished_evt()
6463 struct hci_conn *conn; in hci_le_remote_feat_complete_evt() local
6469 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
6470 if (conn) { in hci_le_remote_feat_complete_evt()
6472 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
6474 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
6486 if (!conn->out && ev->status == HCI_ERROR_UNSUPPORTED_REMOTE_FEATURE && in hci_le_remote_feat_complete_evt()
6492 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
6493 hci_connect_cfm(conn, status); in hci_le_remote_feat_complete_evt()
6494 hci_conn_drop(conn); in hci_le_remote_feat_complete_evt()
6507 struct hci_conn *conn; in hci_le_ltk_request_evt() local
6514 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6515 if (conn == NULL) in hci_le_ltk_request_evt()
6518 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
6534 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
6536 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
6538 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
6549 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6553 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6674 struct hci_conn *conn; in hci_le_phy_update_evt() local
6683 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
6684 if (!conn) in hci_le_phy_update_evt()
6687 conn->le_tx_phy = ev->tx_phy; in hci_le_phy_update_evt()
6688 conn->le_rx_phy = ev->rx_phy; in hci_le_phy_update_evt()
6698 struct hci_conn *conn; in hci_le_cis_estabilished_evt() local
6708 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_cis_estabilished_evt()
6709 if (!conn) { in hci_le_cis_estabilished_evt()
6716 if (conn->type != ISO_LINK) { in hci_le_cis_estabilished_evt()
6723 qos = &conn->iso_qos; in hci_le_cis_estabilished_evt()
6725 pending = test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); in hci_le_cis_estabilished_evt()
6742 switch (conn->role) { in hci_le_cis_estabilished_evt()
6776 conn->state = BT_CONNECTED; in hci_le_cis_estabilished_evt()
6777 hci_debugfs_create_conn(conn); in hci_le_cis_estabilished_evt()
6778 hci_conn_add_sysfs(conn); in hci_le_cis_estabilished_evt()
6779 hci_iso_setup_path(conn); in hci_le_cis_estabilished_evt()
6783 conn->state = BT_CLOSED; in hci_le_cis_estabilished_evt()
6784 hci_connect_cfm(conn, ev->status); in hci_le_cis_estabilished_evt()
6785 hci_conn_del(conn); in hci_le_cis_estabilished_evt()
6876 struct hci_conn *conn; in hci_le_create_big_complete_evt() local
6888 while ((conn = hci_conn_hash_lookup_big_state(hdev, ev->handle, in hci_le_create_big_complete_evt()
6891 hci_connect_cfm(conn, ev->status); in hci_le_create_big_complete_evt()
6892 hci_conn_del(conn); in hci_le_create_big_complete_evt()
6896 if (hci_conn_set_handle(conn, in hci_le_create_big_complete_evt()
6900 conn->state = BT_CONNECTED; in hci_le_create_big_complete_evt()
6901 set_bit(HCI_CONN_BIG_CREATED, &conn->flags); in hci_le_create_big_complete_evt()
6902 hci_debugfs_create_conn(conn); in hci_le_create_big_complete_evt()
6903 hci_conn_add_sysfs(conn); in hci_le_create_big_complete_evt()
6904 hci_iso_setup_path(conn); in hci_le_create_big_complete_evt()
6923 struct hci_conn *bis, *conn; in hci_le_big_sync_established_evt() local
6934 conn = hci_conn_hash_lookup_big_sync_pend(hdev, ev->handle, in hci_le_big_sync_established_evt()
6936 if (!conn) { in hci_le_big_sync_established_evt()
6943 clear_bit(HCI_CONN_CREATE_BIG_SYNC, &conn->flags); in hci_le_big_sync_established_evt()
6945 conn->num_bis = 0; in hci_le_big_sync_established_evt()
6946 memset(conn->bis, 0, sizeof(conn->num_bis)); in hci_le_big_sync_established_evt()
6968 bis->sync_handle = conn->sync_handle; in hci_le_big_sync_established_evt()