diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2015-03-14 23:53:25 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2015-03-15 04:03:41 -0400 |
commit | d3d5305bfd1cb48c8f44207abb567276a1e09cc7 (patch) | |
tree | 5bcc688e2ccdb2b9c5936d3a18a83edc23d75cdf | |
parent | a958452aa40c57a0407ecf84ba1bfa31ad532313 (diff) |
Bluetooth: Add simple version of Read Advertising Features command
This adds support for the simplest possible version of Read Advertising
Features management command. It allows basic testing of the interface.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | include/net/bluetooth/mgmt.h | 11 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 36 |
2 files changed, 47 insertions, 0 deletions
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index f3baad589db0..4d0ccd194c01 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h | |||
@@ -517,6 +517,17 @@ struct mgmt_rp_read_ext_index_list { | |||
517 | } entry[0]; | 517 | } entry[0]; |
518 | } __packed; | 518 | } __packed; |
519 | 519 | ||
520 | #define MGMT_OP_READ_ADV_FEATURES 0x0003D | ||
521 | #define MGMT_READ_ADV_FEATURES_SIZE 0 | ||
522 | struct mgmt_rp_read_adv_features { | ||
523 | __le32 supported_flags; | ||
524 | __u8 max_adv_data_len; | ||
525 | __u8 max_scan_rsp_len; | ||
526 | __u8 max_instances; | ||
527 | __u8 num_instances; | ||
528 | __u8 instance[0]; | ||
529 | } __packed; | ||
530 | |||
520 | #define MGMT_EV_CMD_COMPLETE 0x0001 | 531 | #define MGMT_EV_CMD_COMPLETE 0x0001 |
521 | struct mgmt_ev_cmd_complete { | 532 | struct mgmt_ev_cmd_complete { |
522 | __le16 opcode; | 533 | __le16 opcode; |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index fa5654d89702..25a687c2a112 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -97,6 +97,7 @@ static const u16 mgmt_commands[] = { | |||
97 | MGMT_OP_SET_PUBLIC_ADDRESS, | 97 | MGMT_OP_SET_PUBLIC_ADDRESS, |
98 | MGMT_OP_START_SERVICE_DISCOVERY, | 98 | MGMT_OP_START_SERVICE_DISCOVERY, |
99 | MGMT_OP_READ_EXT_INDEX_LIST, | 99 | MGMT_OP_READ_EXT_INDEX_LIST, |
100 | MGMT_OP_READ_ADV_FEATURES, | ||
100 | }; | 101 | }; |
101 | 102 | ||
102 | static const u16 mgmt_events[] = { | 103 | static const u16 mgmt_events[] = { |
@@ -6254,6 +6255,40 @@ unlock: | |||
6254 | return err; | 6255 | return err; |
6255 | } | 6256 | } |
6256 | 6257 | ||
6258 | static int read_adv_features(struct sock *sk, struct hci_dev *hdev, | ||
6259 | void *data, u16 data_len) | ||
6260 | { | ||
6261 | struct mgmt_rp_read_adv_features *rp; | ||
6262 | size_t rp_len; | ||
6263 | int err; | ||
6264 | |||
6265 | BT_DBG("%s", hdev->name); | ||
6266 | |||
6267 | hci_dev_lock(hdev); | ||
6268 | |||
6269 | rp_len = sizeof(*rp); | ||
6270 | rp = kmalloc(rp_len, GFP_ATOMIC); | ||
6271 | if (!rp) { | ||
6272 | hci_dev_unlock(hdev); | ||
6273 | return -ENOMEM; | ||
6274 | } | ||
6275 | |||
6276 | rp->supported_flags = cpu_to_le32(0); | ||
6277 | rp->max_adv_data_len = 31; | ||
6278 | rp->max_scan_rsp_len = 31; | ||
6279 | rp->max_instances = 0; | ||
6280 | rp->num_instances = 0; | ||
6281 | |||
6282 | hci_dev_unlock(hdev); | ||
6283 | |||
6284 | err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_READ_ADV_FEATURES, | ||
6285 | MGMT_STATUS_SUCCESS, rp, rp_len); | ||
6286 | |||
6287 | kfree(rp); | ||
6288 | |||
6289 | return err; | ||
6290 | } | ||
6291 | |||
6257 | static const struct hci_mgmt_handler mgmt_handlers[] = { | 6292 | static const struct hci_mgmt_handler mgmt_handlers[] = { |
6258 | { NULL }, /* 0x0000 (no command) */ | 6293 | { NULL }, /* 0x0000 (no command) */ |
6259 | { read_version, MGMT_READ_VERSION_SIZE, | 6294 | { read_version, MGMT_READ_VERSION_SIZE, |
@@ -6337,6 +6372,7 @@ static const struct hci_mgmt_handler mgmt_handlers[] = { | |||
6337 | { read_ext_index_list, MGMT_READ_EXT_INDEX_LIST_SIZE, | 6372 | { read_ext_index_list, MGMT_READ_EXT_INDEX_LIST_SIZE, |
6338 | HCI_MGMT_NO_HDEV | | 6373 | HCI_MGMT_NO_HDEV | |
6339 | HCI_MGMT_UNTRUSTED }, | 6374 | HCI_MGMT_UNTRUSTED }, |
6375 | { read_adv_features, MGMT_READ_ADV_FEATURES_SIZE }, | ||
6340 | }; | 6376 | }; |
6341 | 6377 | ||
6342 | int mgmt_control(struct hci_mgmt_chan *chan, struct sock *sk, | 6378 | int mgmt_control(struct hci_mgmt_chan *chan, struct sock *sk, |