aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-02-01 21:02:29 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-13 10:01:32 -0500
commit28424707a2e4ad38ab546d2ed5e3d6b035a84258 (patch)
tree60fd8524c956047add2055b350dc600f3d24ff36 /net/bluetooth/mgmt.c
parent95947a391ebe685b9870cd25cac1433aedf5d49c (diff)
Bluetooth: mgmt: Implement Cancel Pair Device command
This patch implements the Cancel Pair Device command for mgmt. It's used by user space to cancel an ongoing pairing attempt which was triggered by the Pair Device command. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 89707996d352..00ab083749eb 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1594,6 +1594,54 @@ unlock:
1594 return err; 1594 return err;
1595} 1595}
1596 1596
1597static int cancel_pair_device(struct sock *sk, u16 index,
1598 unsigned char *data, u16 len)
1599{
1600 struct mgmt_addr_info *addr = (void *) data;
1601 struct hci_dev *hdev;
1602 struct pending_cmd *cmd;
1603 struct hci_conn *conn;
1604 int err;
1605
1606 BT_DBG("");
1607
1608 if (len != sizeof(*addr))
1609 return cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE,
1610 MGMT_STATUS_INVALID_PARAMS);
1611
1612 hdev = hci_dev_get(index);
1613 if (!hdev)
1614 return cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE,
1615 MGMT_STATUS_INVALID_PARAMS);
1616
1617 hci_dev_lock(hdev);
1618
1619 cmd = mgmt_pending_find(MGMT_OP_PAIR_DEVICE, hdev);
1620 if (!cmd) {
1621 err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE,
1622 MGMT_STATUS_INVALID_PARAMS);
1623 goto unlock;
1624 }
1625
1626 conn = cmd->user_data;
1627
1628 if (bacmp(&addr->bdaddr, &conn->dst) != 0) {
1629 err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE,
1630 MGMT_STATUS_INVALID_PARAMS);
1631 goto unlock;
1632 }
1633
1634 pairing_complete(cmd, MGMT_STATUS_CANCELLED);
1635
1636 err = cmd_complete(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, addr,
1637 sizeof(*addr));
1638unlock:
1639 hci_dev_unlock(hdev);
1640 hci_dev_put(hdev);
1641
1642 return err;
1643}
1644
1597static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, 1645static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr,
1598 u16 mgmt_op, u16 hci_op, __le32 passkey) 1646 u16 mgmt_op, u16 hci_op, __le32 passkey)
1599{ 1647{
@@ -2271,6 +2319,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
2271 case MGMT_OP_PAIR_DEVICE: 2319 case MGMT_OP_PAIR_DEVICE:
2272 err = pair_device(sk, index, buf + sizeof(*hdr), len); 2320 err = pair_device(sk, index, buf + sizeof(*hdr), len);
2273 break; 2321 break;
2322 case MGMT_OP_CANCEL_PAIR_DEVICE:
2323 err = cancel_pair_device(sk, index, buf + sizeof(*hdr), len);
2324 break;
2274 case MGMT_OP_USER_CONFIRM_REPLY: 2325 case MGMT_OP_USER_CONFIRM_REPLY:
2275 err = user_confirm_reply(sk, index, buf + sizeof(*hdr), len); 2326 err = user_confirm_reply(sk, index, buf + sizeof(*hdr), len);
2276 break; 2327 break;