IPv6 network interfaces

IPv6 specific information on Network interfaces. More...

Detailed Description

IPv6 specific information on Network interfaces.

Files

file  ipv6/netif.h
 Definitions for IPv6 specific information of network interfaces.
 

Data Structures

struct  gnrc_ipv6_netif_addr_t
 Type to represent an IPv6 address registered to an interface. More...
 
struct  gnrc_ipv6_netif_t
 Definition of IPv6 interface type. More...
 

Macros

#define GNRC_IPV6_NETIF_ADDR_NUMOF   (6 + GNRC_IPV6_NETIF_RPL_ADDR + GNRC_IPV6_NETIF_RTR_ADDR)
 Number of IPv6 addresses per interface.
 
#define GNRC_IPV6_NETIF_DEFAULT_MTU   (IPV6_MIN_MTU)
 Default MTU. More...
 
#define GNRC_IPV6_NETIF_DEFAULT_HL   (64)
 Default hop limit. More...
 

Functions

void gnrc_ipv6_netif_init (void)
 Initializes the module.
 
void gnrc_ipv6_netif_add (kernel_pid_t pid)
 Add interface to IPv6. More...
 
void gnrc_ipv6_netif_remove (kernel_pid_t pid)
 Remove interface from IPv6. More...
 
gnrc_ipv6_netif_tgnrc_ipv6_netif_get (kernel_pid_t pid)
 Get interface. More...
 
void gnrc_ipv6_netif_set_router (gnrc_ipv6_netif_t *netif, bool enable)
 Set interface to router mode. More...
 
void gnrc_ipv6_netif_set_rtr_adv (gnrc_ipv6_netif_t *netif, bool enable)
 Set interface to router advertisement mode. More...
 
ipv6_addr_tgnrc_ipv6_netif_add_addr (kernel_pid_t pid, const ipv6_addr_t *addr, uint8_t prefix_len, uint8_t flags)
 Adds an address to an interface. More...
 
void gnrc_ipv6_netif_remove_addr (kernel_pid_t pid, ipv6_addr_t *addr)
 Remove an address from the interface. More...
 
void gnrc_ipv6_netif_reset_addr (kernel_pid_t pid)
 Removes all addresses from the interface. More...
 
kernel_pid_t gnrc_ipv6_netif_find_by_addr (ipv6_addr_t **out, const ipv6_addr_t *addr)
 Searches for an address on all interfaces. More...
 
ipv6_addr_tgnrc_ipv6_netif_find_addr (kernel_pid_t pid, const ipv6_addr_t *addr)
 Searches for an address on an interface. More...
 
kernel_pid_t gnrc_ipv6_netif_find_by_prefix (ipv6_addr_t **out, const ipv6_addr_t *prefix)
 Searches for the first address matching a prefix best on all interfaces. More...
 
ipv6_addr_tgnrc_ipv6_netif_match_prefix (kernel_pid_t pid, const ipv6_addr_t *prefix)
 Searches for the first address matching a prefix best on an interface. More...
 
ipv6_addr_tgnrc_ipv6_netif_find_best_src_addr (kernel_pid_t pid, const ipv6_addr_t *dest, bool ll_only)
 Searches for the best address on an interface usable as a source address for a given destination address. More...
 
static gnrc_ipv6_netif_addr_tgnrc_ipv6_netif_addr_get (const ipv6_addr_t *addr)
 Get interface specific meta-information on an address. More...
 
static bool gnrc_ipv6_netif_addr_is_non_unicast (const ipv6_addr_t *addr)
 Checks if an address is non-unicast. More...
 
void gnrc_ipv6_netif_init_by_dev (void)
 Initializes an interface with device-dependent values. More...
 
netstats_tgnrc_ipv6_netif_get_stats (kernel_pid_t pid)
 Get sent and received statistics about IPv6 traffic on this interface. More...
 

Default values for router configuration

See also
RFC 4861, section 6.2.1
#define GNRC_IPV6_NETIF_DEFAULT_MAX_ADV_INT   (600U)
 Maximum time in seconds between sending unsolicited multicast router advertisements.
 
#define GNRC_IPV6_NETIF_DEFAULT_MIN_ADV_INT   (200U)
 Minimum time in seconds between sending unsolicited multicast router advertisements.
 
#define GNRC_IPV6_NETIF_DEFAULT_ROUTER_LTIME   (1800U)
 The router lifetime to propagate in router advertisements.
 

Flags for a registered IPv6 address.

Needed primarily to identify addresses as either anycast or unicast.

See also
RFC 4291, section 2.6
#define GNRC_IPV6_NETIF_ADDR_FLAGS_UNICAST   (0x00)
 unicast address
 
