Commit e319d2e7 authored by Johan Hedberg's avatar Johan Hedberg

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: default avatarJohan Hedberg <johan.hedberg@intel.com>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent afc747a6
...@@ -925,7 +925,7 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, ...@@ -925,7 +925,7 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
u8 *randomizer, u8 status); u8 *randomizer, u8 status);
int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type, u8 *dev_class, s8 rssi, u8 addr_type, u8 *dev_class, s8 rssi,
u8 cfm_name, u8 *eir, u8 eir_len); u8 cfm_name, u8 *eir, u16 eir_len);
int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name);
int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status);
int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status);
......
...@@ -368,7 +368,8 @@ struct mgmt_ev_device_found { ...@@ -368,7 +368,8 @@ struct mgmt_ev_device_found {
__u8 dev_class[3]; __u8 dev_class[3];
__s8 rssi; __s8 rssi;
__u8 confirm_name; __u8 confirm_name;
__u8 eir[HCI_MAX_EIR_LENGTH]; __le16 eir_len;
__u8 eir[0];
} __packed; } __packed;
#define MGMT_EV_REMOTE_NAME 0x0012 #define MGMT_EV_REMOTE_NAME 0x0012
......
...@@ -2782,27 +2782,29 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, ...@@ -2782,27 +2782,29 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type, u8 *dev_class, s8 rssi, u8 addr_type, u8 *dev_class, s8 rssi,
u8 cfm_name, u8 *eir, u8 eir_len) u8 cfm_name, u8 *eir, u16 eir_len)
{ {
struct mgmt_ev_device_found ev; char buf[512];
struct mgmt_ev_device_found *ev = (void *) buf;
size_t ev_size = sizeof(*ev) + eir_len;
if (eir_len > sizeof(ev.eir)) if (ev_size > sizeof(buf))
return -EINVAL; return -EINVAL;
memset(&ev, 0, sizeof(ev)); bacpy(&ev->addr.bdaddr, bdaddr);
ev->addr.type = link_to_mgmt(link_type, addr_type);
ev->rssi = rssi;
ev->confirm_name = cfm_name;
bacpy(&ev.addr.bdaddr, bdaddr); if (eir_len > 0) {
ev.addr.type = link_to_mgmt(link_type, addr_type); put_unaligned_le16(eir_len, &ev->eir_len);
ev.rssi = rssi; memcpy(ev->eir, eir, eir_len);
ev.confirm_name = cfm_name; }
if (eir)
memcpy(ev.eir, eir, eir_len);
if (dev_class) if (dev_class)
memcpy(ev.dev_class, dev_class, sizeof(ev.dev_class)); memcpy(ev->dev_class, dev_class, sizeof(ev->dev_class));
return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, &ev, sizeof(ev), NULL); return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
} }
int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name) int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment