All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
IPv6 addresses

IPv6 address architecture More...

Detailed Description

IPv6 address architecture

See also
RFC 4291

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.
 
#define IPV6_ADDR_UNSPECIFIED
 Static initializer for the unspecified IPv6 address (::)
 
#define IPV6_ADDR_LOOPBACK
 Static initializer for the loopback IPv6 address (::1)
 
#define IPV6_ADDR_LINK_LOCAL_PREFIX
 Static initializer for the link-local prefix (fe80::/64)
 
#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_SOLICITED_NODE_PREFIX
 Static initializer for the solicited node multicast prefix (ff02:0:0:0:0:1:ff00::/104)
 

Functions

static bool ipv6_addr_is_unspecified (const ipv6_addr_t *addr)
 Checks if addr is unspecified (all zero).
 
static bool ipv6_addr_is_loopback (const ipv6_addr_t *addr)
 Checks if addr is a loopback address.
 
static bool ipv6_addr_is_ipv4_compat (const ipv6_addr_t *addr)
 Checks if addr is a IPv4-compatible IPv6 address.
 
static bool ipv6_addr_is_ipv4_mapped (const ipv6_addr_t *addr)
 Checks if addr is a IPv4-mapped IPv6 address.
 
static bool ipv6_addr_is_multicast (const ipv6_addr_t *addr)
 Check if addr is a multicast address.
 
static bool ipv6_addr_is_link_local (const ipv6_addr_t *addr)
 Check if addr is a link-local address.
 
static bool ipv6_addr_is_site_local (const ipv6_addr_t *addr)
 Checks if addr is a site-local address.
 
static bool ipv6_addr_is_unique_local_unicast (const ipv6_addr_t *addr)
 Check if addr is unique local unicast address.
 
static bool ipv6_addr_is_global (const ipv6_addr_t *addr)
 Check if addr is global unicast address.
 
static bool ipv6_addr_is_solicited_node (const ipv6_addr_t *addr)
 Check if addr is solicited-node multicast address.
 
bool ipv6_addr_equal (const ipv6_addr_t *a, const ipv6_addr_t *b)
 Checks if two IPv6 addresses are equal.
 
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.
 
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.
 
static void ipv6_addr_init (ipv6_addr_t *out, uint64_t prefix, uint64_t iid)
 Sets IPv6 address out with a given prefix and interface ID.
 
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.
 
static void ipv6_addr_set_unspecified (ipv6_addr_t *addr)
 Sets addr dynamically to the unspecified IPv6 address (::).
 
static void ipv6_addr_set_loopback (ipv6_addr_t *addr)
 Sets addr dynamically to the loopback IPv6 address (::1).
 
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).
 
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.
 
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.
 
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.
 
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).
 
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).
 
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.
 
char * ipv6_addr_to_str (char *result, const ipv6_addr_t *addr, uint8_t result_len)
 Converts an IPv6 address to its string representation.
 
ipv6_addr_tipv6_addr_from_str (ipv6_addr_t *result, const char *addr)
 Converts an IPv6 address string representation to a byte-represented IPv6 address.
 
int ipv6_prefix_from_str (ipv6_addr_t *result, const char *prefix)
 Converts an IPv6 prefix string representation to a byte-represented IPv6 address.
 
ipv6_addr_tipv6_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.
 
char * ipv6_addr_split_str (char *addr_str, char separator)
 split IPv6 address string representation and return remaining string
 
int ipv6_addr_split_int (char *addr_str, char separator, int _default)
 split IPv6 address string representation
 
static int ipv6_addr_split_prefix (char *addr_str)
 split IPv6 prefix string representation
 
static char * ipv6_addr_split_iface (char *addr_str)
 split IPv6 address + interface specifier
 
void ipv6_addr_print (const ipv6_addr_t *addr)
 Print IPv6 address to stdout.
 
void ipv6_addrs_print (const ipv6_addr_t *addrs, size_t num, const char *separator)
 Print IPv6 addresses to stdout.
 
const ipv6_addr_t ipv6_addr_unspecified
 In-memory constants of defined addresses and prefixes.
 
const ipv6_addr_t ipv6_addr_loopback
 
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
 

Multicast address flags

Values for the flag field in multicast addresses.

See also
RFC 4291, section 2.7
#define IPV6_ADDR_MCAST_FLAG_TRANSIENT   (0x01)
 The address is transient, i.e.
 
