Skip to content

Commit ec2808b

Browse files
paul-szczepanek-armpan-
authored andcommitted
filter based on resolving list size
1 parent 4572688 commit ec2808b

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

connectivity/FEATURE_BLE/source/generic/GapImpl.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,6 +2555,13 @@ void Gap::signal_advertising_report(
25552555
}
25562556
}
25572557
#else
2558+
/* filter out unresolved address if at least one bond exists */
2559+
if (_address_registry.read_resolving_list_size() > 0 &&
2560+
_central_privacy_configuration.resolution_strategy == central_privacy_configuration_t::RESOLVE_AND_FILTER &&
2561+
event.getPeerAddressType() != peer_address_type_t::PUBLIC &&
2562+
is_random_private_resolvable_address(event.getPeerAddress())) {
2563+
return;
2564+
}
25582565
_event_handler->onAdvertisingReport(
25592566
event
25602567
);
@@ -2572,15 +2579,15 @@ void Gap::conclude_signal_advertising_report_after_address_resolution(
25722579
{
25732580
/* fix the report with the new address if there's an identity found */
25742581
if (identity_address) {
2575-
/* filter out resolved address based on policy */
2576-
if (_central_privacy_configuration.resolution_strategy ==
2577-
central_privacy_configuration_t::RESOLVE_AND_FILTER) {
2578-
return;
2579-
}
25802582
event.setPeerAddress(*identity_address);
25812583
event.setPeerAddressType(identity_address_type == target_peer_address_type_t::RANDOM ?
25822584
peer_address_type_t::RANDOM_STATIC_IDENTITY
25832585
: peer_address_type_t::PUBLIC_IDENTITY);
2586+
} else if (_central_privacy_configuration.resolution_strategy ==
2587+
central_privacy_configuration_t::RESOLVE_AND_FILTER &&
2588+
_address_registry.read_resolving_list_size() > 0) {
2589+
/* filter out unresolved address if at least one bond exists */
2590+
return;
25842591
}
25852592

25862593
_event_handler->onAdvertisingReport(event);

connectivity/FEATURE_BLE/source/generic/PrivateAddressController.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ uint8_t PrivateAddressController::read_resolving_list_capacity()
155155
#endif //BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
156156
}
157157

158+
uint8_t PrivateAddressController::read_resolving_list_size()
159+
{
160+
return _resolving_list_size;
161+
}
162+
158163
ble_error_t PrivateAddressController::add_device_to_resolving_list(
159164
target_peer_address_type_t peer_address_type,
160165
const address_t &peer_identity_address,
@@ -185,6 +190,7 @@ ble_error_t PrivateAddressController::add_device_to_resolving_list(
185190
entry.peer_irk = peer_irk;
186191
entry.populated = true;
187192
entry_added = true;
193+
_resolving_list_size++;
188194
break;
189195
}
190196
}
@@ -234,6 +240,7 @@ ble_error_t PrivateAddressController::remove_device_from_resolving_list(
234240
});
235241

236242
entry.populated = false;
243+
_resolving_list_size--;
237244

238245
restart_resolution_process_on_host();
239246
}
@@ -259,6 +266,7 @@ ble_error_t PrivateAddressController::clear_resolving_list()
259266
remove_resolution_entry_from_cache([&](resolution_entry_t& entry) {
260267
return entry.identity != nullptr;
261268
});
269+
_resolving_list_size = 0;
262270

263271
restart_resolution_process_on_host();
264272

@@ -380,6 +388,7 @@ struct PrivateAddressController::PrivacyAddDevToResListControlBlock final :
380388
_peer_irk,
381389
self._local_irk
382390
);
391+
self._resolving_list_size++;
383392
return false;
384393
}
385394

@@ -428,6 +437,7 @@ struct PrivateAddressController::PrivacyRemoveDevFromResListControlBlock final :
428437
_peer_identity_address_type,
429438
_peer_identity_address
430439
);
440+
self._resolving_list_size--;
431441
return false;
432442
}
433443

@@ -464,6 +474,7 @@ struct PrivateAddressController::PrivacyClearResListControlBlock final :
464474
{
465475
// Execute command
466476
self._pal.clear_resolving_list();
477+
self._resolving_list_size = 0;
467478
return false;
468479
}
469480
};

connectivity/FEATURE_BLE/source/generic/PrivateAddressController.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,15 @@ class PrivateAddressController : private PalPrivateAddressController::EventHandl
148148
#endif //!BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
149149

150150
/**
151-
* Read the number of entry that can be put in the resolving list.
151+
* Read the number of entries that can be put in the resolving list.
152152
*/
153153
uint8_t read_resolving_list_capacity();
154154

155+
/**
156+
* Read the number of entries that are in the resolving list.
157+
*/
158+
uint8_t read_resolving_list_size();
159+
155160
/**
156161
* Add a new peer to the resolving list.
157162
* @param peer_address_type The type of the peer's identity address.
@@ -313,6 +318,8 @@ class PrivateAddressController : private PalPrivateAddressController::EventHandl
313318
PrivacyControlBlock *_pending_privacy_control_blocks = nullptr;
314319
bool _processing_privacy_control_block = false;
315320

321+
uint8_t _resolving_list_size = 0;
322+
316323
#if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
317324
struct resolving_list_entry_t {
318325
address_t peer_address = {};

0 commit comments

Comments
 (0)