Loading...
Searching...
No Matches
Universal Address Container

universal address container More...

Detailed Description

universal address container

Files

file  universal_address.h
 Types and functions for operating universal addresses.
 

Data Structures

struct  universal_address_container_t
 The container descriptor used to identify a universal address entry. More...
 

Macros

#define UNIVERSAL_ADDRESS_SIZE
 size of the used addresses in bytes
 
#define UNIVERSAL_ADDRESS_EQUAL   (0)
 return value indicating the compared addresses are equal
 
#define UNIVERSAL_ADDRESS_MATCHING_PREFIX   (1)
 return value indicating the compared addresses match up to a certain prefix
 
#define UNIVERSAL_ADDRESS_IS_ALL_ZERO_ADDRESS   (2)
 return value indicating all address bits of the entry are 0.
 

Functions

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.
 
universal_address_container_tuniversal_address_add (uint8_t *addr, size_t addr_size)
 Add a given address to the universal address entries.
 
void universal_address_rem (universal_address_container_t *entry)
 Add a given container from the universal address 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.
 
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 full size of the used address type behind addr to be comparable with the address stored in entry.
 
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 size of the used address type behind prefix to be comparable with the address stored in entry.
 
void universal_address_print_entry (universal_address_container_t *entry)
 Print the content of the given entry.
 
int universal_address_get_num_used_entries (void)
 Return the number of used entries.
 
void universal_address_print_table (void)
 Print the content of the generic address table up to the used element.
 

Macro Definition Documentation

◆ UNIVERSAL_ADDRESS_EQUAL

#define UNIVERSAL_ADDRESS_EQUAL   (0)

return value indicating the compared addresses are equal

Definition at line 45 of file universal_address.h.

◆ UNIVERSAL_ADDRESS_IS_ALL_ZERO_ADDRESS

#define UNIVERSAL_ADDRESS_IS_ALL_ZERO_ADDRESS   (2)

return value indicating all address bits of the entry are 0.

Its considered as default route address that matches any other prefix.

Definition at line 53 of file universal_address.h.

◆ UNIVERSAL_ADDRESS_MATCHING_PREFIX

#define UNIVERSAL_ADDRESS_MATCHING_PREFIX   (1)

return value indicating the compared addresses match up to a certain prefix

Definition at line 48 of file universal_address.h.

◆ UNIVERSAL_ADDRESS_SIZE

#define UNIVERSAL_ADDRESS_SIZE
Value:
(0) /* rather senseless default, should
trigger warnings */

size of the used addresses in bytes

Definition at line 35 of file universal_address.h.

Function Documentation

◆ 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.

If the entry already exists, the universal_address_container_t::use_count will be increased.

Parameters
[in]addrpointer to the address
[in]addr_sizethe number of bytes required for the address entry
Returns
pointer to the universal_address_container_t containing the address on success
NULL if the address could not be inserted

◆ 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 full size of the used address type behind addr to be comparable with the address stored in entry.

Parameters
[in]entrypointer to the universal_address_container_t for compare
[in]addrpointer to the address for compare
[in,out]addr_size_in_bitsthe number of bits used for the address entry on successful return this value is overwritten with the number of matching bits till the first of trailing 0s
Returns
UNIVERSAL_ADDRESS_EQUAL if the entries are equal
UNIVERSAL_ADDRESS_MATCHING_PREFIX if the entry matches to a certain prefix (trailing '0's in entry)
UNIVERSAL_ADDRESS_IS_ALL_ZERO_ADDRESS if the entry address is all 0s and considered as default route
-ENOENT if the given addresses do not match

◆ 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 size of the used address type behind prefix to be comparable with the address stored in entry.

Parameters
[in]entrypointer to the universal_address_container_t for compare
[in]prefixpointer to the address for compare
[in]prefix_size_in_bitsthe number of bits used for the prefix entry. This size MUST be the full address size including trailing '0's, e.g. for an ipv6_addr_t it would be sizeof(ipv6_addr_t) regardless if the stored prefix is < ::/128
Returns
UNIVERSAL_ADDRESS_EQUAL if the entries are equal
UNIVERSAL_ADDRESS_MATCHING_PREFIX if the entry matches to a certain prefix (trailing '0's in prefix)
-ENOENT if the given addresses do not match

◆ 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.

Parameters
[in]entrypointer to the universal_address_container_t
[out]addrpointer to store the address entry
[in,out]addr_sizepointer providing the size of available memory on addr this value is overwritten with the actual size required
Returns
addr if the address is copied to the addr destination
NULL if the size is insufficient for copy

◆ universal_address_print_entry()

void universal_address_print_entry ( universal_address_container_t entry)

Print the content of the given entry.

Parameters
[in]entrypointer to the universal_address_container_t to be printed

◆ universal_address_rem()

void universal_address_rem ( universal_address_container_t entry)

Add a given container from the universal address entries.

If the entry exists, the universal_address_container_t::use_count will be decreased.

Parameters
[in]entrypointer to the universal_address_container_t to be removed