#define IPV6_ADDR_MCAST_FLAG_PREFIX_BASED   (0x02)
 The address is based on a network prefix.
 
#define IPV6_ADDR_MCAST_FLAG_EMBED_ON_RP   (0x04)
 The address embeds the address on the rendezvous point.
 

Multicast address scopes

Values for the scope field in multicast addresses.

See also
RFC 4291, section 2.7
#define IPV6_ADDR_MCAST_SCP_IF_LOCAL   (0x1)
 interface-local scope
 
#define IPV6_ADDR_MCAST_SCP_LINK_LOCAL   (0x2)
 link-local scope
 
#define IPV6_ADDR_MCAST_SCP_REALM_LOCAL   (0x3)
 realm-local scope
 
#define IPV6_ADDR_MCAST_SCP_ADMIN_LOCAL   (0x4)
 admin-local scope
 
#define IPV6_ADDR_MCAST_SCP_SITE_LOCAL   (0x5)
 site-local scope
 
#define IPV6_ADDR_MCAST_SCP_ORG_LOCAL   (0x8)
 organization-local scope
 
#define IPV6_ADDR_MCAST_SCP_GLOBAL   (0xe)
 global scope
 

Macro Definition Documentation

◆ IPV6_ADDR_ALL_NODES_IF_LOCAL

#define IPV6_ADDR_ALL_NODES_IF_LOCAL
Value:
{{ 0xff, 0x01, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x01 }}

Static initializer for the interface-local all nodes multicast IPv6 address (ff01::1)

See also
RFC 4291, section 2.7

Definition at line 122 of file addr.h.

◆ IPV6_ADDR_ALL_NODES_LINK_LOCAL

#define IPV6_ADDR_ALL_NODES_LINK_LOCAL
Value:
{{ 0xff, 0x02, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x01 }}

Static initializer for the link-local all nodes multicast IPv6 address (ff02::1)

See also
RFC 4291, section 2.7

Definition at line 135 of file addr.h.

◆ IPV6_ADDR_ALL_ROUTERS_IF_LOCAL

#define IPV6_ADDR_ALL_ROUTERS_IF_LOCAL
Value:
{{ 0xff, 0x01, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x02 }}

Static initializer for the interface-local all routers multicast IPv6 address (ff01::2)

See also
RFC 4291, section 2.7

Definition at line 148 of file addr.h.

◆ IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL

#define IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL
Value:
{{ 0xff, 0x02, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x02 }}

Static initializer for the link-local all routers multicast IPv6 address (ff02::2)

See also
RFC 4291, section 2.7

Definition at line 161 of file addr.h.

◆ IPV6_ADDR_ALL_ROUTERS_SITE_LOCAL

#define IPV6_ADDR_ALL_ROUTERS_SITE_LOCAL
Value:
{{ 0xff, 0x05, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x02 }}

Static initializer for the site-local all routers multicast IPv6 address (ff05::2)

See also
RFC 4291, section 2.7

Definition at line 174 of file addr.h.

◆ IPV6_ADDR_BIT_LEN

#define IPV6_ADDR_BIT_LEN   (128)

Length of an IPv6 address in bit.

Definition at line 42 of file addr.h.

◆ IPV6_ADDR_LINK_LOCAL_PREFIX

#define IPV6_ADDR_LINK_LOCAL_PREFIX
Value:
{{ 0xfe, 0x80, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00 }}

Static initializer for the link-local prefix (fe80::/64)

See also
RFC 4291, section 2.5.6

Definition at line 109 of file addr.h.

◆ IPV6_ADDR_LOOPBACK

#define IPV6_ADDR_LOOPBACK
Value:
{{ 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x01 }}

Static initializer for the loopback IPv6 address (::1)

See also
RFC 4291, section 2.5.3

Definition at line 98 of file addr.h.

◆ IPV6_ADDR_MAX_STR_LEN

#define IPV6_ADDR_MAX_STR_LEN   (sizeof("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"))

Maximum length of an IPv6 address as string.

Definition at line 53 of file addr.h.

◆ IPV6_ADDR_MCAST_FLAG_EMBED_ON_RP

#define IPV6_ADDR_MCAST_FLAG_EMBED_ON_RP   (0x04)

