hci.c (c3d19a303edcfd5560dffe8ffd5730527778d815) | hci.c (e8ca66c6cea0a26e6ca0e60d31ab35c6be926aae) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 6194 unchanged lines hidden (view full) --- 6203 case LE_RESOLVING_LIST_READ_SIZE: 6204 hci_stack->le_resolving_list_state = LE_RESOLVING_LIST_SEND_CLEAR; 6205 hci_send_cmd(&hci_le_read_resolving_list_size); 6206 return true; 6207 case LE_RESOLVING_LIST_SEND_CLEAR: 6208 hci_stack->le_resolving_list_state = LE_RESOLVING_LIST_UPDATES_ENTRIES; 6209 (void) memset(hci_stack->le_resolving_list_add_entries, 0xff, 6210 sizeof(hci_stack->le_resolving_list_add_entries)); | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 6194 unchanged lines hidden (view full) --- 6203 case LE_RESOLVING_LIST_READ_SIZE: 6204 hci_stack->le_resolving_list_state = LE_RESOLVING_LIST_SEND_CLEAR; 6205 hci_send_cmd(&hci_le_read_resolving_list_size); 6206 return true; 6207 case LE_RESOLVING_LIST_SEND_CLEAR: 6208 hci_stack->le_resolving_list_state = LE_RESOLVING_LIST_UPDATES_ENTRIES; 6209 (void) memset(hci_stack->le_resolving_list_add_entries, 0xff, 6210 sizeof(hci_stack->le_resolving_list_add_entries)); |
6211 (void) memset(hci_stack->le_resolving_list_set_privacy_mode, 0xff, 6212 sizeof(hci_stack->le_resolving_list_set_privacy_mode)); |
|
6211 (void) memset(hci_stack->le_resolving_list_remove_entries, 0, 6212 sizeof(hci_stack->le_resolving_list_remove_entries)); 6213 hci_send_cmd(&hci_le_clear_resolving_list); 6214 return true; 6215 case LE_RESOLVING_LIST_UPDATES_ENTRIES: 6216 // first remove old entries 6217 for (i = 0; i < MAX_NUM_RESOLVING_LIST_ENTRIES && i < le_device_db_max_count(); i++) { 6218 uint8_t offset = i >> 3; --- 40 unchanged lines hidden (view full) --- 6259 uint8_t local_irk_flipped[16]; 6260 uint8_t peer_irk_flipped[16]; 6261 reverse_128(local_irk, local_irk_flipped); 6262 reverse_128(peer_irk, peer_irk_flipped); 6263 hci_send_cmd(&hci_le_add_device_to_resolving_list, peer_identity_addr_type, peer_identity_addreses, 6264 peer_irk_flipped, local_irk_flipped); 6265 return true; 6266 } | 6213 (void) memset(hci_stack->le_resolving_list_remove_entries, 0, 6214 sizeof(hci_stack->le_resolving_list_remove_entries)); 6215 hci_send_cmd(&hci_le_clear_resolving_list); 6216 return true; 6217 case LE_RESOLVING_LIST_UPDATES_ENTRIES: 6218 // first remove old entries 6219 for (i = 0; i < MAX_NUM_RESOLVING_LIST_ENTRIES && i < le_device_db_max_count(); i++) { 6220 uint8_t offset = i >> 3; --- 40 unchanged lines hidden (view full) --- 6261 uint8_t local_irk_flipped[16]; 6262 uint8_t peer_irk_flipped[16]; 6263 reverse_128(local_irk, local_irk_flipped); 6264 reverse_128(peer_irk, peer_irk_flipped); 6265 hci_send_cmd(&hci_le_add_device_to_resolving_list, peer_identity_addr_type, peer_identity_addreses, 6266 peer_irk_flipped, local_irk_flipped); 6267 return true; 6268 } |
6269 6270 // finally, set privacy mode 6271 for (i = 0; i < MAX_NUM_RESOLVING_LIST_ENTRIES && i < le_device_db_max_count(); i++) { 6272 uint8_t offset = i >> 3; 6273 uint8_t mask = 1 << (i & 7); 6274 if ((hci_stack->le_resolving_list_set_privacy_mode[offset] & mask) == 0) continue; 6275 hci_stack->le_resolving_list_set_privacy_mode[offset] &= ~mask; 6276 if (hci_stack->le_privacy_mode == LE_PRIVACY_MODE_NETWORK) { 6277 // Network Privacy Mode is default 6278 continue; 6279 } 6280 bd_addr_t peer_identity_address; 6281 int peer_identity_addr_type = (int) BD_ADDR_TYPE_UNKNOWN; 6282 sm_key_t peer_irk; 6283 le_device_db_info(i, &peer_identity_addr_type, peer_identity_address, peer_irk); 6284 if (peer_identity_addr_type == BD_ADDR_TYPE_UNKNOWN) continue; 6285 if (btstack_is_null(peer_irk, 16)) continue; 6286 // command uses format specifier 'P' that stores 16-byte value without flip 6287 uint8_t peer_irk_flipped[16]; 6288 reverse_128(peer_irk, peer_irk_flipped); 6289 hci_send_cmd(&hci_le_set_privacy_mode, peer_identity_addr_type, peer_identity_address, hci_stack->le_privacy_mode); 6290 return true; 6291 } |
|
6267 hci_stack->le_resolving_list_state = LE_RESOLVING_LIST_DONE; 6268 break; 6269 6270 default: 6271 break; 6272 } 6273 } 6274 hci_stack->le_resolving_list_state = LE_RESOLVING_LIST_DONE; --- 2814 unchanged lines hidden (view full) --- 9089 9090#ifdef ENABLE_LE_PRIVACY_ADDRESS_RESOLUTION 9091void hci_load_le_device_db_entry_into_resolving_list(uint16_t le_device_db_index){ 9092 if (le_device_db_index >= MAX_NUM_RESOLVING_LIST_ENTRIES) return; 9093 if (le_device_db_index >= le_device_db_max_count()) return; 9094 uint8_t offset = le_device_db_index >> 3; 9095 uint8_t mask = 1 << (le_device_db_index & 7); 9096 hci_stack->le_resolving_list_add_entries[offset] |= mask; | 6292 hci_stack->le_resolving_list_state = LE_RESOLVING_LIST_DONE; 6293 break; 6294 6295 default: 6296 break; 6297 } 6298 } 6299 hci_stack->le_resolving_list_state = LE_RESOLVING_LIST_DONE; --- 2814 unchanged lines hidden (view full) --- 9114 9115#ifdef ENABLE_LE_PRIVACY_ADDRESS_RESOLUTION 9116void hci_load_le_device_db_entry_into_resolving_list(uint16_t le_device_db_index){ 9117 if (le_device_db_index >= MAX_NUM_RESOLVING_LIST_ENTRIES) return; 9118 if (le_device_db_index >= le_device_db_max_count()) return; 9119 uint8_t offset = le_device_db_index >> 3; 9120 uint8_t mask = 1 << (le_device_db_index & 7); 9121 hci_stack->le_resolving_list_add_entries[offset] |= mask; |
9122 hci_stack->le_resolving_list_set_privacy_mode[offset] |= mask; |
|
9097 if (hci_stack->le_resolving_list_state == LE_RESOLVING_LIST_DONE){ 9098 // note: go back to remove entries, otherwise, a remove + add will skip the add 9099 hci_stack->le_resolving_list_state = LE_RESOLVING_LIST_UPDATES_ENTRIES; 9100 } 9101} 9102 9103void hci_remove_le_device_db_entry_from_resolving_list(uint16_t le_device_db_index){ 9104 if (le_device_db_index >= MAX_NUM_RESOLVING_LIST_ENTRIES) return; --- 873 unchanged lines hidden --- | 9123 if (hci_stack->le_resolving_list_state == LE_RESOLVING_LIST_DONE){ 9124 // note: go back to remove entries, otherwise, a remove + add will skip the add 9125 hci_stack->le_resolving_list_state = LE_RESOLVING_LIST_UPDATES_ENTRIES; 9126 } 9127} 9128 9129void hci_remove_le_device_db_entry_from_resolving_list(uint16_t le_device_db_index){ 9130 if (le_device_db_index >= MAX_NUM_RESOLVING_LIST_ENTRIES) return; --- 873 unchanged lines hidden --- |