Universal Address Container¶
universal address container
-
void
universal_address_init
(void)¶ Initialize the data structure for the entries.
-
void
universal_address_reset
(void)¶ Resets the
universal_address.h::universal_address_container_t::use_count
for all entries.
-
universal_address_container_t *
universal_address_add
(uint8_t * addr,msp430_types.h::size_t
addr_size)¶ Add a given address to the universal address entries.
If the entry already exists, the
universal_address.h::universal_address_container_t::use_count
will be increased.Parameters
addr: pointer to the address addr_size: the number of bytes required for the address entry Return values
- pointer to the universal_address_container_t containing the address on success
- NULL if the address could not be inserted
-
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.h::universal_address_container_t::use_count
will be decreased.Parameters
entry: pointer to the universal_address_container_t to be removed
-
uint8_t *
universal_address_get_address
(universal_address_container_t * entry, uint8_t * addr,msp430_types.h::size_t
* addr_size)¶ Copy the address from the given container to the provided pointer.
Parameters
entry: pointer to the universal_address_container_t addr: pointer to store the address entry addr_size: pointer providing the size of available memory on addr this value is overwritten with the actual size required Return values
- addr if the address is copied to the addr destination
- NULL if the size is unsufficient for copy
-
int
universal_address_compare
(universal_address_container_t * entry, uint8_t * addr,msp430_types.h::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 inentry
.Parameters
entry: pointer to the universal_address_container_t for compare addr: pointer to the address for compare addr_size_in_bits: the number of bits used for the address entry on sucessfull return this value is overwritten with the number of matching bits till the first of trailing 0
sReturn values
- 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
0
s and considered as default route - -ENOENT if the given adresses do not match
-
int
universal_address_compare_prefix
(universal_address_container_t * entry, uint8_t * prefix,msp430_types.h::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 inentry
.Parameters
entry: pointer to the universal_address_container_t for compare prefix: pointer to the address for compare prefix_size_in_bits: the 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 Return values
- 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 adresses do not match
-
void
universal_address_print_entry
(universal_address_container_t * entry)¶ Print the content of the given entry.
Parameters
entry: pointer to the universal_address_container_t to be printed
-
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.
-
UNIVERSAL_ADDRESS_SIZE
¶ size of the used addresses in bytes
1 2
(0) /* rather senseless default, should trigger warnings */
-
UNIVERSAL_ADDRESS_EQUAL
¶ return value indicating the compared addresses are equal
1
(0)
-
UNIVERSAL_ADDRESS_MATCHING_PREFIX
¶ return value indicating the compared addresses match up to a certain prefix
1
(1)
-
UNIVERSAL_ADDRESS_IS_ALL_ZERO_ADDRESS
¶ return value indicating all address bits of the entry are
0
.1
(2)
Its considered as default route address that matches any other prefix.