Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 291019
b: refs/heads/master
c: 47990ea
h: refs/heads/master
i:
  291017: 83938de
  291015: 90c83ae
v: v3
  • Loading branch information
Johan Hedberg committed Feb 23, 2012
1 parent da9e73f commit 648b661
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2e0052e4cf78e3e205e92d82ee572ed726e315d6
refs/heads/master: 47990ea09d393da8fb6cf284f4dba704c3661973
1 change: 1 addition & 0 deletions trunk/include/net/bluetooth/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ enum {
HCI_HS_ENABLED,
HCI_CONNECTABLE,
HCI_DISCOVERABLE,
HCI_LINK_SECURITY,
};

/* HCI ioctl defines */
Expand Down
6 changes: 6 additions & 0 deletions trunk/net/bluetooth/hci_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,12 @@ static void hci_setup(struct hci_dev *hdev)
sizeof(cp), &cp);
}

if (test_bit(HCI_LINK_SECURITY, &hdev->dev_flags)) {
u8 enable = 1;
hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE,
sizeof(enable), &enable);
}

if (hdev->features[4] & LMP_LE)
hci_set_le_support(hdev);
}
Expand Down
33 changes: 28 additions & 5 deletions trunk/net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ static u32 get_current_settings(struct hci_dev *hdev)
if (hdev->host_features[0] & LMP_HOST_LE)
settings |= MGMT_SETTING_LE;

if (test_bit(HCI_AUTH, &hdev->flags))
if (test_bit(HCI_LINK_SECURITY, &hdev->dev_flags))
settings |= MGMT_SETTING_LINK_SECURITY;

if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags))
Expand Down Expand Up @@ -1067,8 +1067,21 @@ static int set_link_security(struct sock *sk, u16 index, void *data, u16 len)
hci_dev_lock(hdev);

if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, index, MGMT_OP_SET_LINK_SECURITY,
MGMT_STATUS_NOT_POWERED);
bool changed = false;

if (!!cp->val != test_bit(HCI_LINK_SECURITY,
&hdev->dev_flags)) {
change_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
changed = true;
}

err = send_settings_rsp(sk, MGMT_OP_SET_LINK_SECURITY, hdev);
if (err < 0)
goto failed;

if (changed)
err = new_settings(hdev, sk);

goto failed;
}

Expand Down Expand Up @@ -3338,7 +3351,8 @@ int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status)
{
struct cmd_lookup match = { NULL, hdev };
int err;
bool changed = false;
int err = 0;

if (status) {
u8 mgmt_err = mgmt_status(status);
Expand All @@ -3347,10 +3361,19 @@ int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status)
return 0;
}

if (test_bit(HCI_AUTH, &hdev->flags)) {
if (!test_and_set_bit(HCI_LINK_SECURITY, &hdev->dev_flags))
changed = true;
} else {
if (test_and_clear_bit(HCI_LINK_SECURITY, &hdev->dev_flags))
changed = true;
}

mgmt_pending_foreach(MGMT_OP_SET_LINK_SECURITY, hdev, settings_rsp,
&match);

err = new_settings(hdev, match.sk);
if (changed)
err = new_settings(hdev, match.sk);

if (match.sk)
sock_put(match.sk);
Expand Down

0 comments on commit 648b661

Please sign in to comment.