Forwarding table¶
-
int
gnrc_ipv6_nib_ft_get
(const ipv6_addr_t * dst,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* pkt, gnrc_ipv6_nib_ft_t * fte)¶ Gets the best matching forwarding table entry to a destination.
Parameters
dst: The destination. pkt: Packet that is supposed to go to that destination (is handed over to a reactive routing protocol if one exists on the interface found and no route is found) fte: The resulting forwarding table entry. Return values
- 0, on success.
- -ENETUNREACH, if no route was found.
-
int
gnrc_ipv6_nib_ft_add
(const ipv6_addr_t * dst, unsigned dst_len, const ipv6_addr_t * next_hop, unsigned iface, uint16_t lifetime)¶ Adds a new route to the forwarding table.
If
dst
is the default route, the route will be configured to be the default route.Parameters
dst: The destination to the route. May be NULL or ::
for default route.dst_len: The prefix length of dst
in bits. May be 0 for default route.next_hop: The next hop to dst/dst_len.
May be NULL, ifdst/dst_len is
no the default route.iface: The interface to next_hop
. May not be 0.lifetime: Lifetime of the route in seconds. 0 for infinite lifetime. Return values
- 0, on success.
- -EINVAL, if a parameter was of invalid value.
- -ENOMEM, if there was no space left in forwarding table.
-
void
gnrc_ipv6_nib_ft_del
(const ipv6_addr_t * dst, unsigned dst_len)¶ Deletes a route from forwarding table.
If
dst
is the default route, the function assures, that the current primary default route is removed first.Parameters
dst: The destination of the route. May be NULL or ::
for default route.dst_len: The prefix length of dst
in bits. May be 0 for default route.
-
bool
gnrc_ipv6_nib_ft_iter
(const ipv6_addr_t * next_hop, unsigned iface, void ** state, gnrc_ipv6_nib_ft_t * fte)¶ Iterates over all forwarding table entries in the NIB.
Parameters
next_hop: Restrict iteration to entries to this next hop. NULL for any next hop. Can be used to build a source routing tree. iface: Restrict iteration to entries on this interface. 0 for any interface. state: Iteration state of the forwarding table. Must point to a NULL pointer to start iteration. fte: The next forwarding table entry. gnrc_ipv6_nib_ft_add()
and entries that are currently in the Destination Cache, in the Prefix List, and in the Default Router List.Usage example:
1 2 3 4 5 6 7 8 9 10 11 12
#include "net/gnrc/ipv6/nib/ft.h" int main(void) { void *state = NULL; gnrc_ipv6_nib_ft_t fte; puts("My neighbors:"); while (gnrc_ipv6_nib_ft_iter(NULL, 0, &state, &fte)) { gnrc_ipv6_nib_ft_print(&fte); } return 0; }
Note
The list may change during iteration.
Return values
- true, if iteration can be continued.
- false, if
fte
is the last neighbor cache entry in the NIB.
-
void
gnrc_ipv6_nib_ft_print
(const gnrc_ipv6_nib_ft_t * fte)¶ Prints a forwarding table entry.
Parameters
fte: A forwarding table entry.
-
struct
gnrc_ipv6_nib_ft_t
¶ Forwarding table entry view on NIB.
-
ipv6_addr_t
dst
¶ destination or prefix
-
ipv6_addr_t
next_hop
¶ next hop to
ft.h::gnrc_ipv6_nib_ft_t::dst
-
uint8_t
dst_len
¶ prefix-length in bits of
ft.h::gnrc_ipv6_nib_ft_t::dst
-
uint8_t
primary
¶ != 0 if
ft.h::gnrc_ipv6_nib_ft_t::dst
is preferred default route
-
uint16_t
iface
¶ interface to
ft.h::gnrc_ipv6_nib_ft_t::next_hop
-
ipv6_addr_t