Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 290913
b: refs/heads/master
c: 2842470
h: refs/heads/master
i:
  290911: f7fbdf4
v: v3
  • Loading branch information
Johan Hedberg committed Feb 13, 2012
1 parent 83b35a6 commit 7d7cd8b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 95947a391ebe685b9870cd25cac1433aedf5d49c
refs/heads/master: 28424707a2e4ad38ab546d2ed5e3d6b035a84258
1 change: 1 addition & 0 deletions trunk/include/net/bluetooth/mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#define MGMT_STATUS_INVALID_PARAMS 0x0d
#define MGMT_STATUS_DISCONNECTED 0x0e
#define MGMT_STATUS_NOT_POWERED 0x0f
#define MGMT_STATUS_CANCELLED 0x10

struct mgmt_hdr {
__le16 opcode;
Expand Down
51 changes: 51 additions & 0 deletions trunk/net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,54 @@ static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len)
return err;
}

static int cancel_pair_device(struct sock *sk, u16 index,
unsigned char *data, u16 len)
{
struct mgmt_addr_info *addr = (void *) data;
struct hci_dev *hdev;
struct pending_cmd *cmd;
struct hci_conn *conn;
int err;

BT_DBG("");

if (len != sizeof(*addr))
return cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE,
MGMT_STATUS_INVALID_PARAMS);

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

hci_dev_lock(hdev);

cmd = mgmt_pending_find(MGMT_OP_PAIR_DEVICE, hdev);
if (!cmd) {
err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE,
MGMT_STATUS_INVALID_PARAMS);
goto unlock;
}

conn = cmd->user_data;

if (bacmp(&addr->bdaddr, &conn->dst) != 0) {
err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE,
MGMT_STATUS_INVALID_PARAMS);
goto unlock;
}

pairing_complete(cmd, MGMT_STATUS_CANCELLED);

err = cmd_complete(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, addr,
sizeof(*addr));
unlock:
hci_dev_unlock(hdev);
hci_dev_put(hdev);

return err;
}

static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr,
u16 mgmt_op, u16 hci_op, __le32 passkey)
{
Expand Down Expand Up @@ -2271,6 +2319,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
case MGMT_OP_PAIR_DEVICE:
err = pair_device(sk, index, buf + sizeof(*hdr), len);
break;
case MGMT_OP_CANCEL_PAIR_DEVICE:
err = cancel_pair_device(sk, index, buf + sizeof(*hdr), len);
break;
case MGMT_OP_USER_CONFIRM_REPLY:
err = user_confirm_reply(sk, index, buf + sizeof(*hdr), len);
break;
Expand Down

0 comments on commit 7d7cd8b

Please sign in to comment.