#define GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST   (0x01)
 non-unicast address
 
#define GNRC_IPV6_NETIF_ADDR_FLAGS_NDP_AUTO   (0x40)
 A prefix information option that propagates the prefix of this address should set the autonomous flag. More...
 
#define GNRC_IPV6_NETIF_ADDR_FLAGS_NDP_ON_LINK   (0x80)
 A prefix information option that propagates the prefix of this address should set the on-link flag. More...
 

Flags for the interfaces

Note
The most-significant byte of these flags is identical to the flags in IPv6 router advertisements. See RFC4861, section 4.2, RFC6275, section 7.1, RFC4191, section 2.2, and RFC4389, section 4.1.3.3.
#define GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN   (0x0001)
 Interface is 6LoWPAN interface.
 
#define GNRC_IPV6_NETIF_FLAGS_ROUTER   (0x0002)
 Flag to indicate that routing is enabled on the interface.
 
#define GNRC_IPV6_NETIF_FLAGS_RTR_ADV   (0x0004)
 Flag to indicate that the interface sends periodic router advertisements and in response to router solicitations.
 
#define GNRC_IPV6_NETIF_FLAGS_ADV_MTU   (0x0008)
 Flag to indicate that gnrc_ipv6_netif_t::mtu shall be propagated with the MTU options in router advertisements.
 
#define GNRC_IPV6_NETIF_FLAGS_ADV_CUR_HL   (0x0010)
 Flag to indicate that gnrc_ipv6_netif_t::cur_hl shall be propagated in router advertisements.
 
#define GNRC_IPV6_NETIF_FLAGS_ADV_REACH_TIME   (0x0020)
 Flag to indicate that gnrc_ipv6_netif_t::reach_time shall be propagated in router advertisements.
 
#define GNRC_IPV6_NETIF_FLAGS_ADV_RETRANS_TIMER   (0x0040)
 Flag to indicate that gnrc_ipv6_netif_t::retrans_timer shall be propagated in router advertisements.
 
#define GNRC_IPV6_NETIF_FLAGS_IS_WIRED   (0x0080)
 Flag to indicate if the interface is operating over a wired link.
 
#define GNRC_IPV6_NETIF_FLAGS_RTR_ADV_POS   (8U)
 Offset of the router advertisement flags compared to the position in router advertisements.
 
#define GNRC_IPV6_NETIF_FLAGS_RTR_ADV_MASK   (0xc000)
 Mask for flags intended for router advertisements. More...
 
#define GNRC_IPV6_NETIF_FLAGS_OTHER_CONF   (0x4000)
 Flag to indicate that the interface has other address configuration.
 
