Commit 089fa8c0 authored by Arman Uguray's avatar Arman Uguray Committed by Marcel Holtmann

Bluetooth: Update supported_flags for AD features

This patch updates the "supported_flags" parameter returned from the
"Read Advertising Features" command. Add Advertising will now return
an error if an unsupported flag is provided.
Signed-off-by: default avatarArman Uguray <armansito@chromium.org>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 5507e358
...@@ -6540,6 +6540,21 @@ static int read_local_oob_ext_data(struct sock *sk, struct hci_dev *hdev, ...@@ -6540,6 +6540,21 @@ static int read_local_oob_ext_data(struct sock *sk, struct hci_dev *hdev,
return err; return err;
} }
static u32 get_supported_adv_flags(struct hci_dev *hdev)
{
u32 flags = 0;
flags |= MGMT_ADV_FLAG_CONNECTABLE;
flags |= MGMT_ADV_FLAG_DISCOV;
flags |= MGMT_ADV_FLAG_LIMITED_DISCOV;
flags |= MGMT_ADV_FLAG_MANAGED_FLAGS;
if (hdev->adv_tx_power != HCI_TX_POWER_INVALID)
flags |= MGMT_ADV_FLAG_TX_POWER;
return flags;
}
static int read_adv_features(struct sock *sk, struct hci_dev *hdev, static int read_adv_features(struct sock *sk, struct hci_dev *hdev,
void *data, u16 data_len) void *data, u16 data_len)
{ {
...@@ -6547,9 +6562,14 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev, ...@@ -6547,9 +6562,14 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev,
size_t rp_len; size_t rp_len;
int err; int err;
bool instance; bool instance;
u32 supported_flags;
BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name);
if (!lmp_le_capable(hdev))
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_READ_ADV_FEATURES,
MGMT_STATUS_REJECTED);
hci_dev_lock(hdev); hci_dev_lock(hdev);
rp_len = sizeof(*rp); rp_len = sizeof(*rp);
...@@ -6567,7 +6587,9 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev, ...@@ -6567,7 +6587,9 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev,
return -ENOMEM; return -ENOMEM;
} }
rp->supported_flags = cpu_to_le32(0); supported_flags = get_supported_adv_flags(hdev);
rp->supported_flags = cpu_to_le32(supported_flags);
rp->max_adv_data_len = HCI_MAX_AD_LENGTH; rp->max_adv_data_len = HCI_MAX_AD_LENGTH;
rp->max_scan_rsp_len = HCI_MAX_AD_LENGTH; rp->max_scan_rsp_len = HCI_MAX_AD_LENGTH;
rp->max_instances = 1; rp->max_instances = 1;
...@@ -6689,6 +6711,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, ...@@ -6689,6 +6711,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,
struct mgmt_cp_add_advertising *cp = data; struct mgmt_cp_add_advertising *cp = data;
struct mgmt_rp_add_advertising rp; struct mgmt_rp_add_advertising rp;
u32 flags; u32 flags;
u32 supported_flags;
u8 status; u8 status;
u16 timeout; u16 timeout;
int err; int err;
...@@ -6705,8 +6728,11 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev, ...@@ -6705,8 +6728,11 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,
flags = __le32_to_cpu(cp->flags); flags = __le32_to_cpu(cp->flags);
timeout = __le16_to_cpu(cp->timeout); timeout = __le16_to_cpu(cp->timeout);
/* The current implementation only supports adding one instance */ /* The current implementation only supports adding one instance and only
if (cp->instance != 0x01) * a subset of the specified flags.
*/
supported_flags = get_supported_adv_flags(hdev);
if (cp->instance != 0x01 || (flags & ~supported_flags))
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
......
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