Lines Matching refs:conn

89 	struct l2cap_conn	*conn;  member
584 static void smp_send_cmd(struct l2cap_conn *conn, u8 code, u16 len, void *data) in smp_send_cmd() argument
586 struct l2cap_chan *chan = conn->smp; in smp_send_cmd()
642 static void build_pairing_cmd(struct l2cap_conn *conn, in build_pairing_cmd() argument
646 struct l2cap_chan *chan = conn->smp; in build_pairing_cmd()
648 struct hci_conn *hcon = conn->hcon; in build_pairing_cmd()
697 req->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
708 rsp->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
718 static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size) in check_enc_key_size() argument
720 struct l2cap_chan *chan = conn->smp; in check_enc_key_size()
732 static void smp_chan_destroy(struct l2cap_conn *conn) in smp_chan_destroy() argument
734 struct l2cap_chan *chan = conn->smp; in smp_chan_destroy()
736 struct hci_conn *hcon = conn->hcon; in smp_chan_destroy()
786 static void smp_failure(struct l2cap_conn *conn, u8 reason) in smp_failure() argument
788 struct hci_conn *hcon = conn->hcon; in smp_failure()
789 struct l2cap_chan *chan = conn->smp; in smp_failure()
792 smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason), in smp_failure()
799 smp_chan_destroy(conn); in smp_failure()
841 static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, in tk_request() argument
844 struct hci_conn *hcon = conn->hcon; in tk_request()
845 struct l2cap_chan *chan = conn->smp; in tk_request()
933 struct l2cap_conn *conn = smp->conn; in smp_confirm() local
937 BT_DBG("conn %p", conn); in smp_confirm()
940 conn->hcon->init_addr_type, &conn->hcon->init_addr, in smp_confirm()
941 conn->hcon->resp_addr_type, &conn->hcon->resp_addr, in smp_confirm()
948 smp_send_cmd(smp->conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp); in smp_confirm()
950 if (conn->hcon->out) in smp_confirm()
960 struct l2cap_conn *conn = smp->conn; in smp_random() local
961 struct hci_conn *hcon = conn->hcon; in smp_random()
968 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); in smp_random()
1002 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_random()
1026 static void smp_notify_keys(struct l2cap_conn *conn) in smp_notify_keys() argument
1028 struct l2cap_chan *chan = conn->smp; in smp_notify_keys()
1030 struct hci_conn *hcon = conn->hcon; in smp_notify_keys()
1045 queue_work(hdev->workqueue, &conn->id_addr_update_work); in smp_notify_keys()
1115 key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst, in smp_notify_keys()
1134 struct hci_conn *hcon = smp->conn->hcon; in sc_add_ltk()
1201 struct hci_conn *hcon = smp->conn->hcon; in sc_generate_ltk()
1226 struct l2cap_conn *conn = smp->conn; in smp_distribute_keys() local
1227 struct hci_conn *hcon = conn->hcon; in smp_distribute_keys()
1231 BT_DBG("conn %p", conn); in smp_distribute_keys()
1275 smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc); in smp_distribute_keys()
1286 smp_send_cmd(conn, SMP_CMD_MASTER_IDENT, sizeof(ident), &ident); in smp_distribute_keys()
1297 smp_send_cmd(conn, SMP_CMD_IDENT_INFO, sizeof(idinfo), &idinfo); in smp_distribute_keys()
1308 smp_send_cmd(conn, SMP_CMD_IDENT_ADDR_INFO, sizeof(addrinfo), in smp_distribute_keys()
1331 smp_send_cmd(conn, SMP_CMD_SIGN_INFO, sizeof(sign), &sign); in smp_distribute_keys()
1343 smp_notify_keys(conn); in smp_distribute_keys()
1345 smp_chan_destroy(conn); in smp_distribute_keys()
1352 struct l2cap_conn *conn = smp->conn; in smp_timeout() local
1354 BT_DBG("conn %p", conn); in smp_timeout()
1356 hci_disconnect(conn->hcon, HCI_ERROR_REMOTE_USER_TERM); in smp_timeout()
1359 static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) in smp_chan_create() argument
1361 struct l2cap_chan *chan = conn->smp; in smp_chan_create()
1383 smp->conn = conn; in smp_chan_create()
1390 hci_conn_hold(conn->hcon); in smp_chan_create()
1397 struct hci_conn *hcon = smp->conn->hcon; in sc_mackey_and_ltk()
1418 struct hci_conn *hcon = smp->conn->hcon; in sc_dhkey_check()
1449 smp_send_cmd(smp->conn, SMP_CMD_DHKEY_CHECK, sizeof(check), &check); in sc_dhkey_check()
1454 struct l2cap_conn *conn = smp->conn; in sc_passkey_send_confirm() local
1455 struct hci_conn *hcon = conn->hcon; in sc_passkey_send_confirm()
1468 smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cfm), &cfm); in sc_passkey_send_confirm()
1475 struct l2cap_conn *conn = smp->conn; in sc_passkey_round() local
1476 struct hci_conn *hcon = conn->hcon; in sc_passkey_round()
1508 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, in sc_passkey_round()
1536 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, in sc_passkey_round()
1562 struct l2cap_conn *conn = smp->conn; in sc_user_reply() local
1563 struct hci_conn *hcon = conn->hcon; in sc_user_reply()
1570 smp_failure(smp->conn, SMP_PASSKEY_ENTRY_FAILED); in sc_user_reply()
1573 smp_failure(smp->conn, SMP_NUMERIC_COMP_FAILED); in sc_user_reply()
1604 struct l2cap_conn *conn = hcon->l2cap_data; in smp_user_confirm_reply() local
1612 if (!conn) in smp_user_confirm_reply()
1615 chan = conn->smp; in smp_user_confirm_reply()
1644 smp_failure(conn, SMP_PASSKEY_ENTRY_FAILED); in smp_user_confirm_reply()
1648 smp_failure(conn, SMP_PASSKEY_ENTRY_FAILED); in smp_user_confirm_reply()
1659 smp_failure(conn, rsp); in smp_user_confirm_reply()
1671 struct l2cap_conn *conn = smp->conn; in build_bredr_pairing_cmd() local
1672 struct hci_dev *hdev = conn->hcon->hdev; in build_bredr_pairing_cmd()
1707 static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_pairing_req() argument
1710 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_req()
1711 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_req()
1716 BT_DBG("conn %p", conn); in smp_cmd_pairing_req()
1721 if (conn->hcon->role != HCI_ROLE_SLAVE) in smp_cmd_pairing_req()
1725 smp = smp_chan_create(conn); in smp_cmd_pairing_req()
1754 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_req()
1756 if (!test_bit(HCI_CONN_AES_CCM, &conn->hcon->flags) && in smp_cmd_pairing_req()
1765 if (check_enc_key_size(conn, key_size)) in smp_cmd_pairing_req()
1773 smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(rsp), &rsp); in smp_cmd_pairing_req()
1779 build_pairing_cmd(conn, req, &rsp, auth); in smp_cmd_pairing_req()
1784 if (conn->hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_pairing_req()
1789 if (sec_level > conn->hcon->pending_sec_level) in smp_cmd_pairing_req()
1790 conn->hcon->pending_sec_level = sec_level; in smp_cmd_pairing_req()
1793 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_req()
1796 method = get_auth_method(smp, conn->hcon->io_capability, in smp_cmd_pairing_req()
1803 if (check_enc_key_size(conn, key_size)) in smp_cmd_pairing_req()
1811 smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(rsp), &rsp); in smp_cmd_pairing_req()
1831 ret = tk_request(conn, 0, auth, rsp.io_capability, req->io_capability); in smp_cmd_pairing_req()
1840 struct hci_dev *hdev = smp->conn->hcon->hdev; in sc_send_public_key()
1887 smp_send_cmd(smp->conn, SMP_CMD_PUBLIC_KEY, 64, smp->local_pk); in sc_send_public_key()
1892 static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_pairing_rsp() argument
1895 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_rsp()
1897 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_rsp()
1901 BT_DBG("conn %p", conn); in smp_cmd_pairing_rsp()
1906 if (conn->hcon->role != HCI_ROLE_MASTER) in smp_cmd_pairing_rsp()
1914 if (check_enc_key_size(conn, key_size)) in smp_cmd_pairing_rsp()
1938 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_rsp()
1947 else if (conn->hcon->pending_sec_level > BT_SECURITY_HIGH) in smp_cmd_pairing_rsp()
1948 conn->hcon->pending_sec_level = BT_SECURITY_HIGH; in smp_cmd_pairing_rsp()
1951 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_rsp()
1976 ret = tk_request(conn, 0, auth, req->io_capability, rsp->io_capability); in smp_cmd_pairing_rsp()
1991 struct l2cap_conn *conn = smp->conn; in sc_check_confirm() local
1998 if (conn->hcon->out) { in sc_check_confirm()
1999 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in sc_check_confirm()
2013 struct l2cap_conn *conn = smp->conn; in fixup_sc_false_positive() local
2014 struct hci_conn *hcon = conn->hcon; in fixup_sc_false_positive()
2038 if (tk_request(conn, 0, auth, rsp->io_capability, req->io_capability)) { in fixup_sc_false_positive()
2048 static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_pairing_confirm() argument
2050 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_confirm()
2053 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); in smp_cmd_pairing_confirm()
2075 if (conn->hcon->out) { in smp_cmd_pairing_confirm()
2076 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_cmd_pairing_confirm()
2090 static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_pairing_random() argument
2092 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_random()
2094 struct hci_conn *hcon = conn->hcon; in smp_cmd_pairing_random()
2099 BT_DBG("conn %p", conn); in smp_cmd_pairing_random()
2124 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, in smp_cmd_pairing_random()
2145 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_cmd_pairing_random()
2178 static bool smp_ltk_encrypt(struct l2cap_conn *conn, u8 sec_level) in smp_ltk_encrypt() argument
2181 struct hci_conn *hcon = conn->hcon; in smp_ltk_encrypt()
2225 static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_security_req() argument
2229 struct hci_conn *hcon = conn->hcon; in smp_cmd_security_req()
2234 BT_DBG("conn %p", conn); in smp_cmd_security_req()
2258 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_cmd_security_req()
2261 smp = smp_chan_create(conn); in smp_cmd_security_req()
2272 build_pairing_cmd(conn, &cp, NULL, auth); in smp_cmd_security_req()
2277 smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); in smp_cmd_security_req()
2285 struct l2cap_conn *conn = hcon->l2cap_data; in smp_conn_security() local
2291 BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level); in smp_conn_security()
2294 if (!conn) in smp_conn_security()
2307 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_conn_security()
2310 chan = conn->smp; in smp_conn_security()
2324 smp = smp_chan_create(conn); in smp_conn_security()
2345 build_pairing_cmd(conn, &cp, NULL, authreq); in smp_conn_security()
2349 smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); in smp_conn_security()
2354 smp_send_cmd(conn, SMP_CMD_SECURITY_REQ, sizeof(cp), &cp); in smp_conn_security()
2366 static int smp_cmd_encrypt_info(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_encrypt_info() argument
2369 struct l2cap_chan *chan = conn->smp; in smp_cmd_encrypt_info()
2372 BT_DBG("conn %p", conn); in smp_cmd_encrypt_info()
2386 static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_master_ident() argument
2389 struct l2cap_chan *chan = conn->smp; in smp_cmd_master_ident()
2391 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_master_ident()
2392 struct hci_conn *hcon = conn->hcon; in smp_cmd_master_ident()
2396 BT_DBG("conn %p", conn); in smp_cmd_master_ident()
2422 static int smp_cmd_ident_info(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_ident_info() argument
2425 struct l2cap_chan *chan = conn->smp; in smp_cmd_ident_info()
2442 static int smp_cmd_ident_addr_info(struct l2cap_conn *conn, in smp_cmd_ident_addr_info() argument
2446 struct l2cap_chan *chan = conn->smp; in smp_cmd_ident_addr_info()
2448 struct hci_conn *hcon = conn->hcon; in smp_cmd_ident_addr_info()
2488 smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, in smp_cmd_ident_addr_info()
2498 static int smp_cmd_sign_info(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_sign_info() argument
2501 struct l2cap_chan *chan = conn->smp; in smp_cmd_sign_info()
2505 BT_DBG("conn %p", conn); in smp_cmd_sign_info()
2517 if (conn->hcon->sec_level > BT_SECURITY_MEDIUM) in smp_cmd_sign_info()
2531 struct l2cap_conn *conn = smp->conn; in sc_select_method() local
2532 struct hci_conn *hcon = conn->hcon; in sc_select_method()
2574 static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_public_key() argument
2577 struct hci_conn *hcon = conn->hcon; in smp_cmd_public_key()
2578 struct l2cap_chan *chan = conn->smp; in smp_cmd_public_key()
2584 BT_DBG("conn %p", conn); in smp_cmd_public_key()
2650 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, in smp_cmd_public_key()
2673 if (conn->hcon->out) in smp_cmd_public_key()
2681 smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cfm), &cfm); in smp_cmd_public_key()
2687 static int smp_cmd_dhkey_check(struct l2cap_conn *conn, struct sk_buff *skb) in smp_cmd_dhkey_check() argument
2690 struct l2cap_chan *chan = conn->smp; in smp_cmd_dhkey_check()
2691 struct hci_conn *hcon = conn->hcon; in smp_cmd_dhkey_check()
2697 BT_DBG("conn %p", conn); in smp_cmd_dhkey_check()
2752 static int smp_cmd_keypress_notify(struct l2cap_conn *conn, in smp_cmd_keypress_notify() argument
2764 struct l2cap_conn *conn = chan->conn; in smp_sig_channel() local
2765 struct hci_conn *hcon = conn->hcon; in smp_sig_channel()
2797 reason = smp_cmd_pairing_req(conn, skb); in smp_sig_channel()
2801 smp_failure(conn, 0); in smp_sig_channel()
2806 reason = smp_cmd_pairing_rsp(conn, skb); in smp_sig_channel()
2810 reason = smp_cmd_security_req(conn, skb); in smp_sig_channel()
2814 reason = smp_cmd_pairing_confirm(conn, skb); in smp_sig_channel()
2818 reason = smp_cmd_pairing_random(conn, skb); in smp_sig_channel()
2822 reason = smp_cmd_encrypt_info(conn, skb); in smp_sig_channel()
2826 reason = smp_cmd_master_ident(conn, skb); in smp_sig_channel()
2830 reason = smp_cmd_ident_info(conn, skb); in smp_sig_channel()
2834 reason = smp_cmd_ident_addr_info(conn, skb); in smp_sig_channel()
2838 reason = smp_cmd_sign_info(conn, skb); in smp_sig_channel()
2842 reason = smp_cmd_public_key(conn, skb); in smp_sig_channel()
2846 reason = smp_cmd_dhkey_check(conn, skb); in smp_sig_channel()
2850 reason = smp_cmd_keypress_notify(conn, skb); in smp_sig_channel()
2862 smp_failure(conn, reason); in smp_sig_channel()
2877 struct l2cap_conn *conn = chan->conn; in smp_teardown_cb() local
2882 smp_chan_destroy(conn); in smp_teardown_cb()
2884 conn->smp = NULL; in smp_teardown_cb()
2890 struct l2cap_conn *conn = chan->conn; in bredr_pairing() local
2891 struct hci_conn *hcon = conn->hcon; in bredr_pairing()
2928 if (!(conn->remote_fixed_chan & L2CAP_FC_SMP_BREDR)) in bredr_pairing()
2935 smp = smp_chan_create(conn); in bredr_pairing()
2952 smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(req), &req); in bredr_pairing()
2959 struct l2cap_conn *conn = chan->conn; in smp_resume_cb() local
2960 struct hci_conn *hcon = conn->hcon; in smp_resume_cb()
2982 struct l2cap_conn *conn = chan->conn; in smp_ready_cb() local
2983 struct hci_conn *hcon = conn->hcon; in smp_ready_cb()
2987 conn->smp = chan; in smp_ready_cb()
3007 hci_disconnect(chan->conn->hcon, HCI_ERROR_AUTH_FAILURE); in smp_recv_cb()