aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaganath Kanakkassery <jaganath.k.os@gmail.com>2018-07-19 07:39:38 -0400
committerMarcel Holtmann <marcel@holtmann.org>2018-07-30 07:44:52 -0400
commitb2cc9761f144e8ef714be8c590603073b80ddc13 (patch)
tree2e851982556116b7ff997f7d885a742a3d311f98
parent45bdd86eafc7d29e0b4b6681bec9c6ab8eddc6bf (diff)
Bluetooth: Handle extended ADV PDU types
This patch defines the extended ADV types and handle it in ADV report. Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--include/net/bluetooth/hci.h8
-rw-r--r--net/bluetooth/hci_event.c50
2 files changed, 45 insertions, 13 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 04211457367a..83a1593a128e 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1976,6 +1976,14 @@ struct hci_ev_le_conn_complete {
1976#define LE_LEGACY_SCAN_RSP_ADV 0x001b 1976#define LE_LEGACY_SCAN_RSP_ADV 0x001b
1977#define LE_LEGACY_SCAN_RSP_ADV_SCAN 0x001a 1977#define LE_LEGACY_SCAN_RSP_ADV_SCAN 0x001a
1978 1978
1979/* Extended Advertising event types */
1980#define LE_EXT_ADV_NON_CONN_IND 0x0000
1981#define LE_EXT_ADV_CONN_IND 0x0001
1982#define LE_EXT_ADV_SCAN_IND 0x0002
1983#define LE_EXT_ADV_DIRECT_IND 0x0004
1984#define LE_EXT_ADV_SCAN_RSP 0x0008
1985#define LE_EXT_ADV_LEGACY_PDU 0x0010
1986
1979#define ADDR_LE_DEV_PUBLIC 0x00 1987#define ADDR_LE_DEV_PUBLIC 0x00
1980#define ADDR_LE_DEV_RANDOM 0x01 1988#define ADDR_LE_DEV_RANDOM 0x01
1981 1989
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 694231541a4c..5fa00f488cfc 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -5137,21 +5137,45 @@ static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
5137 hci_dev_unlock(hdev); 5137 hci_dev_unlock(hdev);
5138} 5138}
5139 5139
5140static u8 convert_legacy_evt_type(u16 evt_type) 5140static u8 ext_evt_type_to_legacy(u16 evt_type)
5141{ 5141{
5142 switch (evt_type) { 5142 if (evt_type & LE_EXT_ADV_LEGACY_PDU) {
5143 case LE_LEGACY_ADV_IND: 5143 switch (evt_type) {
5144 case LE_LEGACY_ADV_IND:
5145 return LE_ADV_IND;
5146 case LE_LEGACY_ADV_DIRECT_IND:
5147 return LE_ADV_DIRECT_IND;
5148 case LE_LEGACY_ADV_SCAN_IND:
5149 return LE_ADV_SCAN_IND;
5150 case LE_LEGACY_NONCONN_IND:
5151 return LE_ADV_NONCONN_IND;
5152 case LE_LEGACY_SCAN_RSP_ADV:
5153 case LE_LEGACY_SCAN_RSP_ADV_SCAN:
5154 return LE_ADV_SCAN_RSP;
5155 }
5156
5157 BT_ERR_RATELIMITED("Unknown advertising packet type: 0x%02x",
5158 evt_type);
5159
5160 return LE_ADV_INVALID;
5161 }
5162
5163 if (evt_type & LE_EXT_ADV_CONN_IND) {
5164 if (evt_type & LE_EXT_ADV_DIRECT_IND)
5165 return LE_ADV_DIRECT_IND;
5166
5144 return LE_ADV_IND; 5167 return LE_ADV_IND;
5145 case LE_LEGACY_ADV_DIRECT_IND: 5168 }
5146 return LE_ADV_DIRECT_IND; 5169
5147 case LE_LEGACY_ADV_SCAN_IND: 5170 if (evt_type & LE_EXT_ADV_SCAN_RSP)
5171 return LE_ADV_SCAN_RSP;
5172
5173 if (evt_type & LE_EXT_ADV_SCAN_IND)
5148 return LE_ADV_SCAN_IND; 5174 return LE_ADV_SCAN_IND;
5149 case LE_LEGACY_NONCONN_IND: 5175
5176 if (evt_type == LE_EXT_ADV_NON_CONN_IND ||
5177 evt_type & LE_EXT_ADV_DIRECT_IND)
5150 return LE_ADV_NONCONN_IND; 5178 return LE_ADV_NONCONN_IND;
5151 case LE_LEGACY_SCAN_RSP_ADV:
5152 case LE_LEGACY_SCAN_RSP_ADV_SCAN:
5153 return LE_ADV_SCAN_RSP;
5154 }
5155 5179
5156 BT_ERR_RATELIMITED("Unknown advertising packet type: 0x%02x", 5180 BT_ERR_RATELIMITED("Unknown advertising packet type: 0x%02x",
5157 evt_type); 5181 evt_type);
@@ -5172,7 +5196,7 @@ static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
5172 u16 evt_type; 5196 u16 evt_type;
5173 5197
5174 evt_type = __le16_to_cpu(ev->evt_type); 5198 evt_type = __le16_to_cpu(ev->evt_type);
5175 legacy_evt_type = convert_legacy_evt_type(evt_type); 5199 legacy_evt_type = ext_evt_type_to_legacy(evt_type);
5176 if (legacy_evt_type != LE_ADV_INVALID) { 5200 if (legacy_evt_type != LE_ADV_INVALID) {
5177 process_adv_report(hdev, legacy_evt_type, &ev->bdaddr, 5201 process_adv_report(hdev, legacy_evt_type, &ev->bdaddr,
5178 ev->bdaddr_type, NULL, 0, ev->rssi, 5202 ev->bdaddr_type, NULL, 0, ev->rssi,