Skip to content

Commit

Permalink
WIP: multiple instances of FIB
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegHahm committed Aug 12, 2015
1 parent 5fffc17 commit 725420f
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 115 deletions.
8 changes: 0 additions & 8 deletions sys/auto_init/auto_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@
#include "dev_eth_autoinit.h"
#endif

#ifdef MODULE_FIB
#include "net/fib.h"
#endif

#define ENABLE_DEBUG (0)
#include "debug.h"

Expand Down Expand Up @@ -153,10 +149,6 @@ void auto_init(void)
DEBUG("Auto init UDP module.\n");
ng_udp_init();
#endif
#ifdef MODULE_FIB
DEBUG("Auto init FIB module.\n");
fib_init();
#endif


/* initialize network devices */
Expand Down
29 changes: 18 additions & 11 deletions sys/include/net/fib.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@
#ifndef FIB_H_
#define FIB_H_

#include "net/fib/table.h"
#include "kernel_types.h"
#include "timex.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief maximum number of FIB tables entries handled
*/
#define FIB_MAX_FIB_TABLE_ENTRIES (20)

/**
* @brief Routing Protocol (RP) message content to request/reply notification
*/
Expand Down Expand Up @@ -62,12 +68,12 @@ typedef struct fib_destination_set_entry_t {
/**
* @brief initializes all FIB entries with 0
*/
void fib_init(void);
void fib_init(fib_entry_t table[]);

/**
* @brief de-initializes the FIB entries
*/
void fib_deinit(void);
void fib_deinit(fib_entry_t table[]);

/**
* @brief Registration of a routing protocol handler function
Expand Down Expand Up @@ -98,8 +104,9 @@ int fib_register_rp(uint8_t *prefix, size_t prefix_addr_type_size);
* -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_add_entry(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,
int fib_add_entry(fib_entry_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);

/**
Expand All @@ -116,7 +123,7 @@ int fib_add_entry(kernel_pid_t iface_id, uint8_t *dst, size_t dst_size, uint32_t
* -ENOMEM if the entry cannot be updated due to insufficient RAM
* -EFAULT if dst and/or next_hop is not a valid pointer
*/
int fib_update_entry(uint8_t *dst, size_t dst_size,
int fib_update_entry(fib_entry_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);

Expand All @@ -126,7 +133,7 @@ int fib_update_entry(uint8_t *dst, size_t dst_size,
* @param[in] dst the destination address
* @param[in] dst_size the destination address size
*/
void fib_remove_entry(uint8_t *dst, size_t dst_size);
void fib_remove_entry(fib_entry_t table[], uint8_t *dst, size_t dst_size);

/**
* @brief provides a next hop for a given destination
Expand All @@ -147,7 +154,7 @@ void fib_remove_entry(uint8_t *dst, size_t dst_size);
* -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_next_hop(kernel_pid_t *iface_id,
int fib_get_next_hop(fib_entry_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);

Expand All @@ -169,14 +176,14 @@ int fib_get_next_hop(kernel_pid_t *iface_id,
* The actual needed size is stored then in dst_set_size,
* however the required size may change in between calls.
*/
int fib_get_destination_set(uint8_t *prefix, size_t prefix_size,
int fib_get_destination_set(fib_entry_t table[], uint8_t *prefix, size_t prefix_size,
fib_destination_set_entry_t *dst_set, size_t* dst_set_size);


/**
* @brief returns the actual number of used FIB entries
*/
int fib_get_num_used_entries(void);
int fib_get_num_used_entries(fib_entry_t table[]);

/**
* @brief Prints the kernel_pid_t for all registered RRPs
Expand All @@ -186,12 +193,12 @@ void fib_print_notify_rrp(void);
/**
* @brief Prints the FIB content (does not print the entries)
*/
void fib_print_fib_table(void);
void fib_print_fib_table(fib_entry_t table[]);

/**
* @brief Prints the FIB content
*/
void fib_print_routes(void);
void fib_print_routes(fib_entry_t table[]);

#if FIB_DEVEL_HELPER
/**
Expand Down
8 changes: 8 additions & 0 deletions sys/include/net/ng_ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#include "net/ng_ipv6/nc.h"
#include "net/ng_ipv6/netif.h"

#ifdef MODULE_FIB
#include "net/fib.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -73,6 +77,10 @@ extern "C" {
*/
extern kernel_pid_t ng_ipv6_pid;

extern fib_entry_t ng_ipv6_fib_table[FIB_MAX_FIB_TABLE_ENTRIES];

extern fib_entry_t ng_ipv6_dest_cache[FIB_MAX_FIB_TABLE_ENTRIES];

/**
* @brief Initialization of the IPv6 thread.
*
Expand Down
Loading

0 comments on commit 725420f

Please sign in to comment.