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 24 extern "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 struct ble_ll_resolv_entry 34 { 35 uint8_t rl_addr_type; 36 uint8_t rl_reserved; 37 uint8_t rl_priv_mode; 38 uint8_t rl_local_irk[16]; 39 uint8_t rl_peer_irk[16]; 40 uint8_t rl_identity_addr[BLE_DEV_ADDR_LEN]; 41 uint8_t rl_local_rpa[BLE_DEV_ADDR_LEN]; 42 uint8_t rl_peer_rpa[BLE_DEV_ADDR_LEN]; 43 }; 44 45 extern struct ble_ll_resolv_entry g_ble_ll_resolv_list[]; 46 47 /* Clear the resolving list */ 48 int ble_ll_resolv_list_clr(void); 49 50 /* Read the size of the resolving list */ 51 int ble_ll_resolv_list_read_size(uint8_t *rspbuf, uint8_t *rsplen); 52 53 /* Add a device to the resolving list */ 54 int ble_ll_resolv_list_add(uint8_t *cmdbuf); 55 56 /* Remove a device from the resolving list */ 57 int ble_ll_resolv_list_rmv(uint8_t *cmdbuf); 58 59 /* Address resolution enable command */ 60 int ble_ll_resolv_enable_cmd(uint8_t *cmdbuf); 61 62 int ble_ll_resolv_peer_addr_rd(uint8_t *cmdbuf, uint8_t *rspbuf, 63 uint8_t *rsplen); 64 int ble_ll_resolv_local_addr_rd(uint8_t *cmdbuf, uint8_t *rspbuf, 65 uint8_t *rsplen); 66 67 /* Finds 'addr' in resolving list. Doesnt check if address resolution enabled */ 68 struct ble_ll_resolv_entry * 69 ble_ll_resolv_list_find(uint8_t *addr, uint8_t addr_type); 70 71 /* Called to determine if the IRK is all zero. */ 72 int ble_ll_resolv_irk_nonzero(uint8_t *irk); 73 74 /* Returns true if address resolution is enabled */ 75 uint8_t ble_ll_resolv_enabled(void); 76 77 /* Reset private address resolution */ 78 void ble_ll_resolv_list_reset(void); 79 80 void ble_ll_resolv_get_priv_addr(struct ble_ll_resolv_entry *rl, int local, 81 uint8_t *addr); 82 83 void ble_ll_resolv_set_peer_rpa(int index, uint8_t *rpa); 84 85 /* Generate a resolvable private address. */ 86 int ble_ll_resolv_gen_rpa(uint8_t *addr, uint8_t addr_type, uint8_t *rpa, 87 int local); 88 89 /* Set the resolvable private address timeout */ 90 int ble_ll_resolv_set_rpa_tmo(uint8_t *cmdbuf); 91 92 /* Set the privacy mode */ 93 int ble_ll_resolve_set_priv_mode(uint8_t *cmdbuf); 94 95 /* Get the RPA timeout, in seconds */ 96 uint32_t ble_ll_resolv_get_rpa_tmo(void); 97 98 /* Resolve a resolvable private address */ 99 int ble_ll_resolv_rpa(uint8_t *rpa, uint8_t *irk); 100 101 /* Initialize resolv*/ 102 void ble_ll_resolv_init(void); 103 104 #ifdef __cplusplus 105 } 106 #endif 107 108 #endif 109