Lines Matching refs:conn
95 struct l2cap_conn *conn; member
602 static void smp_send_cmd(struct l2cap_conn *conn, u8 code, u16 len, void *data) in smp_send_cmd() argument
604 struct l2cap_chan *chan = conn->smp; in smp_send_cmd()
660 static void build_pairing_cmd(struct l2cap_conn *conn, in build_pairing_cmd() argument
664 struct l2cap_chan *chan = conn->smp; in build_pairing_cmd()
666 struct hci_conn *hcon = conn->hcon; in build_pairing_cmd()
715 req->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
726 rsp->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
736 static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size) in check_enc_key_size() argument
738 struct l2cap_chan *chan = conn->smp; in check_enc_key_size()
739 struct hci_dev *hdev = conn->hcon->hdev; in check_enc_key_size()
751 static void smp_chan_destroy(struct l2cap_conn *conn) in smp_chan_destroy() argument
753 struct l2cap_chan *chan = conn->smp; in smp_chan_destroy()
755 struct hci_conn *hcon = conn->hcon; in smp_chan_destroy()
805 static void smp_failure(struct l2cap_conn *conn, u8 reason) in smp_failure() argument
807 struct hci_conn *hcon = conn->hcon; in smp_failure()
808 struct l2cap_chan *chan = conn->smp; in smp_failure()
811 smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason), in smp_failure()
817 smp_chan_destroy(conn); in smp_failure()
859 static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, in tk_request() argument
862 struct hci_conn *hcon = conn->hcon; in tk_request()
863 struct l2cap_chan *chan = conn->smp; in tk_request()
951 struct l2cap_conn *conn = smp->conn; in smp_confirm() local
955 BT_DBG("conn %p", conn); in smp_confirm()
958 conn->hcon->init_addr_type, &conn->hcon->init_addr, in smp_confirm()
959 conn->hcon->resp_addr_type, &conn->hcon->resp_addr, in smp_confirm()
966 smp_send_cmd(smp->conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp); in smp_confirm()
968 if (conn->hcon->out) in smp_confirm()
978 struct l2cap_conn *conn = smp->conn; in smp_random() local
979 struct hci_conn *hcon = conn->hcon; in smp_random()
986 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); in smp_random()
1017 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_random()
1038 static void smp_notify_keys(struct l2cap_conn *conn) in smp_notify_keys() argument
1040 struct l2cap_chan *chan = conn->smp; in smp_notify_keys()
1042 struct hci_conn *hcon = conn->hcon; in smp_notify_keys()
1073 queue_work(hdev->workqueue, &conn->id_addr_update_work); in smp_notify_keys()
1112 key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst, in smp_notify_keys()
1131 struct hci_conn *hcon = smp->conn->hcon; in sc_add_ltk()
1195 struct hci_conn *hcon = smp->conn->hcon; in sc_generate_ltk()
1220 struct l2cap_conn *conn = smp->conn; in smp_distribute_keys() local
1221 struct hci_conn *hcon = conn->hcon; in smp_distribute_keys()
1225 BT_DBG("conn %p", conn); in smp_distribute_keys()
1276 smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc); in smp_distribute_keys()
1287 smp_send_cmd(conn, SMP_CMD_MASTER_IDENT, sizeof(ident), &ident); in smp_distribute_keys()
1298 smp_send_cmd(conn, SMP_CMD_IDENT_INFO, sizeof(idinfo), &idinfo); in smp_distribute_keys()
1309 smp_send_cmd(conn, SMP_CMD_IDENT_ADDR_INFO, sizeof(addrinfo), in smp_distribute_keys()
1332 smp_send_cmd(conn, SMP_CMD_SIGN_INFO, sizeof(sign), &sign); in smp_distribute_keys()
1344 smp_notify_keys(conn); in smp_distribute_keys()
1346 smp_chan_destroy(conn); in smp_distribute_keys()
1353 struct l2cap_conn *conn = smp->conn; in smp_timeout() local
1355 BT_DBG("conn %p", conn); in smp_timeout()
1357 hci_disconnect(conn->hcon, HCI_ERROR_REMOTE_USER_TERM); in smp_timeout()
1360 static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) in smp_chan_create() argument
1362 struct l2cap_chan *chan = conn->smp; in smp_chan_create()
1384 smp->conn = conn; in smp_chan_create()
1391 hci_conn_hold(conn->hcon); in smp_chan_create()
1398 struct hci_conn *hcon = smp->conn->hcon; in sc_mackey_and_ltk()
1419 struct hci_conn *hcon = smp->conn->hcon; in sc_dhkey_check()
1450 smp_send_cmd(smp->conn, SMP_CMD_DHKEY_CHECK, sizeof(check), &check); in sc_dhkey_check()
1455 struct l2cap_conn *conn = smp->conn; in sc_passkey_send_confirm() local
1456 struct hci_conn *hcon = conn->hcon; in sc_passkey_send_confirm()
1469 smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cfm), &cfm); in sc_passkey_send_confirm()
1476 struct l2cap_conn *conn = smp->conn; in sc_passkey_round() local
1477 struct hci_conn *hcon = conn->hcon; in sc_passkey_round()
1509 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, in sc_passkey_round()
1537 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, in sc_passkey_round()
1563 struct l2cap_conn *conn = smp->conn; in sc_user_reply() local
1564 struct hci_conn *hcon = conn->hcon; in sc_user_reply()
1571 smp_failure(smp->conn, SMP_PASSKEY_ENTRY_FAILED); in sc_user_reply()
1574 smp_failure(smp->conn, SMP_NUMERIC_COMP_FAILED); in sc_user_reply()
1605 struct l2cap_conn *conn = hcon->l2cap_data; in smp_user_confirm_reply() local
1613 if (!conn) in smp_user_confirm_reply()
1616 chan = conn->smp; in smp_user_confirm_reply()
1645 smp_failure(conn, SMP_PASSKEY_ENTRY_FAILED); in smp_user_confirm_reply()
1649 smp_failure(conn, SMP_PASSKEY_ENTRY_FAILED); in smp_user_confirm_reply()
1660 smp_failure(conn, rsp); in smp_user_confirm_reply()
1672 struct l2cap_conn *conn = smp->conn; in build_bredr_pairing_cmd() local
1673 struct hci_dev *hdev = conn->hcon->hdev; in build_bredr_pairing_cmd()
1692 req->max_key_size = conn->hcon->enc_key_size; in build_bredr_pairing_cmd()
1701 rsp->max_key_size = conn->hcon->enc_key_size; in build_bredr_pairing_cmd()
1708 static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_pairing_req() argument
1711 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_req()
1712 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_req()
1717 BT_DBG("conn %p", conn); in smp_cmd_pairing_req()
1722 if (conn->hcon->role != HCI_ROLE_SLAVE) in smp_cmd_pairing_req()
1726 smp = smp_chan_create(conn); in smp_cmd_pairing_req()
1755 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_req()
1757 if (!test_bit(HCI_CONN_AES_CCM, &conn->hcon->flags) && in smp_cmd_pairing_req()
1766 if (check_enc_key_size(conn, key_size)) in smp_cmd_pairing_req()
1774 smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(rsp), &rsp); in smp_cmd_pairing_req()
1780 build_pairing_cmd(conn, req, &rsp, auth); in smp_cmd_pairing_req()
1785 if (conn->hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_pairing_req()
1790 if (sec_level > conn->hcon->pending_sec_level) in smp_cmd_pairing_req()
1791 conn->hcon->pending_sec_level = sec_level; in smp_cmd_pairing_req()
1794 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_req()
1797 method = get_auth_method(smp, conn->hcon->io_capability, in smp_cmd_pairing_req()
1804 if (check_enc_key_size(conn, key_size)) in smp_cmd_pairing_req()
1812 smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(rsp), &rsp); in smp_cmd_pairing_req()
1832 ret = tk_request(conn, 0, auth, rsp.io_capability, req->io_capability); in smp_cmd_pairing_req()
1841 struct hci_dev *hdev = smp->conn->hcon->hdev; in sc_send_public_key()
1888 smp_send_cmd(smp->conn, SMP_CMD_PUBLIC_KEY, 64, smp->local_pk); in sc_send_public_key()
1893 static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_pairing_rsp() argument
1896 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_rsp()
1898 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_rsp()
1902 BT_DBG("conn %p", conn); in smp_cmd_pairing_rsp()
1907 if (conn->hcon->role != HCI_ROLE_MASTER) in smp_cmd_pairing_rsp()
1915 if (check_enc_key_size(conn, key_size)) in smp_cmd_pairing_rsp()
1939 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_rsp()
1948 else if (conn->hcon->pending_sec_level > BT_SECURITY_HIGH) in smp_cmd_pairing_rsp()
1949 conn->hcon->pending_sec_level = BT_SECURITY_HIGH; in smp_cmd_pairing_rsp()
1952 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_rsp()
1977 ret = tk_request(conn, 0, auth, req->io_capability, rsp->io_capability); in smp_cmd_pairing_rsp()
1992 struct l2cap_conn *conn = smp->conn; in sc_check_confirm() local
1999 if (conn->hcon->out) { in sc_check_confirm()
2000 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in sc_check_confirm()
2014 struct l2cap_conn *conn = smp->conn; in fixup_sc_false_positive() local
2015 struct hci_conn *hcon = conn->hcon; in fixup_sc_false_positive()
2039 if (tk_request(conn, 0, auth, rsp->io_capability, req->io_capability)) { in fixup_sc_false_positive()
2049 static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_pairing_confirm() argument
2051 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_confirm()
2054 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); in smp_cmd_pairing_confirm()
2076 if (conn->hcon->out) { in smp_cmd_pairing_confirm()
2077 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_cmd_pairing_confirm()
2091 static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_pairing_random() argument
2093 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_random()
2095 struct hci_conn *hcon = conn->hcon; in smp_cmd_pairing_random()
2100 BT_DBG("conn %p", conn); in smp_cmd_pairing_random()
2125 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, in smp_cmd_pairing_random()
2146 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_cmd_pairing_random()
2179 static bool smp_ltk_encrypt(struct l2cap_conn *conn, u8 sec_level) in smp_ltk_encrypt() argument
2182 struct hci_conn *hcon = conn->hcon; in smp_ltk_encrypt()
2226 static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_security_req() argument
2230 struct hci_conn *hcon = conn->hcon; in smp_cmd_security_req()
2235 BT_DBG("conn %p", conn); in smp_cmd_security_req()
2259 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_cmd_security_req()
2262 smp = smp_chan_create(conn); in smp_cmd_security_req()
2273 build_pairing_cmd(conn, &cp, NULL, auth); in smp_cmd_security_req()
2278 smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); in smp_cmd_security_req()
2286 struct l2cap_conn *conn = hcon->l2cap_data; in smp_conn_security() local
2292 BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level); in smp_conn_security()
2295 if (!conn) in smp_conn_security()
2308 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_conn_security()
2311 chan = conn->smp; in smp_conn_security()
2325 smp = smp_chan_create(conn); in smp_conn_security()
2346 build_pairing_cmd(conn, &cp, NULL, authreq); in smp_conn_security()
2350 smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); in smp_conn_security()
2355 smp_send_cmd(conn, SMP_CMD_SECURITY_REQ, sizeof(cp), &cp); in smp_conn_security()
2369 struct l2cap_conn *conn = hcon->l2cap_data; in smp_cancel_pairing() local
2373 if (!conn) in smp_cancel_pairing()
2376 chan = conn->smp; in smp_cancel_pairing()
2385 smp_failure(conn, 0); in smp_cancel_pairing()
2387 smp_failure(conn, SMP_UNSPECIFIED); in smp_cancel_pairing()
2393 static int smp_cmd_encrypt_info(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_encrypt_info() argument
2396 struct l2cap_chan *chan = conn->smp; in smp_cmd_encrypt_info()
2399 BT_DBG("conn %p", conn); in smp_cmd_encrypt_info()
2413 static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_master_ident() argument
2416 struct l2cap_chan *chan = conn->smp; in smp_cmd_master_ident()
2418 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_master_ident()
2419 struct hci_conn *hcon = conn->hcon; in smp_cmd_master_ident()
2423 BT_DBG("conn %p", conn); in smp_cmd_master_ident()
2449 static int smp_cmd_ident_info(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_ident_info() argument
2452 struct l2cap_chan *chan = conn->smp; in smp_cmd_ident_info()
2469 static int smp_cmd_ident_addr_info(struct l2cap_conn *conn, in smp_cmd_ident_addr_info() argument
2473 struct l2cap_chan *chan = conn->smp; in smp_cmd_ident_addr_info()
2475 struct hci_conn *hcon = conn->hcon; in smp_cmd_ident_addr_info()
2515 smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, in smp_cmd_ident_addr_info()
2525 static int smp_cmd_sign_info(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_sign_info() argument
2528 struct l2cap_chan *chan = conn->smp; in smp_cmd_sign_info()
2532 BT_DBG("conn %p", conn); in smp_cmd_sign_info()
2544 if (conn->hcon->sec_level > BT_SECURITY_MEDIUM) in smp_cmd_sign_info()
2558 struct l2cap_conn *conn = smp->conn; in sc_select_method() local
2559 struct hci_conn *hcon = conn->hcon; in sc_select_method()
2601 static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_public_key() argument
2604 struct hci_conn *hcon = conn->hcon; in smp_cmd_public_key()
2605 struct l2cap_chan *chan = conn->smp; in smp_cmd_public_key()
2611 BT_DBG("conn %p", conn); in smp_cmd_public_key()
2677 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, in smp_cmd_public_key()
2700 if (conn->hcon->out) in smp_cmd_public_key()
2708 smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cfm), &cfm); in smp_cmd_public_key()
2714 static int smp_cmd_dhkey_check(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_dhkey_check() argument
2717 struct l2cap_chan *chan = conn->smp; in smp_cmd_dhkey_check()
2718 struct hci_conn *hcon = conn->hcon; in smp_cmd_dhkey_check()
2724 BT_DBG("conn %p", conn); in smp_cmd_dhkey_check()
2779 static int smp_cmd_keypress_notify(struct l2cap_conn *conn, in smp_cmd_keypress_notify() argument
2791 struct l2cap_conn *conn = chan->conn; in smp_sig_channel() local
2792 struct hci_conn *hcon = conn->hcon; in smp_sig_channel()
2824 reason = smp_cmd_pairing_req(conn, skb); in smp_sig_channel()
2828 smp_failure(conn, 0); in smp_sig_channel()
2833 reason = smp_cmd_pairing_rsp(conn, skb); in smp_sig_channel()
2837 reason = smp_cmd_security_req(conn, skb); in smp_sig_channel()
2841 reason = smp_cmd_pairing_confirm(conn, skb); in smp_sig_channel()
2845 reason = smp_cmd_pairing_random(conn, skb); in smp_sig_channel()
2849 reason = smp_cmd_encrypt_info(conn, skb); in smp_sig_channel()
2853 reason = smp_cmd_master_ident(conn, skb); in smp_sig_channel()
2857 reason = smp_cmd_ident_info(conn, skb); in smp_sig_channel()
2861 reason = smp_cmd_ident_addr_info(conn, skb); in smp_sig_channel()
2865 reason = smp_cmd_sign_info(conn, skb); in smp_sig_channel()
2869 reason = smp_cmd_public_key(conn, skb); in smp_sig_channel()
2873 reason = smp_cmd_dhkey_check(conn, skb); in smp_sig_channel()
2877 reason = smp_cmd_keypress_notify(conn, skb); in smp_sig_channel()
2889 smp_failure(conn, reason); in smp_sig_channel()
2904 struct l2cap_conn *conn = chan->conn; in smp_teardown_cb() local
2909 smp_chan_destroy(conn); in smp_teardown_cb()
2911 conn->smp = NULL; in smp_teardown_cb()
2917 struct l2cap_conn *conn = chan->conn; in bredr_pairing() local
2918 struct hci_conn *hcon = conn->hcon; in bredr_pairing()
2955 if (!(conn->remote_fixed_chan & L2CAP_FC_SMP_BREDR)) in bredr_pairing()
2962 smp = smp_chan_create(conn); in bredr_pairing()
2979 smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(req), &req); in bredr_pairing()
2986 struct l2cap_conn *conn = chan->conn; in smp_resume_cb() local
2987 struct hci_conn *hcon = conn->hcon; in smp_resume_cb()
3009 struct l2cap_conn *conn = chan->conn; in smp_ready_cb() local
3010 struct hci_conn *hcon = conn->hcon; in smp_ready_cb()
3020 conn->smp = chan; in smp_ready_cb()
3039 hci_disconnect(chan->conn->hcon, HCI_ERROR_AUTH_FAILURE); in smp_recv_cb()