diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2011-01-25 06:28:33 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-02-07 22:40:08 -0500 |
commit | 17fa4b9dff72fb3a1a68cc80caf98fc941d2b8b3 (patch) | |
tree | 34febcb1be7bf64995dd94c5db5755c5d9d7754f /net/bluetooth/mgmt.c | |
parent | 980e1a537fed7dfa53e9a4b6e586b43341f8c2d5 (diff) |
Bluetooth: Add set_io_capability management command
This patch adds a new set_io_capability management command which is used
to set the IO capability for Secure Simple Pairing (SSP) as well as the
Security Manager Protocol (SMP). The value is per hci_dev and each
hci_conn object inherits it upon creation.
Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r-- | net/bluetooth/mgmt.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 3800aaf5792d..b2bda83050a4 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -1016,6 +1016,35 @@ failed: | |||
1016 | return err; | 1016 | return err; |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | static int set_io_capability(struct sock *sk, unsigned char *data, u16 len) | ||
1020 | { | ||
1021 | struct hci_dev *hdev; | ||
1022 | struct mgmt_cp_set_io_capability *cp; | ||
1023 | u16 dev_id; | ||
1024 | |||
1025 | BT_DBG(""); | ||
1026 | |||
1027 | cp = (void *) data; | ||
1028 | dev_id = get_unaligned_le16(&cp->index); | ||
1029 | |||
1030 | hdev = hci_dev_get(dev_id); | ||
1031 | if (!hdev) | ||
1032 | return cmd_status(sk, MGMT_OP_SET_IO_CAPABILITY, ENODEV); | ||
1033 | |||
1034 | hci_dev_lock_bh(hdev); | ||
1035 | |||
1036 | hdev->io_capability = cp->io_capability; | ||
1037 | |||
1038 | BT_DBG("%s IO capability set to 0x%02x", hdev->name, | ||
1039 | hdev->io_capability); | ||
1040 | |||
1041 | hci_dev_unlock_bh(hdev); | ||
1042 | hci_dev_put(hdev); | ||
1043 | |||
1044 | return cmd_complete(sk, MGMT_OP_SET_IO_CAPABILITY, | ||
1045 | &dev_id, sizeof(dev_id)); | ||
1046 | } | ||
1047 | |||
1019 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) | 1048 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) |
1020 | { | 1049 | { |
1021 | unsigned char *buf; | 1050 | unsigned char *buf; |
@@ -1098,6 +1127,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) | |||
1098 | case MGMT_OP_PIN_CODE_NEG_REPLY: | 1127 | case MGMT_OP_PIN_CODE_NEG_REPLY: |
1099 | err = pin_code_neg_reply(sk, buf + sizeof(*hdr), len); | 1128 | err = pin_code_neg_reply(sk, buf + sizeof(*hdr), len); |
1100 | break; | 1129 | break; |
1130 | case MGMT_OP_SET_IO_CAPABILITY: | ||
1131 | err = set_io_capability(sk, buf + sizeof(*hdr), len); | ||
1132 | break; | ||
1101 | default: | 1133 | default: |
1102 | BT_DBG("Unknown op %u", opcode); | 1134 | BT_DBG("Unknown op %u", opcode); |
1103 | err = cmd_status(sk, opcode, 0x01); | 1135 | err = cmd_status(sk, opcode, 0x01); |