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()
2358 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
2361 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
2362 if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
2363 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
2368 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
2388 type = conn->type; in hci_disconn_complete_evt()
2390 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
2391 hci_conn_del(conn); in hci_disconn_complete_evt()
2413 struct hci_conn *conn; in hci_auth_complete_evt() local
2419 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
2420 if (!conn) in hci_auth_complete_evt()
2424 if (!hci_conn_ssp_enabled(conn) && in hci_auth_complete_evt()
2425 test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { in hci_auth_complete_evt()
2428 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
2429 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
2432 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
2435 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
2436 clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags); in hci_auth_complete_evt()
2438 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
2439 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
2446 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
2447 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
2448 hci_conn_drop(conn); in hci_auth_complete_evt()
2451 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
2453 hci_conn_hold(conn); in hci_auth_complete_evt()
2454 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
2455 hci_conn_drop(conn); in hci_auth_complete_evt()
2458 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
2466 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
2467 hci_encrypt_cfm(conn, ev->status, 0x00); in hci_auth_complete_evt()
2478 struct hci_conn *conn; in hci_remote_name_evt() local
2486 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
2492 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
2495 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
2498 if (!conn) in hci_remote_name_evt()
2501 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_remote_name_evt()
2504 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
2507 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
2509 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
2521 struct hci_conn *conn; in read_enc_key_size_complete() local
2537 conn = hci_conn_hash_lookup_handle(hdev, handle); in read_enc_key_size_complete()
2538 if (!conn) in read_enc_key_size_complete()
2548 conn->enc_key_size = HCI_LINK_KEY_SIZE; in read_enc_key_size_complete()
2550 conn->enc_key_size = rp->key_size; in read_enc_key_size_complete()
2553 if (conn->state == BT_CONFIG) { in read_enc_key_size_complete()
2554 conn->state = BT_CONNECTED; in read_enc_key_size_complete()
2555 hci_connect_cfm(conn, 0); in read_enc_key_size_complete()
2556 hci_conn_drop(conn); in read_enc_key_size_complete()
2560 if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags)) in read_enc_key_size_complete()
2562 else if (test_bit(HCI_CONN_AES_CCM, &conn->flags)) in read_enc_key_size_complete()
2567 hci_encrypt_cfm(conn, 0, encrypt); in read_enc_key_size_complete()
2577 struct hci_conn *conn; in hci_encrypt_change_evt() local
2583 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
2584 if (!conn) in hci_encrypt_change_evt()
2590 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
2591 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
2592 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
2595 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
2596 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
2598 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
2599 conn->type == LE_LINK) in hci_encrypt_change_evt()
2600 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
2602 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
2603 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
2610 if (ev->status && conn->type == LE_LINK) in hci_encrypt_change_evt()
2613 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
2615 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
2616 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_encrypt_change_evt()
2617 hci_conn_drop(conn); in hci_encrypt_change_evt()
2626 (!test_bit(HCI_CONN_AES_CCM, &conn->flags) || in hci_encrypt_change_evt()
2627 conn->key_type != HCI_LK_AUTH_COMBINATION_P256)) { in hci_encrypt_change_evt()
2628 hci_connect_cfm(conn, HCI_ERROR_AUTH_FAILURE); in hci_encrypt_change_evt()
2629 hci_conn_drop(conn); in hci_encrypt_change_evt()
2634 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
2643 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
2649 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
2654 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
2662 if (conn->state == BT_CONFIG) { in hci_encrypt_change_evt()
2664 conn->state = BT_CONNECTED; in hci_encrypt_change_evt()
2666 hci_connect_cfm(conn, ev->status); in hci_encrypt_change_evt()
2667 hci_conn_drop(conn); in hci_encrypt_change_evt()
2669 hci_encrypt_cfm(conn, ev->status, ev->encrypt); in hci_encrypt_change_evt()
2679 struct hci_conn *conn; in hci_change_link_key_complete_evt() local
2685 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
2686 if (conn) { in hci_change_link_key_complete_evt()
2688 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
2690 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
2692 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
2702 struct hci_conn *conn; in hci_remote_features_evt() local
2708 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
2709 if (!conn) in hci_remote_features_evt()
2713 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
2715 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
2719 lmp_ext_feat_capable(conn)) { in hci_remote_features_evt()
2728 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_features_evt()
2731 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
2734 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_features_evt()
2735 mgmt_device_connected(hdev, conn, 0, NULL, 0); in hci_remote_features_evt()
2737 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_features_evt()
2738 conn->state = BT_CONNECTED; in hci_remote_features_evt()
2739 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
2740 hci_conn_drop(conn); in hci_remote_features_evt()
3161 struct hci_conn *conn; in hci_role_change_evt() local
3167 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
3168 if (conn) { in hci_role_change_evt()
3170 conn->role = ev->role; in hci_role_change_evt()
3172 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
3174 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
3200 struct hci_conn *conn; in hci_num_comp_pkts_evt() local
3206 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_num_comp_pkts_evt()
3207 if (!conn) in hci_num_comp_pkts_evt()
3210 conn->sent -= count; in hci_num_comp_pkts_evt()
3212 switch (conn->type) { in hci_num_comp_pkts_evt()
3238 BT_ERR("Unknown type %d conn %p", conn->type, conn); in hci_num_comp_pkts_evt()
3257 return chan->conn; in __hci_conn_lookup_handle()
3288 struct hci_conn *conn = NULL; in hci_num_comp_blocks_evt() local
3294 conn = __hci_conn_lookup_handle(hdev, handle); in hci_num_comp_blocks_evt()
3295 if (!conn) in hci_num_comp_blocks_evt()
3298 conn->sent -= block_count; in hci_num_comp_blocks_evt()
3300 switch (conn->type) { in hci_num_comp_blocks_evt()
3309 BT_ERR("Unknown type %d conn %p", conn->type, conn); in hci_num_comp_blocks_evt()
3320 struct hci_conn *conn; in hci_mode_change_evt() local
3326 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
3327 if (conn) { in hci_mode_change_evt()
3328 conn->mode = ev->mode; in hci_mode_change_evt()
3331 &conn->flags)) { in hci_mode_change_evt()
3332 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
3333 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
3335 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
3338 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
3339 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
3348 struct hci_conn *conn; in hci_pin_code_request_evt() local
3354 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
3355 if (!conn) in hci_pin_code_request_evt()
3358 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
3359 hci_conn_hold(conn); in hci_pin_code_request_evt()
3360 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
3361 hci_conn_drop(conn); in hci_pin_code_request_evt()
3365 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
3371 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
3383 static void conn_set_key(struct hci_conn *conn, u8 key_type, u8 pin_len) in conn_set_key() argument
3388 conn->pin_length = pin_len; in conn_set_key()
3389 conn->key_type = key_type; in conn_set_key()
3398 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
3400 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
3404 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
3407 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
3410 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
3419 struct hci_conn *conn; in hci_link_key_request_evt() local
3439 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
3440 if (conn) { in hci_link_key_request_evt()
3441 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
3445 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
3451 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
3452 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
3458 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
3478 struct hci_conn *conn; in hci_link_key_notify_evt() local
3487 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
3488 if (!conn) in hci_link_key_notify_evt()
3491 hci_conn_hold(conn); in hci_link_key_notify_evt()
3492 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
3493 hci_conn_drop(conn); in hci_link_key_notify_evt()
3495 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
3496 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
3501 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
3510 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
3527 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
3529 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
3538 struct hci_conn *conn; in hci_clock_offset_evt() local
3544 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
3545 if (conn && !ev->status) { in hci_clock_offset_evt()
3548 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
3561 struct hci_conn *conn; in hci_pkt_type_change_evt() local
3567 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
3568 if (conn && !ev->status) in hci_pkt_type_change_evt()
3569 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
3660 struct hci_conn *conn; in hci_remote_ext_features_evt() local
3666 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
3667 if (!conn) in hci_remote_ext_features_evt()
3671 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
3676 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
3681 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
3691 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
3695 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
3698 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
3701 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
3704 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
3707 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_ext_features_evt()
3708 mgmt_device_connected(hdev, conn, 0, NULL, 0); in hci_remote_ext_features_evt()
3710 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_ext_features_evt()
3711 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
3712 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
3713 hci_conn_drop(conn); in hci_remote_ext_features_evt()
3724 struct hci_conn *conn; in hci_sync_conn_complete_evt() local
3730 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
3731 if (!conn) { in hci_sync_conn_complete_evt()
3744 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
3745 if (!conn) in hci_sync_conn_complete_evt()
3751 conn->handle = __le16_to_cpu(ev->handle); in hci_sync_conn_complete_evt()
3752 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
3753 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
3755 hci_debugfs_create_conn(conn); in hci_sync_conn_complete_evt()
3756 hci_conn_add_sysfs(conn); in hci_sync_conn_complete_evt()
3766 if (conn->out) { in hci_sync_conn_complete_evt()
3767 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
3769 if (hci_setup_sync(conn, conn->link->handle)) in hci_sync_conn_complete_evt()
3775 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
3779 hci_connect_cfm(conn, ev->status); in hci_sync_conn_complete_evt()
3781 hci_conn_del(conn); in hci_sync_conn_complete_evt()
3858 struct hci_conn *conn; in hci_key_refresh_complete_evt() local
3865 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
3866 if (!conn) in hci_key_refresh_complete_evt()
3872 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
3876 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
3878 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
3880 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
3881 hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); in hci_key_refresh_complete_evt()
3882 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
3886 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
3888 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
3890 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
3891 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
3893 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
3895 hci_conn_hold(conn); in hci_key_refresh_complete_evt()
3896 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
3897 hci_conn_drop(conn); in hci_key_refresh_complete_evt()
3904 static u8 hci_get_auth_req(struct hci_conn *conn) in hci_get_auth_req() argument
3907 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
3908 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
3909 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
3914 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
3915 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
3916 return conn->remote_auth | 0x01; in hci_get_auth_req()
3919 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
3922 static u8 bredr_oob_data_present(struct hci_conn *conn) in bredr_oob_data_present() argument
3924 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
3927 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
3967 struct hci_conn *conn; in hci_io_capa_request_evt() local
3973 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
3974 if (!conn) in hci_io_capa_request_evt()
3977 hci_conn_hold(conn); in hci_io_capa_request_evt()
3986 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
3987 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
3993 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
3994 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
3997 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
4001 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
4002 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
4003 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
4005 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
4012 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
4014 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
4015 cp.oob_data = bredr_oob_data_present(conn); in hci_io_capa_request_evt()
4036 struct hci_conn *conn; in hci_io_capa_reply_evt() local
4042 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
4043 if (!conn) in hci_io_capa_reply_evt()
4046 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
4047 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
4058 struct hci_conn *conn; in hci_user_confirm_request_evt() local
4067 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
4068 if (!conn) in hci_user_confirm_request_evt()
4071 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
4072 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
4079 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
4080 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
4088 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
4089 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
4097 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
4098 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_user_confirm_request_evt()
4110 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
4111 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
4143 struct hci_conn *conn; in hci_user_passkey_notify_evt() local
4147 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
4148 if (!conn) in hci_user_passkey_notify_evt()
4151 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
4152 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
4155 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
4156 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
4157 conn->passkey_entered); in hci_user_passkey_notify_evt()
4163 struct hci_conn *conn; in hci_keypress_notify_evt() local
4167 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
4168 if (!conn) in hci_keypress_notify_evt()
4173 conn->passkey_entered = 0; in hci_keypress_notify_evt()
4177 conn->passkey_entered++; in hci_keypress_notify_evt()
4181 conn->passkey_entered--; in hci_keypress_notify_evt()
4185 conn->passkey_entered = 0; in hci_keypress_notify_evt()
4193 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
4194 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
4195 conn->passkey_entered); in hci_keypress_notify_evt()
4202 struct hci_conn *conn; in hci_simple_pair_complete_evt() local
4208 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
4209 if (!conn) in hci_simple_pair_complete_evt()
4213 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
4220 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
4221 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
4223 hci_conn_drop(conn); in hci_simple_pair_complete_evt()
4234 struct hci_conn *conn; in hci_remote_host_features_evt() local
4240 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
4241 if (conn) in hci_remote_host_features_evt()
4242 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
4392 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
4451 struct hci_conn *conn; in hci_le_conn_complete_evt() local
4464 conn = hci_lookup_le_connect(hdev); in hci_le_conn_complete_evt()
4465 if (!conn) { in hci_le_conn_complete_evt()
4466 conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr, ev->role); in hci_le_conn_complete_evt()
4467 if (!conn) { in hci_le_conn_complete_evt()
4472 conn->dst_type = ev->bdaddr_type; in hci_le_conn_complete_evt()
4482 if (conn->out) { in hci_le_conn_complete_evt()
4483 conn->resp_addr_type = ev->bdaddr_type; in hci_le_conn_complete_evt()
4484 bacpy(&conn->resp_addr, &ev->bdaddr); in hci_le_conn_complete_evt()
4486 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in hci_le_conn_complete_evt()
4487 bacpy(&conn->init_addr, &hdev->rpa); in hci_le_conn_complete_evt()
4490 &conn->init_addr, in hci_le_conn_complete_evt()
4491 &conn->init_addr_type); in hci_le_conn_complete_evt()
4495 cancel_delayed_work(&conn->le_conn_timeout); in hci_le_conn_complete_evt()
4498 if (!conn->out) { in hci_le_conn_complete_evt()
4502 conn->resp_addr_type = hdev->adv_addr_type; in hci_le_conn_complete_evt()
4504 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_conn_complete_evt()
4506 bacpy(&conn->resp_addr, &hdev->bdaddr); in hci_le_conn_complete_evt()
4508 conn->init_addr_type = ev->bdaddr_type; in hci_le_conn_complete_evt()
4509 bacpy(&conn->init_addr, &ev->bdaddr); in hci_le_conn_complete_evt()
4516 conn->le_conn_min_interval = hdev->le_conn_min_interval; in hci_le_conn_complete_evt()
4517 conn->le_conn_max_interval = hdev->le_conn_max_interval; in hci_le_conn_complete_evt()
4529 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in hci_le_conn_complete_evt()
4531 bacpy(&conn->dst, &irk->bdaddr); in hci_le_conn_complete_evt()
4532 conn->dst_type = irk->addr_type; in hci_le_conn_complete_evt()
4536 hci_le_conn_failed(conn, ev->status); in hci_le_conn_complete_evt()
4540 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in hci_le_conn_complete_evt()
4546 if (hci_bdaddr_list_lookup(&hdev->blacklist, &conn->dst, addr_type)) { in hci_le_conn_complete_evt()
4547 hci_conn_drop(conn); in hci_le_conn_complete_evt()
4551 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_le_conn_complete_evt()
4552 mgmt_device_connected(hdev, conn, 0, NULL, 0); in hci_le_conn_complete_evt()
4554 conn->sec_level = BT_SECURITY_LOW; in hci_le_conn_complete_evt()
4555 conn->handle = __le16_to_cpu(ev->handle); in hci_le_conn_complete_evt()
4556 conn->state = BT_CONFIG; in hci_le_conn_complete_evt()
4558 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_complete_evt()
4559 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_complete_evt()
4560 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_complete_evt()
4562 hci_debugfs_create_conn(conn); in hci_le_conn_complete_evt()
4563 hci_conn_add_sysfs(conn); in hci_le_conn_complete_evt()
4575 if (conn->out || in hci_le_conn_complete_evt()
4579 cp.handle = __cpu_to_le16(conn->handle); in hci_le_conn_complete_evt()
4584 hci_conn_hold(conn); in hci_le_conn_complete_evt()
4586 conn->state = BT_CONNECTED; in hci_le_conn_complete_evt()
4587 hci_connect_cfm(conn, ev->status); in hci_le_conn_complete_evt()
4590 hci_connect_cfm(conn, ev->status); in hci_le_conn_complete_evt()
4593 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in hci_le_conn_complete_evt()
4594 conn->dst_type); in hci_le_conn_complete_evt()
4597 if (params->conn) { in hci_le_conn_complete_evt()
4598 hci_conn_drop(params->conn); in hci_le_conn_complete_evt()
4599 hci_conn_put(params->conn); in hci_le_conn_complete_evt()
4600 params->conn = NULL; in hci_le_conn_complete_evt()
4613 struct hci_conn *conn; in hci_le_conn_update_complete_evt() local
4622 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
4623 if (conn) { in hci_le_conn_update_complete_evt()
4624 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
4625 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
4626 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
4637 struct hci_conn *conn; in check_pending_le_conn() local
4685 conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW, in check_pending_le_conn()
4687 if (!IS_ERR(conn)) { in check_pending_le_conn()
4698 params->conn = hci_conn_get(conn); in check_pending_le_conn()
4700 return conn; in check_pending_le_conn()
4703 switch (PTR_ERR(conn)) { in check_pending_le_conn()
4712 BT_DBG("Failed to connect: err %ld", PTR_ERR(conn)); in check_pending_le_conn()
4725 struct hci_conn *conn; in process_adv_report() local
4784 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type); in process_adv_report()
4785 if (conn && type == LE_ADV_IND) { in process_adv_report()
4789 memcpy(conn->le_adv_data, data, len); in process_adv_report()
4790 conn->le_adv_data_len = len; in process_adv_report()
4925 struct hci_conn *conn; in hci_le_remote_feat_complete_evt() local
4931 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
4932 if (conn) { in hci_le_remote_feat_complete_evt()
4934 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
4936 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
4949 !conn->out && ev->status == 0x1a) in hci_le_remote_feat_complete_evt()
4954 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
4955 hci_connect_cfm(conn, status); in hci_le_remote_feat_complete_evt()
4956 hci_conn_drop(conn); in hci_le_remote_feat_complete_evt()
4968 struct hci_conn *conn; in hci_le_ltk_request_evt() local
4975 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
4976 if (conn == NULL) in hci_le_ltk_request_evt()
4979 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
4995 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
4997 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
4999 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
5010 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
5014 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()