fib.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Martin Landsmann <Martin.Landsmann@HAW-Hamburg.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
25 #ifndef NET_FIB_H
26 #define NET_FIB_H
27 
28 #include <stdint.h>
29 
30 #include "net/fib/table.h"
31 #include "sched.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
40 typedef struct {
41  uint8_t *address;
42  uint8_t address_size;
43  uint32_t address_flags;
45 
50 #define FIB_MSG_RP_SIGNAL_UNREACHABLE_DESTINATION (0x99)
51 
55 #define FIB_MSG_RP_SIGNAL_DESTINATION_USED (0x98)
56 
60 #define FIB_MSG_RP_SIGNAL_SOURCE_ROUTE_CREATED (0x97)
61 
65 typedef struct {
66  uint8_t dest[UNIVERSAL_ADDRESS_SIZE];
67  size_t dest_size;
69 
73 #define FIB_LIFETIME_NO_EXPIRE (0xFFFFFFFFffffffff)
74 
78 #define FIB_FLAG_RPL_ROUTE (1UL << 0)
79 
83 #define FIB_FLAG_NET_PREFIX_SHIFT (24)
84 
88 #define FIB_FLAG_NET_PREFIX_MASK (0xffUL << FIB_FLAG_NET_PREFIX_SHIFT)
89 
95 void fib_init(fib_table_t *table);
96 
102 void fib_deinit(fib_table_t *table);
103 
116 int fib_register_rp(fib_table_t *table, uint8_t *prefix, size_t prefix_addr_type_size);
117 
135 int fib_add_entry(fib_table_t *table, kernel_pid_t iface_id, uint8_t *dst,
136  size_t dst_size, uint32_t dst_flags, uint8_t *next_hop,
137  size_t next_hop_size, uint32_t next_hop_flags,
138  uint32_t lifetime);
139 
155 int fib_update_entry(fib_table_t *table, uint8_t *dst, size_t dst_size,
156  uint8_t *next_hop, size_t next_hop_size,
157  uint32_t next_hop_flags, uint32_t lifetime);
158 
166 void fib_remove_entry(fib_table_t *table, uint8_t *dst, size_t dst_size);
167 
177 void fib_flush(fib_table_t *table, kernel_pid_t interface);
178 
199 int fib_get_next_hop(fib_table_t *table, kernel_pid_t *iface_id,
200  uint8_t *next_hop, size_t *next_hop_size,
201  uint32_t* next_hop_flags, uint8_t *dst, size_t dst_size,
202  uint32_t dst_flags);
203 
223 int fib_get_destination_set(fib_table_t *table, uint8_t *prefix,
224  size_t prefix_size,
226  size_t *dst_set_size);
227 
241 int fib_sr_create(fib_table_t *table, fib_sr_t **fib_sr, kernel_pid_t sr_iface_id,
242  uint32_t sr_flags, uint32_t sr_lifetime);
243 
257 int fib_sr_read_head(fib_table_t *table, fib_sr_t *fib_sr, kernel_pid_t *sr_iface_id,
258  uint32_t *sr_flags, uint32_t *sr_lifetime);
259 
274 int fib_sr_read_destination(fib_table_t *table, fib_sr_t *fib_sr,
275  uint8_t *dst, size_t *dst_size);
276 
291 int fib_sr_set(fib_table_t *table, fib_sr_t *fib_sr, kernel_pid_t *sr_iface_id,
292  uint32_t *sr_flags, uint32_t *sr_lifetime);
293 
303 int fib_sr_delete(fib_table_t *table, fib_sr_t *fib_sr);
304 
317 int fib_sr_next(fib_table_t *table, fib_sr_t *fib_sr, fib_sr_entry_t **sr_path_entry);
318 
333 int fib_sr_search(fib_table_t *table, fib_sr_t *fib_sr, uint8_t *addr, size_t addr_size,
334  fib_sr_entry_t **sr_path_entry);
335 
349 int fib_sr_entry_append(fib_table_t *table, fib_sr_t *fib_sr,
350  uint8_t *dst, size_t dst_size);
351 
368 int fib_sr_entry_add(fib_table_t *table, fib_sr_t *fib_sr,
369  fib_sr_entry_t *sr_path_entry, uint8_t *addr, size_t addr_size,
370  bool keep_remaining_route);
371 
386 int fib_sr_entry_delete(fib_table_t *table, fib_sr_t *fib_sr, uint8_t *addr, size_t addr_size,
387  bool keep_remaining_route);
388 
405 int fib_sr_entry_overwrite(fib_table_t *table, fib_sr_t *fib_sr,
406  uint8_t *addr_old, size_t addr_old_size,
407  uint8_t *addr_new, size_t addr_new_size);
408 
423 int fib_sr_entry_get_address(fib_table_t *table, fib_sr_t *fib_sr, fib_sr_entry_t *sr_path_entry,
424  uint8_t *addr, size_t *addr_size);
425 
426 
456 int fib_sr_get_route(fib_table_t *table, uint8_t *dst, size_t dst_size, kernel_pid_t *sr_iface_id,
457  uint32_t *sr_flags,
458  uint8_t *addr_list, size_t *addr_list_size, size_t *element_size,
459  bool reverse, fib_sr_t **fib_sr);
460 
467 
471 void fib_print_notify_rrp(void);
472 
478 void fib_print_fib_table(fib_table_t *table);
479 
485 void fib_print_routes(fib_table_t *table);
486 
493 void fib_print_sr(fib_table_t *table, fib_sr_t *sr);
494 
495 #if FIB_DEVEL_HELPER
496 
507 int fib_devel_get_lifetime(fib_table_t *table, uint64_t *lifetime, uint8_t *dst,
508  size_t dst_size);
509 
510 #endif
511 
512 #ifdef __cplusplus
513 }
514 #endif
515 
516 #endif /* NET_FIB_H */
517 
kernel_pid_t
int16_t kernel_pid_t
Unique process identifier.
Definition: sched.h:125
fib_destination_set_entry_t
entry used to collect available destinations
Definition: fib.h:65
UNIVERSAL_ADDRESS_SIZE
#define UNIVERSAL_ADDRESS_SIZE
size of the used addresses in bytes
Definition: universal_address.h:35
rp_address_msg_t::address
uint8_t * address
The pointer to the address.
Definition: fib.h:41
fib_sr_next
int fib_sr_next(fib_table_t *table, fib_sr_t *fib_sr, fib_sr_entry_t **sr_path_entry)
iterates to the next entry in the sr_path
fib_flush
void fib_flush(fib_table_t *table, kernel_pid_t interface)
removes all entries from the corresponding FIB table and interface combination
fib_sr_entry_append
int fib_sr_entry_append(fib_table_t *table, fib_sr_t *fib_sr, uint8_t *dst, size_t dst_size)
append a new entry at the end of the source route, i.e.
fib_table_t
Meta information of a FIB table.
Definition: table.h:108
fib_update_entry
int fib_update_entry(fib_table_t *table, uint8_t *dst, size_t dst_size, uint8_t *next_hop, 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.
fib_sr_entry_delete
int fib_sr_entry_delete(fib_table_t *table, fib_sr_t *fib_sr, uint8_t *addr, size_t addr_size, bool keep_remaining_route)
removes an entry from a source route
fib_sr_entry_get_address
int fib_sr_entry_get_address(fib_table_t *table, fib_sr_t *fib_sr, fib_sr_entry_t *sr_path_entry, uint8_t *addr, size_t *addr_size)
writes the address of an entry to the given out pointers
fib_sr_entry_overwrite
int fib_sr_entry_overwrite(fib_table_t *table, fib_sr_t *fib_sr, uint8_t *addr_old, size_t addr_old_size, uint8_t *addr_new, size_t addr_new_size)
overwrites the address of an entry with a new address
fib_print_sr
void fib_print_sr(fib_table_t *table, fib_sr_t *sr)
Prints the given FIB sourceroute.
fib_sr_set
int fib_sr_set(fib_table_t *table, fib_sr_t *fib_sr, 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 t...
sched.h
Scheduler API definition.
fib_deinit
void fib_deinit(fib_table_t *table)
de-initializes the FIB entries and source route entries
fib_get_next_hop
int fib_get_next_hop(fib_table_t *table, kernel_pid_t *iface_id, uint8_t *next_hop, size_t *next_hop_size, uint32_t *next_hop_flags, uint8_t *dst, size_t dst_size, uint32_t dst_flags)
provides a next hop for a given destination
fib_register_rp
int fib_register_rp(fib_table_t *table, uint8_t *prefix, size_t prefix_addr_type_size)
Registration of a routing protocol handler function.
fib_print_notify_rrp
void fib_print_notify_rrp(void)
Prints the kernel_pid_t for all registered RRPs.
fib_sr_read_head
int fib_sr_read_head(fib_table_t *table, fib_sr_t *fib_sr, 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
fib_get_destination_set
int fib_get_destination_set(fib_table_t *table, uint8_t *prefix, size_t prefix_size, fib_destination_set_entry_t *dst_set, size_t *dst_set_size)
provides a set of destination addresses matching the given prefix If the out buffer is insufficient l...
fib_sr_t
Container descriptor for a FIB source route.
Definition: table.h:69
fib_sr_delete
int fib_sr_delete(fib_table_t *table, fib_sr_t *fib_sr)
deletes the sr
fib_sr_read_destination
int fib_sr_read_destination(fib_table_t *table, fib_sr_t *fib_sr, uint8_t *dst, size_t *dst_size)
reads the destination address from the sr head to the given location
fib_sr_create
int fib_sr_create(fib_table_t *table, fib_sr_t **fib_sr, kernel_pid_t sr_iface_id, uint32_t sr_flags, uint32_t sr_lifetime)
creates a new source route
fib_destination_set_entry_t::dest_size
size_t dest_size
The destination address size.
Definition: fib.h:67
rp_address_msg_t::address_flags
uint32_t address_flags
The flags for the given address.
Definition: fib.h:43
rp_address_msg_t::address_size
uint8_t address_size
The address size.
Definition: fib.h:42
fib_init
void fib_init(fib_table_t *table)
initializes all FIB entries with 0
fib_sr_entry_add
int fib_sr_entry_add(fib_table_t *table, fib_sr_t *fib_sr, fib_sr_entry_t *sr_path_entry, uint8_t *addr, size_t addr_size, bool keep_remaining_route)
adds a new entry behind a given sr entry
fib_sr_entry
Container descriptor for a FIB source route entry.
Definition: table.h:59
fib_print_fib_table
void fib_print_fib_table(fib_table_t *table)
Prints the FIB content (does not print the entries)
rp_address_msg_t
Routing Protocol (RP) message content to request/reply notification.
Definition: fib.h:40
fib_print_routes
void fib_print_routes(fib_table_t *table)
Prints the FIB content.
fib_sr_get_route
int fib_sr_get_route(fib_table_t *table, uint8_t *dst, size_t dst_size, kernel_pid_t *sr_iface_id, uint32_t *sr_flags, uint8_t *addr_list, size_t *addr_list_size, size_t *element_size, bool reverse, fib_sr_t **fib_sr)
copies a source route to the given destination
fib_get_num_used_entries
int fib_get_num_used_entries(fib_table_t *table)
returns the actual number of used FIB entries
fib_add_entry
int fib_add_entry(fib_table_t *table, kernel_pid_t iface_id, uint8_t *dst, size_t dst_size, uint32_t dst_flags, uint8_t *next_hop, 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.
fib_sr_search
int fib_sr_search(fib_table_t *table, fib_sr_t *fib_sr, uint8_t *addr, size_t addr_size, fib_sr_entry_t **sr_path_entry)
searches the entry containing the given address
table.h
Types and functions for operating fib tables.
fib_remove_entry
void fib_remove_entry(fib_table_t *table, uint8_t *dst, size_t dst_size)
removes an entry from the corresponding FIB table