Bluetooth: LE advertising info caching
Subsystems (2)
RFC v2 2/4 Bluetooth: LE advertising info caching
From: Andre Guedes <[email protected]>
This patch implements a fixed-size circular list to store sensitive information (bdaddr and bdaddr_type so far) gathered from LE advertising report events.
The fixed-size circular list has max size equal to 64. Once the buffer reaches its max size, new advertising entries will replace old ones.
Signed-off-by Andre Guedes <[email protected]>
--- include/net/bluetooth/hci_core.h | 17 +++++++++ net/bluetooth/hci_core.c | 75 ++++++++++++++++++++++++++++++++++++++ net/bluetooth/hci_event.c | 5 +-- 3 files changed, 94 insertions(+), 3 deletions(-)
include/net/bluetooth/hci_core.h +17 -0
@@ -82,6 +82,18 @@ struct link_key {u8 pin_len; }; +struct adv_entry { +struct list_head list; +bdaddr_t bdaddr; +u8 bdaddr_type; +}; + +#define ADV_LIST_MAX_SIZE 64 +struct adv_list { +struct list_head list; +size_t size; +}; +#define NUM_REASSEMBLY 4struct hci_dev {struct list_head list;
@@ -171,6 +183,8 @@ struct hci_dev {struct list_head link_keys; +struct adv_list adv_entries; +struct hci_dev_stats stat;struct sk_buff_head driver_init;
@@ -504,6 +518,9 @@ int hci_add_link_key(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, u8 *key, u8 type, u8 pin_len);int hci_remove_link_key (struct hci_dev *hdev,bdaddr_t *bdaddr); +struct adv_entry *hci_find_adv_entry (struct hci_dev *hdev,bdaddr_t *bdaddr); +int hci_add_adv_entry (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 bdaddr_type); +void hci_del_off_timer (struct hci_dev *hdev);void hci_event_packet (struct hci_dev *hdev,struct sk_buff *skb);
net/bluetooth/hci_core.c +75 -0
93 lines not on this page · raw message
net/bluetooth/hci_event.c +2 -3
@@ -2507,12 +2507,11 @@ static inline void hci_le_adv_report_evt(struct hci_dev *hdev, num_reports = skb->data[0 ]; ev = (void *) &skb->data[1 ]; - -BT_DBG ("adv from: %s" ,batostr (&ev->bdaddr)); +hci_add_adv_entry (hdev, &ev->bdaddr, ev->bdaddr_type);for (i =1 ; i < num_reports; i++) { ev = (void *) (ev->data + ev->length +1 ); -BT_DBG ("adv from: %s" ,batostr (&ev->bdaddr)); +hci_add_adv_entry (hdev, &ev->bdaddr, ev->bdaddr_type); } }
Signature · 1 line
1.7.1