Adding Fibroute addr on RIOT interface

Hi Kaspar,

Thanks for the tip, but while i was waiting for the reply i did it :wink: Include the “shell_commands.h” and try something like :

char** argum[] = {“fibroute”, “add”, “::”, “via”, “fe80::1ac0:ffee:1ac0:ffee”}; _fib_route_handler(5, argum);

This above is just an example with a fixed root ipv6 address.

Hi,

I would suggest to use the functions directly instead of “sailing” around them with shell commands.

You will need the following:

// the :: destination address [1]. (Alternatively it can be set anywhere using [2] or [3]) ipv6_addr_t dest = IPV6_ADDR_UNSPECIFIED;

// your next-hop ipv6_addr_t next = IPV6_ADDR_UNSPECIFIED;

// for example you can use [3] to get the ipv6 address from a string (or set the values manually) ipv6_addr_from_str(&next, “fe80::1ac0:ffee:1ac0:ffee”);

// get your interface pid of your transceiver handling the address [4] kernel_pid_t iface = gnrc_ipv6_netif_find_by_addr(NULL, next);

// prepare FIB flags with prefix length of your destination, i.e. 128 for :: uint32_t dst_flags = ((uint32_t)128 << FIB_FLAG_NET_PREFIX_SHIFT);

// and finally add the entry to the FIB [5] fib_add_entry( &gnrc_ipv6_fib_table, // the FIB table is accessible when GNRC+FIB is used [6] iface, dest.u8, sizeof(ipv6_addr_t), dst_flags, next.u8, sizeof(ipv6_addr_t), 0, FIB_LIFETIME_NO_EXPIRE // prevents auto-removing of this entry by the FIB );

I haven’t tested the code-snips, but in general this should work. I hope it helps a bit.

Best Regards, Martin

[1] https://github.com/RIOT-OS/RIOT/blob/master/sys/include/net/ipv6/addr.h#L88 [2] https://github.com/RIOT-OS/RIOT/blob/master/sys/include/net/ipv6/addr.h#L559 [3] https://github.com/RIOT-OS/RIOT/blob/master/sys/include/net/ipv6/addr.h#L730 [4] https://github.com/RIOT-OS/RIOT/blob/master/sys/include/net/gnrc/ipv6/netif.h#L466 [5] https://github.com/RIOT-OS/RIOT/blob/master/sys/include/net/fib.h#L135 [6] https://github.com/RIOT-OS/RIOT/blob/master/sys/include/net/gnrc/ipv6.h#L99