Lines Matching defs:hdev
40 #define SMP_DEV(hdev) \
41 ((struct smp_dev *)((struct l2cap_chan *)((hdev)->smp_data))->data)
497 bool smp_irk_matches(struct hci_dev *hdev, const u8 irk[16],
500 struct l2cap_chan *chan = hdev->smp_data;
507 bt_dev_dbg(hdev, "RPA %pMR IRK %*phN", bdaddr, 16, irk);
516 int smp_generate_rpa(struct hci_dev *hdev, const u8 irk[16], bdaddr_t *rpa)
518 struct l2cap_chan *chan = hdev->smp_data;
533 bt_dev_dbg(hdev, "RPA %pMR", rpa);
538 int smp_generate_oob(struct hci_dev *hdev, u8 hash[16], u8 rand[16])
540 struct l2cap_chan *chan = hdev->smp_data;
549 if (hci_dev_test_flag(hdev, HCI_USE_DEBUG_KEYS)) {
550 bt_dev_dbg(hdev, "Using debug keys");
599 bt_dev_dbg(conn->hcon->hdev, "code 0x%2.2x", code);
654 struct hci_dev *hdev = hcon->hdev;
657 if (hci_dev_test_flag(hdev, HCI_BONDABLE)) {
665 if (hci_dev_test_flag(hdev, HCI_RPA_RESOLVING))
668 if (hci_dev_test_flag(hdev, HCI_PRIVACY))
671 if (hci_dev_test_flag(hdev, HCI_SC_ENABLED) &&
676 if (hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) {
686 oob_data = hci_find_remote_oob_data(hdev, &hcon->dst,
704 req->max_key_size = hdev->le_max_key_size;
707 req->auth_req = (authreq & AUTH_REQ_MASK(hdev));
715 rsp->max_key_size = hdev->le_max_key_size;
718 rsp->auth_req = (authreq & AUTH_REQ_MASK(hdev));
726 struct hci_dev *hdev = conn->hcon->hdev;
733 if (max_key_size > hdev->le_max_key_size ||
767 !hci_dev_test_flag(hcon->hdev, HCI_KEEP_DEBUG_KEYS)) {
863 bt_dev_dbg(hcon->hdev, "auth:%d lcl:%d rem:%d", auth, local_io,
890 ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
929 bt_dev_dbg(hcon->hdev, "PassKey: %d", passkey);
934 ret = mgmt_user_passkey_request(hcon->hdev, &hcon->dst,
937 ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
941 ret = mgmt_user_passkey_notify(hcon->hdev, &hcon->dst,
954 bt_dev_dbg(conn->hcon->hdev, "conn %p", conn);
982 bt_dev_dbg(conn->hcon->hdev, "conn %p %s", conn,
992 bt_dev_err(hcon->hdev, "pairing failed "
1029 hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type,
1041 struct hci_dev *hdev = hcon->hdev;
1063 mgmt_new_irk(hdev, smp->remote_irk, persistent);
1072 queue_work(hdev->workqueue, &conn->id_addr_update_work);
1080 mgmt_new_csrk(hdev, smp->csrk, persistent);
1087 mgmt_new_csrk(hdev, smp->responder_csrk, persistent);
1094 mgmt_new_ltk(hdev, smp->ltk, persistent);
1101 mgmt_new_ltk(hdev, smp->responder_ltk, persistent);
1115 key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst,
1120 mgmt_new_link_key(hdev, key, persistent);
1125 if (!hci_dev_test_flag(hdev, HCI_KEEP_DEBUG_KEYS) &&
1149 smp->ltk = hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type,
1209 struct hci_dev *hdev = hcon->hdev;
1212 key = hci_find_link_key(hdev, &hcon->dst);
1214 bt_dev_err(hdev, "no Link Key found to generate LTK");
1246 struct hci_dev *hdev = hcon->hdev;
1249 bt_dev_dbg(hdev, "conn %p", conn);
1279 bt_dev_dbg(hdev, "keydist 0x%x", *keydist);
1303 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type,
1321 memcpy(idinfo.irk, hdev->irk, sizeof(idinfo.irk));
1380 bt_dev_dbg(conn->hcon->hdev, "conn %p", conn);
1397 bt_dev_err(hcon->hdev, "Unable to create CMAC crypto context");
1403 bt_dev_err(hcon->hdev, "Unable to create ECDH crypto context");
1507 struct hci_dev *hdev = hcon->hdev;
1579 bt_dev_dbg(hdev, "Starting passkey round %u",
1640 bt_dev_dbg(conn->hcon->hdev, "");
1666 bt_dev_dbg(conn->hcon->hdev, "PassKey: %d", value);
1702 struct hci_dev *hdev = conn->hcon->hdev;
1705 if (hci_dev_test_flag(hdev, HCI_BONDABLE)) {
1710 if (hci_dev_test_flag(hdev, HCI_RPA_RESOLVING))
1713 if (hci_dev_test_flag(hdev, HCI_PRIVACY))
1743 struct hci_dev *hdev = conn->hcon->hdev;
1748 bt_dev_dbg(hdev, "conn %p", conn);
1765 auth = req->auth_req & AUTH_REQ_MASK(hdev);
1767 if (!hci_dev_test_flag(hdev, HCI_BONDABLE) &&
1771 if (hci_dev_test_flag(hdev, HCI_SC_ONLY) && !(auth & SMP_AUTH_SC))
1782 if (req->oob_flag == SMP_OOB_PRESENT && SMP_DEV(hdev)->local_oob)
1789 !hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP))
1879 struct hci_dev *hdev = smp->conn->hcon->hdev;
1881 bt_dev_dbg(hdev, "");
1884 struct l2cap_chan *chan = hdev->smp_data;
1901 if (hci_dev_test_flag(hdev, HCI_USE_DEBUG_KEYS)) {
1902 bt_dev_dbg(hdev, "Using debug keys");
1935 struct hci_dev *hdev = conn->hcon->hdev;
1939 bt_dev_dbg(hdev, "conn %p", conn);
1955 auth = rsp->auth_req & AUTH_REQ_MASK(hdev);
1957 if (hci_dev_test_flag(hdev, HCI_SC_ONLY) && !(auth & SMP_AUTH_SC))
1964 if (rsp->oob_flag == SMP_OOB_PRESENT && SMP_DEV(hdev)->local_oob)
2034 bt_dev_dbg(conn->hcon->hdev, "");
2056 struct hci_dev *hdev = hcon->hdev;
2064 if (hci_dev_test_flag(hdev, HCI_SC_ONLY)) {
2065 bt_dev_err(hdev, "refusing legacy fallback in SC-only mode");
2069 bt_dev_err(hdev, "trying to fall back to legacy SMP");
2077 auth = req->auth_req & AUTH_REQ_MASK(hdev);
2080 bt_dev_err(hdev, "failed to fall back to legacy SMP");
2094 struct hci_dev *hdev = hcon->hdev;
2096 bt_dev_dbg(hdev, "conn %p %s", conn,
2112 bt_dev_err(hdev, "Unexpected SMP Pairing Confirm");
2143 bt_dev_dbg(hcon->hdev, "conn %p", conn);
2201 if (hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type,
2236 err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, hcon->type,
2251 key = hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role);
2284 hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role))
2298 struct hci_dev *hdev = hcon->hdev;
2302 bt_dev_dbg(hdev, "conn %p", conn);
2310 auth = rp->auth_req & AUTH_REQ_MASK(hdev);
2312 if (hci_dev_test_flag(hdev, HCI_SC_ONLY) && !(auth & SMP_AUTH_SC))
2339 if (!hci_dev_test_flag(hdev, HCI_BONDABLE) &&
2365 bt_dev_dbg(hcon->hdev, "conn %p hcon %p level 0x%2.2x", conn, hcon,
2372 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED))
2387 bt_dev_err(hcon->hdev, "security requested but not available");
2407 if (hci_dev_test_flag(hcon->hdev, HCI_SC_ENABLED)) {
2409 if (hci_dev_test_flag(hcon->hdev, HCI_SSP_ENABLED))
2416 if (!hci_dev_test_flag(hcon->hdev, HCI_FORCE_NO_MITM)) {
2449 int smp_cancel_and_remove_pairing(struct hci_dev *hdev, bdaddr_t *bdaddr,
2458 err = hci_remove_ltk(hdev, bdaddr, addr_type);
2459 hci_remove_irk(hdev, bdaddr, addr_type);
2461 hcon = hci_conn_hash_lookup_le(hdev, bdaddr, addr_type);
2502 bt_dev_dbg(conn->hcon->hdev, "conn %p", conn);
2508 if (hci_is_blocked_key(conn->hcon->hdev, HCI_BLOCKED_KEY_TYPE_LTK,
2510 bt_dev_warn_ratelimited(conn->hcon->hdev,
2530 struct hci_dev *hdev = conn->hcon->hdev;
2535 bt_dev_dbg(hdev, "conn %p", conn);
2551 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, SMP_LTK,
2567 bt_dev_dbg(conn->hcon->hdev, "");
2573 if (hci_is_blocked_key(conn->hcon->hdev, HCI_BLOCKED_KEY_TYPE_IRK,
2575 bt_dev_warn_ratelimited(conn->hcon->hdev,
2599 bt_dev_dbg(hcon->hdev, "");
2624 bt_dev_err(hcon->hdev, "ignoring IRK with no identity address");
2636 bt_dev_err(hcon->hdev,
2649 smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr,
2666 bt_dev_dbg(conn->hcon->hdev, "conn %p", conn);
2741 struct hci_dev *hdev = hcon->hdev;
2746 bt_dev_dbg(hdev, "conn %p", conn);
2756 bt_dev_err(hdev, "Remote and local public keys are identical");
2788 struct l2cap_chan *hchan = hdev->smp_data;
2810 bt_dev_dbg(hdev, "selected method 0x%02x", smp->method);
2827 if (mgmt_user_passkey_notify(hdev, &hcon->dst, hcon->type,
2850 if (mgmt_user_passkey_request(hdev, &hcon->dst, hcon->type,
2885 bt_dev_dbg(hcon->hdev, "conn %p", conn);
2945 bt_dev_dbg(conn->hcon->hdev, "value 0x%02x", kp->value);
2961 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) {
3042 bt_dev_dbg(hcon->hdev, "Unknown command code 0x%2.2x", code);
3057 bt_dev_err(hcon->hdev, "unexpected SMP command 0x%02x from %pMR",
3067 bt_dev_dbg(conn->hcon->hdev, "chan %p", chan);
3080 struct hci_dev *hdev = hcon->hdev;
3084 bt_dev_dbg(hdev, "chan %p", chan);
3099 if (!hci_dev_test_flag(hdev, HCI_SC_ENABLED))
3104 !hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP))
3108 if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED))
3125 bt_dev_err(hdev, "unable to create SMP context for BR/EDR");
3131 bt_dev_dbg(hdev, "starting SMP over BR/EDR");
3149 bt_dev_dbg(hcon->hdev, "chan %p", chan);
3172 bt_dev_dbg(hcon->hdev, "chan %p", chan);
3190 bt_dev_dbg(chan->conn->hcon->hdev, "chan %p", chan);
3286 static struct l2cap_chan *smp_add_cid(struct hci_dev *hdev, u16 cid)
3304 bt_dev_err(hdev, "Unable to create CMAC crypto context");
3311 bt_dev_err(hdev, "Unable to create ECDH crypto context");
3341 hci_copy_identity_address(hdev, &chan->src, &bdaddr_type);
3348 bacpy(&chan->src, &hdev->bdaddr);
3384 struct hci_dev *hdev = file->private_data;
3387 buf[0] = hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP) ? 'Y': 'N';
3397 struct hci_dev *hdev = file->private_data;
3405 if (enable == hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP))
3411 chan = smp_add_cid(hdev, L2CAP_CID_SMP_BREDR);
3415 hdev->smp_bredr_data = chan;
3419 chan = hdev->smp_bredr_data;
3420 hdev->smp_bredr_data = NULL;
3424 hci_dev_change_flag(hdev, HCI_FORCE_BREDR_SMP);
3436 int smp_register(struct hci_dev *hdev)
3440 bt_dev_dbg(hdev, "");
3445 if (!lmp_le_capable(hdev))
3448 if (WARN_ON(hdev->smp_data)) {
3449 chan = hdev->smp_data;
3450 hdev->smp_data = NULL;
3454 chan = smp_add_cid(hdev, L2CAP_CID_SMP);
3458 hdev->smp_data = chan;
3467 if (!lmp_sc_capable(hdev)) {
3468 debugfs_create_file("force_bredr_smp", 0644, hdev->debugfs,
3469 hdev, &force_bredr_smp_fops);
3472 if (!hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP))
3476 if (WARN_ON(hdev->smp_bredr_data)) {
3477 chan = hdev->smp_bredr_data;
3478 hdev->smp_bredr_data = NULL;
3482 chan = smp_add_cid(hdev, L2CAP_CID_SMP_BREDR);
3485 chan = hdev->smp_data;
3486 hdev->smp_data = NULL;
3491 hdev->smp_bredr_data = chan;
3496 void smp_unregister(struct hci_dev *hdev)
3500 if (hdev->smp_bredr_data) {
3501 chan = hdev->smp_bredr_data;
3502 hdev->smp_bredr_data = NULL;
3506 if (hdev->smp_data) {
3507 chan = hdev->smp_data;
3508 hdev->smp_data = NULL;