Loading...
Searching...
No Matches
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
9#pragma once
10
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include <stdint.h>
28#include <stdlib.h>
29#include "net/ipv6/addr.h"
30
32/* determine the widest possible address type */
33#ifndef UNIVERSAL_ADDRESS_SIZE
34#define UNIVERSAL_ADDRESS_SIZE (0) /* rather senseless default, should
35 trigger warnings */
36#endif
37
38/* IPv6 address has 128 bit -> 16 bytes */
39#if defined(MODULE_IPV6_ADDR) && ((IPV6_ADDR_BIT_LEN >> 3) > UNIVERSAL_ADDRESS_SIZE)
40#undef UNIVERSAL_ADDRESS_SIZE
41#define UNIVERSAL_ADDRESS_SIZE (IPV6_ADDR_BIT_LEN >> 3)
42#endif
43
45#define UNIVERSAL_ADDRESS_EQUAL (0)
46
48#define UNIVERSAL_ADDRESS_MATCHING_PREFIX (1)
49
53#define UNIVERSAL_ADDRESS_IS_ALL_ZERO_ADDRESS (2)
54
57 */
58typedef struct {
59 uint8_t use_count;
60 uint8_t address_size;
63
67void universal_address_init(void);
68
73
84universal_address_container_t *universal_address_add(uint8_t *addr, size_t addr_size);
85
93
106 uint8_t *addr, size_t *addr_size);
107
128 uint8_t *addr, size_t *addr_size_in_bits);
129
149 uint8_t *prefix, size_t prefix_size_in_bits);
150
157
162
167
168#ifdef __cplusplus
169}
170#endif
171
void universal_address_print_entry(universal_address_container_t *entry)
Print the content of the given entry.
void universal_address_init(void)
Initialize the data structure for the entries.
void universal_address_reset(void)
Resets the universal_address_container_t::use_count for all entries.
int universal_address_get_num_used_entries(void)
Return the number of used entries.
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_container_t * universal_address_add(uint8_t *addr, size_t addr_size)
Add a given address to the universal address entries.
#define UNIVERSAL_ADDRESS_SIZE
size of the used addresses in bytes
void universal_address_rem(universal_address_container_t *entry)
Add a given container from the universal address entries.
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...
void universal_address_print_table(void)
Print the content of the generic address table up to the used element.
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...
Definitions for IPv6 addresses.
The container descriptor used to identify a universal address entry.
uint8_t use_count
The number of entries link here.
uint8_t address[UNIVERSAL_ADDRESS_SIZE]
The generic address data.
uint8_t address_size
Size in bytes of the used generic address.