diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2012-01-15 12:51:59 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-02-13 10:01:27 -0500 |
commit | e319d2e74378660c5e09a1b8703663ba97f0f62a (patch) | |
tree | ed4b4a2e9e4add922eeac59b7d7e038d5b3e03d0 | |
parent | afc747a600ff2e3a4eef8f312fc766608a1360e2 (diff) |
Bluetooth: Add eir_len parameter to mgmt_ev_device_found
This patch add a two byte eir_len parameter mgmt_ev_device_found. Since
it's unlikely that the data will in the short term be much bigger than
conventional EIR lengths just use a small stack based buffer for now to
avoid dynamic memory allocation & freeing.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r-- | include/net/bluetooth/hci_core.h | 2 | ||||
-rw-r--r-- | include/net/bluetooth/mgmt.h | 3 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 28 |
3 files changed, 18 insertions, 15 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index f3fbfd6f6c3b..33dff8ef2e08 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -925,7 +925,7 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, | |||
925 | u8 *randomizer, u8 status); | 925 | u8 *randomizer, u8 status); |
926 | int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | 926 | int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
927 | u8 addr_type, u8 *dev_class, s8 rssi, | 927 | u8 addr_type, u8 *dev_class, s8 rssi, |
928 | u8 cfm_name, u8 *eir, u8 eir_len); | 928 | u8 cfm_name, u8 *eir, u16 eir_len); |
929 | int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); | 929 | int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); |
930 | int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); | 930 | int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); |
931 | int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status); | 931 | int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status); |
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index d1d13dc0cca8..4f166c834ddb 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h | |||
@@ -368,7 +368,8 @@ struct mgmt_ev_device_found { | |||
368 | __u8 dev_class[3]; | 368 | __u8 dev_class[3]; |
369 | __s8 rssi; | 369 | __s8 rssi; |
370 | __u8 confirm_name; | 370 | __u8 confirm_name; |
371 | __u8 eir[HCI_MAX_EIR_LENGTH]; | 371 | __le16 eir_len; |
372 | __u8 eir[0]; | ||
372 | } __packed; | 373 | } __packed; |
373 | 374 | ||
374 | #define MGMT_EV_REMOTE_NAME 0x0012 | 375 | #define MGMT_EV_REMOTE_NAME 0x0012 |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c8042c6e2b46..b7e7fdfaee38 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -2782,27 +2782,29 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, | |||
2782 | 2782 | ||
2783 | int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | 2783 | int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
2784 | u8 addr_type, u8 *dev_class, s8 rssi, | 2784 | u8 addr_type, u8 *dev_class, s8 rssi, |
2785 | u8 cfm_name, u8 *eir, u8 eir_len) | 2785 | u8 cfm_name, u8 *eir, u16 eir_len) |
2786 | { | 2786 | { |
2787 | struct mgmt_ev_device_found ev; | 2787 | char buf[512]; |
2788 | struct mgmt_ev_device_found *ev = (void *) buf; | ||
2789 | size_t ev_size = sizeof(*ev) + eir_len; | ||
2788 | 2790 | ||
2789 | if (eir_len > sizeof(ev.eir)) | 2791 | if (ev_size > sizeof(buf)) |
2790 | return -EINVAL; | 2792 | return -EINVAL; |
2791 | 2793 | ||
2792 | memset(&ev, 0, sizeof(ev)); | 2794 | bacpy(&ev->addr.bdaddr, bdaddr); |
2795 | ev->addr.type = link_to_mgmt(link_type, addr_type); | ||
2796 | ev->rssi = rssi; | ||
2797 | ev->confirm_name = cfm_name; | ||
2793 | 2798 | ||
2794 | bacpy(&ev.addr.bdaddr, bdaddr); | 2799 | if (eir_len > 0) { |
2795 | ev.addr.type = link_to_mgmt(link_type, addr_type); | 2800 | put_unaligned_le16(eir_len, &ev->eir_len); |
2796 | ev.rssi = rssi; | 2801 | memcpy(ev->eir, eir, eir_len); |
2797 | ev.confirm_name = cfm_name; | 2802 | } |
2798 | |||
2799 | if (eir) | ||
2800 | memcpy(ev.eir, eir, eir_len); | ||
2801 | 2803 | ||
2802 | if (dev_class) | 2804 | if (dev_class) |
2803 | memcpy(ev.dev_class, dev_class, sizeof(ev.dev_class)); | 2805 | memcpy(ev->dev_class, dev_class, sizeof(ev->dev_class)); |
2804 | 2806 | ||
2805 | return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, &ev, sizeof(ev), NULL); | 2807 | return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL); |
2806 | } | 2808 | } |
2807 | 2809 | ||
2808 | int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name) | 2810 | int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name) |