1f4854a5eSMatthias Ringwald /* 2f4854a5eSMatthias Ringwald * Copyright (C) 2019 BlueKitchen GmbH 3f4854a5eSMatthias Ringwald * 4f4854a5eSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5f4854a5eSMatthias Ringwald * modification, are permitted provided that the following conditions 6f4854a5eSMatthias Ringwald * are met: 7f4854a5eSMatthias Ringwald * 8f4854a5eSMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9f4854a5eSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10f4854a5eSMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11f4854a5eSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12f4854a5eSMatthias Ringwald * documentation and/or other materials provided with the distribution. 13f4854a5eSMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14f4854a5eSMatthias Ringwald * contributors may be used to endorse or promote products derived 15f4854a5eSMatthias Ringwald * from this software without specific prior written permission. 16f4854a5eSMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17f4854a5eSMatthias Ringwald * personal benefit and not for any commercial purpose or for 18f4854a5eSMatthias Ringwald * monetary gain. 19f4854a5eSMatthias Ringwald * 20f4854a5eSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21f4854a5eSMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22f4854a5eSMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*2fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24*2fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25f4854a5eSMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26f4854a5eSMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27f4854a5eSMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28f4854a5eSMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29f4854a5eSMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30f4854a5eSMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31f4854a5eSMatthias Ringwald * SUCH DAMAGE. 32f4854a5eSMatthias Ringwald * 33f4854a5eSMatthias Ringwald * Please inquire about commercial licensing options at 34f4854a5eSMatthias Ringwald * [email protected] 35f4854a5eSMatthias Ringwald * 36f4854a5eSMatthias Ringwald */ 37f4854a5eSMatthias Ringwald 38f4854a5eSMatthias Ringwald #ifndef __MESH_VIRTUAL_ADDRESSES_H 39f4854a5eSMatthias Ringwald #define __MESH_VIRTUAL_ADDRESSES_H 40f4854a5eSMatthias Ringwald 41f4854a5eSMatthias Ringwald #include <stdint.h> 42f4854a5eSMatthias Ringwald 43f4854a5eSMatthias Ringwald #include "btstack_linked_list.h" 44f4854a5eSMatthias Ringwald 45f4854a5eSMatthias Ringwald #ifdef __cplusplus 46f4854a5eSMatthias Ringwald extern "C" 47f4854a5eSMatthias Ringwald { 48f4854a5eSMatthias Ringwald #endif 49f4854a5eSMatthias Ringwald 50f4854a5eSMatthias Ringwald typedef struct { 51f4854a5eSMatthias Ringwald btstack_linked_item_t item; 52f4854a5eSMatthias Ringwald uint16_t pseudo_dst; 53f4854a5eSMatthias Ringwald uint16_t hash; 54f4854a5eSMatthias Ringwald uint16_t ref_count; 55f4854a5eSMatthias Ringwald uint8_t label_uuid[16]; 56f4854a5eSMatthias Ringwald } mesh_virtual_address_t; 57f4854a5eSMatthias Ringwald 58f4854a5eSMatthias Ringwald typedef struct { 59f4854a5eSMatthias Ringwald btstack_linked_list_iterator_t it; 60f4854a5eSMatthias Ringwald uint16_t hash; 61f4854a5eSMatthias Ringwald mesh_virtual_address_t * address; 62f4854a5eSMatthias Ringwald } mesh_virtual_address_iterator_t; 63f4854a5eSMatthias Ringwald 64f4854a5eSMatthias Ringwald // virtual address management 65f4854a5eSMatthias Ringwald 66f4854a5eSMatthias Ringwald uint16_t mesh_virtual_addresses_get_free_pseudo_dst(void); 67f4854a5eSMatthias Ringwald 68f4854a5eSMatthias Ringwald void mesh_virtual_address_add(mesh_virtual_address_t * virtual_address); 69f4854a5eSMatthias Ringwald 70f4854a5eSMatthias Ringwald void mesh_virtual_address_remove(mesh_virtual_address_t * virtual_address); 71f4854a5eSMatthias Ringwald 72f4854a5eSMatthias Ringwald mesh_virtual_address_t * mesh_virtual_address_register(uint8_t * label_uuid, uint16_t hash); 73f4854a5eSMatthias Ringwald 74f4854a5eSMatthias Ringwald mesh_virtual_address_t * mesh_virtual_address_for_pseudo_dst(uint16_t pseudo_dst); 75f4854a5eSMatthias Ringwald 76f4854a5eSMatthias Ringwald mesh_virtual_address_t * mesh_virtual_address_for_label_uuid(uint8_t * label_uuid); 77f4854a5eSMatthias Ringwald 78f4854a5eSMatthias Ringwald // virtual address iterator 79f4854a5eSMatthias Ringwald 80f4854a5eSMatthias Ringwald void mesh_virtual_address_iterator_init(mesh_virtual_address_iterator_t * it, uint16_t hash); 81f4854a5eSMatthias Ringwald 82f4854a5eSMatthias Ringwald int mesh_virtual_address_iterator_has_more(mesh_virtual_address_iterator_t * it); 83f4854a5eSMatthias Ringwald 84f4854a5eSMatthias Ringwald const mesh_virtual_address_t * mesh_virtual_address_iterator_get_next(mesh_virtual_address_iterator_t * it); 85f4854a5eSMatthias Ringwald 86f4854a5eSMatthias Ringwald 87f4854a5eSMatthias Ringwald #ifdef __cplusplus 88f4854a5eSMatthias Ringwald } /* end of extern "C" */ 89f4854a5eSMatthias Ringwald #endif 90f4854a5eSMatthias Ringwald 91f4854a5eSMatthias Ringwald #endif 92