summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorArman Uguray <armansito@chromium.org>2015-03-25 21:53:44 -0400
committerMarcel Holtmann <marcel@holtmann.org>2015-03-25 22:30:29 -0400
commit5507e358112af307c1c8595a04a0ef172d197f3c (patch)
tree0ecffc6aef8e907941e0df15af5207efec5435b9 /net/bluetooth/mgmt.c
parent67e0c0cd8f5afea17689f7688041e9d215df6875 (diff)
Bluetooth: Support the "tx-power" adv flag
This patch adds support for the "tx-power" flag of the Add Advertising command. Signed-off-by: Arman Uguray <armansito@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index cc4e76f8be0e..de321b9087e7 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1004,6 +1004,16 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 *ptr)
1004 ptr += 3; 1004 ptr += 3;
1005 } 1005 }
1006 1006
1007 if (hdev->adv_tx_power != HCI_TX_POWER_INVALID &&
1008 (hdev->adv_instance.flags & MGMT_ADV_FLAG_TX_POWER)) {
1009 ptr[0] = 0x02;
1010 ptr[1] = EIR_TX_POWER;
1011 ptr[2] = (u8)hdev->adv_tx_power;
1012
1013 ad_len += 3;
1014 ptr += 3;
1015 }
1016
1007 memcpy(ptr, hdev->adv_instance.adv_data, 1017 memcpy(ptr, hdev->adv_instance.adv_data,
1008 hdev->adv_instance.adv_data_len); 1018 hdev->adv_instance.adv_data_len);
1009 ad_len += hdev->adv_instance.adv_data_len; 1019 ad_len += hdev->adv_instance.adv_data_len;
@@ -6588,6 +6598,7 @@ static bool tlv_data_is_valid(struct hci_dev *hdev, u32 adv_flags, u8 *data,
6588 u8 max_len = HCI_MAX_AD_LENGTH; 6598 u8 max_len = HCI_MAX_AD_LENGTH;
6589 int i, cur_len; 6599 int i, cur_len;
6590 bool flags_managed = false; 6600 bool flags_managed = false;
6601 bool tx_power_managed = false;
6591 u32 flags_params = MGMT_ADV_FLAG_DISCOV | MGMT_ADV_FLAG_LIMITED_DISCOV | 6602 u32 flags_params = MGMT_ADV_FLAG_DISCOV | MGMT_ADV_FLAG_LIMITED_DISCOV |
6592 MGMT_ADV_FLAG_MANAGED_FLAGS; 6603 MGMT_ADV_FLAG_MANAGED_FLAGS;
6593 6604
@@ -6596,6 +6607,11 @@ static bool tlv_data_is_valid(struct hci_dev *hdev, u32 adv_flags, u8 *data,
6596 max_len -= 3; 6607 max_len -= 3;
6597 } 6608 }
6598 6609
6610 if (is_adv_data && (adv_flags & MGMT_ADV_FLAG_TX_POWER)) {
6611 tx_power_managed = true;
6612 max_len -= 3;
6613 }
6614
6599 if (len > max_len) 6615 if (len > max_len)
6600 return false; 6616 return false;
6601 6617
@@ -6606,6 +6622,9 @@ static bool tlv_data_is_valid(struct hci_dev *hdev, u32 adv_flags, u8 *data,
6606 if (flags_managed && data[i + 1] == EIR_FLAGS) 6622 if (flags_managed && data[i + 1] == EIR_FLAGS)
6607 return false; 6623 return false;
6608 6624
6625 if (tx_power_managed && data[i + 1] == EIR_TX_POWER)
6626 return false;
6627
6609 /* If the current field length would exceed the total data 6628 /* If the current field length would exceed the total data
6610 * length, then it's invalid. 6629 * length, then it's invalid.
6611 */ 6630 */