Lines Matching refs:conn
97 struct l2cap_conn *conn; member
589 static void smp_send_cmd(struct l2cap_conn *conn, u8 code, u16 len, void *data) in smp_send_cmd() argument
591 struct l2cap_chan *chan = conn->smp; in smp_send_cmd()
599 bt_dev_dbg(conn->hcon->hdev, "code 0x%2.2x", code); in smp_send_cmd()
647 static void build_pairing_cmd(struct l2cap_conn *conn, in build_pairing_cmd() argument
651 struct l2cap_chan *chan = conn->smp; in build_pairing_cmd()
653 struct hci_conn *hcon = conn->hcon; in build_pairing_cmd()
702 req->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
713 rsp->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
723 static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size) in check_enc_key_size() argument
725 struct l2cap_chan *chan = conn->smp; in check_enc_key_size()
726 struct hci_dev *hdev = conn->hcon->hdev; in check_enc_key_size()
729 if (conn->hcon->pending_sec_level == BT_SECURITY_FIPS && in check_enc_key_size()
742 static void smp_chan_destroy(struct l2cap_conn *conn) in smp_chan_destroy() argument
744 struct l2cap_chan *chan = conn->smp; in smp_chan_destroy()
746 struct hci_conn *hcon = conn->hcon; in smp_chan_destroy()
796 static void smp_failure(struct l2cap_conn *conn, u8 reason) in smp_failure() argument
798 struct hci_conn *hcon = conn->hcon; in smp_failure()
799 struct l2cap_chan *chan = conn->smp; in smp_failure()
802 smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason), in smp_failure()
808 smp_chan_destroy(conn); in smp_failure()
850 static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, in tk_request() argument
853 struct hci_conn *hcon = conn->hcon; in tk_request()
854 struct l2cap_chan *chan = conn->smp; in tk_request()
950 struct l2cap_conn *conn = smp->conn; in smp_confirm() local
954 bt_dev_dbg(conn->hcon->hdev, "conn %p", conn); in smp_confirm()
957 conn->hcon->init_addr_type, &conn->hcon->init_addr, in smp_confirm()
958 conn->hcon->resp_addr_type, &conn->hcon->resp_addr, in smp_confirm()
965 smp_send_cmd(smp->conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp); in smp_confirm()
977 struct l2cap_conn *conn = smp->conn; in smp_random() local
978 struct hci_conn *hcon = conn->hcon; in smp_random()
982 bt_dev_dbg(conn->hcon->hdev, "conn %p %s", conn, in smp_random()
1016 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_random()
1037 static void smp_notify_keys(struct l2cap_conn *conn) in smp_notify_keys() argument
1039 struct l2cap_chan *chan = conn->smp; in smp_notify_keys()
1041 struct hci_conn *hcon = conn->hcon; in smp_notify_keys()
1076 &conn->id_addr_timer, in smp_notify_keys()
1116 key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst, in smp_notify_keys()
1135 struct hci_conn *hcon = smp->conn->hcon; in sc_add_ltk()
1207 struct hci_conn *hcon = smp->conn->hcon; in sc_generate_ltk()
1243 struct l2cap_conn *conn = smp->conn; in smp_distribute_keys() local
1244 struct hci_conn *hcon = conn->hcon; in smp_distribute_keys()
1248 bt_dev_dbg(hdev, "conn %p", conn); in smp_distribute_keys()
1300 smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc); in smp_distribute_keys()
1311 smp_send_cmd(conn, SMP_CMD_INITIATOR_IDENT, sizeof(ident), in smp_distribute_keys()
1323 smp_send_cmd(conn, SMP_CMD_IDENT_INFO, sizeof(idinfo), &idinfo); in smp_distribute_keys()
1334 smp_send_cmd(conn, SMP_CMD_IDENT_ADDR_INFO, sizeof(addrinfo), in smp_distribute_keys()
1357 smp_send_cmd(conn, SMP_CMD_SIGN_INFO, sizeof(sign), &sign); in smp_distribute_keys()
1369 smp_notify_keys(conn); in smp_distribute_keys()
1371 smp_chan_destroy(conn); in smp_distribute_keys()
1378 struct l2cap_conn *conn = smp->conn; in smp_timeout() local
1380 bt_dev_dbg(conn->hcon->hdev, "conn %p", conn); in smp_timeout()
1382 hci_disconnect(conn->hcon, HCI_ERROR_AUTH_FAILURE); in smp_timeout()
1385 static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) in smp_chan_create() argument
1387 struct hci_conn *hcon = conn->hcon; in smp_chan_create()
1388 struct l2cap_chan *chan = conn->smp; in smp_chan_create()
1407 smp->conn = conn; in smp_chan_create()
1427 struct hci_conn *hcon = smp->conn->hcon; in sc_mackey_and_ltk()
1448 struct hci_conn *hcon = smp->conn->hcon; in sc_dhkey_check()
1479 smp_send_cmd(smp->conn, SMP_CMD_DHKEY_CHECK, sizeof(check), &check); in sc_dhkey_check()
1484 struct l2cap_conn *conn = smp->conn; in sc_passkey_send_confirm() local
1485 struct hci_conn *hcon = conn->hcon; in sc_passkey_send_confirm()
1498 smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cfm), &cfm); in sc_passkey_send_confirm()
1505 struct l2cap_conn *conn = smp->conn; in sc_passkey_round() local
1506 struct hci_conn *hcon = conn->hcon; in sc_passkey_round()
1538 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, in sc_passkey_round()
1566 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, in sc_passkey_round()
1592 struct l2cap_conn *conn = smp->conn; in sc_user_reply() local
1593 struct hci_conn *hcon = conn->hcon; in sc_user_reply()
1600 smp_failure(smp->conn, SMP_PASSKEY_ENTRY_FAILED); in sc_user_reply()
1603 smp_failure(smp->conn, SMP_NUMERIC_COMP_FAILED); in sc_user_reply()
1634 struct l2cap_conn *conn = hcon->l2cap_data; in smp_user_confirm_reply() local
1640 if (!conn) in smp_user_confirm_reply()
1643 bt_dev_dbg(conn->hcon->hdev, ""); in smp_user_confirm_reply()
1645 chan = conn->smp; in smp_user_confirm_reply()
1666 bt_dev_dbg(conn->hcon->hdev, "PassKey: %u", value); in smp_user_confirm_reply()
1674 smp_failure(conn, SMP_PASSKEY_ENTRY_FAILED); in smp_user_confirm_reply()
1678 smp_failure(conn, SMP_PASSKEY_ENTRY_FAILED); in smp_user_confirm_reply()
1689 smp_failure(conn, rsp); in smp_user_confirm_reply()
1701 struct l2cap_conn *conn = smp->conn; in build_bredr_pairing_cmd() local
1702 struct hci_dev *hdev = conn->hcon->hdev; in build_bredr_pairing_cmd()
1722 req->max_key_size = conn->hcon->enc_key_size; in build_bredr_pairing_cmd()
1732 rsp->max_key_size = conn->hcon->enc_key_size; in build_bredr_pairing_cmd()
1739 static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_pairing_req() argument
1742 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_req()
1743 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_req()
1748 bt_dev_dbg(hdev, "conn %p", conn); in smp_cmd_pairing_req()
1757 smp = smp_chan_create(conn); in smp_cmd_pairing_req()
1784 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_req()
1786 if (!test_bit(HCI_CONN_AES_CCM, &conn->hcon->flags) && in smp_cmd_pairing_req()
1798 if (check_enc_key_size(conn, key_size)) in smp_cmd_pairing_req()
1806 smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(rsp), &rsp); in smp_cmd_pairing_req()
1812 build_pairing_cmd(conn, req, &rsp, auth); in smp_cmd_pairing_req()
1821 if (conn->hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_pairing_req()
1826 if (sec_level > conn->hcon->pending_sec_level) in smp_cmd_pairing_req()
1827 conn->hcon->pending_sec_level = sec_level; in smp_cmd_pairing_req()
1830 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_req()
1833 method = get_auth_method(smp, conn->hcon->io_capability, in smp_cmd_pairing_req()
1840 if (check_enc_key_size(conn, key_size)) in smp_cmd_pairing_req()
1848 smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(rsp), &rsp); in smp_cmd_pairing_req()
1868 ret = tk_request(conn, 0, auth, rsp.io_capability, req->io_capability); in smp_cmd_pairing_req()
1877 struct hci_dev *hdev = smp->conn->hcon->hdev; in sc_send_public_key()
1923 smp_send_cmd(smp->conn, SMP_CMD_PUBLIC_KEY, 64, smp->local_pk); in sc_send_public_key()
1928 static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_pairing_rsp() argument
1931 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_rsp()
1933 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_rsp()
1937 bt_dev_dbg(hdev, "conn %p", conn); in smp_cmd_pairing_rsp()
1950 if (check_enc_key_size(conn, key_size)) in smp_cmd_pairing_rsp()
1977 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_rsp()
1986 else if (conn->hcon->pending_sec_level > BT_SECURITY_HIGH) in smp_cmd_pairing_rsp()
1987 conn->hcon->pending_sec_level = BT_SECURITY_HIGH; in smp_cmd_pairing_rsp()
1990 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_rsp()
2015 ret = tk_request(conn, 0, auth, req->io_capability, rsp->io_capability); in smp_cmd_pairing_rsp()
2030 struct l2cap_conn *conn = smp->conn; in sc_check_confirm() local
2032 bt_dev_dbg(conn->hcon->hdev, ""); in sc_check_confirm()
2038 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in sc_check_confirm()
2052 struct l2cap_conn *conn = smp->conn; in fixup_sc_false_positive() local
2053 struct hci_conn *hcon = conn->hcon; in fixup_sc_false_positive()
2077 if (tk_request(conn, 0, auth, rsp->io_capability, req->io_capability)) { in fixup_sc_false_positive()
2087 static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_pairing_confirm() argument
2089 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_confirm()
2091 struct hci_conn *hcon = conn->hcon; in smp_cmd_pairing_confirm()
2094 bt_dev_dbg(hdev, "conn %p %s", conn, in smp_cmd_pairing_confirm()
2119 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_cmd_pairing_confirm()
2133 static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_pairing_random() argument
2135 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_random()
2137 struct hci_conn *hcon = conn->hcon; in smp_cmd_pairing_random()
2142 bt_dev_dbg(hcon->hdev, "conn %p", conn); in smp_cmd_pairing_random()
2167 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, in smp_cmd_pairing_random()
2188 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_cmd_pairing_random()
2245 static bool smp_ltk_encrypt(struct l2cap_conn *conn, u8 sec_level) in smp_ltk_encrypt() argument
2248 struct hci_conn *hcon = conn->hcon; in smp_ltk_encrypt()
2296 if (smp->conn->hcon->type == ACL_LINK) in smp_send_pairing_req()
2299 build_pairing_cmd(smp->conn, &cp, NULL, auth); in smp_send_pairing_req()
2304 smp_send_cmd(smp->conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); in smp_send_pairing_req()
2310 static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_security_req() argument
2313 struct hci_conn *hcon = conn->hcon; in smp_cmd_security_req()
2318 bt_dev_dbg(hdev, "conn %p", conn); in smp_cmd_security_req()
2341 smp_ltk_encrypt(conn, hcon->sec_level); in smp_cmd_security_req()
2348 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_cmd_security_req()
2351 smp = smp_chan_create(conn); in smp_cmd_security_req()
2371 smp_send_cmd(smp->conn, SMP_CMD_SECURITY_REQ, sizeof(cp), &cp); in smp_send_security_req()
2379 struct l2cap_conn *conn = hcon->l2cap_data; in smp_conn_security() local
2385 bt_dev_dbg(hcon->hdev, "conn %p hcon %p level 0x%2.2x", conn, hcon, in smp_conn_security()
2389 if (!conn) in smp_conn_security()
2402 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_conn_security()
2405 chan = conn->smp; in smp_conn_security()
2419 smp = smp_chan_create(conn); in smp_conn_security()
2461 struct l2cap_conn *conn; in smp_cancel_and_remove_pairing() local
2473 conn = hcon->l2cap_data; in smp_cancel_and_remove_pairing()
2474 if (!conn) in smp_cancel_and_remove_pairing()
2477 chan = conn->smp; in smp_cancel_and_remove_pairing()
2492 smp_failure(conn, 0); in smp_cancel_and_remove_pairing()
2494 smp_failure(conn, SMP_UNSPECIFIED); in smp_cancel_and_remove_pairing()
2504 static int smp_cmd_encrypt_info(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_encrypt_info() argument
2507 struct l2cap_chan *chan = conn->smp; in smp_cmd_encrypt_info()
2510 bt_dev_dbg(conn->hcon->hdev, "conn %p", conn); in smp_cmd_encrypt_info()
2516 if (hci_is_blocked_key(conn->hcon->hdev, HCI_BLOCKED_KEY_TYPE_LTK, in smp_cmd_encrypt_info()
2518 bt_dev_warn_ratelimited(conn->hcon->hdev, in smp_cmd_encrypt_info()
2520 &conn->hcon->dst); in smp_cmd_encrypt_info()
2533 static int smp_cmd_initiator_ident(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_initiator_ident() argument
2536 struct l2cap_chan *chan = conn->smp; in smp_cmd_initiator_ident()
2538 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_initiator_ident()
2539 struct hci_conn *hcon = conn->hcon; in smp_cmd_initiator_ident()
2543 bt_dev_dbg(hdev, "conn %p", conn); in smp_cmd_initiator_ident()
2569 static int smp_cmd_ident_info(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_ident_info() argument
2572 struct l2cap_chan *chan = conn->smp; in smp_cmd_ident_info()
2575 bt_dev_dbg(conn->hcon->hdev, ""); in smp_cmd_ident_info()
2581 if (hci_is_blocked_key(conn->hcon->hdev, HCI_BLOCKED_KEY_TYPE_IRK, in smp_cmd_ident_info()
2583 bt_dev_warn_ratelimited(conn->hcon->hdev, in smp_cmd_ident_info()
2585 &conn->hcon->dst); in smp_cmd_ident_info()
2598 static int smp_cmd_ident_addr_info(struct l2cap_conn *conn, in smp_cmd_ident_addr_info() argument
2602 struct l2cap_chan *chan = conn->smp; in smp_cmd_ident_addr_info()
2604 struct hci_conn *hcon = conn->hcon; in smp_cmd_ident_addr_info()
2657 smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, in smp_cmd_ident_addr_info()
2667 static int smp_cmd_sign_info(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_sign_info() argument
2670 struct l2cap_chan *chan = conn->smp; in smp_cmd_sign_info()
2674 bt_dev_dbg(conn->hcon->hdev, "conn %p", conn); in smp_cmd_sign_info()
2686 if (conn->hcon->sec_level > BT_SECURITY_MEDIUM) in smp_cmd_sign_info()
2741 static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_public_key() argument
2744 struct hci_conn *hcon = conn->hcon; in smp_cmd_public_key()
2745 struct l2cap_chan *chan = conn->smp; in smp_cmd_public_key()
2752 bt_dev_dbg(hdev, "conn %p", conn); in smp_cmd_public_key()
2844 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, in smp_cmd_public_key()
2875 smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cfm), &cfm); in smp_cmd_public_key()
2881 static int smp_cmd_dhkey_check(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_dhkey_check() argument
2884 struct l2cap_chan *chan = conn->smp; in smp_cmd_dhkey_check()
2885 struct hci_conn *hcon = conn->hcon; in smp_cmd_dhkey_check()
2891 bt_dev_dbg(hcon->hdev, "conn %p", conn); in smp_cmd_dhkey_check()
2946 static int smp_cmd_keypress_notify(struct l2cap_conn *conn, in smp_cmd_keypress_notify() argument
2951 bt_dev_dbg(conn->hcon->hdev, "value 0x%02x", kp->value); in smp_cmd_keypress_notify()
2958 struct l2cap_conn *conn = chan->conn; in smp_sig_channel() local
2959 struct hci_conn *hcon = conn->hcon; in smp_sig_channel()
2994 smp_failure(conn, SMP_KEY_REJECTED); in smp_sig_channel()
3008 reason = smp_cmd_pairing_req(conn, skb); in smp_sig_channel()
3012 smp_failure(conn, 0); in smp_sig_channel()
3017 reason = smp_cmd_pairing_rsp(conn, skb); in smp_sig_channel()
3021 reason = smp_cmd_security_req(conn, skb); in smp_sig_channel()
3025 reason = smp_cmd_pairing_confirm(conn, skb); in smp_sig_channel()
3029 reason = smp_cmd_pairing_random(conn, skb); in smp_sig_channel()
3033 reason = smp_cmd_encrypt_info(conn, skb); in smp_sig_channel()
3037 reason = smp_cmd_initiator_ident(conn, skb); in smp_sig_channel()
3041 reason = smp_cmd_ident_info(conn, skb); in smp_sig_channel()
3045 reason = smp_cmd_ident_addr_info(conn, skb); in smp_sig_channel()
3049 reason = smp_cmd_sign_info(conn, skb); in smp_sig_channel()
3053 reason = smp_cmd_public_key(conn, skb); in smp_sig_channel()
3057 reason = smp_cmd_dhkey_check(conn, skb); in smp_sig_channel()
3061 reason = smp_cmd_keypress_notify(conn, skb); in smp_sig_channel()
3073 smp_failure(conn, reason); in smp_sig_channel()
3088 struct l2cap_conn *conn = chan->conn; in smp_teardown_cb() local
3090 bt_dev_dbg(conn->hcon->hdev, "chan %p", chan); in smp_teardown_cb()
3093 smp_chan_destroy(conn); in smp_teardown_cb()
3095 conn->smp = NULL; in smp_teardown_cb()
3101 struct l2cap_conn *conn = chan->conn; in bredr_pairing() local
3102 struct hci_conn *hcon = conn->hcon; in bredr_pairing()
3138 if (!(conn->remote_fixed_chan & L2CAP_FC_SMP_BREDR)) in bredr_pairing()
3145 smp = smp_chan_create(conn); in bredr_pairing()
3161 struct l2cap_conn *conn = chan->conn; in smp_resume_cb() local
3162 struct hci_conn *hcon = conn->hcon; in smp_resume_cb()
3184 struct l2cap_conn *conn = chan->conn; in smp_ready_cb() local
3185 struct hci_conn *hcon = conn->hcon; in smp_ready_cb()
3195 conn->smp = chan; in smp_ready_cb()
3205 bt_dev_dbg(chan->conn->hcon->hdev, "chan %p", chan); in smp_recv_cb()
3214 hci_disconnect(chan->conn->hcon, HCI_ERROR_AUTH_FAILURE); in smp_recv_cb()