The address embeds the address on the rendezvous point.

See also
RFC 3956, section 3

Definition at line 223 of file addr.h.

◆ IPV6_ADDR_MCAST_FLAG_PREFIX_BASED

#define IPV6_ADDR_MCAST_FLAG_PREFIX_BASED   (0x02)

The address is based on a network prefix.

See also
RFC 3306, section 4

Definition at line 214 of file addr.h.

◆ IPV6_ADDR_MCAST_FLAG_TRANSIENT

#define IPV6_ADDR_MCAST_FLAG_TRANSIENT   (0x01)

The address is transient, i.e.

not well-known, permanently assigned address by IANA.

Definition at line 205 of file addr.h.

◆ IPV6_ADDR_MCAST_SCP_ADMIN_LOCAL

#define IPV6_ADDR_MCAST_SCP_ADMIN_LOCAL   (0x4)

admin-local scope

Definition at line 249 of file addr.h.

◆ IPV6_ADDR_MCAST_SCP_GLOBAL

#define IPV6_ADDR_MCAST_SCP_GLOBAL   (0xe)

global scope

Definition at line 252 of file addr.h.

◆ IPV6_ADDR_MCAST_SCP_IF_LOCAL

#define IPV6_ADDR_MCAST_SCP_IF_LOCAL   (0x1)

interface-local scope

Definition at line 235 of file addr.h.

◆ IPV6_ADDR_MCAST_SCP_LINK_LOCAL

#define IPV6_ADDR_MCAST_SCP_LINK_LOCAL   (0x2)

link-local scope

Definition at line 236 of file addr.h.

◆ IPV6_ADDR_MCAST_SCP_ORG_LOCAL

#define IPV6_ADDR_MCAST_SCP_ORG_LOCAL   (0x8)

organization-local scope

Definition at line 251 of file addr.h.

◆ IPV6_ADDR_MCAST_SCP_REALM_LOCAL

#define IPV6_ADDR_MCAST_SCP_REALM_LOCAL   (0x3)

realm-local scope

See also
RFC 7346, section 3 and RFC 7346, section 5 and

Definition at line 248 of file addr.h.

◆ IPV6_ADDR_MCAST_SCP_SITE_LOCAL

#define IPV6_ADDR_MCAST_SCP_SITE_LOCAL   (0x5)

site-local scope

Definition at line 250 of file addr.h.

◆ IPV6_ADDR_SITE_LOCAL_PREFIX

#define IPV6_ADDR_SITE_LOCAL_PREFIX   (0xfec0)

The first 10 bits of a site-local IPv6 unicast address.

See also
RFC 4291, section 2.5.7
Note
Site-local addresses are now deprecated as defined in SLDEP. They are only defined here for the distinction of global unicast addresses.

Definition at line 67 of file addr.h.

◆ IPV6_ADDR_SOLICITED_NODE_PREFIX

#define IPV6_ADDR_SOLICITED_NODE_PREFIX
Value:
{{ 0xff, 0x02, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x01, \
0xff, 0x00, 0x00, 0x00 }}

Static initializer for the solicited node multicast prefix (ff02:0:0:0:0:1:ff00::/104)

See also
RFC 4291, section 2.7

Definition at line 187 of file addr.h.

◆ IPV6_ADDR_UNSPECIFIED

#define IPV6_ADDR_UNSPECIFIED
Value:
{{ 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00 }}

Static initializer for the unspecified IPv6 address (::)

See also
RFC 4291, section 2.5.2

Definition at line 86 of file addr.h.

Function Documentation

◆ ipv6_addr_equal()

bool ipv6_addr_equal ( const ipv6_addr_t * a,
const ipv6_addr_t * b )

Checks if two IPv6 addresses are equal.

Parameters
[in]aAn IPv6 address.
[in]bAnother IPv6 address.
Returns
true, if a and b are equal
false, otherwise.

◆ ipv6_addr_from_buf()

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.

See also
RFC 5952
Note
addr_len should be between 0 and IPV6_ADDR_MAX_STR_LEN
Parameters
[out]resultThe resulting byte representation
[in]addrAn IPv6 address string representation
[in]addr_lenThe amount of characters to parse
Returns
result, on success
NULL, if addr was malformed
NULL, if result or addr was NULL

