universal_address.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Martin Landsmann <Martin.Landsmann@HAW-Hamburg.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
21 #ifndef UNIVERSAL_ADDRESS_H
22 #define UNIVERSAL_ADDRESS_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include <stdint.h>
29 #include <stdlib.h>
30 #include "net/ipv6/addr.h"
31 
33 /* determine the widest possible address type */
34 #ifndef UNIVERSAL_ADDRESS_SIZE
35 #define UNIVERSAL_ADDRESS_SIZE (0) /* rather senseless default, should
36  trigger warnings */
37 #endif
38 
39 /* IPv6 address has 128 bit -> 16 bytes */
40 #if defined(MODULE_IPV6_ADDR) && ((IPV6_ADDR_BIT_LEN >> 3) > UNIVERSAL_ADDRESS_SIZE)
41 #undef UNIVERSAL_ADDRESS_SIZE
42 #define UNIVERSAL_ADDRESS_SIZE (IPV6_ADDR_BIT_LEN >> 3)
43 #endif
44 
46 #define UNIVERSAL_ADDRESS_EQUAL (0)
47 
49 #define UNIVERSAL_ADDRESS_MATCHING_PREFIX (1)
50 
54 #define UNIVERSAL_ADDRESS_IS_ALL_ZERO_ADDRESS (2)
55 
59 typedef struct {
60  uint8_t use_count;
61  uint8_t address_size;
62  uint8_t address[UNIVERSAL_ADDRESS_SIZE];
64 
68 void universal_address_init(void);
69 
73 void universal_address_reset(void);
74 
85 universal_address_container_t *universal_address_add(uint8_t *addr, size_t addr_size);
86 
94 
107  uint8_t *addr, size_t *addr_size);
108 
129  uint8_t *addr, size_t *addr_size_in_bits);
130 
131 
151  uint8_t *prefix, size_t prefix_size_in_bits);
152 
159 
164 
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 
174 #endif /* UNIVERSAL_ADDRESS_H */
175 
UNIVERSAL_ADDRESS_SIZE
#define UNIVERSAL_ADDRESS_SIZE
size of the used addresses in bytes
Definition: universal_address.h:35
universal_address_print_entry
void universal_address_print_entry(universal_address_container_t *entry)
Print the content of the given entry.
universal_address_rem
void universal_address_rem(universal_address_container_t *entry)
Add a given container from the universal address entries.
universal_address_container_t
The container descriptor used to identify a universal address entry.
Definition: universal_address.h:58
addr.h
Definitions for IPv6 addresses.
universal_address_get_address
uint8_t * universal_address_get_address(universal_address_container_t *entry, uint8_t *addr, size_t *addr_size)
Copy the address from the given container to the provided pointer.
universal_address_compare_prefix
int universal_address_compare_prefix(universal_address_container_t *entry, uint8_t *prefix, size_t prefix_size_in_bits)
Determine if the entry equals the provided prefix This function requires to be provided with the full...
universal_address_reset
void universal_address_reset(void)
Resets the universal_address_container_t::use_count for all entries.
universal_address_compare
int universal_address_compare(universal_address_container_t *entry, uint8_t *addr, size_t *addr_size_in_bits)
Determine if the entry equals the provided address This function requires to be provided with the ful...
universal_address_add
universal_address_container_t * universal_address_add(uint8_t *addr, size_t addr_size)
Add a given address to the universal address entries.
universal_address_print_table
void universal_address_print_table(void)
Print the content of the generic address table up to the used element.
universal_address_init
void universal_address_init(void)
Initialize the data structure for the entries.
universal_address_get_num_used_entries
int universal_address_get_num_used_entries(void)
Return the number of used entries.