Lines Matching refs:conn
104 struct hci_conn *conn; in hci_cc_role_discovery() local
113 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
114 if (conn) in hci_cc_role_discovery()
115 conn->role = rp->role; in hci_cc_role_discovery()
123 struct hci_conn *conn; in hci_cc_read_link_policy() local
132 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
133 if (conn) in hci_cc_read_link_policy()
134 conn->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_link_policy()
142 struct hci_conn *conn; in hci_cc_write_link_policy() local
156 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
157 if (conn) in hci_cc_write_link_policy()
158 conn->link_policy = get_unaligned_le16(sent + 2); in hci_cc_write_link_policy()
792 struct hci_conn *conn; in hci_cc_read_clock() local
813 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
814 if (conn) { in hci_cc_read_clock()
815 conn->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
816 conn->clock_accuracy = le16_to_cpu(rp->accuracy); in hci_cc_read_clock()
862 struct hci_conn *conn; in hci_cc_pin_code_reply() local
878 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
879 if (conn) in hci_cc_pin_code_reply()
880 conn->pin_length = cp->pin_len; in hci_cc_pin_code_reply()
1063 struct hci_conn *conn; in hci_cc_le_set_adv_enable() local
1067 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_adv_enable()
1068 if (conn) in hci_cc_le_set_adv_enable()
1070 &conn->le_conn_timeout, in hci_cc_le_set_adv_enable()
1071 conn->conn_timeout); in hci_cc_le_set_adv_enable()
1380 struct hci_conn *conn; in hci_cc_read_rssi() local
1389 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
1390 if (conn) in hci_cc_read_rssi()
1391 conn->rssi = rp->rssi; in hci_cc_read_rssi()
1400 struct hci_conn *conn; in hci_cc_read_tx_power() local
1413 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
1414 if (!conn) in hci_cc_read_tx_power()
1419 conn->tx_power = rp->tx_power; in hci_cc_read_tx_power()
1422 conn->max_tx_power = rp->tx_power; in hci_cc_read_tx_power()
1460 struct hci_conn *conn; in hci_cs_create_conn() local
1470 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
1472 BT_DBG("%s bdaddr %pMR hcon %p", hdev->name, &cp->bdaddr, conn); in hci_cs_create_conn()
1475 if (conn && conn->state == BT_CONNECT) { in hci_cs_create_conn()
1476 if (status != 0x0c || conn->attempt > 2) { in hci_cs_create_conn()
1477 conn->state = BT_CLOSED; in hci_cs_create_conn()
1478 hci_connect_cfm(conn, status); in hci_cs_create_conn()
1479 hci_conn_del(conn); in hci_cs_create_conn()
1481 conn->state = BT_CONNECT2; in hci_cs_create_conn()
1484 if (!conn) { in hci_cs_create_conn()
1485 conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
1487 if (!conn) in hci_cs_create_conn()
1533 struct hci_conn *conn; in hci_cs_auth_requested() local
1546 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
1547 if (conn) { in hci_cs_auth_requested()
1548 if (conn->state == BT_CONFIG) { in hci_cs_auth_requested()
1549 hci_connect_cfm(conn, status); in hci_cs_auth_requested()
1550 hci_conn_drop(conn); in hci_cs_auth_requested()
1560 struct hci_conn *conn; in hci_cs_set_conn_encrypt() local
1573 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
1574 if (conn) { in hci_cs_set_conn_encrypt()
1575 if (conn->state == BT_CONFIG) { in hci_cs_set_conn_encrypt()
1576 hci_connect_cfm(conn, status); in hci_cs_set_conn_encrypt()
1577 hci_conn_drop(conn); in hci_cs_set_conn_encrypt()
1585 struct hci_conn *conn) in hci_outgoing_auth_needed() argument
1587 if (conn->state != BT_CONFIG || !conn->out) in hci_outgoing_auth_needed()
1590 if (conn->pending_sec_level == BT_SECURITY_SDP) in hci_outgoing_auth_needed()
1597 if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) && in hci_outgoing_auth_needed()
1598 conn->pending_sec_level != BT_SECURITY_FIPS && in hci_outgoing_auth_needed()
1599 conn->pending_sec_level != BT_SECURITY_HIGH && in hci_outgoing_auth_needed()
1600 conn->pending_sec_level != BT_SECURITY_MEDIUM) in hci_outgoing_auth_needed()
1641 static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, in hci_check_pending_name() argument
1652 if (conn && in hci_check_pending_name()
1653 (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) && in hci_check_pending_name()
1654 !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_check_pending_name()
1655 mgmt_device_connected(hdev, conn, 0, name, name_len); in hci_check_pending_name()
1693 struct hci_conn *conn; in hci_cs_remote_name_req() local
1708 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
1711 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
1713 if (!conn) in hci_cs_remote_name_req()
1716 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_cs_remote_name_req()
1719 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_cs_remote_name_req()
1722 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_cs_remote_name_req()
1724 auth_cp.handle = __cpu_to_le16(conn->handle); in hci_cs_remote_name_req()
1736 struct hci_conn *conn; in hci_cs_read_remote_features() local
1749 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
1750 if (conn) { in hci_cs_read_remote_features()
1751 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_features()
1752 hci_connect_cfm(conn, status); in hci_cs_read_remote_features()
1753 hci_conn_drop(conn); in hci_cs_read_remote_features()
1763 struct hci_conn *conn; in hci_cs_read_remote_ext_features() local
1776 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
1777 if (conn) { in hci_cs_read_remote_ext_features()
1778 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_ext_features()
1779 hci_connect_cfm(conn, status); in hci_cs_read_remote_ext_features()
1780 hci_conn_drop(conn); in hci_cs_read_remote_ext_features()
1825 struct hci_conn *conn; in hci_cs_sniff_mode() local
1838 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
1839 if (conn) { in hci_cs_sniff_mode()
1840 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_sniff_mode()
1842 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_sniff_mode()
1843 hci_sco_setup(conn, status); in hci_cs_sniff_mode()
1852 struct hci_conn *conn; in hci_cs_exit_sniff_mode() local
1865 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
1866 if (conn) { in hci_cs_exit_sniff_mode()
1867 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_exit_sniff_mode()
1869 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_exit_sniff_mode()
1870 hci_sco_setup(conn, status); in hci_cs_exit_sniff_mode()
1879 struct hci_conn *conn; in hci_cs_disconnect() local
1890 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
1891 if (conn) in hci_cs_disconnect()
1892 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
1893 conn->dst_type, status); in hci_cs_disconnect()
1901 struct hci_conn *conn; in hci_cs_le_create_conn() local
1918 conn = hci_conn_hash_lookup_le(hdev, &cp->peer_addr, in hci_cs_le_create_conn()
1920 if (!conn) in hci_cs_le_create_conn()
1927 conn->init_addr_type = cp->own_address_type; in hci_cs_le_create_conn()
1929 bacpy(&conn->init_addr, &hdev->random_addr); in hci_cs_le_create_conn()
1931 bacpy(&conn->init_addr, &hdev->bdaddr); in hci_cs_le_create_conn()
1933 conn->resp_addr_type = cp->peer_addr_type; in hci_cs_le_create_conn()
1934 bacpy(&conn->resp_addr, &cp->peer_addr); in hci_cs_le_create_conn()
1942 queue_delayed_work(conn->hdev->workqueue, in hci_cs_le_create_conn()
1943 &conn->le_conn_timeout, in hci_cs_le_create_conn()
1944 conn->conn_timeout); in hci_cs_le_create_conn()
1953 struct hci_conn *conn; in hci_cs_le_read_remote_features() local
1966 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
1967 if (conn) { in hci_cs_le_read_remote_features()
1968 if (conn->state == BT_CONFIG) { in hci_cs_le_read_remote_features()
1969 hci_connect_cfm(conn, status); in hci_cs_le_read_remote_features()
1970 hci_conn_drop(conn); in hci_cs_le_read_remote_features()
1980 struct hci_conn *conn; in hci_cs_le_start_enc() local
1993 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
1994 if (!conn) in hci_cs_le_start_enc()
1997 if (conn->state != BT_CONNECTED) in hci_cs_le_start_enc()
2000 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_cs_le_start_enc()
2001 hci_conn_drop(conn); in hci_cs_le_start_enc()
2010 struct hci_conn *conn; in hci_cs_switch_role() local
2023 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
2024 if (conn) in hci_cs_switch_role()
2025 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_cs_switch_role()
2130 struct hci_conn *conn; in hci_conn_complete_evt() local
2136 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
2137 if (!conn) { in hci_conn_complete_evt()
2141 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_conn_complete_evt()
2142 if (!conn) in hci_conn_complete_evt()
2145 conn->type = SCO_LINK; in hci_conn_complete_evt()
2149 conn->handle = __le16_to_cpu(ev->handle); in hci_conn_complete_evt()
2151 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
2152 conn->state = BT_CONFIG; in hci_conn_complete_evt()
2153 hci_conn_hold(conn); in hci_conn_complete_evt()
2155 if (!conn->out && !hci_conn_ssp_enabled(conn) && in hci_conn_complete_evt()
2157 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_conn_complete_evt()
2159 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_conn_complete_evt()
2161 conn->state = BT_CONNECTED; in hci_conn_complete_evt()
2163 hci_debugfs_create_conn(conn); in hci_conn_complete_evt()
2164 hci_conn_add_sysfs(conn); in hci_conn_complete_evt()
2167 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_conn_complete_evt()
2170 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
2173 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
2183 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
2186 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_complete_evt()
2191 conn->state = BT_CLOSED; in hci_conn_complete_evt()
2192 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
2193 mgmt_connect_failed(hdev, &conn->dst, conn->type, in hci_conn_complete_evt()
2194 conn->dst_type, ev->status); in hci_conn_complete_evt()
2197 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
2198 hci_sco_setup(conn, ev->status); in hci_conn_complete_evt()
2201 hci_connect_cfm(conn, ev->status); in hci_conn_complete_evt()
2202 hci_conn_del(conn); in hci_conn_complete_evt()
2204 hci_connect_cfm(conn, ev->status); in hci_conn_complete_evt()
2226 struct hci_conn *conn; in hci_conn_request_evt() local
2266 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
2268 if (!conn) { in hci_conn_request_evt()
2269 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
2271 if (!conn) { in hci_conn_request_evt()
2278 memcpy(conn->dev_class, ev->dev_class, 3); in hci_conn_request_evt()
2285 conn->state = BT_CONNECT; in hci_conn_request_evt()
2297 conn->state = BT_CONNECT; in hci_conn_request_evt()
2300 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_request_evt()
2311 conn->state = BT_CONNECT2; in hci_conn_request_evt()
2312 hci_connect_cfm(conn, 0); in hci_conn_request_evt()
2337 struct hci_conn *conn; in hci_disconn_complete_evt() local
2345 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
2346 if (!conn) in hci_disconn_complete_evt()
2350 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
2351 conn->dst_type, ev->status); in hci_disconn_complete_evt()
2355 conn->state = BT_CLOSED; in hci_disconn_complete_evt()
2357 mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_disconn_complete_evt()
2359 if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags)) in hci_disconn_complete_evt()
2364 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
2367 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
2368 if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
2369 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
2374 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
2394 type = conn->type; in hci_disconn_complete_evt()
2396 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
2397 hci_conn_del(conn); in hci_disconn_complete_evt()
2419 struct hci_conn *conn; in hci_auth_complete_evt() local
2425 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
2426 if (!conn) in hci_auth_complete_evt()
2430 clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
2432 if (!hci_conn_ssp_enabled(conn) && in hci_auth_complete_evt()
2433 test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { in hci_auth_complete_evt()
2436 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
2437 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
2441 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
2443 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
2446 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
2447 clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags); in hci_auth_complete_evt()
2449 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
2450 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
2457 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
2458 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
2459 hci_conn_drop(conn); in hci_auth_complete_evt()
2462 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
2464 hci_conn_hold(conn); in hci_auth_complete_evt()
2465 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
2466 hci_conn_drop(conn); in hci_auth_complete_evt()
2469 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
2477 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
2478 hci_encrypt_cfm(conn, ev->status, 0x00); in hci_auth_complete_evt()
2489 struct hci_conn *conn; in hci_remote_name_evt() local
2497 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
2503 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
2506 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
2509 if (!conn) in hci_remote_name_evt()
2512 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_remote_name_evt()
2515 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
2518 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
2520 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
2532 struct hci_conn *conn; in read_enc_key_size_complete() local
2548 conn = hci_conn_hash_lookup_handle(hdev, handle); in read_enc_key_size_complete()
2549 if (!conn) in read_enc_key_size_complete()
2559 conn->enc_key_size = HCI_LINK_KEY_SIZE; in read_enc_key_size_complete()
2561 conn->enc_key_size = rp->key_size; in read_enc_key_size_complete()
2564 if (conn->state == BT_CONFIG) { in read_enc_key_size_complete()
2565 conn->state = BT_CONNECTED; in read_enc_key_size_complete()
2566 hci_connect_cfm(conn, 0); in read_enc_key_size_complete()
2567 hci_conn_drop(conn); in read_enc_key_size_complete()
2571 if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags)) in read_enc_key_size_complete()
2573 else if (test_bit(HCI_CONN_AES_CCM, &conn->flags)) in read_enc_key_size_complete()
2578 hci_encrypt_cfm(conn, 0, encrypt); in read_enc_key_size_complete()
2588 struct hci_conn *conn; in hci_encrypt_change_evt() local
2594 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
2595 if (!conn) in hci_encrypt_change_evt()
2601 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
2602 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
2603 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
2606 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
2607 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
2609 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
2610 conn->type == LE_LINK) in hci_encrypt_change_evt()
2611 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
2613 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
2614 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
2621 if (ev->status && conn->type == LE_LINK) in hci_encrypt_change_evt()
2624 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
2626 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
2628 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_encrypt_change_evt()
2630 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_encrypt_change_evt()
2631 hci_conn_drop(conn); in hci_encrypt_change_evt()
2640 (!test_bit(HCI_CONN_AES_CCM, &conn->flags) || in hci_encrypt_change_evt()
2641 conn->key_type != HCI_LK_AUTH_COMBINATION_P256)) { in hci_encrypt_change_evt()
2642 hci_connect_cfm(conn, HCI_ERROR_AUTH_FAILURE); in hci_encrypt_change_evt()
2643 hci_conn_drop(conn); in hci_encrypt_change_evt()
2648 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
2657 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
2663 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
2668 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
2676 if (conn->state == BT_CONFIG) { in hci_encrypt_change_evt()
2678 conn->state = BT_CONNECTED; in hci_encrypt_change_evt()
2680 hci_connect_cfm(conn, ev->status); in hci_encrypt_change_evt()
2681 hci_conn_drop(conn); in hci_encrypt_change_evt()
2683 hci_encrypt_cfm(conn, ev->status, ev->encrypt); in hci_encrypt_change_evt()
2693 struct hci_conn *conn; in hci_change_link_key_complete_evt() local
2699 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
2700 if (conn) { in hci_change_link_key_complete_evt()
2702 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
2704 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
2706 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
2716 struct hci_conn *conn; in hci_remote_features_evt() local
2722 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
2723 if (!conn) in hci_remote_features_evt()
2727 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
2729 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
2733 lmp_ext_feat_capable(conn)) { in hci_remote_features_evt()
2742 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_features_evt()
2745 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
2748 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_features_evt()
2749 mgmt_device_connected(hdev, conn, 0, NULL, 0); in hci_remote_features_evt()
2751 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_features_evt()
2752 conn->state = BT_CONNECTED; in hci_remote_features_evt()
2753 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
2754 hci_conn_drop(conn); in hci_remote_features_evt()
3175 struct hci_conn *conn; in hci_role_change_evt() local
3181 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
3182 if (conn) { in hci_role_change_evt()
3184 conn->role = ev->role; in hci_role_change_evt()
3186 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
3188 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
3214 struct hci_conn *conn; in hci_num_comp_pkts_evt() local
3220 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_num_comp_pkts_evt()
3221 if (!conn) in hci_num_comp_pkts_evt()
3224 conn->sent -= count; in hci_num_comp_pkts_evt()
3226 switch (conn->type) { in hci_num_comp_pkts_evt()
3252 BT_ERR("Unknown type %d conn %p", conn->type, conn); in hci_num_comp_pkts_evt()
3271 return chan->conn; in __hci_conn_lookup_handle()
3302 struct hci_conn *conn = NULL; in hci_num_comp_blocks_evt() local
3308 conn = __hci_conn_lookup_handle(hdev, handle); in hci_num_comp_blocks_evt()
3309 if (!conn) in hci_num_comp_blocks_evt()
3312 conn->sent -= block_count; in hci_num_comp_blocks_evt()
3314 switch (conn->type) { in hci_num_comp_blocks_evt()
3323 BT_ERR("Unknown type %d conn %p", conn->type, conn); in hci_num_comp_blocks_evt()
3334 struct hci_conn *conn; in hci_mode_change_evt() local
3340 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
3341 if (conn) { in hci_mode_change_evt()
3342 conn->mode = ev->mode; in hci_mode_change_evt()
3345 &conn->flags)) { in hci_mode_change_evt()
3346 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
3347 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
3349 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
3352 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
3353 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
3362 struct hci_conn *conn; in hci_pin_code_request_evt() local
3368 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
3369 if (!conn) in hci_pin_code_request_evt()
3372 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
3373 hci_conn_hold(conn); in hci_pin_code_request_evt()
3374 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
3375 hci_conn_drop(conn); in hci_pin_code_request_evt()
3379 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
3385 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
3397 static void conn_set_key(struct hci_conn *conn, u8 key_type, u8 pin_len) in conn_set_key() argument
3402 conn->pin_length = pin_len; in conn_set_key()
3403 conn->key_type = key_type; in conn_set_key()
3412 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
3414 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
3418 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
3421 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
3424 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
3433 struct hci_conn *conn; in hci_link_key_request_evt() local
3453 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
3454 if (conn) { in hci_link_key_request_evt()
3455 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
3459 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
3465 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
3466 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
3472 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
3492 struct hci_conn *conn; in hci_link_key_notify_evt() local
3501 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
3502 if (!conn) in hci_link_key_notify_evt()
3505 hci_conn_hold(conn); in hci_link_key_notify_evt()
3506 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
3507 hci_conn_drop(conn); in hci_link_key_notify_evt()
3509 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
3510 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
3515 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
3524 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
3541 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
3543 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
3552 struct hci_conn *conn; in hci_clock_offset_evt() local
3558 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
3559 if (conn && !ev->status) { in hci_clock_offset_evt()
3562 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
3575 struct hci_conn *conn; in hci_pkt_type_change_evt() local
3581 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
3582 if (conn && !ev->status) in hci_pkt_type_change_evt()
3583 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
3674 struct hci_conn *conn; in hci_remote_ext_features_evt() local
3680 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
3681 if (!conn) in hci_remote_ext_features_evt()
3685 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
3690 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
3695 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
3705 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
3709 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
3712 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
3715 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
3718 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
3721 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_ext_features_evt()
3722 mgmt_device_connected(hdev, conn, 0, NULL, 0); in hci_remote_ext_features_evt()
3724 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_ext_features_evt()
3725 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
3726 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
3727 hci_conn_drop(conn); in hci_remote_ext_features_evt()
3738 struct hci_conn *conn; in hci_sync_conn_complete_evt() local
3744 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
3745 if (!conn) { in hci_sync_conn_complete_evt()
3758 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
3759 if (!conn) in hci_sync_conn_complete_evt()
3765 conn->handle = __le16_to_cpu(ev->handle); in hci_sync_conn_complete_evt()
3766 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
3767 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
3769 hci_debugfs_create_conn(conn); in hci_sync_conn_complete_evt()
3770 hci_conn_add_sysfs(conn); in hci_sync_conn_complete_evt()
3780 if (conn->out) { in hci_sync_conn_complete_evt()
3781 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
3783 if (hci_setup_sync(conn, conn->link->handle)) in hci_sync_conn_complete_evt()
3789 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
3793 hci_connect_cfm(conn, ev->status); in hci_sync_conn_complete_evt()
3795 hci_conn_del(conn); in hci_sync_conn_complete_evt()
3872 struct hci_conn *conn; in hci_key_refresh_complete_evt() local
3879 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
3880 if (!conn) in hci_key_refresh_complete_evt()
3886 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
3890 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
3892 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
3894 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
3895 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_key_refresh_complete_evt()
3896 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
3900 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
3902 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
3904 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
3905 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
3907 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
3909 hci_conn_hold(conn); in hci_key_refresh_complete_evt()
3910 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
3911 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
3918 static u8 hci_get_auth_req(struct hci_conn *conn) in hci_get_auth_req() argument
3921 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
3922 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
3923 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
3928 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
3929 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
3930 return conn->remote_auth | 0x01; in hci_get_auth_req()
3933 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
3936 static u8 bredr_oob_data_present(struct hci_conn *conn) in bredr_oob_data_present() argument
3938 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
3941 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
3981 struct hci_conn *conn; in hci_io_capa_request_evt() local
3987 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
3988 if (!conn) in hci_io_capa_request_evt()
3991 hci_conn_hold(conn); in hci_io_capa_request_evt()
4000 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
4001 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
4007 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
4008 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
4011 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
4015 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
4016 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
4017 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
4019 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
4026 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
4028 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
4029 cp.oob_data = bredr_oob_data_present(conn); in hci_io_capa_request_evt()
4050 struct hci_conn *conn; in hci_io_capa_reply_evt() local
4056 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
4057 if (!conn) in hci_io_capa_reply_evt()
4060 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
4061 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
4072 struct hci_conn *conn; in hci_user_confirm_request_evt() local
4081 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
4082 if (!conn) in hci_user_confirm_request_evt()
4085 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
4086 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
4093 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
4094 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
4102 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
4103 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
4111 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
4112 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_user_confirm_request_evt()
4124 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
4125 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
4157 struct hci_conn *conn; in hci_user_passkey_notify_evt() local
4161 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
4162 if (!conn) in hci_user_passkey_notify_evt()
4165 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
4166 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
4169 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
4170 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
4171 conn->passkey_entered); in hci_user_passkey_notify_evt()
4177 struct hci_conn *conn; in hci_keypress_notify_evt() local
4181 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
4182 if (!conn) in hci_keypress_notify_evt()
4187 conn->passkey_entered = 0; in hci_keypress_notify_evt()
4191 conn->passkey_entered++; in hci_keypress_notify_evt()
4195 conn->passkey_entered--; in hci_keypress_notify_evt()
4199 conn->passkey_entered = 0; in hci_keypress_notify_evt()
4207 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
4208 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
4209 conn->passkey_entered); in hci_keypress_notify_evt()
4216 struct hci_conn *conn; in hci_simple_pair_complete_evt() local
4222 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
4223 if (!conn) in hci_simple_pair_complete_evt()
4227 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
4234 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
4235 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
4237 hci_conn_drop(conn); in hci_simple_pair_complete_evt()
4248 struct hci_conn *conn; in hci_remote_host_features_evt() local
4254 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
4255 if (conn) in hci_remote_host_features_evt()
4256 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
4406 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
4465 struct hci_conn *conn; in hci_le_conn_complete_evt() local
4478 conn = hci_lookup_le_connect(hdev); in hci_le_conn_complete_evt()
4479 if (!conn) { in hci_le_conn_complete_evt()
4480 conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr, ev->role); in hci_le_conn_complete_evt()
4481 if (!conn) { in hci_le_conn_complete_evt()
4486 conn->dst_type = ev->bdaddr_type; in hci_le_conn_complete_evt()
4496 if (conn->out) { in hci_le_conn_complete_evt()
4497 conn->resp_addr_type = ev->bdaddr_type; in hci_le_conn_complete_evt()
4498 bacpy(&conn->resp_addr, &ev->bdaddr); in hci_le_conn_complete_evt()
4500 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in hci_le_conn_complete_evt()
4501 bacpy(&conn->init_addr, &hdev->rpa); in hci_le_conn_complete_evt()
4504 &conn->init_addr, in hci_le_conn_complete_evt()
4505 &conn->init_addr_type); in hci_le_conn_complete_evt()
4509 cancel_delayed_work(&conn->le_conn_timeout); in hci_le_conn_complete_evt()
4512 if (!conn->out) { in hci_le_conn_complete_evt()
4516 conn->resp_addr_type = hdev->adv_addr_type; in hci_le_conn_complete_evt()
4518 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_conn_complete_evt()
4520 bacpy(&conn->resp_addr, &hdev->bdaddr); in hci_le_conn_complete_evt()
4522 conn->init_addr_type = ev->bdaddr_type; in hci_le_conn_complete_evt()
4523 bacpy(&conn->init_addr, &ev->bdaddr); in hci_le_conn_complete_evt()
4530 conn->le_conn_min_interval = hdev->le_conn_min_interval; in hci_le_conn_complete_evt()
4531 conn->le_conn_max_interval = hdev->le_conn_max_interval; in hci_le_conn_complete_evt()
4543 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in hci_le_conn_complete_evt()
4545 bacpy(&conn->dst, &irk->bdaddr); in hci_le_conn_complete_evt()
4546 conn->dst_type = irk->addr_type; in hci_le_conn_complete_evt()
4550 hci_le_conn_failed(conn, ev->status); in hci_le_conn_complete_evt()
4554 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in hci_le_conn_complete_evt()
4560 if (hci_bdaddr_list_lookup(&hdev->blacklist, &conn->dst, addr_type)) { in hci_le_conn_complete_evt()
4561 hci_conn_drop(conn); in hci_le_conn_complete_evt()
4565 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_le_conn_complete_evt()
4566 mgmt_device_connected(hdev, conn, 0, NULL, 0); in hci_le_conn_complete_evt()
4568 conn->sec_level = BT_SECURITY_LOW; in hci_le_conn_complete_evt()
4569 conn->handle = __le16_to_cpu(ev->handle); in hci_le_conn_complete_evt()
4570 conn->state = BT_CONFIG; in hci_le_conn_complete_evt()
4572 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_complete_evt()
4573 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_complete_evt()
4574 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_complete_evt()
4576 hci_debugfs_create_conn(conn); in hci_le_conn_complete_evt()
4577 hci_conn_add_sysfs(conn); in hci_le_conn_complete_evt()
4589 if (conn->out || in hci_le_conn_complete_evt()
4593 cp.handle = __cpu_to_le16(conn->handle); in hci_le_conn_complete_evt()
4598 hci_conn_hold(conn); in hci_le_conn_complete_evt()
4600 conn->state = BT_CONNECTED; in hci_le_conn_complete_evt()
4601 hci_connect_cfm(conn, ev->status); in hci_le_conn_complete_evt()
4604 hci_connect_cfm(conn, ev->status); in hci_le_conn_complete_evt()
4607 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in hci_le_conn_complete_evt()
4608 conn->dst_type); in hci_le_conn_complete_evt()
4611 if (params->conn) { in hci_le_conn_complete_evt()
4612 hci_conn_drop(params->conn); in hci_le_conn_complete_evt()
4613 hci_conn_put(params->conn); in hci_le_conn_complete_evt()
4614 params->conn = NULL; in hci_le_conn_complete_evt()
4627 struct hci_conn *conn; in hci_le_conn_update_complete_evt() local
4636 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
4637 if (conn) { in hci_le_conn_update_complete_evt()
4638 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
4639 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
4640 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
4652 struct hci_conn *conn; in check_pending_le_conn() local
4700 conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW, in check_pending_le_conn()
4703 if (!IS_ERR(conn)) { in check_pending_le_conn()
4714 params->conn = hci_conn_get(conn); in check_pending_le_conn()
4716 return conn; in check_pending_le_conn()
4719 switch (PTR_ERR(conn)) { in check_pending_le_conn()
4728 BT_DBG("Failed to connect: err %ld", PTR_ERR(conn)); in check_pending_le_conn()
4741 struct hci_conn *conn; in process_adv_report() local
4817 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type, in process_adv_report()
4819 if (conn && type == LE_ADV_IND) { in process_adv_report()
4823 memcpy(conn->le_adv_data, data, len); in process_adv_report()
4824 conn->le_adv_data_len = len; in process_adv_report()
4959 struct hci_conn *conn; in hci_le_remote_feat_complete_evt() local
4965 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
4966 if (conn) { in hci_le_remote_feat_complete_evt()
4968 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
4970 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
4983 !conn->out && ev->status == 0x1a) in hci_le_remote_feat_complete_evt()
4988 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
4989 hci_connect_cfm(conn, status); in hci_le_remote_feat_complete_evt()
4990 hci_conn_drop(conn); in hci_le_remote_feat_complete_evt()
5002 struct hci_conn *conn; in hci_le_ltk_request_evt() local
5009 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
5010 if (conn == NULL) in hci_le_ltk_request_evt()
5013 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
5029 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
5031 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
5033 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
5044 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
5048 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()