[RFC v2 06/12] core: Check if device has RSI

Luiz Augusto von Dentz
2023-03-07T22:25:42Z

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This checks if device is advertising an RSI and if so disregards if it
is not discoverable since other members can be.
---
src/adapter.c | 4 ++--
src/eir.c | 3 +++
src/eir.h | 2 ++
3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index ae0eb364bad5..7947160a6c5c 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -7122,7 +7122,7 @@ void btd_adapter_update_found_device(struct btd_adapter *adapter,

dev = btd_adapter_find_device(adapter, bdaddr, bdaddr_type);
if (!dev) {
- if (!discoverable && !monitoring) {
+ if (!discoverable && !monitoring && !eir_data.rsi) {
eir_data_free(&eir_data);
return;
}
@@ -7169,7 +7169,7 @@ void btd_adapter_update_found_device(struct btd_adapter *adapter,
/* If there is no matched Adv monitors, don't continue if not
* discoverable or if active discovery filter don't match.
*/
- if (!monitoring && (!discoverable ||
+ if (!eir_data.rsi && !monitoring && (!discoverable ||
(adapter->filtered_discovery && !is_filter_match(
adapter->discovery_list, &eir_data, rssi)))) {
eir_data_free(&eir_data);
diff --git a/src/eir.c b/src/eir.c
index 2f9ee036ffd5..52152c0d7f52 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -236,6 +236,9 @@ static void eir_parse_data(struct eir_data *eir, uint8_t type,
memcpy(ad->data, data, len);

eir->data_list = g_slist_append(eir->data_list, ad);
+
+ if (type == EIR_CSIP_RSI)
+ eir->rsi = true;
}

void eir_parse(struct eir_data *eir, const uint8_t *eir_data, uint8_t eir_len)
diff --git a/src/eir.h b/src/eir.h
index 6154e23ec266..a4bf5fbd33f3 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -37,6 +37,7 @@
#define EIR_SVC_DATA32 0x20 /* LE: Service data, 32-bit UUID */
#define EIR_SVC_DATA128 0x21 /* LE: Service data, 128-bit UUID */
#define EIR_TRANSPORT_DISCOVERY 0x26 /* Transport Discovery Service */
+#define EIR_CSIP_RSI 0x2e /* Resolvable Set Identifier */
#define EIR_MANUFACTURER_DATA 0xFF /* Manufacturer Specific Data */

/* Flags Descriptions */
@@ -76,6 +77,7 @@ struct eir_data {
uint32_t class;
uint16_t appearance;
bool name_complete;
+ bool rsi;
int8_t tx_power;
uint8_t *hash;
uint8_t *randomizer;
--
2.39.2