◆ ipv6_addr_from_str()

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
RFC 5952
Parameters
[out]resultThe resulting byte representation
[in]addrAn IPv6 address string representation
Returns
result, on success
NULL, if addr was malformed
NULL, if result or addr was NULL

◆ ipv6_addr_init()

static void ipv6_addr_init ( ipv6_addr_t * out,
uint64_t prefix,
uint64_t iid )
inlinestatic

Sets IPv6 address out with a given prefix and interface ID.

Parameters
[out]outAddress to initialize
[in]prefixPrefix in host byte order
[in]iidInterface ID in host byte order

Definition at line 541 of file addr.h.

◆ ipv6_addr_init_iid()

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.

Parameters
[out]outIPv6 address to be set.
[in]iidbuffer representing the iid.
[in]bitsBits to be copied from iid to out (set to 128 when greater than 128).

◆ ipv6_addr_init_prefix()

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.

Parameters
[out]outPrefix to be set.
[in]prefixAddress to take prefix from.
[in]bitsBits to be copied from prefix to out (set to 128 when greater than 128).

◆ ipv6_addr_is_global()

static bool ipv6_addr_is_global ( const ipv6_addr_t * addr)
inlinestatic

Check if addr is global unicast address.

See also
RFC 4291, section 2.5.4
Parameters
[in]addrAn IPv6 address.
Returns
true, if addr is global unicast address,
false, otherwise.

Definition at line 470 of file addr.h.

◆ ipv6_addr_is_ipv4_compat()

static bool ipv6_addr_is_ipv4_compat ( const ipv6_addr_t * addr)
inlinestatic

Checks if addr is a IPv4-compatible IPv6 address.

See also
RFC 4291, section 2.5.5.1
Parameters
[in]addrAn IPv6 address.
Returns
true, if addr is an IPv4-compatible IPv6 address,
false, otherwise.

Definition at line 353 of file addr.h.

◆ ipv6_addr_is_ipv4_mapped()

static bool ipv6_addr_is_ipv4_mapped ( const ipv6_addr_t * addr)
inlinestatic

Checks if addr is a IPv4-mapped IPv6 address.

See also
RFC 4291, section 2.5.5.2
Parameters
[in]addrAn IPv6 address.
Returns
true, if addr is an IPv4-compatible IPv6 address,
false, otherwise.

Definition at line 371 of file addr.h.

◆ ipv6_addr_is_link_local()

static bool ipv6_addr_is_link_local ( const ipv6_addr_t * addr)
inlinestatic

Check if addr is a link-local address.

See also
RFC 4291, section 2.5.6
RFC 4291, section 2.7
Parameters
[in]addrAn IPv6 address.
Returns
true, if addr is link-local address,
false, otherwise.

Definition at line 410 of file addr.h.

◆ ipv6_addr_is_loopback()

static bool ipv6_addr_is_loopback ( const ipv6_addr_t * addr)
inlinestatic

Checks if addr is a loopback address.

See also
RFC 4291, section 2.5.3
Parameters
[in]addrAn IPv6 address.
Returns
true, if addr is loopback address,
false, otherwise.

Definition at line 336 of file addr.h.

◆ ipv6_addr_is_multicast()

static bool ipv6_addr_is_multicast ( const ipv6_addr_t * addr)
inlinestatic

Check if addr is a multicast address.

See also
RFC 4291, section 2.7
Parameters
[in]addrAn IPv6 address.
Returns
true, if addr is multicast address,
false, otherwise.

Definition at line 390 of file addr.h.

◆ ipv6_addr_is_site_local()

static bool ipv6_addr_is_site_local ( const ipv6_addr_t * addr)
inlinestatic

Checks if addr is a site-local address.

See also
RFC 4291, section 2.5.7
Note
Site-local addresses are now deprecated as defined in SLDEP. They are only defined here for the distinction of global unicast addresses.
Parameters
[in]addrAn IPv6 address.
Returns
true, if addr is a site-local unicast address,
false, otherwise.

Definition at line 433 of file addr.h.

◆ ipv6_addr_is_solicited_node()

static bool ipv6_addr_is_solicited_node ( const ipv6_addr_t * addr)
inlinestatic

Check if addr is solicited-node multicast address.

See also
RFC 4291, section 2.7.1
Parameters
[in]addrAn IPv6 address.
Returns
true, if addr is solicited-node multicast address,
false, otherwise.

