Skip to content

Commit 5d2e9fa

Browse files
jhedbergholtmann
authored andcommitted
Bluetooth: Add scan_rsp parameter to mgmt_device_found()
In preparation for being able to merge ADV_IND/ADV_SCAN_IND and SCAN_RSP together into a single device found event add a second parameter to the mgmt_device_found function. For now all callers pass NULL as this parameters since we don't yet have storing of the last received advertising report. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent ca5c4be commit 5d2e9fa

3 files changed

Lines changed: 19 additions & 12 deletions

File tree

‎include/net/bluetooth/hci_core.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,8 +1264,9 @@ void mgmt_read_local_oob_data_complete(struct hci_dev *hdev, u8 *hash192,
12641264
u8 *randomizer192, u8 *hash256,
12651265
u8 *randomizer256, u8 status);
12661266
void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
1267-
u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name,
1268-
u8 ssp, u8 *eir, u16 eir_len);
1267+
u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, u8
1268+
ssp, u8 *eir, u16 eir_len, u8 *scan_rsp,
1269+
u8 scan_rsp_len);
12691270
void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
12701271
u8 addr_type, s8 rssi, u8 *name, u8 name_len);
12711272
void mgmt_discovering(struct hci_dev *hdev, u8 discovering);

‎net/bluetooth/hci_event.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
18271827
name_known = hci_inquiry_cache_update(hdev, &data, false, &ssp);
18281828
mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
18291829
info->dev_class, 0, !name_known, ssp, NULL,
1830-
0);
1830+
0, NULL, 0);
18311831
}
18321832

18331833
hci_dev_unlock(hdev);
@@ -3102,7 +3102,7 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
31023102
false, &ssp);
31033103
mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
31043104
info->dev_class, info->rssi,
3105-
!name_known, ssp, NULL, 0);
3105+
!name_known, ssp, NULL, 0, NULL, 0);
31063106
}
31073107
} else {
31083108
struct inquiry_info_with_rssi *info = (void *) (skb->data + 1);
@@ -3120,7 +3120,7 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
31203120
false, &ssp);
31213121
mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
31223122
info->dev_class, info->rssi,
3123-
!name_known, ssp, NULL, 0);
3123+
!name_known, ssp, NULL, 0, NULL, 0);
31243124
}
31253125
}
31263126

@@ -3309,7 +3309,7 @@ static void hci_extended_inquiry_result_evt(struct hci_dev *hdev,
33093309
eir_len = eir_get_length(info->data, sizeof(info->data));
33103310
mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
33113311
info->dev_class, info->rssi, !name_known,
3312-
ssp, info->data, eir_len);
3312+
ssp, info->data, eir_len, NULL, 0);
33133313
}
33143314

33153315
hci_dev_unlock(hdev);
@@ -3972,7 +3972,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
39723972
}
39733973

39743974
mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, rssi, 0, 1,
3975-
data, len);
3975+
data, len, NULL, 0);
39763976
}
39773977

39783978
static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)

‎net/bluetooth/mgmt.c‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5669,7 +5669,8 @@ void mgmt_read_local_oob_data_complete(struct hci_dev *hdev, u8 *hash192,
56695669

56705670
void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
56715671
u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, u8
5672-
ssp, u8 *eir, u16 eir_len)
5672+
ssp, u8 *eir, u16 eir_len, u8 *scan_rsp,
5673+
u8 scan_rsp_len)
56735674
{
56745675
char buf[512];
56755676
struct mgmt_ev_device_found *ev = (void *) buf;
@@ -5679,8 +5680,10 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
56795680
if (!hci_discovery_active(hdev))
56805681
return;
56815682

5682-
/* Leave 5 bytes for a potential CoD field */
5683-
if (sizeof(*ev) + eir_len + 5 > sizeof(buf))
5683+
/* Make sure that the buffer is big enough. The 5 extra bytes
5684+
* are for the potential CoD field.
5685+
*/
5686+
if (sizeof(*ev) + eir_len + scan_rsp_len + 5 > sizeof(buf))
56845687
return;
56855688

56865689
memset(buf, 0, sizeof(buf));
@@ -5707,8 +5710,11 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
57075710
eir_len = eir_append_data(ev->eir, eir_len, EIR_CLASS_OF_DEV,
57085711
dev_class, 3);
57095712

5710-
ev->eir_len = cpu_to_le16(eir_len);
5711-
ev_size = sizeof(*ev) + eir_len;
5713+
if (scan_rsp_len > 0)
5714+
memcpy(ev->eir + eir_len, scan_rsp, scan_rsp_len);
5715+
5716+
ev->eir_len = cpu_to_le16(eir_len + scan_rsp_len);
5717+
ev_size = sizeof(*ev) + eir_len + scan_rsp_len;
57125718

57135719
mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
57145720
}

0 commit comments

Comments
 (0)