Bluetooth: MGMT: Fix always using HCI_MAX_AD_LENGTH
HCI_MAX_AD_LENGTH shall only be used if the controller doesn't support extended advertising, otherwise HCI_MAX_EXT_AD_LENGTH shall be used instead. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
6f55eea116
commit
112b5090c2
3 changed files with 14 additions and 8 deletions
|
@ -1801,6 +1801,10 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
|
||||||
/* Extended advertising support */
|
/* Extended advertising support */
|
||||||
#define ext_adv_capable(dev) (((dev)->le_features[1] & HCI_LE_EXT_ADV))
|
#define ext_adv_capable(dev) (((dev)->le_features[1] & HCI_LE_EXT_ADV))
|
||||||
|
|
||||||
|
/* Maximum advertising length */
|
||||||
|
#define max_adv_len(dev) \
|
||||||
|
(ext_adv_capable(dev) ? HCI_MAX_EXT_AD_LENGTH : HCI_MAX_AD_LENGTH)
|
||||||
|
|
||||||
/* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E page 1789:
|
/* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E page 1789:
|
||||||
*
|
*
|
||||||
* C24: Mandatory if the LE Controller supports Connection State and either
|
* C24: Mandatory if the LE Controller supports Connection State and either
|
||||||
|
|
|
@ -1747,7 +1747,7 @@ static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr,
|
||||||
{
|
{
|
||||||
struct discovery_state *d = &hdev->discovery;
|
struct discovery_state *d = &hdev->discovery;
|
||||||
|
|
||||||
if (len > HCI_MAX_AD_LENGTH)
|
if (len > max_adv_len(hdev))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bacpy(&d->last_adv_addr, bdaddr);
|
bacpy(&d->last_adv_addr, bdaddr);
|
||||||
|
@ -6249,8 +6249,9 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ext_adv && len > HCI_MAX_AD_LENGTH) {
|
if (len > max_adv_len(hdev)) {
|
||||||
bt_dev_err_ratelimited(hdev, "legacy adv larger than 31 bytes");
|
bt_dev_err_ratelimited(hdev,
|
||||||
|
"adv larger than maximum supported");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6315,7 +6316,8 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
|
||||||
*/
|
*/
|
||||||
conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, bdaddr_resolved,
|
conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, bdaddr_resolved,
|
||||||
type);
|
type);
|
||||||
if (!ext_adv && conn && type == LE_ADV_IND && len <= HCI_MAX_AD_LENGTH) {
|
if (!ext_adv && conn && type == LE_ADV_IND &&
|
||||||
|
len <= max_adv_len(hdev)) {
|
||||||
/* Store report for later inclusion by
|
/* Store report for later inclusion by
|
||||||
* mgmt_device_connected
|
* mgmt_device_connected
|
||||||
*/
|
*/
|
||||||
|
@ -6456,7 +6458,7 @@ static void hci_le_adv_report_evt(struct hci_dev *hdev, void *data,
|
||||||
info->length + 1))
|
info->length + 1))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (info->length <= HCI_MAX_AD_LENGTH) {
|
if (info->length <= max_adv_len(hdev)) {
|
||||||
rssi = info->data[info->length];
|
rssi = info->data[info->length];
|
||||||
process_adv_report(hdev, info->type, &info->bdaddr,
|
process_adv_report(hdev, info->type, &info->bdaddr,
|
||||||
info->bdaddr_type, NULL, 0, rssi,
|
info->bdaddr_type, NULL, 0, rssi,
|
||||||
|
|
|
@ -8428,8 +8428,8 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev,
|
||||||
supported_flags = get_supported_adv_flags(hdev);
|
supported_flags = get_supported_adv_flags(hdev);
|
||||||
|
|
||||||
rp->supported_flags = cpu_to_le32(supported_flags);
|
rp->supported_flags = cpu_to_le32(supported_flags);
|
||||||
rp->max_adv_data_len = HCI_MAX_AD_LENGTH;
|
rp->max_adv_data_len = max_adv_len(hdev);
|
||||||
rp->max_scan_rsp_len = HCI_MAX_AD_LENGTH;
|
rp->max_scan_rsp_len = max_adv_len(hdev);
|
||||||
rp->max_instances = hdev->le_num_of_adv_sets;
|
rp->max_instances = hdev->le_num_of_adv_sets;
|
||||||
rp->num_instances = hdev->adv_instance_cnt;
|
rp->num_instances = hdev->adv_instance_cnt;
|
||||||
|
|
||||||
|
@ -8465,7 +8465,7 @@ static u8 calculate_name_len(struct hci_dev *hdev)
|
||||||
static u8 tlv_data_max_len(struct hci_dev *hdev, u32 adv_flags,
|
static u8 tlv_data_max_len(struct hci_dev *hdev, u32 adv_flags,
|
||||||
bool is_adv_data)
|
bool is_adv_data)
|
||||||
{
|
{
|
||||||
u8 max_len = HCI_MAX_AD_LENGTH;
|
u8 max_len = max_adv_len(hdev);
|
||||||
|
|
||||||
if (is_adv_data) {
|
if (is_adv_data) {
|
||||||
if (adv_flags & (MGMT_ADV_FLAG_DISCOV |
|
if (adv_flags & (MGMT_ADV_FLAG_DISCOV |
|
||||||
|
|
Loading…
Add table
Reference in a new issue