Definition at line 495 of file addr.h.

◆ ipv6_addr_is_unique_local_unicast()

static bool ipv6_addr_is_unique_local_unicast ( const ipv6_addr_t * addr)
inlinestatic

Check if addr is unique local unicast address.

See also
RFC 4193
Parameters
[in]addrAn IPv6 address.
Returns
true, if addr is unique local unicast address,
false, otherwise.

Definition at line 453 of file addr.h.

◆ ipv6_addr_is_unspecified()

static bool ipv6_addr_is_unspecified ( const ipv6_addr_t * addr)
inlinestatic

Checks if addr is unspecified (all zero).

See also
RFC 4291, section 2.5.2
Parameters
[in]addrAn IPv6 address.
Returns
true, if addr is unspecified address
false, otherwise.

Definition at line 319 of file addr.h.

◆ ipv6_addr_match_prefix()

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
[in]aAn IPv6 address.
[in]bAnother IPv6 address.
Returns
The number of bits a and b match in their prefix

◆ ipv6_addr_print()

void ipv6_addr_print ( const ipv6_addr_t * addr)

Print IPv6 address to stdout.

Parameters
[in]addrPointer to ipv6_addr_t to print

◆ ipv6_addr_set_aiid()

static void ipv6_addr_set_aiid ( ipv6_addr_t * addr,
uint8_t * iid )
inlinestatic

Sets the 64-bit interface ID (as array) of a unicast or anycast IPv6 address.

See also
RFC 4291, section 2.5.4
Parameters
[in,out]addrThe address to set.
[in]iidThe interface ID as array of at least length 8 to set.

Definition at line 628 of file addr.h.

◆ ipv6_addr_set_all_nodes_multicast()

static void ipv6_addr_set_all_nodes_multicast ( ipv6_addr_t * addr,
unsigned int scope )
inlinestatic

Sets addr dynamically to an all nodes multicast IPv6 address (ff0S::1, where S is the scope).

See also
RFC 4291, section 2.7.1
Parameters
[in,out]addrThe address to set.
[in]scopeThe multicast address' scope.

Definition at line 662 of file addr.h.

◆ ipv6_addr_set_all_routers_multicast()

static void ipv6_addr_set_all_routers_multicast ( ipv6_addr_t * addr,
unsigned int scope )
inlinestatic

Sets addr dynamically to an all routers multicast IPv6 address (ff0S::2, where S is the scope).

See also
RFC 4291, section 2.7.1
Parameters
[in,out]addrThe address to set.
[in]scopeThe multicast address' scope.

Definition at line 679 of file addr.h.

◆ ipv6_addr_set_iid()

static void ipv6_addr_set_iid ( ipv6_addr_t * addr,
uint64_t iid )
inlinestatic

Sets the 64-bit interface ID (as integer) of a unicast or anycast IPv6 address.

See also
RFC 4291, section 2.5.4
Parameters
[in,out]addrThe address to set.
[in]iidThe interface ID as integer to set.

Definition at line 612 of file addr.h.

◆ ipv6_addr_set_link_local_prefix()

static void ipv6_addr_set_link_local_prefix ( ipv6_addr_t * addr)
inlinestatic

Sets the first 64 bit of addr to link local prefix (fe08::/64).

See also
RFC 4291, section 2.5.6
Parameters
[in,out]addrThe address to set.

Definition at line 596 of file addr.h.

◆ ipv6_addr_set_loopback()

static void ipv6_addr_set_loopback ( ipv6_addr_t * addr)
inlinestatic

Sets addr dynamically to the loopback IPv6 address (::1).

See also
RFC 4291, section 2.5.3
Parameters
[in,out]addrThe address to set.

Definition at line 581 of file addr.h.

◆ ipv6_addr_set_multicast()

static void ipv6_addr_set_multicast ( ipv6_addr_t * addr,
unsigned int flags,
unsigned int scope )
inlinestatic

Sets the bits for an address required to be a multicast address.

See also
RFC 4291, section 2.7
Parameters
[in,out]addrThe address to set.
[in]flagsThe multicast address' flags.
[in]scopeThe multicast address' scope.

Definition at line 644 of file addr.h.

◆ ipv6_addr_set_solicited_nodes()

static void ipv6_addr_set_solicited_nodes ( ipv6_addr_t * out,
const ipv6_addr_t * in )
inlinestatic

