IPv6 neighbor discovery (v2)¶
Provides build and send functions for neighbor discovery packets.
-
include/net/gnrc/pkt.h::gnrc_pktsnip_t
*gnrc_ndp_nbr_sol_build
(const ipv6_addr_t * tgt,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* options)¶ Builds a neighbor solicitation message for sending.
See also
Parameters
tgt: The target address of the neighbor solicitation. Must not be NULL or a multicast address. options: Options to append to the neighbor solicitation. May be NULL for none. Return values
- The resulting ICMPv6 packet on success.
- NULL, if packet buffer is full.
-
include/net/gnrc/pkt.h::gnrc_pktsnip_t
*gnrc_ndp_nbr_adv_build
(const ipv6_addr_t * tgt, uint8_t flags,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* options)¶ Builds a neighbor advertisement message for sending.
See also
Parameters
tgt: For solicited advertisements, the Target Address field in the neighbor solicitaton. For and unsolicited advertisement, the address whose link-layer address has changed. Must not be NULL or a multicast address. flags: Neighbor advertisement flags: ndp.h::NDP_NBR_ADV_FLAGS_R
== 1 indicates, that the sender is a router,ndp.h::NDP_NBR_ADV_FLAGS_S
== 1 indicates that the advertisement was sent in response to a neighbor solicitation,ndp.h::NDP_NBR_ADV_FLAGS_O
== 1 indicates that the advertisement should override an existing cache entry and update the cached link-layer address.
options: Options to append to the neighbor advertisement. May be NULL for none. Return values
- The resulting ICMPv6 packet on success.
- NULL, if packet buffer is full.
-
include/net/gnrc/pkt.h::gnrc_pktsnip_t
*gnrc_ndp_rtr_sol_build
(include/net/gnrc/pkt.h::gnrc_pktsnip_t
* options)¶ Builds a router solicitation message for sending.
See also
Parameters
options: Options to append to the router solicitation. May be NULL for none. Return values
- The resulting ICMPv6 packet on success.
- NULL, if packet buffer is full.
-
include/net/gnrc/pkt.h::gnrc_pktsnip_t
*gnrc_ndp_rtr_adv_build
(uint8_t cur_hl, uint8_t flags, uint16_t ltime, uint32_t reach_time, uint32_t retrans_timer,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* options)¶ Builds a router advertisement message for sending.
See also
Note
The source address for the packet MUST be the link-local address of the interface.
Parameters
cur_hl: Default hop limit for outgoing IP packets, 0 if unspecified by this router. flags: Flags as defined in net/ndp.h. ndp.h::NDP_RTR_ADV_FLAGS_M
== 1 indicates, that the addresses are managed by DHCPv6,ndp.h::NDP_RTR_ADV_FLAGS_O
== 1 indicates that other configuration information is available via DHCPv6.
ltime: Lifetime of the default router in seconds. reach_time: Time in milliseconds a node should assume a neighbor reachable. 0 means unspecified by the router. retrans_timer: Time in milliseconds between retransmitted neighbor solicitations. 0 means unspecified by the router. options: Options to append to the router advertisement. May be NULL for none. Return values
- The resulting ICMPv6 packet on success.
- NULL, if packet buffer is full.
-
include/net/gnrc/pkt.h::gnrc_pktsnip_t
*gnrc_ndp_opt_build
(uint8_t type,msp430_types.h::size_t
size,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* next)¶ Builds a generic NDP option.
Parameters
type: Type of the option. size: Size in byte of the option (will be rounded up to the next multiple of 8). next: More options in the packet. NULL, if there are none. Return values
- The packet snip list of options, on success
- NULL, if packet buffer is full
-
include/net/gnrc/pkt.h::gnrc_pktsnip_t
*gnrc_ndp_opt_sl2a_build
(const uint8_t * l2addr, uint8_t l2addr_len,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* next)¶ Builds the source link-layer address option.
See also
Note
Should only be used with neighbor solicitations, router solicitations, and router advertisements. This is not checked however, since hosts should silently ignore it in other NDP messages.
Parameters
l2addr: A link-layer address of variable length. Must not be NULL. l2addr_len: Length of l2addr
. Must not be 0.next: More options in the packet. NULL, if there are none. Return values
- The packet snip list of options, on success
- NULL, if packet buffer is full
-
include/net/gnrc/pkt.h::gnrc_pktsnip_t
*gnrc_ndp_opt_tl2a_build
(const uint8_t * l2addr, uint8_t l2addr_len,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* next)¶ Builds the target link-layer address option.
See also
Note
Should only be used with neighbor advertisemnents and redirect packets. This is not checked however, since hosts should silently ignore it in other NDP messages.
Parameters
l2addr: A link-layer address of variable length. Must not be NULL. l2addr_len: Length of l2addr
. Must not be 0.next: More options in the packet. NULL, if there are none. Return values
- The pkt snip list of options, on success
- NULL, if packet buffer is full
-
include/net/gnrc/pkt.h::gnrc_pktsnip_t
*gnrc_ndp_opt_pi_build
(const ipv6_addr_t * prefix, uint8_t prefix_len, uint32_t valid_ltime, uint32_t pref_ltime, uint8_t flags,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* next)¶ Builds the prefix information option.
See also
Note
Should only be used with router advertisemnents. This is not checked however, since nodes should silently ignore it in other NDP messages.
Parameters
prefix: An IPv6 address or a prefix of an IPv6 address. Must not be NULL or be a link-local or multicast address. prefix_len: The length of prefix
in bits. Must be between 0 and 128.valid_ltime: Length of time in seconds that prefix
is valid. UINT32_MAX represents infinity.pref_ltime: Length of time in seconds that addresses using prefix
remain prefered. UINT32_MAX represents infinity.flags: Flags as defined in net/ndp.h. ndp.h::NDP_OPT_PI_FLAGS_L
== 1 indicates, thatprefix
can be used for on-link determination,ndp.h::NDP_OPT_PI_FLAGS_A
== 1 indicates, thatprefix
can be used for stateless address configuration.
next: More options in the packet. NULL, if there are none. Return values
- The packet snip list of options, on success
- NULL, if packet buffer is full
-
include/net/gnrc/pkt.h::gnrc_pktsnip_t
*gnrc_ndp_opt_mtu_build
(uint32_t mtu,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* next)¶ Builds the MTU option.
See also
Note
Should only be used with router advertisemnents. This is not checked however, since nodes should silently ignore it in other NDP messages.
Parameters
mtu: The recommended MTU for the link. next: More options in the packet. NULL, if there are none. Return values
- The packet snip list of options, on success
- NULL, if packet buffer is full
-
include/net/gnrc/pkt.h::gnrc_pktsnip_t
*gnrc_ndp_opt_rdnss_build
(uint32_t lifetime, ipv6_addr_t * addrs, unsigned addrs_num,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* next)¶ Builts the recursive DNS server option.
See also
Note
Should only be used with router advertisemnents. This is not checked however, since nodes should silently ignore it in other NDP messages.
Parameters
lifetime: The lifetime of the recursive DNS servers addrs: The addresses of the recursive DNS servers addrs_num: The number of addresses in addrs
next: More options in the packet. NULL, if there are none. Return values
- The packet snip list of options, on success
next
, if RDNSS is not supported- NULL, if packet buffer is full
-
void
gnrc_ndp_nbr_sol_send
(const ipv6_addr_t * tgt, gnrc_netif_t * netif, const ipv6_addr_t * src, const ipv6_addr_t * dst,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* ext_opts)¶ Send pre-compiled neighbor solicitation depending on a given network interface.
Parameters
tgt: The target address of the neighbor solicitation. Must not be NULL or a multicast address. netif: Interface to send over. Must not be NULL. src: Source address for the neighbor solicitation. Will be chosen from the interface according to dst
, if NULL.dst: Destination address for neighbor solicitation. Must not be NULL. ext_opts: External options for the neighbor advertisement. Leave NULL for none. Warning: these are not tested if they are suitable for a neighbor solicitation so be sure to check that. Will be released in an error case.
-
void
gnrc_ndp_nbr_adv_send
(const ipv6_addr_t * tgt, gnrc_netif_t * netif, const ipv6_addr_t * dst, bool supply_tl2a,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* ext_opts)¶ Send pre-compiled neighbor advertisement depending on a given network interface.
If
netif
is a forwarding interface and router advertisements are activated thendp.h::NDP_NBR_ADV_FLAGS_R
is set in the neighbor advertisement. Ifdst
isipv6/addr.h::IPV6_ADDR_UNSPECIFIED
it will be replaced withipv6/addr.h::IPV6_ADDR_ALL_NODES_LINK_LOCAL
and*supply_tl2a
is set to true implicitly. Otherwise, thendp.h::NDP_NBR_ADV_FLAGS_S
will be set. Iftgt
is an anycast address onnetif
thendp.h::NDP_NBR_ADV_FLAGS_O
flag will be set.The source address of the IPv6 packet will be left unspecified, so the IPv6 module selects a fitting IPv6 address.
Parameters
tgt: Target address for the neighbor advertisement. May not be NULL and MUST NOT be multicast. netif: Interface to send over. Must not be NULL. dst: Destination address for neighbor advertisement. May not be NULL. Is set to ipv6/addr.h::IPV6_ADDR_ALL_NODES_LINK_LOCAL
when equal toipv6/addr.h::IPV6_ADDR_UNSPECIFIED
(to allow for simple reply mechanisms to neighbor solicitations). This also implies thatsupply_tl2a
must be true and the parameter will be reset accordingly. Ifdst
is notipv6/addr.h::IPV6_ADDR_UNSPECIFIED
, thendp.h::NDP_NBR_ADV_FLAGS_S
flag will be set implicitly.supply_tl2a: Add target link-layer address option to neighbor advertisement if link-layer has addresses. If dst
isipv6/addr.h::IPV6_ADDR_UNSPECIFIED
, it will be set to true.ext_opts: External options for the neighbor advertisement. Leave NULL for none. Warning: these are not tested if they are suitable for a neighbor advertisement so be sure to check that. Will be released in an error case.
-
void
gnrc_ndp_rtr_sol_send
(gnrc_netif_t * netif, const ipv6_addr_t * dst)¶ Send pre-compiled router solicitation depending on a given network interface.
Parameters
netif: Interface to send over. Must not be NULL. dst: Destination for the router solicitation. ff02::2 if NULL.
-
void
gnrc_ndp_rtr_adv_send
(gnrc_netif_t * netif, const ipv6_addr_t * src, const ipv6_addr_t * dst, bool fin,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* ext_opts)¶ Send pre-compiled router advertisement depending on a given network interface.
This function does not add the PIOs to the router, since they are highly dependent on external set-ups (e.g. if multihop prefix distribution is used). Provide them via
ext_opts
Parameters
netif: Interface to send over. Must not be NULL. src: Source address for the router advertisement. May be NULL to be determined by source address selection (:: if netif
has no address).dst: Destination address for router advertisement. ff02::1 if NULL. fin: This is part of the router’s final batch of router advertisements before ceising to be a router (set’s router lifetime field to 0). ext_opts: External options for the neighbor advertisement. Leave NULL for none. Warning: these are not tested if they are suitable for a neighbor advertisement so be sure to check that. Will be released in an error case.
-
GNRC_NETTYPE_NDP
¶ Protocol type to send NDP packets to
1
(GNRC_NETTYPE_IPV6) /* usual configuration */