Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 290961
b: refs/heads/master
c: ed2c4ee
h: refs/heads/master
i:
  290959: a7477f2
v: v3
  • Loading branch information
Johan Hedberg committed Feb 17, 2012
1 parent b32388a commit de50d0f
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 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: 33ef95ed30283eb17c686a815caf1d33e966fe4a
refs/heads/master: ed2c4ee360709ca838efa0ea4d6295590aff3d24
1 change: 1 addition & 0 deletions trunk/include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@ int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type, u8 status);
int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status);
int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 status);
int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status);
int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
u8 *randomizer, u8 status);
Expand Down
6 changes: 5 additions & 1 deletion trunk/net/bluetooth/hci_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
BT_DBG("%s status 0x%x", hdev->name, status);

if (status)
return;
goto done;

sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_MODE);
if (!sent)
Expand All @@ -457,6 +457,10 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
set_bit(HCI_SSP_ENABLED, &hdev->dev_flags);
else
clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags);

done:
if (test_bit(HCI_MGMT, &hdev->dev_flags))
mgmt_ssp_enable_complete(hdev, status);
}

static u8 hci_get_inquiry_mode(struct hci_dev *hdev)
Expand Down
85 changes: 85 additions & 0 deletions trunk/net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,64 @@ static int set_link_security(struct sock *sk, u16 index, void *data, u16 len)
return err;
}

static int set_ssp(struct sock *sk, u16 index, void *data, u16 len)
{
struct mgmt_mode *cp = data;
struct pending_cmd *cmd;
struct hci_dev *hdev;
uint8_t val;
int err;

BT_DBG("request for hci%u", index);

if (len != sizeof(*cp))
return cmd_status(sk, index, MGMT_OP_SET_SSP,
MGMT_STATUS_INVALID_PARAMS);

hdev = hci_dev_get(index);
if (!hdev)
return cmd_status(sk, index, MGMT_OP_SET_SSP,
MGMT_STATUS_INVALID_PARAMS);

hci_dev_lock(hdev);

if (!test_bit(HCI_UP, &hdev->flags)) {
err = cmd_status(sk, index, MGMT_OP_SET_SSP,
MGMT_STATUS_NOT_POWERED);
goto failed;
}

if (mgmt_pending_find(MGMT_OP_SET_SSP, hdev)) {
err = cmd_status(sk, index, MGMT_OP_SET_SSP, MGMT_STATUS_BUSY);
goto failed;
}

val = !!cp->val;

if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) == val) {
err = send_settings_rsp(sk, MGMT_OP_SET_SSP, hdev);
goto failed;
}

cmd = mgmt_pending_add(sk, MGMT_OP_SET_SSP, hdev, data, len);
if (!cmd) {
err = -ENOMEM;
goto failed;
}

err = hci_send_cmd(hdev, HCI_OP_WRITE_SSP_MODE, sizeof(val), &val);
if (err < 0) {
mgmt_pending_remove(cmd);
goto failed;
}

failed:
hci_dev_unlock(hdev);
hci_dev_put(hdev);

return err;
}

static int add_uuid(struct sock *sk, u16 index, void *data, u16 len)
{
struct mgmt_cp_add_uuid *cp = data;
Expand Down Expand Up @@ -2505,6 +2563,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
case MGMT_OP_SET_LINK_SECURITY:
err = set_link_security(sk, index, cp, len);
break;
case MGMT_OP_SET_SSP:
err = set_ssp(sk, index, cp, len);
break;
case MGMT_OP_ADD_UUID:
err = add_uuid(sk, index, cp, len);
break;
Expand Down Expand Up @@ -3052,6 +3113,30 @@ int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status)
return err;
}

int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 status)
{
struct cmd_lookup match = { NULL, hdev };
__le32 ev;
int err;

if (status) {
u8 mgmt_err = mgmt_status(status);
mgmt_pending_foreach(MGMT_OP_SET_SSP, hdev,
cmd_status_rsp, &mgmt_err);
return 0;
}

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

ev = cpu_to_le32(get_current_settings(hdev));
err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), match.sk);

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

return err;
}

int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status)
{
struct pending_cmd *cmd;
Expand Down

0 comments on commit de50d0f

Please sign in to comment.