Set out to the solicited-node multicast address computed from in.

See also
RFC 4291
Parameters
[out]outIs set to solicited-node address of this node.
[in]inThe IPv6 address the solicited-node address.

Definition at line 696 of file addr.h.

◆ ipv6_addr_set_unspecified()

static void ipv6_addr_set_unspecified ( ipv6_addr_t * addr)
inlinestatic

Sets addr dynamically to the unspecified IPv6 address (::).

See also
RFC 4291, section 2.5.2
Parameters
[in,out]addrThe address to set.

Definition at line 567 of file addr.h.

◆ ipv6_addr_split_iface()

static char * ipv6_addr_split_iface ( char * addr_str)
inlinestatic

split IPv6 address + interface specifier

E.g., "fe80::1%5" returns "5", changes addr_str to "fe80::1"

Parameters
[in,out]addr_strAddress to split
Returns
string containing the interface specifier.
NULL if no interface was specified.

Definition at line 827 of file addr.h.

◆ ipv6_addr_split_int()

int ipv6_addr_split_int ( char * addr_str,
char separator,
int _default )

split IPv6 address string representation

Note
Will change separator position in addr_str to '\0'
Parameters
[in,out]addr_strAddress to split
[in]separatorSeparator char to use
[in]_defaultDefault value
Returns
atoi(string after split)
_default if no string after separator

◆ ipv6_addr_split_prefix()

static int ipv6_addr_split_prefix ( char * addr_str)
inlinestatic

split IPv6 prefix string representation

E.g., "2001:db8::1/64" returns "64", changes addr_str to "2001:db8::1"

Parameters
[in,out]addr_strAddress to split
Returns
prefix length or 128 if none specified

Definition at line 813 of file addr.h.

◆ ipv6_addr_split_str()

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'

Parameters
[in,out]addr_strAddress to split
[in]separatorSeparator char to use
Returns
string following the first occurrence of separator in addr_str.
NULL if separator was not found.

◆ ipv6_addr_to_str()

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
RFC 5952
Parameters
[out]resultThe resulting string representation of at least IPV6_ADDR_MAX_STR_LEN
[in]addrAn IPv6 address
[in]result_lenLength of result
Returns
result, on success
NULL, if result_len was lesser than IPV6_ADDR_MAX_STR_LEN
NULL, if result or addr was NULL

◆ ipv6_addrs_print()

void ipv6_addrs_print ( const ipv6_addr_t * addrs,
size_t num,
const char * separator )

Print IPv6 addresses to stdout.

Parameters
[in]addrsArray of addresses to print
[in]numNumber of elements in addrs
[in]separatorSeparator to print between addresses

◆ ipv6_prefix_from_str()

int ipv6_prefix_from_str ( ipv6_addr_t * result,
const char * prefix )

Converts an IPv6 prefix string representation to a byte-represented IPv6 address.

See also
RFC 5952
Parameters
[out]resultThe resulting byte representation
[in]prefixAn IPv6 prefix string representation
Returns
prefix length in bits, on success
<0 on error

Variable Documentation

◆ ipv6_addr_all_nodes_if_local

const ipv6_addr_t ipv6_addr_all_nodes_if_local
extern

◆ ipv6_addr_all_nodes_link_local

const ipv6_addr_t ipv6_addr_all_nodes_link_local
extern

◆ ipv6_addr_all_routers_if_local

const ipv6_addr_t ipv6_addr_all_routers_if_local
extern

◆ ipv6_addr_all_routers_link_local

const ipv6_addr_t ipv6_addr_all_routers_link_local
extern

◆ ipv6_addr_all_routers_site_local

const ipv6_addr_t ipv6_addr_all_routers_site_local
extern

◆ ipv6_addr_link_local_prefix

const ipv6_addr_t ipv6_addr_link_local_prefix
extern

◆ ipv6_addr_loopback

const ipv6_addr_t ipv6_addr_loopback
extern

◆ ipv6_addr_solicited_node_prefix

const ipv6_addr_t ipv6_addr_solicited_node_prefix
extern

◆ ipv6_addr_unspecified

const ipv6_addr_t ipv6_addr_unspecified
extern

In-memory constants of defined addresses and prefixes.

See also
IPV6_ADDR_UNSPECIFIED