Is your enhancement proposal related to a problem? Please describe.
We have several public APIs where are receive a bt_addr_le_t *addr, but we never check if the addr is valid before sending it on air or to the controller.
Describe the solution you'd like
Add a bool bt_addr_le_is_valid function that verifies if the address provided is valid. The easiest check to add for it is simply to verify that the type is valid, but the core spec may have additional requirements for valid addresses.
The check should then be added to all public functions where we have a bt_addr_le_t *addr as an argument like so
Additional context
Core spec, 5.4, vol 6, Part B adds additional requirements for some address.
For example for random device addresses, certain bits shall be set based on the type:
With additional requirements such as
These requirements should also be added to the function.
Functions such as int bt_addr_le_create_nrpa(bt_addr_le_t *addr) and int bt_addr_le_create_static(bt_addr_le_t *addr) should also use this function to verify that the address they generate is valid.
No objections to the feature proposal, but the name should really be bt_addr_le_is_valid() if it takes a bt_addr_le_t * as input (since we also have a bt_addr_t type).
Is your enhancement proposal related to a problem? Please describe. We have several public APIs where are receive a
bt_addr_le_t *addr
, but we never check if theaddr
is valid before sending it on air or to the controller.Describe the solution you'd like Add a
bool bt_addr_le_is_valid
function that verifies if the address provided is valid. The easiest check to add for it is simply to verify that thetype
is valid, but the core spec may have additional requirements for valid addresses.The check should then be added to all public functions where we have a
bt_addr_le_t *addr
as an argument like soDescribe alternatives you've considered N/A
Additional context Core spec, 5.4, vol 6, Part B adds additional requirements for some address. For example for random device addresses, certain bits shall be set based on the type:![image](https://github.com/zephyrproject-rtos/zephyr/assets/2520413/b5264576-8fd4-4f7d-8d58-6603ddb42939)
With additional requirements such as![image](https://github.com/zephyrproject-rtos/zephyr/assets/2520413/fd253d37-11b5-46c8-a54f-7c60c3e26c0f)
These requirements should also be added to the function.
Functions such as
int bt_addr_le_create_nrpa(bt_addr_le_t *addr)
andint bt_addr_le_create_static(bt_addr_le_t *addr)
should also use this function to verify that the address they generate is valid.