Skip to content

Commit 694171b

Browse files
nimble/ll: Use const for addr parameters
In general we should pass any addr parameter to function as const since we only rarely need to modify its contents and the address itself may point to our device address which we never want to be able to modify from outsied ble_ll_addr by mistake...
1 parent 8ee043c commit 694171b

File tree

10 files changed

+32
-30
lines changed

10 files changed

+32
-30
lines changed

nimble/controller/include/controller/ble_ll.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ int ble_ll_addr_subtype(const uint8_t *addr, uint8_t addr_type);
540540
int ble_ll_addr_is_id(uint8_t *addr, uint8_t addr_type);
541541

542542
/* Is 'addr' our device address? 'addr_type' is public (0) or random (!=0) */
543-
int ble_ll_is_our_devaddr(uint8_t *addr, int addr_type);
543+
int ble_ll_is_our_devaddr(const uint8_t* addr, int addr_type);
544544

545545
/* Get identity address 'addr_type' is public (0) or random (!=0) */
546546
uint8_t *ble_ll_get_our_devaddr(uint8_t addr_type);

nimble/controller/include/controller/ble_ll_conn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ void ble_ll_conn_send_connect_req_cancel(void);
483483
/* Signal connection created via CONNECT_IND */
484484
void ble_ll_conn_created_on_legacy(struct os_mbuf *rxpdu,
485485
struct ble_ll_scan_addr_data *addrd,
486-
uint8_t *targeta);
486+
const uint8_t* targeta);
487487
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
488488
/* Signal connection created via AUX_CONNECT_REQ */
489489
void ble_ll_conn_created_on_aux(struct os_mbuf *rxpdu,

nimble/controller/include/controller/ble_ll_resolv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ void ble_ll_resolv_list_reset(void);
9090
void ble_ll_resolv_get_priv_addr(struct ble_ll_resolv_entry *rl, int local,
9191
uint8_t *addr);
9292

93-
void ble_ll_resolv_set_peer_rpa(int index, uint8_t *rpa);
94-
void ble_ll_resolv_set_local_rpa(int index, uint8_t *rpa);
93+
void ble_ll_resolv_set_peer_rpa(int index, const uint8_t* rpa);
94+
void ble_ll_resolv_set_local_rpa(int index, const uint8_t* rpa);
9595

9696
/* Generate a resolvable private address. */
9797
int ble_ll_resolv_gen_rpa(uint8_t *addr, uint8_t addr_type, uint8_t *rpa,

nimble/controller/include/controller/ble_ll_scan.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ struct ble_ll_scan_vs_config {
108108
};
109109

110110
struct ble_ll_scan_addr_data {
111-
uint8_t *adva;
112-
uint8_t *targeta;
113-
uint8_t *adv_addr;
111+
const uint8_t *adva;
112+
const uint8_t *targeta;
113+
const uint8_t *adv_addr;
114114
uint8_t adva_type : 1;
115115
uint8_t targeta_type : 1;
116116
uint8_t adv_addr_type : 1;
@@ -223,7 +223,7 @@ ble_ll_scan_initiator_start(struct ble_ll_conn_sm *connsm, uint8_t ext,
223223
struct ble_ll_scan_pdu_data *ble_ll_scan_get_pdu_data(void);
224224

225225
/* Called to set the resolvable private address of the last connected peer */
226-
void ble_ll_scan_set_peer_rpa(uint8_t *rpa);
226+
void ble_ll_scan_set_peer_rpa(const uint8_t* rpa);
227227

228228
/* Returns peer RPA of last connection made */
229229
uint8_t *ble_ll_scan_get_peer_rpa(void);
@@ -256,14 +256,14 @@ uint8_t ble_ll_scan_get_filt_dups(void);
256256
uint8_t ble_ll_scan_backoff_kick(void);
257257
void ble_ll_scan_backoff_update(int success);
258258

259-
int ble_ll_scan_dup_check_ext(uint8_t addr_type, uint8_t *addr, bool has_aux,
260-
uint16_t adi);
261-
int ble_ll_scan_dup_update_ext(uint8_t addr_type, uint8_t *addr, bool has_aux,
262-
uint16_t adi);
263-
int ble_ll_scan_have_rxd_scan_rsp(uint8_t *addr, uint8_t txadd, uint8_t ext_adv,
264-
uint16_t adi);
265-
void ble_ll_scan_add_scan_rsp_adv(uint8_t *addr, uint8_t txadd, uint8_t ext_adv,
266-
uint16_t adi);
259+
int ble_ll_scan_dup_check_ext(uint8_t addr_type, const uint8_t* addr,
260+
bool has_aux, uint16_t adi);
261+
int ble_ll_scan_dup_update_ext(uint8_t addr_type, const uint8_t* addr,
262+
bool has_aux, uint16_t adi);
263+
int ble_ll_scan_have_rxd_scan_rsp(const uint8_t* addr, uint8_t txadd,
264+
uint8_t ext_adv, uint16_t adi);
265+
void ble_ll_scan_add_scan_rsp_adv(const uint8_t* addr, uint8_t txadd,
266+
uint8_t ext_adv, uint16_t adi);
267267

268268
struct ble_ll_scan_sm *ble_ll_scan_sm_get(void);
269269

nimble/controller/include/controller/ble_ll_whitelist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void ble_ll_whitelist_enable(void);
4343
void ble_ll_whitelist_disable(void);
4444

4545
/* Boolean function returning true if address matches a whitelist entry */
46-
int ble_ll_whitelist_match(uint8_t *addr, uint8_t addr_type, int is_ident);
46+
int ble_ll_whitelist_match(const uint8_t* addr, uint8_t addr_type, int is_ident);
4747

4848
#ifdef __cplusplus
4949
}

nimble/controller/src/ble_ll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ ble_ll_set_random_addr(const uint8_t *cmdbuf, uint8_t len, bool hci_adv_ext)
717717
* @return int 0: not our device address. 1: is our device address
718718
*/
719719
int
720-
ble_ll_is_our_devaddr(uint8_t *addr, int addr_type)
720+
ble_ll_is_our_devaddr(const uint8_t* addr, int addr_type)
721721
{
722722
int rc;
723723
uint8_t *our_addr;

nimble/controller/src/ble_ll_conn.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,7 +3304,8 @@ ble_ll_conn_send_connect_req_cancel(void)
33043304

33053305
static void
33063306
ble_ll_conn_central_start(uint8_t phy, uint8_t csa,
3307-
struct ble_ll_scan_addr_data *addrd, uint8_t *targeta)
3307+
struct ble_ll_scan_addr_data *addrd,
3308+
const uint8_t *targeta)
33083309
{
33093310
struct ble_ll_conn_sm *connsm;
33103311

@@ -3340,7 +3341,7 @@ ble_ll_conn_central_start(uint8_t phy, uint8_t csa,
33403341
void
33413342
ble_ll_conn_created_on_legacy(struct os_mbuf *rxpdu,
33423343
struct ble_ll_scan_addr_data *addrd,
3343-
uint8_t *targeta)
3344+
const uint8_t* targeta)
33443345
{
33453346
uint8_t *rxbuf;
33463347
uint8_t csa;

nimble/controller/src/ble_ll_resolv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ ble_ll_resolv_get_priv_addr(struct ble_ll_resolv_entry *rl, int local,
621621
}
622622

623623
void
624-
ble_ll_resolv_set_peer_rpa(int index, uint8_t *rpa)
624+
ble_ll_resolv_set_peer_rpa(int index, const uint8_t* rpa)
625625
{
626626
os_sr_t sr;
627627
struct ble_ll_resolv_entry *rl;
@@ -633,7 +633,7 @@ ble_ll_resolv_set_peer_rpa(int index, uint8_t *rpa)
633633
}
634634

635635
void
636-
ble_ll_resolv_set_local_rpa(int index, uint8_t *rpa)
636+
ble_ll_resolv_set_local_rpa(int index, const uint8_t* rpa)
637637
{
638638
os_sr_t sr;
639639
struct ble_ll_resolv_entry *rl;

nimble/controller/src/ble_ll_scan.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ ble_ll_scan_halt(void)
391391
* @return int 0: have not received a scan response; 1 otherwise.
392392
*/
393393
int
394-
ble_ll_scan_have_rxd_scan_rsp(uint8_t *addr, uint8_t txadd,
394+
ble_ll_scan_have_rxd_scan_rsp(const uint8_t* addr, uint8_t txadd,
395395
uint8_t ext_adv, uint16_t adi)
396396
{
397397
uint8_t num_advs;
@@ -435,7 +435,7 @@ ble_ll_scan_have_rxd_scan_rsp(uint8_t *addr, uint8_t txadd,
435435

436436
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
437437
void
438-
ble_ll_scan_add_scan_rsp_adv(uint8_t *addr, uint8_t txadd,
438+
ble_ll_scan_add_scan_rsp_adv(const uint8_t* addr, uint8_t txadd,
439439
uint8_t ext_adv, uint16_t adi)
440440
{
441441
uint8_t num_advs;
@@ -1800,7 +1800,8 @@ ble_ll_scan_dup_new(void)
18001800
}
18011801

18021802
static int
1803-
ble_ll_scan_dup_check_legacy(uint8_t addr_type, uint8_t *addr, uint8_t pdu_type)
1803+
ble_ll_scan_dup_check_legacy(uint8_t addr_type, const uint8_t* addr,
1804+
uint8_t pdu_type)
18041805
{
18051806
struct ble_ll_scan_dup_entry *e;
18061807
uint8_t type;
@@ -1840,7 +1841,7 @@ ble_ll_scan_dup_check_legacy(uint8_t addr_type, uint8_t *addr, uint8_t pdu_type)
18401841

18411842
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
18421843
int
1843-
ble_ll_scan_dup_check_ext(uint8_t addr_type, uint8_t *addr, bool has_aux,
1844+
ble_ll_scan_dup_check_ext(uint8_t addr_type, const uint8_t* addr, bool has_aux,
18441845
uint16_t adi)
18451846
{
18461847
struct ble_ll_scan_dup_entry *e;
@@ -1889,7 +1890,7 @@ ble_ll_scan_dup_check_ext(uint8_t addr_type, uint8_t *addr, bool has_aux,
18891890
}
18901891

18911892
int
1892-
ble_ll_scan_dup_update_ext(uint8_t addr_type, uint8_t *addr, bool has_aux,
1893+
ble_ll_scan_dup_update_ext(uint8_t addr_type, const uint8_t* addr, bool has_aux,
18931894
uint16_t adi)
18941895
{
18951896
struct ble_ll_scan_dup_entry *e;
@@ -2010,7 +2011,7 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
20102011
struct ble_mbuf_hdr_rxinfo *rxinfo = &hdr->rxinfo;
20112012
#endif
20122013
#if MYNEWT_VAL(BLE_LL_ROLE_CENTRAL)
2013-
uint8_t *targeta;
2014+
const uint8_t *targeta;
20142015
#endif
20152016
struct ble_ll_scan_sm *scansm;
20162017
struct ble_ll_scan_addr_data addrd;
@@ -2710,7 +2711,7 @@ ble_ll_scan_get_local_rpa(void)
27102711
* @param rpa
27112712
*/
27122713
void
2713-
ble_ll_scan_set_peer_rpa(uint8_t *rpa)
2714+
ble_ll_scan_set_peer_rpa(const uint8_t *rpa)
27142715
{
27152716
struct ble_ll_scan_sm *scansm;
27162717

nimble/controller/src/ble_ll_whitelist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ ble_ll_whitelist_search(const uint8_t *addr, uint8_t addr_type)
164164
* @return int
165165
*/
166166
int
167-
ble_ll_whitelist_match(uint8_t *addr, uint8_t addr_type, int is_ident)
167+
ble_ll_whitelist_match(const uint8_t* addr, uint8_t addr_type, int is_ident)
168168
{
169169
int rc;
170170
#if (BLE_USES_HW_WHITELIST == 1)

0 commit comments

Comments
 (0)