#define GNRC_IPV6_NETIF_FLAGS_MANAGED   (0x8000)
 Flag to indicate that the interface has managed address configuration (e.g. More...
 

Macro Definition Documentation

◆ GNRC_IPV6_NETIF_ADDR_FLAGS_NDP_AUTO

#define GNRC_IPV6_NETIF_ADDR_FLAGS_NDP_AUTO   (0x40)

A prefix information option that propagates the prefix of this address should set the autonomous flag.

See also
RFC 4861, section 6.2.1

Definition at line 139 of file ipv6/netif.h.

◆ GNRC_IPV6_NETIF_ADDR_FLAGS_NDP_ON_LINK

#define GNRC_IPV6_NETIF_ADDR_FLAGS_NDP_ON_LINK   (0x80)

A prefix information option that propagates the prefix of this address should set the on-link flag.

See also
RFC 4861, section 6.2.1

Definition at line 148 of file ipv6/netif.h.

◆ GNRC_IPV6_NETIF_DEFAULT_HL

#define GNRC_IPV6_NETIF_DEFAULT_HL   (64)

Default hop limit.

See also
RFC 4861, section 6.3.2
IANA, IP TIME TO LIVE PARAMETER

Definition at line 95 of file ipv6/netif.h.

◆ GNRC_IPV6_NETIF_DEFAULT_MTU

#define GNRC_IPV6_NETIF_DEFAULT_MTU   (IPV6_MIN_MTU)

Default MTU.

An interface will choose this MTU if the link-layer's maximum packet size (see NETOPT_MAX_PACKET_SIZE) is lesser than the IPV6_MIN_MTU or if it just not provide it. For RFC-compatible communication it must be at least IPV6_MIN_MTU.

Note
If the scenario the node is used in allows for it and the packet size is predictable, a user might choose to set GNRC_IPV6_NETIF_DEFAULT_MTU to a lesser value than IPV6_MIN_MTU to optimize for code size (e.g. because it is then possible to omit 6LoWPAN Fragmentation) and memory usage (e.g. because GNRC_PKTBUF_SIZE can be much smaller).

Definition at line 82 of file ipv6/netif.h.

◆ GNRC_IPV6_NETIF_FLAGS_MANAGED

#define GNRC_IPV6_NETIF_FLAGS_MANAGED   (0x8000)

Flag to indicate that the interface has managed address configuration (e.g.

via DHCPv6).

Definition at line 235 of file ipv6/netif.h.

◆ GNRC_IPV6_NETIF_FLAGS_RTR_ADV_MASK

#define GNRC_IPV6_NETIF_FLAGS_RTR_ADV_MASK   (0xc000)

Mask for flags intended for router advertisements.

Note
Please expand if more router advertisement flags are introduced.

Definition at line 223 of file ipv6/netif.h.

Function Documentation

◆ gnrc_ipv6_netif_add()

void gnrc_ipv6_netif_add ( kernel_pid_t  pid)

Add interface to IPv6.

This function will be called by gnrc_netif_add().

Parameters
[in]pidThe PID to the interface.

◆ gnrc_ipv6_netif_add_addr()

ipv6_addr_t* gnrc_ipv6_netif_add_addr ( kernel_pid_t  pid,
const ipv6_addr_t addr,
uint8_t  prefix_len,
uint8_t  flags 
)

Adds an address to an interface.

Parameters
[in]pidThe PID to the interface.
[in]addrAn address you want to add to the interface.
[in]prefix_lenLength of the prefix of the address. Must be between 1 and 128.
[in]flagsFlags for the address entry If addr should be an anycast address, flags must have GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST set. Otherwise leave it unset. If addr is a multicast address, the status of GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST will be ignored and set in either case.
See also
RFC 4291, section 2.6
Returns
The address on the interface, on success.
NULL, on failure

◆ gnrc_ipv6_netif_addr_get()

static gnrc_ipv6_netif_addr_t* gnrc_ipv6_netif_addr_get ( const ipv6_addr_t addr)
inlinestatic

Get interface specific meta-information on an address.

This only works with addresses you retrieved via the following functions:

  • gnrc_ipv6_netif_add_addr()
  • gnrc_ipv6_find_addr()
  • gnrc_ipv6_find_addr_local()
  • gnrc_ipv6_find_prefix_match()
  • gnrc_ipv6_find_prefix_match_local()
  • gnrc_ipv6_find_best_src_address()

The behaviour for other addresses is undefined.

Parameters
[in]addrThe address you want to get the meta-information for.
Returns
Interface specific meta-information on addr

Definition at line 561 of file ipv6/netif.h.

◆ gnrc_ipv6_netif_addr_is_non_unicast()

static bool gnrc_ipv6_netif_addr_is_non_unicast ( const ipv6_addr_t addr)
inlinestatic

Checks if an address is non-unicast.

This only works with addresses you retrieved via the following functions:

  • gnrc_ipv6_netif_add_addr()
  • gnrc_ipv6_find_addr()
  • gnrc_ipv6_find_addr_local()
  • gnrc_ipv6_find_prefix_match()
  • gnrc_ipv6_find_prefix_match_local()
  • gnrc_ipv6_find_best_src_address()

The behaviour for other addresses is undefined.

Parameters
[in]addrThe address you want to check.
Returns
true, if address is anycast or multicast.
false, if address is unicast.

Definition at line 586 of file ipv6/netif.h.

◆ gnrc_ipv6_netif_find_addr()

ipv6_addr_t* gnrc_ipv6_netif_find_addr ( kernel_pid_t  pid,
const ipv6_addr_t addr 
)

Searches for an address on an interface.

Parameters
[in]pidThe PID to the interface.
[in]addrThe address you want to search for.
Returns
The reference to the address on the interface.
NULL, if the address can not be found on the interface.
NULL, if pid is no interface.

◆ gnrc_ipv6_netif_find_best_src_addr()

ipv6_addr_t* gnrc_ipv6_netif_find_best_src_addr ( kernel_pid_t  pid,
const ipv6_addr_t dest,
bool  ll_only 
)

Searches for the best address on an interface usable as a source address for a given destination address.

Parameters
[in]pidThe PID to the interface.
[in]destThe destination address you want to find a destination address for.
[in]ll_onlyIf only link local addresses qualify
Todo:
Rule 4 from RFC 6724 is currently not implemented. Has to updated as soon as gnrc supports Mobile IP.
Todo:
Rule 6 from RFC 6724 is currently not implemented. Has to updated as soon as gnrc supports flow labels.
Todo:
Rule 7 from RFC 6724 is currently not implemented. Has to updated as soon as gnrc supports temporary addresses.
Returns
The reference to the found address on the interface.
NULL, if no matching address can be found on the interface.
NULL, if pid is no interface.

◆ gnrc_ipv6_netif_find_by_addr()

kernel_pid_t gnrc_ipv6_netif_find_by_addr ( ipv6_addr_t **  out,
const ipv6_addr_t addr 
)

Searches for an address on all interfaces.

Parameters
[out]outThe reference to the address on the interface.
[in]addrThe address you want to search for.
Returns
The PID to the interface the address is registered to.
KERNEL_PID_UNDEF, if the address can not be found on any interface.

◆ gnrc_ipv6_netif_find_by_prefix()

kernel_pid_t gnrc_ipv6_netif_find_by_prefix ( ipv6_addr_t **  out,
const ipv6_addr_t prefix 
)

Searches for the first address matching a prefix best on all interfaces.

Parameters
[out]outThe reference to the found address on the interface. Must be a pointer to NULL on calling and may stay unchanged if no match can be found.
[in]prefixThe prefix you want to search for.
Precondition
out must not be NULL.
Returns
The PID to the interface the address is registered to.
KERNEL_PID_UNDEF, if no matching address can not be found on any interface.

◆ gnrc_ipv6_netif_get()

gnrc_ipv6_netif_t* gnrc_ipv6_netif_get ( kernel_pid_t  pid)

Get interface.

Parameters
[in]pidThe PID to the interface.
Returns
The interface describing structure, on success.
NULL, if there is no interface with PID pid.

◆ gnrc_ipv6_netif_get_stats()

netstats_t* gnrc_ipv6_netif_get_stats ( kernel_pid_t  pid)

Get sent and received statistics about IPv6 traffic on this interface.

Note
This function is only available if compiled with module netstats_ipv6.
Parameters
[in]pidThe PID to the interface.
Returns
A netstats_t pointer to the statistics.
NULL if no statistics are available.

◆ gnrc_ipv6_netif_init_by_dev()

void gnrc_ipv6_netif_init_by_dev ( void  )

Initializes an interface with device-dependent values.

Note
Must be called after all interfaces were initialized and must not be called in an interface's thread (will otherwise hang up).

◆ gnrc_ipv6_netif_match_prefix()

ipv6_addr_t* gnrc_ipv6_netif_match_prefix ( kernel_pid_t  pid,
const ipv6_addr_t prefix 
)

Searches for the first address matching a prefix best on an interface.

Parameters
[in]pidThe PID to the interface.
[in]prefixThe prefix you want to search for.
Returns
The reference to the found address on the interface.
NULL, if no matching address can be found on the interface.
NULL, if pid is no interface.

◆ gnrc_ipv6_netif_remove()

void gnrc_ipv6_netif_remove ( kernel_pid_t  pid)

Remove interface from IPv6.

This function will be called by gnrc_netif_remove().

Parameters
[in]pidThe PID to the interface.

◆ gnrc_ipv6_netif_remove_addr()

void gnrc_ipv6_netif_remove_addr ( kernel_pid_t  pid,
ipv6_addr_t addr 
)

Remove an address from the interface.

Parameters
[in]pidThe PID to the interface. If pid is KERNEL_PID_UNDEF it will be removed from all interfaces.
[in]addrAn address you want to remove from interface.

◆ gnrc_ipv6_netif_reset_addr()

void gnrc_ipv6_netif_reset_addr ( kernel_pid_t  pid)

Removes all addresses from the interface.

Parameters
[in]pidThe PID to the interface.

◆ gnrc_ipv6_netif_set_router()

void gnrc_ipv6_netif_set_router ( gnrc_ipv6_netif_t netif,
bool  enable 
)

Set interface to router mode.

This sets/unsets the GNRC_IPV6_NETIF_FLAGS_ROUTER and initializes or ceases router behavior for neighbor discovery.

Parameters
[in]netifThe interface.
[in]enableStatus for the GNRC_IPV6_NETIF_FLAGS_ROUTER flag.

◆ gnrc_ipv6_netif_set_rtr_adv()

void gnrc_ipv6_netif_set_rtr_adv ( gnrc_ipv6_netif_t netif,
bool  enable 
)

Set interface to router advertisement mode.

If GNRC_IPV6_NETIF_FLAGS_ROUTER is set this sets/unsets the GNRC_IPV6_NETIF_FLAGS_RTR_ADV and initializes or ceases router advertising behavior for neighbor discovery.

Parameters
[in]netifThe interface.
[in]enableStatus for the GNRC_IPV6_NETIF_FLAGS_RTR flag.