Skip to content

nimble/ll: Introduce ble_ll_addr #2015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
6 changes: 0 additions & 6 deletions nimble/controller/include/controller/ble_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@ uint8_t ble_hw_resolv_list_size(void);
/* Returns index of resolved address; -1 if not resolved */
int ble_hw_resolv_list_match(void);

/* Returns public device address or -1 if not present */
int ble_hw_get_public_addr(ble_addr_t *addr);

/* Returns random static address or -1 if not present */
int ble_hw_get_static_addr(ble_addr_t *addr);

#ifdef __cplusplus
}
#endif
Expand Down
16 changes: 0 additions & 16 deletions nimble/controller/include/controller/ble_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,16 +517,6 @@ struct ble_ll_acad_channel_map_update_ind {
/* Reset the Link Layer */
int ble_ll_reset(void);

/* 'Boolean' function returning true if address is a valid random address */
int ble_ll_is_valid_random_addr(const uint8_t *addr);

/*
* Check if given own_addr_type is valid for current controller configuration
* given the random address provided (when applicable)
*/
int ble_ll_is_valid_own_addr_type(uint8_t own_addr_type,
const uint8_t *random_addr);

/* Calculate maximum octets of PDU payload which can be transmitted during
* 'usecs' on a PHY 'phy_mode'. */
uint16_t ble_ll_pdu_max_tx_octets_get(uint32_t usecs, int phy_mode);
Expand All @@ -539,12 +529,6 @@ int ble_ll_addr_subtype(const uint8_t *addr, uint8_t addr_type);
/* Is this address an identity address? */
int ble_ll_addr_is_id(uint8_t *addr, uint8_t addr_type);

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

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

/**
* Called to put a packet on the Link Layer transmit packet queue.
*
Expand Down
52 changes: 52 additions & 0 deletions nimble/controller/include/controller/ble_ll_addr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#ifndef H_BLE_LL_ADDR_
#define H_BLE_LL_ADDR_

#include <stdbool.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

int ble_ll_addr_init(void);
int ble_ll_addr_public_set(const uint8_t *addr);

const uint8_t *ble_ll_addr_get(uint8_t addr_type);
const uint8_t *ble_ll_addr_public_get(void);
const uint8_t *ble_ll_addr_random_get(void);
int ble_ll_addr_random_set(const uint8_t *addr);

bool ble_ll_addr_is_our(int addr_type, const uint8_t *addr);
bool ble_ll_addr_is_valid_own_addr_type(uint8_t addr_type,
const uint8_t *random_addr);

/* Address provider APIs - should be implemented by packages supporting
* relevant APIs
*/
int ble_ll_addr_provide_public(uint8_t *addr);
int ble_ll_addr_provide_static(uint8_t *addr);

#ifdef __cplusplus
}
#endif

#endif /* H_BLE_LL_ADDR_ */
2 changes: 1 addition & 1 deletion nimble/controller/include/controller/ble_ll_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ void ble_ll_conn_send_connect_req_cancel(void);
/* Signal connection created via CONNECT_IND */
void ble_ll_conn_created_on_legacy(struct os_mbuf *rxpdu,
struct ble_ll_scan_addr_data *addrd,
uint8_t *targeta);
const uint8_t *targeta);
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
/* Signal connection created via AUX_CONNECT_REQ */
void ble_ll_conn_created_on_aux(struct os_mbuf *rxpdu,
Expand Down
4 changes: 2 additions & 2 deletions nimble/controller/include/controller/ble_ll_resolv.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ void ble_ll_resolv_list_reset(void);
void ble_ll_resolv_get_priv_addr(struct ble_ll_resolv_entry *rl, int local,
uint8_t *addr);

void ble_ll_resolv_set_peer_rpa(int index, uint8_t *rpa);
void ble_ll_resolv_set_local_rpa(int index, uint8_t *rpa);
void ble_ll_resolv_set_peer_rpa(int index, const uint8_t *rpa);
void ble_ll_resolv_set_local_rpa(int index, const uint8_t *rpa);

/* Generate a resolvable private address. */
int ble_ll_resolv_gen_rpa(uint8_t *addr, uint8_t addr_type, uint8_t *rpa,
Expand Down
24 changes: 12 additions & 12 deletions nimble/controller/include/controller/ble_ll_scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ struct ble_ll_scan_vs_config {
};

struct ble_ll_scan_addr_data {
uint8_t *adva;
uint8_t *targeta;
uint8_t *adv_addr;
const uint8_t *adva;
const uint8_t *targeta;
const uint8_t *adv_addr;
uint8_t adva_type : 1;
uint8_t targeta_type : 1;
uint8_t adv_addr_type : 1;
Expand Down Expand Up @@ -223,7 +223,7 @@ ble_ll_scan_initiator_start(struct ble_ll_conn_sm *connsm, uint8_t ext,
struct ble_ll_scan_pdu_data *ble_ll_scan_get_pdu_data(void);

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

/* Returns peer RPA of last connection made */
uint8_t *ble_ll_scan_get_peer_rpa(void);
Expand Down Expand Up @@ -256,14 +256,14 @@ uint8_t ble_ll_scan_get_filt_dups(void);
uint8_t ble_ll_scan_backoff_kick(void);
void ble_ll_scan_backoff_update(int success);

int ble_ll_scan_dup_check_ext(uint8_t addr_type, uint8_t *addr, bool has_aux,
uint16_t adi);
int ble_ll_scan_dup_update_ext(uint8_t addr_type, uint8_t *addr, bool has_aux,
uint16_t adi);
int ble_ll_scan_have_rxd_scan_rsp(uint8_t *addr, uint8_t txadd, uint8_t ext_adv,
uint16_t adi);
void ble_ll_scan_add_scan_rsp_adv(uint8_t *addr, uint8_t txadd, uint8_t ext_adv,
uint16_t adi);
int ble_ll_scan_dup_check_ext(uint8_t addr_type, const uint8_t *addr,
bool has_aux, uint16_t adi);
int ble_ll_scan_dup_update_ext(uint8_t addr_type, const uint8_t *addr,
bool has_aux, uint16_t adi);
int ble_ll_scan_have_rxd_scan_rsp(const uint8_t *addr, uint8_t txadd,
uint8_t ext_adv, uint16_t adi);
void ble_ll_scan_add_scan_rsp_adv(const uint8_t *addr, uint8_t txadd,
uint8_t ext_adv, uint16_t adi);

struct ble_ll_scan_sm *ble_ll_scan_sm_get(void);

Expand Down
2 changes: 1 addition & 1 deletion nimble/controller/include/controller/ble_ll_whitelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void ble_ll_whitelist_enable(void);
void ble_ll_whitelist_disable(void);

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

#ifdef __cplusplus
}
Expand Down
Loading
Loading