NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_ll_resolv.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef H_BLE_LL_RESOLV_
21#define H_BLE_LL_RESOLV_
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/*
28 * An entry in the resolving list.
29 * The identity address is stored in little endian format.
30 * The local rpa is stored in little endian format.
31 * The IRKs are stored in big endian format.
32 *
33 * Note:
34 * rl_local_irk and rl_peer_irk need to be word aligned
35 */
36struct ble_ll_resolv_entry
37{
38 uint8_t rl_addr_type;
39 uint8_t rl_priv_mode;
40 uint8_t rl_has_local;
41 uint8_t rl_has_peer;
42 uint8_t rl_local_irk[16];
43 uint8_t rl_peer_irk[16];
44 uint8_t rl_identity_addr[BLE_DEV_ADDR_LEN];
45 uint8_t rl_local_rpa[BLE_DEV_ADDR_LEN];
46 uint8_t rl_peer_rpa[BLE_DEV_ADDR_LEN];
47};
48
49extern struct ble_ll_resolv_entry g_ble_ll_resolv_list[];
50
51/* Clear the resolving list */
52int ble_ll_resolv_list_clr(void);
53
54/* Read the size of the resolving list */
55int ble_ll_resolv_list_read_size(uint8_t *rspbuf, uint8_t *rsplen);
56
57/* Add a device to the resolving list */
58int ble_ll_resolv_list_add(const uint8_t *cmdbuf, uint8_t len);
59
60/* Remove a device from the resolving list */
61int ble_ll_resolv_list_rmv(const uint8_t *cmdbuf, uint8_t len);
62
63/* Address resolution enable command */
64int ble_ll_resolv_enable_cmd(const uint8_t *cmdbuf, uint8_t len);
65
66int ble_ll_resolv_peer_addr_rd(const uint8_t *cmdbuf, uint8_t len,
67 uint8_t *rspbuf, uint8_t *rsplen);
68int ble_ll_resolv_local_addr_rd(const uint8_t *cmdbuf, uint8_t len,
69 uint8_t *rspbuf, uint8_t *rsplen);
70
71/* Finds 'addr' in resolving list. Doesnt check if address resolution enabled */
72struct ble_ll_resolv_entry *
73ble_ll_resolv_list_find(const uint8_t *addr, uint8_t addr_type);
74
75static inline int8_t
76ble_ll_resolv_get_idx(struct ble_ll_resolv_entry *rl)
77{
78 return rl - g_ble_ll_resolv_list;
79}
80
81/* Returns true if address resolution is enabled */
82uint8_t ble_ll_resolv_enabled(void);
83
84/* Reset private address resolution */
85void ble_ll_resolv_list_reset(void);
86
87/* Generate local or peer RPA. It is up to caller to make sure required IRK
88 * is present on RL
89 */
90void ble_ll_resolv_get_priv_addr(struct ble_ll_resolv_entry *rl, int local,
91 uint8_t *addr);
92
93void ble_ll_resolv_set_peer_rpa(int index, uint8_t *rpa);
94void ble_ll_resolv_set_local_rpa(int index, uint8_t *rpa);
95
96/* Generate a resolvable private address. */
97int ble_ll_resolv_gen_rpa(uint8_t *addr, uint8_t addr_type, uint8_t *rpa,
98 int local);
99
100/* Set the resolvable private address timeout */
101int ble_ll_resolv_set_rpa_tmo(const uint8_t *cmdbuf, uint8_t len);
102
103/* Set the privacy mode */
104int ble_ll_resolve_set_priv_mode(const uint8_t *cmdbuf, uint8_t len);
105
106/* Get the RPA timeout, in seconds */
107uint32_t ble_ll_resolv_get_rpa_tmo(void);
108
109/* Resolve a resolvable private address */
110int ble_ll_resolv_rpa(const uint8_t *rpa, const uint8_t *irk);
111
112/* Try to resolve peer RPA and return index on RL if matched */
113int ble_ll_resolv_peer_rpa_any(const uint8_t *rpa);
114
115/* Initialize resolv*/
116void ble_ll_resolv_init(void);
117
118#ifdef __cplusplus
119}
120#endif
121
122#endif