IPv6 addresses¶
IPv6 address architecture.
See also
-
IPV6_ADDR_MCAST_FLAG_TRANSIENT
¶ The address is transient, i.e.
1
(0x01)
not well-known, permanantly assigned address by IANA.
-
IPV6_ADDR_MCAST_FLAG_PREFIX_BASED
¶ The address is based on a network prefix.
1
(0x02)
See also
-
IPV6_ADDR_MCAST_FLAG_EMBED_ON_RP
¶ The address embeds the address on the rendezvous point.
1
(0x04)
See also
-
IPV6_ADDR_MCAST_SCP_IF_LOCAL
¶ interface-local scope
1
(0x1)
-
IPV6_ADDR_MCAST_SCP_LINK_LOCAL
¶ link-local scope
1
(0x2)
-
IPV6_ADDR_MCAST_SCP_REALM_LOCAL
¶ realm-local scope
1
(0x3)
See also
-
IPV6_ADDR_MCAST_SCP_ADMIN_LOCAL
¶ admin-local scope
1
(0x4)
-
IPV6_ADDR_MCAST_SCP_SITE_LOCAL
¶ site-local scope
1
(0x5)
-
IPV6_ADDR_MCAST_SCP_ORG_LOCAL
¶ organization-local scope
1
(0x8)
-
IPV6_ADDR_MCAST_SCP_GLOBAL
¶ global scope
1
(0xe)
-
const ipv6_addr_t
ipv6_addr_unspecified
¶ In-memory constants of defined addresses and prefixes.
See also
-
const ipv6_addr_t
ipv6_addr_loopback
¶ See also
-
const ipv6_addr_t
ipv6_addr_link_local_prefix
¶
-
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_solicited_node_prefix
¶
-
bool
ipv6_addr_is_unspecified
(const ipv6_addr_t * addr)¶ Checks if
addr
is unspecified (all zero).See also
Parameters
addr: An IPv6 address. Return values
- true, if
addr
is unspecified address - false, otherwise.
- true, if
-
bool
ipv6_addr_is_loopback
(const ipv6_addr_t * addr)¶ Checks if
addr
is a loopback address.See also
Parameters
addr: An IPv6 address. Return values
- true, if
addr
is loopback address, - false, otherwise.
- true, if
-
bool
ipv6_addr_is_ipv4_compat
(const ipv6_addr_t * addr)¶ Checks if
addr
is a IPv4-compatible IPv6 address.See also
Parameters
addr: An IPv6 address. Return values
- true, if
addr
is an IPv4-compatible IPv6 address, - false, otherwise.
- true, if
-
bool
ipv6_addr_is_ipv4_mapped
(const ipv6_addr_t * addr)¶ Checks if
addr
is a IPv4-mapped IPv6 address.See also
Parameters
addr: An IPv6 address. Return values
- true, if
addr
is an IPv4-compatible IPv6 address, - false, otherwise.
- true, if
-
bool
ipv6_addr_is_multicast
(const ipv6_addr_t * addr)¶ Check if
addr
is a multicast address.See also
Parameters
addr: An IPv6 address. Return values
- true, if
addr
is multicast address, - false, otherwise.
- true, if
-
bool
ipv6_addr_is_link_local
(const ipv6_addr_t * addr)¶ Check if
addr
is a link-local address.See also
See also
Parameters
addr: An IPv6 address. Return values
- true, if
addr
is link-local address, - false, otherwise.
- true, if
-
bool
ipv6_addr_is_site_local
(const ipv6_addr_t * addr)¶ Checks if
addr
is a site-local address.See also
Note
Site-local addresses are now deprecated as defined in SLDEP. They are only defined here for the distinction of global unicast addresses.
Parameters
addr: An IPv6 address. Return values
- true, if
addr
is a site-local unicast address, - false, otherwise.
- true, if
-
bool
ipv6_addr_is_unique_local_unicast
(const ipv6_addr_t * addr)¶ Check if
addr
is unique local unicast address.See also
Parameters
addr: An IPv6 address. Return values
- true, if
addr
is unique local unicast address, - false, otherwise.
- true, if
-
bool
ipv6_addr_is_global
(const ipv6_addr_t * addr)¶ Check if
addr
is global unicast address.See also
Parameters
addr: An IPv6 address. Return values
- true, if
addr
is global unicast address, - false, otherwise.
- true, if
-
bool
ipv6_addr_is_solicited_node
(const ipv6_addr_t * addr)¶ Check if
addr
is solicited-node multicast address.See also
Parameters
addr: An IPv6 address. Return values
- true, if
addr
is solicited-node multicast address, - false, otherwise.
- true, if
-
bool
ipv6_addr_equal
(const ipv6_addr_t * a, const ipv6_addr_t * b)¶ Checks if two IPv6 addresses are equal.
Parameters
a: An IPv6 address. b: Another IPv6 address. Return values
- true, if
a
andb
are equal - false, otherwise.
- true, if
-
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.
Parameters
a: An IPv6 address. b: Another IPv6 address. Return values
- The number of bits
a
andb
match in their prefix
- The number of bits
-
void
ipv6_addr_init_prefix
(ipv6_addr_t * out, const ipv6_addr_t * prefix, uint8_t bits)¶ Sets IPv6 address
out
with the firstbits
taken fromprefix
and leaves the remaining bits untouched.Parameters
out: Prefix to be set. prefix: Address to take prefix from. bits: Bits to be copied from prefix
toout
(set to 128 when greater than 128).
-
void
ipv6_addr_init_iid
(ipv6_addr_t * out, const uint8_t * iid, uint8_t bits)¶ Sets the last
bits
of IPv6 addressout
toiid
.Leading bits of
out
stay untouched.Parameters
out: IPv6 address to be set. iid: buffer representing the iid. bits: Bits to be copied from iid
toout
(set to 128 when greater than 128).
-
void
ipv6_addr_set_unspecified
(ipv6_addr_t * addr)¶ Sets
addr
dynamically to the unspecified IPv6 address (::).See also
Parameters
addr: The address to set.
-
void
ipv6_addr_set_loopback
(ipv6_addr_t * addr)¶ Sets
addr
dynamically to the loopback IPv6 address (::1).See also
Parameters
addr: The address to set.
-
void
ipv6_addr_set_link_local_prefix
(ipv6_addr_t * addr)¶ Sets the first 64 bit of
addr
to link local prefix (fe08::/64).See also
Parameters
addr: The address to set.
-
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.
See also
Parameters
addr: The address to set. iid: The interface ID as integer to set.
-
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.
See also
Parameters
addr: The address to set. iid: The interface ID as array of at least length 8 to set.
-
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.
See also
Parameters
addr: The address to set. flags: The multicast address’ flags. scope: The multicast address’ scope.
-
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).See also
Parameters
addr: The address to set. scope: The multicast address’ scope.
-
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).See also
Parameters
addr: The address to set. scope: The multicast address’ scope.
-
void
ipv6_addr_set_solicited_nodes
(ipv6_addr_t * out, const ipv6_addr_t * in)¶ Set
out
to the solicited-node multicast address computed fromin
.See also
Parameters
out: Is set to solicited-node address of this node. in: The IPv6 address the solicited-node address.
-
char *
ipv6_addr_to_str
(char * result, const ipv6_addr_t * addr, uint8_t result_len)¶ Converts an IPv6 address to its string representation.
See also
Parameters
result: The resulting string representation of at least ipv6/addr.h::IPV6_ADDR_MAX_STR_LEN
addr: An IPv6 address result_len: Length of result_len
Return values
result
, on success- NULL, if
result_len
was lesser than IPV6_ADDR_MAX_STR_LEN - NULL, if
result
oraddr
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.
See also
Parameters
result: The resulting byte representation addr: An IPv6 address string representation Return values
result
, on success- NULL, if
addr
was malformed - NULL, if
result
oraddr
was NULL
-
int
ipv6_addr_split
(char * addr_str, char seperator, int _default)¶ split IPv6 address string representation
Note
Will change
seperator
position inaddr_str
to ‘\0’Parameters
addr_str: Address to split seperator: Seperator char to use _default: Default value Return values
- atoi(string after split)
_default
if no string afterseperator
-
int
ipv6_addr_split_prefix
(char * addr_str)¶ split IPv6 prefix string representation
E.g., “2001:db8::1/64” returns “64”, changes
addr_str
to “2001:db8::1”Parameters
addr_str: Address to split Return values
- prefix length or 128 if none specified
-
int
ipv6_addr_split_iface
(char * addr_str)¶ split IPv6 address + interface specifier
E.g., “fe80::1%5” returns “5”, changes
addr_str
to “fe80::1”Parameters
addr_str: Address to split Return values
- interface number or -1 if none specified
-
void
ipv6_addr_print
(const ipv6_addr_t * addr)¶ Print IPv6 address to stdout.
Parameters
addr: Pointer to ipv6_addr_t to print
-
IPV6_ADDR_BIT_LEN
¶ Length of an IPv6 address in bit.
1
(128)
-
IPV6_ADDR_MAX_STR_LEN
¶ Maximum length of an IPv6 address as string.
1
(sizeof("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"))
-
IPV6_ADDR_SITE_LOCAL_PREFIX
¶ The first 10 bits of a site-local IPv6 unicast address.
1
(0xfec0)
See also
Note
Site-local addresses are now deprecated as defined in SLDEP. They are only defined here for the distinction of global unicast addresses.
-
IPV6_ADDR_UNSPECIFIED
¶ Static initializer for the unspecified IPv6 address (::)
1 2 3 4
{{ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00 }}
See also
-
IPV6_ADDR_LOOPBACK
¶ Static initializer for the loopback IPv6 address (::1)
1 2 3 4
{{ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x01 }}
See also
-
IPV6_ADDR_LINK_LOCAL_PREFIX
¶ Static initializer for the link-local prefix (fe80::/64)
1 2 3 4
{{ 0xfe, 0x80, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00 }}
See also
-
IPV6_ADDR_ALL_NODES_IF_LOCAL
¶ Static initializer for the interface-local all nodes multicast IPv6 address (ff01::1)
1 2 3 4
{{ 0xff, 0x01, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x01 }}
See also
-
IPV6_ADDR_ALL_NODES_LINK_LOCAL
¶ Static initializer for the link-local all nodes multicast IPv6 address (ff02::1)
1 2 3 4
{{ 0xff, 0x02, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x01 }}
See also
-
IPV6_ADDR_ALL_ROUTERS_IF_LOCAL
¶ Static initializer for the interface-local all routers multicast IPv6 address (ff01::2)
1 2 3 4
{{ 0xff, 0x01, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x02 }}
See also
-
IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL
¶ Static initializer for the link-local all routers multicast IPv6 address (ff02::2)
1 2 3 4
{{ 0xff, 0x02, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x02 }}
See also
-
IPV6_ADDR_ALL_ROUTERS_SITE_LOCAL
¶ Static initializer for the site-local all routers multicast IPv6 address (ff05::2)
1 2 3 4
{{ 0xff, 0x05, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x02 }}
See also
-
IPV6_ADDR_SOLICITED_NODE_PREFIX
¶ Static initializer for the solicited node multicast prefix (ff02:0:0:0:0:1:ff00::/104)
1 2 3 4
{{ 0xff, 0x02, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x01, \ 0xff, 0x00, 0x00, 0x00 }}
See also
-
union
ipv6_addr_t
¶ Data type to represent an IPv6 address.