IPv6 address architecture. More...
IPv6 address architecture.
Files | |
file | addr.h |
Definitions for IPv6 addresses. | |
Data Structures | |
union | ipv6_addr_t |
Data type to represent an IPv6 address. More... | |
Macros | |
#define | IPV6_ADDR_BIT_LEN (128) |
Length of an IPv6 address in bit. | |
#define | IPV6_ADDR_MAX_STR_LEN (sizeof("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")) |
Maximum length of an IPv6 address as string. | |
#define | IPV6_ADDR_SITE_LOCAL_PREFIX (0xfec0) |
The first 10 bits of a site-local IPv6 unicast address. More... | |
#define | IPV6_ADDR_UNSPECIFIED |
Static initializer for the unspecified IPv6 address (::) More... | |
#define | IPV6_ADDR_LOOPBACK |
Static initializer for the loopback IPv6 address (::1) More... | |
#define | IPV6_ADDR_LINK_LOCAL_PREFIX |
Static initializer for the link-local prefix (fe80::/64) More... | |
#define | IPV6_ADDR_ALL_NODES_IF_LOCAL |
Static initializer for the interface-local all nodes multicast IPv6 address (ff01::1) More... | |
#define | IPV6_ADDR_ALL_NODES_LINK_LOCAL |
Static initializer for the link-local all nodes multicast IPv6 address (ff02::1) More... | |
#define | IPV6_ADDR_ALL_ROUTERS_IF_LOCAL |
Static initializer for the interface-local all routers multicast IPv6 address (ff01::2) More... | |
#define | IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL |
Static initializer for the link-local all routers multicast IPv6 address (ff02::2) More... | |
#define | IPV6_ADDR_ALL_ROUTERS_SITE_LOCAL |
Static initializer for the site-local all routers multicast IPv6 address (ff05::2) More... | |
#define | IPV6_ADDR_SOLICITED_NODE_PREFIX |
Static initializer for the solicited node multicast prefix (ff02:0:0:0:0:1:ff00::/104) More... | |
Functions | |
static bool | ipv6_addr_is_unspecified (const ipv6_addr_t *addr) |
Checks if addr is unspecified (all zero). More... | |
static bool | ipv6_addr_is_loopback (const ipv6_addr_t *addr) |
Checks if addr is a loopback address. More... | |
static bool | ipv6_addr_is_ipv4_compat (const ipv6_addr_t *addr) |
Checks if addr is a IPv4-compatible IPv6 address. More... | |
static bool | ipv6_addr_is_ipv4_mapped (const ipv6_addr_t *addr) |
Checks if addr is a IPv4-mapped IPv6 address. More... | |
static bool | ipv6_addr_is_multicast (const ipv6_addr_t *addr) |
Check if addr is a multicast address. More... | |
static bool | ipv6_addr_is_link_local (const ipv6_addr_t *addr) |
Check if addr is a link-local address. More... | |
static bool | ipv6_addr_is_site_local (const ipv6_addr_t *addr) |
Checks if addr is a site-local address. More... | |
static bool | ipv6_addr_is_unique_local_unicast (const ipv6_addr_t *addr) |
Check if addr is unique local unicast address. More... | |
static bool | ipv6_addr_is_global (const ipv6_addr_t *addr) |
Check if addr is global unicast address. More... | |
static bool | ipv6_addr_is_solicited_node (const ipv6_addr_t *addr) |
Check if addr is solicited-node multicast address. More... | |
bool | ipv6_addr_equal (const ipv6_addr_t *a, const ipv6_addr_t *b) |
Checks if two IPv6 addresses are equal. More... | |
uint8_t | ipv6_addr_match_prefix (const ipv6_addr_t *a, const ipv6_addr_t *b) |
Checks up to which bit-count two IPv6 addresses match in their prefix. More... | |
void | ipv6_addr_init_prefix (ipv6_addr_t *out, const ipv6_addr_t *prefix, uint8_t bits) |
Sets IPv6 address out with the first bits taken from prefix and leaves the remaining bits untouched. More... | |
void | ipv6_addr_init_iid (ipv6_addr_t *out, const uint8_t *iid, uint8_t bits) |
Sets the last bits of IPv6 address out to iid . More... | |
static void | ipv6_addr_set_unspecified (ipv6_addr_t *addr) |
Sets addr dynamically to the unspecified IPv6 address (::). More... | |
static void | ipv6_addr_set_loopback (ipv6_addr_t *addr) |
Sets addr dynamically to the loopback IPv6 address (::1). More... | |
static void | ipv6_addr_set_link_local_prefix (ipv6_addr_t *addr) |
Sets the first 64 bit of addr to link local prefix (fe08::/64). More... | |
static void | ipv6_addr_set_iid (ipv6_addr_t *addr, uint64_t iid) |
Sets the 64-bit interface ID (as integer) of a unicast or anycast IPv6 address. More... | |
static void | ipv6_addr_set_aiid (ipv6_addr_t *addr, uint8_t *iid) |
Sets the 64-bit interface ID (as array) of a unicast or anycast IPv6 address. More... | |
static void | ipv6_addr_set_multicast (ipv6_addr_t *addr, unsigned int flags, unsigned int scope) |
Sets the bits for an address required to be a multicast address. More... | |
static void | ipv6_addr_set_all_nodes_multicast (ipv6_addr_t *addr, unsigned int scope) |
Sets addr dynamically to an all nodes multicast IPv6 address (ff0S::1, where S is the scope). More... | |
static void | ipv6_addr_set_all_routers_multicast (ipv6_addr_t *addr, unsigned int scope) |
Sets addr dynamically to an all routers multicast IPv6 address (ff0S::2, where S is the scope). More... | |
static void | ipv6_addr_set_solicited_nodes (ipv6_addr_t *out, const ipv6_addr_t *in) |
Set out to the solicited-node multicast address computed from in . More... | |
char * | ipv6_addr_to_str (char *result, const ipv6_addr_t *addr, uint8_t result_len) |
Converts an IPv6 address to its string representation. More... | |
ipv6_addr_t * | ipv6_addr_from_str (ipv6_addr_t *result, const char *addr) |
Converts an IPv6 address string representation to a byte-represented IPv6 address. More... | |
ipv6_addr_t * | ipv6_addr_from_buf (ipv6_addr_t *result, const char *addr, size_t addr_len) |
Converts an IPv6 address from a buffer of characters to a byte-represented IPv6 address. More... | |
char * | ipv6_addr_split_str (char *addr_str, char separator) |
split IPv6 address string representation and return remaining string More... | |
int | ipv6_addr_split_int (char *addr_str, char separator, int _default) |
split IPv6 address string representation More... | |
static int | ipv6_addr_split_prefix (char *addr_str) |
split IPv6 prefix string representation More... | |
static char * | ipv6_addr_split_iface (char *addr_str) |
split IPv6 address + interface specifier More... | |
void | ipv6_addr_print (const ipv6_addr_t *addr) |
Print IPv6 address to stdout. More... | |
Multicast address flags | |
Values for the flag field in multicast addresses.
| |
#define | IPV6_ADDR_MCAST_FLAG_TRANSIENT (0x01) |
The address is transient, i.e. More... | |
#define | IPV6_ADDR_MCAST_FLAG_PREFIX_BASED (0x02) |
The address is based on a network prefix. More... | |
#define | IPV6_ADDR_MCAST_FLAG_EMBED_ON_RP (0x04) |
The address embeds the address on the rendezvous point. More... | |
#define IPV6_ADDR_ALL_NODES_IF_LOCAL |
Static initializer for the interface-local all nodes multicast IPv6 address (ff01::1)
#define IPV6_ADDR_ALL_NODES_LINK_LOCAL |
Static initializer for the link-local all nodes multicast IPv6 address (ff02::1)
#define IPV6_ADDR_ALL_ROUTERS_IF_LOCAL |
Static initializer for the interface-local all routers multicast IPv6 address (ff01::2)
#define IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL |
Static initializer for the link-local all routers multicast IPv6 address (ff02::2)
#define IPV6_ADDR_ALL_ROUTERS_SITE_LOCAL |
Static initializer for the site-local all routers multicast IPv6 address (ff05::2)
#define IPV6_ADDR_LINK_LOCAL_PREFIX |
Static initializer for the link-local prefix (fe80::/64)
#define IPV6_ADDR_LOOPBACK |
Static initializer for the loopback IPv6 address (::1)
#define IPV6_ADDR_MCAST_FLAG_EMBED_ON_RP (0x04) |
The address embeds the address on the rendezvous point.
#define IPV6_ADDR_MCAST_FLAG_PREFIX_BASED (0x02) |
The address is based on a network prefix.
#define IPV6_ADDR_MCAST_FLAG_TRANSIENT (0x01) |
#define IPV6_ADDR_MCAST_SCP_REALM_LOCAL (0x3) |
realm-local scope
#define IPV6_ADDR_SITE_LOCAL_PREFIX (0xfec0) |
The first 10 bits of a site-local IPv6 unicast address.
#define IPV6_ADDR_SOLICITED_NODE_PREFIX |
Static initializer for the solicited node multicast prefix (ff02:0:0:0:0:1:ff00::/104)
#define IPV6_ADDR_UNSPECIFIED |
Static initializer for the unspecified IPv6 address (::)
bool ipv6_addr_equal | ( | const ipv6_addr_t * | a, |
const ipv6_addr_t * | b | ||
) |
Checks if two IPv6 addresses are equal.
[in] | a | An IPv6 address. |
[in] | b | Another IPv6 address. |
a
and b
are equal ipv6_addr_t* ipv6_addr_from_buf | ( | ipv6_addr_t * | result, |
const char * | addr, | ||
size_t | addr_len | ||
) |
Converts an IPv6 address from a buffer of characters to a byte-represented IPv6 address.
addr_len
should be between 0 and IPV6_ADDR_MAX_STR_LEN[out] | result | The resulting byte representation |
[in] | addr | An IPv6 address string representation |
[in] | addr_len | The amount of characters to parse |
result
, on success addr
was malformed result
or addr
was NULL ipv6_addr_t* ipv6_addr_from_str | ( | ipv6_addr_t * | result, |
const char * | addr | ||
) |
Converts an IPv6 address string representation to a byte-represented IPv6 address.
[out] | result | The resulting byte representation |
[in] | addr | An IPv6 address string representation |
result
, on success addr
was malformed result
or addr
was NULL void ipv6_addr_init_iid | ( | ipv6_addr_t * | out, |
const uint8_t * | iid, | ||
uint8_t | bits | ||
) |
Sets the last bits
of IPv6 address out
to iid
.
Leading bits of out
stay untouched.
[out] | out | IPv6 address to be set. |
[in] | iid | buffer representing the iid. |
[in] | bits | Bits to be copied from iid to out (set to 128 when greater than 128). |
void ipv6_addr_init_prefix | ( | ipv6_addr_t * | out, |
const ipv6_addr_t * | prefix, | ||
uint8_t | bits | ||
) |
Sets IPv6 address out
with the first bits
taken from prefix
and leaves the remaining bits untouched.
[out] | out | Prefix to be set. |
[in] | prefix | Address to take prefix from. |
[in] | bits | Bits to be copied from prefix to out (set to 128 when greater than 128). |
|
inlinestatic |
Check if addr
is global unicast address.
[in] | addr | An IPv6 address. |
addr
is global unicast address,
|
inlinestatic |
Checks if addr
is a IPv4-compatible IPv6 address.
[in] | addr | An IPv6 address. |
addr
is an IPv4-compatible IPv6 address,
|
inlinestatic |
Checks if addr
is a IPv4-mapped IPv6 address.
[in] | addr | An IPv6 address. |
addr
is an IPv4-compatible IPv6 address,
|
inlinestatic |
Check if addr
is a link-local address.
[in] | addr | An IPv6 address. |
addr
is link-local address,
|
inlinestatic |
Checks if addr
is a loopback address.
[in] | addr | An IPv6 address. |
addr
is loopback address,
|
inlinestatic |
Check if addr
is a multicast address.
[in] | addr | An IPv6 address. |
addr
is multicast address,
|
inlinestatic |
Checks if addr
is a site-local address.
[in] | addr | An IPv6 address. |
addr
is a site-local unicast address,
|
inlinestatic |
Check if addr
is solicited-node multicast address.
[in] | addr | An IPv6 address. |
addr
is solicited-node multicast address,
|
inlinestatic |
|
inlinestatic |
Checks if addr
is unspecified (all zero).
[in] | addr | An IPv6 address. |
addr
is unspecified address uint8_t ipv6_addr_match_prefix | ( | const ipv6_addr_t * | a, |
const ipv6_addr_t * | b | ||
) |
Checks up to which bit-count two IPv6 addresses match in their prefix.
[in] | a | An IPv6 address. |
[in] | b | Another IPv6 address. |
a
and b
match in their prefix void ipv6_addr_print | ( | const ipv6_addr_t * | addr | ) |
Print IPv6 address to stdout.
[in] | addr | Pointer to ipv6_addr_t to print |
|
inlinestatic |
Sets the 64-bit interface ID (as array) of a unicast or anycast IPv6 address.
[in,out] | addr | The address to set. |
[in] | iid | The interface ID as array of at least length 8 to set. |
|
inlinestatic |
Sets addr
dynamically to an all nodes multicast IPv6 address (ff0S::1, where S is the scope).
[in,out] | addr | The address to set. |
[in] | scope | The multicast address' scope. |
|
inlinestatic |
Sets addr
dynamically to an all routers multicast IPv6 address (ff0S::2, where S is the scope).
[in,out] | addr | The address to set. |
[in] | scope | The multicast address' scope. |
|
inlinestatic |
Sets the 64-bit interface ID (as integer) of a unicast or anycast IPv6 address.
[in,out] | addr | The address to set. |
[in] | iid | The interface ID as integer to set. |
|
inlinestatic |
Sets the first 64 bit of addr
to link local prefix (fe08::/64).
[in,out] | addr | The address to set. |
|
inlinestatic |
Sets addr
dynamically to the loopback IPv6 address (::1).
[in,out] | addr | The address to set. |
|
inlinestatic |
Sets the bits for an address required to be a multicast address.
[in,out] | addr | The address to set. |
[in] | flags | The multicast address' flags. |
[in] | scope | The multicast address' scope. |
|
inlinestatic |
|
inlinestatic |
Sets addr
dynamically to the unspecified IPv6 address (::).
[in,out] | addr | The address to set. |
|
inlinestatic |
int ipv6_addr_split_int | ( | char * | addr_str, |
char | separator, | ||
int | _default | ||
) |
split IPv6 address string representation
separator
position in addr_str
to '\0'[in,out] | addr_str | Address to split |
[in] | separator | Separator char to use |
[in] | _default | Default value |
_default
if no string after separator
|
inlinestatic |
char* ipv6_addr_split_str | ( | char * | addr_str, |
char | separator | ||
) |
split IPv6 address string representation and return remaining string
Will change separator
position in addr_str
to '\0'
[in,out] | addr_str | Address to split |
[in] | separator | Separator char to use |
separator
in addr_str
. separator
was not found. char* ipv6_addr_to_str | ( | char * | result, |
const ipv6_addr_t * | addr, | ||
uint8_t | result_len | ||
) |
Converts an IPv6 address to its string representation.
[out] | result | The resulting string representation of at least IPV6_ADDR_MAX_STR_LEN |
[in] | addr | An IPv6 address |
[in] | result_len | Length of result_len |
result
, on success result_len
was lesser than IPV6_ADDR_MAX_STR_LEN result
or addr
was NULL const ipv6_addr_t ipv6_addr_all_nodes_if_local |
const ipv6_addr_t ipv6_addr_all_nodes_link_local |
const ipv6_addr_t ipv6_addr_all_routers_if_local |
const ipv6_addr_t ipv6_addr_all_routers_link_local |
const ipv6_addr_t ipv6_addr_all_routers_site_local |
const ipv6_addr_t ipv6_addr_link_local_prefix |
const ipv6_addr_t ipv6_addr_loopback |
const ipv6_addr_t ipv6_addr_solicited_node_prefix |
const ipv6_addr_t ipv6_addr_unspecified |
In-memory constants of defined addresses and prefixes.