Forwarding Information Base (FIB)¶
FIB implementation.
-
void
fib_init
(fib_table_t * table)¶ initializes all FIB entries with 0
Parameters
table: the fib instance to initialize
-
void
fib_deinit
(fib_table_t * table)¶ de-initializes the FIB entries and source route entries
Parameters
table: the fib instance to de-initialize
-
int
fib_register_rp
(fib_table_t * table, uint8_t * prefix,msp430_types.h::size_t
prefix_addr_type_size)¶ Registration of a routing protocol handler function.
Parameters
table: the fib table the RP should be registered to prefix: the prefix handled by the according RP prefix_addr_type_size: the size of the address type used for the prefix Return values
- 0 on success -ENOMEM if the entry cannot be registered (mximum registrations reached) -EINVAL if the prefix is NULL or the provided size is 0
-
int
fib_add_entry
(fib_table_t * table,kernel_types.h::kernel_pid_t
iface_id, uint8_t * dst,msp430_types.h::size_t
dst_size, uint32_t dst_flags, uint8_t * next_hop,msp430_types.h::size_t
next_hop_size, uint32_t next_hop_flags, uint32_t lifetime)¶ Adds a new entry in the corresponding FIB table for global destination and next hop.
Parameters
table: the fib table the entry should be added to iface_id: the interface ID dst: the destination address dst_size: the destination address size dst_flags: the destination address flags next_hop: the next hop address to be updated next_hop_size: the next hop address size next_hop_flags: the next-hop address flags lifetime: the lifetime in ms to be updates Return values
- 0 on success -ENOMEM if the entry cannot be created due to insufficient RAM -EFAULT if dst and/or next_hop is not a valid pointer
-
int
fib_update_entry
(fib_table_t * table, uint8_t * dst,msp430_types.h::size_t
dst_size, uint8_t * next_hop,msp430_types.h::size_t
next_hop_size, uint32_t next_hop_flags, uint32_t lifetime)¶ Updates an entry in the FIB table with next hop and lifetime.
Parameters
table: the fib table containing the entry to update dst: the destination address dst_size: the destination address size next_hop: the next hop address to be updated next_hop_size: the next hop address size next_hop_flags: the next-hop address flags lifetime: the lifetime in ms to be updates Return values
- 0 on success -ENOMEM if the entry cannot be updated due to insufficient RAM -EFAULT if dst and/or next_hop is not a valid pointer
-
void
fib_remove_entry
(fib_table_t * table, uint8_t * dst,msp430_types.h::size_t
dst_size)¶ removes an entry from the corresponding FIB table
Parameters
table: the fib table containing the entry to remove dst: the destination address dst_size: the destination address size
-
void
fib_flush
(fib_table_t * table,kernel_types.h::kernel_pid_t
interface)¶ removes all entries from the corresponding FIB table and interface combination
Note
if interface is KERNEL_PID_UNDEF, then all entries regardless of the interface will be removed.
Parameters
table: the fib table to flush interface: entries associated with this interface will be removed
-
int
fib_get_next_hop
(fib_table_t * table,kernel_types.h::kernel_pid_t
* iface_id, uint8_t * next_hop,msp430_types.h::size_t
* next_hop_size, uint32_t * next_hop_flags, uint8_t * dst,msp430_types.h::size_t
dst_size, uint32_t dst_flags)¶ provides a next hop for a given destination
Parameters
table: the fib table that should be searched iface_id: pointer to store the interface ID for the next hop next_hop: pointer where the next hop address should be stored next_hop_size: the next hop address size. The value is overwritten with the actual next hop size next_hop_flags: the next-hop address flags, e.g. compression type dst: the destination address dst_size: the destination address size dst_flags: the destination address flags Return values
- 0 on success -EHOSTUNREACH if no next hop is available in any FIB table all RRPs are notified before the return -ENOBUFS if the size for the next hop address is insufficient low -EFAULT if dst and/or next_hop is not a valid pointer -EINVAL if one of the other passed out pointers is NULL
-
int
fib_get_destination_set
(fib_table_t * table, uint8_t * prefix,msp430_types.h::size_t
prefix_size, fib_destination_set_entry_t * dst_set,msp430_types.h::size_t
* dst_set_size)¶ provides a set of destination addresses matching the given prefix If the out buffer is insufficient low or passed as NULL, the function will continue to count the number of matching entries and provide the number to the caller.
Parameters
table: the fib table that should be searched prefix: the destination address prefix_size: the destination address size dst_set: the destination addresses matching the prefix dst_set_size: the number of entries available on in and used on out Return values
- 0 on success -EHOSTUNREACH if no entry matches the type in the FIB -ENOBUFS if the size for the found entries is insufficient low The actual needed size is stored then in dst_set_size, however the required size may change in between calls.
-
int
fib_sr_create
(fib_table_t * table, fib_sr_t ** fib_sr,kernel_types.h::kernel_pid_t
sr_iface_id, uint32_t sr_flags, uint32_t sr_lifetime)¶ creates a new source route
Parameters
table: the table the new source route belongs to fib_sr: pointer to store the new created source route pointer sr_iface_id: the interface ID used for the created source route sr_flags: the flags for the source route sr_lifetime: the lifetime in ms of the source route Return values
- 0 on success -EFAULT on wrong parameters, i.e. fib_sr is NULL and/or sr_lifetime is 0 -ENOBUFS on insufficient memory, i.e. all source route fields are in use
-
int
fib_sr_read_head
(fib_table_t * table, fib_sr_t * fib_sr,kernel_types.h::kernel_pid_t
* sr_iface_id, uint32_t * sr_flags, uint32_t * sr_lifetime)¶ reads the information from the sr head to the given locations
Parameters
table: the fib instance to access fib_sr: pointer to the sr to read from sr_iface_id: pointer to store the iface_id sr_flags: pointer to store the flags sr_lifetime: pointer to store the current left lifetime Return values
- 0 on success -ENOENT on expired lifetime of the source route -EFAULT on fib_sr is NULL
-
int
fib_sr_read_destination
(fib_table_t * table, fib_sr_t * fib_sr, uint8_t * dst,msp430_types.h::size_t
* dst_size)¶ reads the destination address from the sr head to the given location
Parameters
table: the fib instance to access fib_sr: pointer to the sr to read from dst: pointer to the store destination address bytes dst_size: pointer to store the destination address size Return values
- 0 on success -ENOENT on expired lifetime of the source route -EFAULT on one of the parameter pointers is NULL -ENOBUFS if the size to store the destination is insufficient low -EHOSTUNREACH on the destination address is not set
-
int
fib_sr_set
(fib_table_t * table, fib_sr_t * fib_sr,kernel_types.h::kernel_pid_t
* sr_iface_id, uint32_t * sr_flags, uint32_t * sr_lifetime)¶ sets the provided parameters in the given sr header if a given parameter is NULL its considered not to be changed
Parameters
table: the fib instance to access fib_sr: pointer to the sr to write to sr_iface_id: pointer to the new iface_id sr_flags: pointer to the new flags sr_lifetime: pointer to store the new lifetime Return values
- 0 on success -ENOENT on expired lifetime of the source route -EFAULT on passed fib_sr is NULL
-
int
fib_sr_delete
(fib_table_t * table, fib_sr_t * fib_sr)¶ deletes the sr
Parameters
table: the fib instance to access fib_sr: pointer to the source route to be deleted Return values
- 0 on success -EFAULT on fib_sr pointer is NULL
-
int
fib_sr_next
(fib_table_t * table, fib_sr_t * fib_sr,table.h::fib_sr_entry_t
** sr_path_entry)¶ iterates to the next entry in the sr_path
Parameters
table: the fib instance to access fib_sr: pointer to the sr to iterate sr_path_entry: pointer to the entry for iterating to the next entry Return values
- 0 on success 1 on success, end reached -ENOENT on expired lifetime of the source route -EFAULT on fib_sr and/or sr_path_entry is NULL
-
int
fib_sr_search
(fib_table_t * table, fib_sr_t * fib_sr, uint8_t * addr,msp430_types.h::size_t
addr_size,table.h::fib_sr_entry_t
** sr_path_entry)¶ searches the entry containing the given address
Parameters
table: the fib instance to access fib_sr: pointer to the sr to search for a hop address addr: pointer to the searched address bytes addr_size: the size in bytes of the searched address type sr_path_entry: pointer to the found address entry Return values
- 0 on success -EHOSTUNREACH when no address matches on the path -ENOENT on expired lifetime of the source route -EFAULT on one of the given parameter pointer is NULL
-
int
fib_sr_entry_append
(fib_table_t * table, fib_sr_t * fib_sr, uint8_t * dst,msp430_types.h::size_t
dst_size)¶ append a new entry at the end of the source route, i.e.
a new destination
Parameters
table: the table with the source route to append the new entry fib_sr: pointer to the sr to append a hop address dst: pointer to the new destination address bytes dst_size: the size in bytes of the destination address type Return values
- 0 on success -EINVAL on the given destination is already on the path in the source route -ENOENT on expired lifetime of the source route -EFAULT on fib_sr and/or dst is NULL
-
int
fib_sr_entry_add
(fib_table_t * table, fib_sr_t * fib_sr,table.h::fib_sr_entry_t
* sr_path_entry, uint8_t * addr,msp430_types.h::size_t
addr_size, bool keep_remaining_route)¶ adds a new entry behind a given sr entry
Parameters
table: the table with the source route to add the new entry fib_sr: pointer to the sr to add a hop address sr_path_entry: pointer to the entry after which we add the new one addr: pointer to the new address bytes addr_size: the size in bytes of the address type keep_remaining_route: indicate if the remaining route after sr_path_entry should be kept and appended after the new entry Return values
- 0 on success -EFAULT on fib_sr and/or sr_path_entry and/or addr is NULL -ENOENT on expired lifetime of the source route -EINVAL on the given address is already present in the path
-
int
fib_sr_entry_delete
(fib_table_t * table, fib_sr_t * fib_sr, uint8_t * addr,msp430_types.h::size_t
addr_size, bool keep_remaining_route)¶ removes an entry from a source route
Parameters
table: the fib instance to access fib_sr: pointer to the sr to delete a hop address addr: pointer to the address bytes to delete addr_size: the size in bytes of the address type keep_remaining_route: indicate if the remaining route should be kept and appended after the predecessor of the removed entry Return values
- 0 on success -EFAULT on one of the passed pointers is NULL -ENOENT on expired lifetime of the source route
-
int
fib_sr_entry_overwrite
(fib_table_t * table, fib_sr_t * fib_sr, uint8_t * addr_old,msp430_types.h::size_t
addr_old_size, uint8_t * addr_new,msp430_types.h::size_t
addr_new_size)¶ overwrites the address of an entry with a new address
Parameters
table: the fib instance to access fib_sr: pointer to the sr to overwrite a hop address addr_old: pointer to the address bytes to overwrite addr_old_size: the size in bytes of the address type addr_new: pointer to the new address bytes addr_new_size: the size in bytes of the address type Return values
- 0 on success -EINVAL on the given address is already present in the path -ENOMEM on no memory left to create a new address entry to overwrite the old one -EFAULT on one of the passed pointers is NULL -ENOENT on expired lifetime of the source route
-
int
fib_sr_entry_get_address
(fib_table_t * table, fib_sr_t * fib_sr,table.h::fib_sr_entry_t
* sr_path_entry, uint8_t * addr,msp430_types.h::size_t
* addr_size)¶ writes the address of an entry to the given out pointers
Parameters
table: the fib instance to access fib_sr: pointer to the sr to get a hop address sr_path_entry: pointer to the entry with the address addr: pointer to store the address bytes addr_size: the size in bytes of the address type Return values
- 0 on success -ENOMEM on insufficient memory provided to store the address -EFAULT on one of the passed pointers is NULL -ENOENT on expired lifetime of the source route
-
int
fib_sr_get_route
(fib_table_t * table, uint8_t * dst,msp430_types.h::size_t
dst_size,kernel_types.h::kernel_pid_t
* sr_iface_id, uint32_t * sr_flags, uint8_t * addr_list,msp430_types.h::size_t
* addr_list_size,msp430_types.h::size_t
* element_size, bool reverse, fib_sr_t ** fib_sr)¶ copies a source route to the given destination
Parameters
table: table to search for a source route dst: pointer to the destination address bytes dst_size: the size in bytes of the destination address type sr_iface_id: pointer to the store the iface_id for this route sr_flags: pointer to store the flags of this route addr_list: pointer to the location for storing the source route addresses addr_list_size: the number of elements available in addr_list element_size: the provided size for one element in addr_list reverse: indicator if the hops should be stored in reverse order fib_sr: pointer for cosecutive receiving matching source routes. If NULL only the first matching source route is returned. If !NULL the pointer will be overwritten with the current returned fib_sr. The FIB skips all entries until the provided fib_sr+1. The fib_sr pointer is only overwritten when a further matching sr has been found. Note
The actual needed size for an element and the number of elements is stored in addr_list_elements and element_size respectively when the return value is NOT -EFAULT or NOT -EHOSTUNREACH. However,the required size for may change in between calls.
Return values
- 0 on success, path to destination with equal flags 1 on success, path to destination with distinct flags -EFAULT on one of the provided parameter pointers is NULL -EHOSTUNREACH if no sr for the destination exists in the FIB -ENOBUFS if the size to store all hops is insufficient low
-
int
fib_get_num_used_entries
(fib_table_t * table)¶ returns the actual number of used FIB entries
Parameters
table: the fib instance to check
-
void
fib_print_notify_rrp
(void)¶ Prints the kernel_pid_t for all registered RRPs.
-
void
fib_print_fib_table
(fib_table_t * table)¶ Prints the FIB content (does not print the entries)
Parameters
table: the fib instance to print
-
void
fib_print_routes
(fib_table_t * table)¶ Prints the FIB content.
Parameters
table: the fib instance to print
-
void
fib_print_sr
(fib_table_t * table, fib_sr_t * sr)¶ Prints the given FIB sourceroute.
Parameters
table: the fib instance to print sr: the source route to print
-
FIB_MSG_RP_SIGNAL_UNREACHABLE_DESTINATION
¶ message type for RP notification: no route to destination available, start route discovery if appropriate
1
(0x99)
-
FIB_MSG_RP_SIGNAL_DESTINATION_USED
¶ message type for RP notification: entry used
1
(0x98)
-
FIB_MSG_RP_SIGNAL_SOURCE_ROUTE_CREATED
¶ message type for RP notification: source route created
1
(0x97)
-
FIB_LIFETIME_NO_EXPIRE
¶ indicator of a lifetime that does not expire (2^64 - 1)
1
(0xFFFFFFFFffffffff)
-
FIB_FLAG_RPL_ROUTE
¶ flag to identify if a route was set by RPL
1
(1UL << 0)
-
FIB_FLAG_NET_PREFIX_SHIFT
¶ flag used as shift for the net prefix length in bits
1
(24)
-
FIB_FLAG_NET_PREFIX_MASK
¶ flag used as mask for the net prefix length in bits
1
(0xffUL << FIB_FLAG_NET_PREFIX_SHIFT)