diff options
Diffstat (limited to 'net/bluetooth/hci_event.c')
-rw-r--r-- | net/bluetooth/hci_event.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index e3d7151e808e..3ae8ae1a029c 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1641,6 +1641,47 @@ static void hci_cs_accept_phylink(struct hci_dev *hdev, u8 status) | |||
1641 | amp_write_remote_assoc(hdev, cp->phy_handle); | 1641 | amp_write_remote_assoc(hdev, cp->phy_handle); |
1642 | } | 1642 | } |
1643 | 1643 | ||
1644 | static void hci_cs_le_create_conn(struct hci_dev *hdev, u8 status) | ||
1645 | { | ||
1646 | struct hci_cp_le_create_conn *cp; | ||
1647 | struct hci_conn *conn; | ||
1648 | |||
1649 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | ||
1650 | |||
1651 | /* All connection failure handling is taken care of by the | ||
1652 | * hci_le_conn_failed function which is triggered by the HCI | ||
1653 | * request completion callbacks used for connecting. | ||
1654 | */ | ||
1655 | if (status) | ||
1656 | return; | ||
1657 | |||
1658 | cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CONN); | ||
1659 | if (!cp) | ||
1660 | return; | ||
1661 | |||
1662 | hci_dev_lock(hdev); | ||
1663 | |||
1664 | conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->peer_addr); | ||
1665 | if (!conn) | ||
1666 | goto unlock; | ||
1667 | |||
1668 | /* Store the initiator and responder address information which | ||
1669 | * is needed for SMP. These values will not change during the | ||
1670 | * lifetime of the connection. | ||
1671 | */ | ||
1672 | conn->init_addr_type = cp->own_address_type; | ||
1673 | if (cp->own_address_type == ADDR_LE_DEV_RANDOM) | ||
1674 | bacpy(&conn->init_addr, &hdev->random_addr); | ||
1675 | else | ||
1676 | bacpy(&conn->init_addr, &hdev->bdaddr); | ||
1677 | |||
1678 | conn->resp_addr_type = cp->peer_addr_type; | ||
1679 | bacpy(&conn->resp_addr, &cp->peer_addr); | ||
1680 | |||
1681 | unlock: | ||
1682 | hci_dev_unlock(hdev); | ||
1683 | } | ||
1684 | |||
1644 | static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | 1685 | static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) |
1645 | { | 1686 | { |
1646 | __u8 status = *((__u8 *) skb->data); | 1687 | __u8 status = *((__u8 *) skb->data); |
@@ -2532,6 +2573,10 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2532 | hci_cs_accept_phylink(hdev, ev->status); | 2573 | hci_cs_accept_phylink(hdev, ev->status); |
2533 | break; | 2574 | break; |
2534 | 2575 | ||
2576 | case HCI_OP_LE_CREATE_CONN: | ||
2577 | hci_cs_le_create_conn(hdev, ev->status); | ||
2578 | break; | ||
2579 | |||
2535 | default: | 2580 | default: |
2536 | BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); | 2581 | BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); |
2537 | break; | 2582 | break; |
@@ -3716,6 +3761,39 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
3716 | conn->out = true; | 3761 | conn->out = true; |
3717 | conn->link_mode |= HCI_LM_MASTER; | 3762 | conn->link_mode |= HCI_LM_MASTER; |
3718 | } | 3763 | } |
3764 | |||
3765 | /* If we didn't have a hci_conn object previously | ||
3766 | * but we're in master role this must be something | ||
3767 | * initiated using a white list. Since white list based | ||
3768 | * connections are not "first class citizens" we don't | ||
3769 | * have full tracking of them. Therefore, we go ahead | ||
3770 | * with a "best effort" approach of determining the | ||
3771 | * initiator address based on the HCI_PRIVACY flag. | ||
3772 | */ | ||
3773 | if (conn->out) { | ||
3774 | conn->resp_addr_type = ev->bdaddr_type; | ||
3775 | bacpy(&conn->resp_addr, &ev->bdaddr); | ||
3776 | if (test_bit(HCI_PRIVACY, &hdev->dev_flags)) { | ||
3777 | conn->init_addr_type = ADDR_LE_DEV_RANDOM; | ||
3778 | bacpy(&conn->init_addr, &hdev->rpa); | ||
3779 | } else { | ||
3780 | hci_copy_identity_address(hdev, | ||
3781 | &conn->init_addr, | ||
3782 | &conn->init_addr_type); | ||
3783 | } | ||
3784 | } else { | ||
3785 | /* Set the responder (our side) address type based on | ||
3786 | * the advertising address type. | ||
3787 | */ | ||
3788 | conn->resp_addr_type = hdev->adv_addr_type; | ||
3789 | if (hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) | ||
3790 | bacpy(&conn->resp_addr, &hdev->random_addr); | ||
3791 | else | ||
3792 | bacpy(&conn->resp_addr, &hdev->bdaddr); | ||
3793 | |||
3794 | conn->init_addr_type = ev->bdaddr_type; | ||
3795 | bacpy(&conn->init_addr, &ev->bdaddr); | ||
3796 | } | ||
3719 | } | 3797 | } |
3720 | 3798 | ||
3721 | /* Ensure that the hci_conn contains the identity address type | 3799 | /* Ensure that the hci_conn contains the identity address type |