mesh_keys.c (6535961a1f105e850ecdf294c128b9fc982ee05a) | mesh_keys.c (ff3cc4a5378c2f681cc9b75cf54d154a12a3051e) |
---|---|
1/* 2 * Copyright (C) 2019 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 --- 96 unchanged lines hidden (view full) --- 105void mesh_network_key_nid_iterator_init(mesh_network_key_iterator_t *it, uint8_t nid){ 106 btstack_linked_list_iterator_init(&it->it, &network_keys); 107 it->key = NULL; 108 it->nid = nid; 109} 110 111int mesh_network_key_nid_iterator_has_more(mesh_network_key_iterator_t *it){ 112 // find next matching key | 1/* 2 * Copyright (C) 2019 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 --- 96 unchanged lines hidden (view full) --- 105void mesh_network_key_nid_iterator_init(mesh_network_key_iterator_t *it, uint8_t nid){ 106 btstack_linked_list_iterator_init(&it->it, &network_keys); 107 it->key = NULL; 108 it->nid = nid; 109} 110 111int mesh_network_key_nid_iterator_has_more(mesh_network_key_iterator_t *it){ 112 // find next matching key |
113 while (1){ | 113 while (true){ |
114 if (it->key && it->key->nid == it->nid) return 1; 115 if (!btstack_linked_list_iterator_has_next(&it->it)) break; 116 it->key = (mesh_network_key_t *) btstack_linked_list_iterator_next(&it->it); 117 } 118 return 0; 119} 120 121mesh_network_key_t * mesh_network_key_nid_iterator_get_next(mesh_network_key_iterator_t *it){ --- 61 unchanged lines hidden (view full) --- 183void mesh_transport_key_iterator_init(mesh_transport_key_iterator_t *it, uint16_t netkey_index){ 184 btstack_linked_list_iterator_init(&it->it, &application_keys); 185 it->netkey_index = netkey_index; 186 it->key = NULL; 187} 188 189int mesh_transport_key_iterator_has_more(mesh_transport_key_iterator_t *it){ 190 // find next matching key | 114 if (it->key && it->key->nid == it->nid) return 1; 115 if (!btstack_linked_list_iterator_has_next(&it->it)) break; 116 it->key = (mesh_network_key_t *) btstack_linked_list_iterator_next(&it->it); 117 } 118 return 0; 119} 120 121mesh_network_key_t * mesh_network_key_nid_iterator_get_next(mesh_network_key_iterator_t *it){ --- 61 unchanged lines hidden (view full) --- 183void mesh_transport_key_iterator_init(mesh_transport_key_iterator_t *it, uint16_t netkey_index){ 184 btstack_linked_list_iterator_init(&it->it, &application_keys); 185 it->netkey_index = netkey_index; 186 it->key = NULL; 187} 188 189int mesh_transport_key_iterator_has_more(mesh_transport_key_iterator_t *it){ 190 // find next matching key |
191 while (1){ | 191 while (true){ |
192 if (it->key && it->key->netkey_index == it->netkey_index) return 1; 193 if (!btstack_linked_list_iterator_has_next(&it->it)) break; 194 it->key = (mesh_transport_key_t *) btstack_linked_list_iterator_next(&it->it); 195 } 196 return 0; 197} 198 199mesh_transport_key_t * mesh_transport_key_iterator_get_next(mesh_transport_key_iterator_t *it){ --- 15 unchanged lines hidden (view full) --- 215 } 216} 217 218int mesh_transport_key_aid_iterator_has_more(mesh_transport_key_iterator_t *it){ 219 if (it->akf == 0){ 220 return it->key != NULL; 221 } 222 // find next matching key | 192 if (it->key && it->key->netkey_index == it->netkey_index) return 1; 193 if (!btstack_linked_list_iterator_has_next(&it->it)) break; 194 it->key = (mesh_transport_key_t *) btstack_linked_list_iterator_next(&it->it); 195 } 196 return 0; 197} 198 199mesh_transport_key_t * mesh_transport_key_iterator_get_next(mesh_transport_key_iterator_t *it){ --- 15 unchanged lines hidden (view full) --- 215 } 216} 217 218int mesh_transport_key_aid_iterator_has_more(mesh_transport_key_iterator_t *it){ 219 if (it->akf == 0){ 220 return it->key != NULL; 221 } 222 // find next matching key |
223 while (1){ | 223 while (true){ |
224 if (it->key && it->key->aid == it->aid && it->key->netkey_index == it->netkey_index) return 1; 225 if (!btstack_linked_list_iterator_has_next(&it->it)) break; 226 it->key = (mesh_transport_key_t *) btstack_linked_list_iterator_next(&it->it); 227 } 228 return 0; 229} 230 231mesh_transport_key_t * mesh_transport_key_aid_iterator_get_next(mesh_transport_key_iterator_t *it){ 232 mesh_transport_key_t * key = it->key; 233 it->key = NULL; 234 return key; 235} | 224 if (it->key && it->key->aid == it->aid && it->key->netkey_index == it->netkey_index) return 1; 225 if (!btstack_linked_list_iterator_has_next(&it->it)) break; 226 it->key = (mesh_transport_key_t *) btstack_linked_list_iterator_next(&it->it); 227 } 228 return 0; 229} 230 231mesh_transport_key_t * mesh_transport_key_aid_iterator_get_next(mesh_transport_key_iterator_t *it){ 232 mesh_transport_key_t * key = it->key; 233 it->key = NULL; 234 return key; 235} |