Loading...
Searching...
No Matches
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
27#ifndef NET_FIB_H
28#define NET_FIB_H
29
30#include <stdint.h>
31
32#include "net/fib/table.h"
33#include "sched.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
42typedef struct {
43 uint8_t *address;
44 uint8_t address_size;
45 uint32_t address_flags;
47
52#define FIB_MSG_RP_SIGNAL_UNREACHABLE_DESTINATION (0x99)
53
57#define FIB_MSG_RP_SIGNAL_DESTINATION_USED (0x98)
58
62#define FIB_MSG_RP_SIGNAL_SOURCE_ROUTE_CREATED (0x97)
63
67typedef struct {
68 uint8_t dest[UNIVERSAL_ADDRESS_SIZE];
69 size_t dest_size;
71
75#define FIB_LIFETIME_NO_EXPIRE (0xFFFFFFFFffffffff)
76
80#define FIB_FLAG_RPL_ROUTE (1UL << 0)
81
85#define FIB_FLAG_NET_PREFIX_SHIFT (24)
86
90#define FIB_FLAG_NET_PREFIX_MASK (0xffUL << FIB_FLAG_NET_PREFIX_SHIFT)
91
97void fib_init(fib_table_t *table);
98
105
118int fib_register_rp(fib_table_t *table, uint8_t *prefix, size_t prefix_addr_type_size);
119
137int fib_add_entry(fib_table_t *table, kernel_pid_t iface_id, uint8_t *dst,
138 size_t dst_size, uint32_t dst_flags, uint8_t *next_hop,
139 size_t next_hop_size, uint32_t next_hop_flags,
140 uint32_t lifetime);
141
157int fib_update_entry(fib_table_t *table, uint8_t *dst, size_t dst_size,
158 uint8_t *next_hop, size_t next_hop_size,
159 uint32_t next_hop_flags, uint32_t lifetime);
160
168void fib_remove_entry(fib_table_t *table, uint8_t *dst, size_t dst_size);
169
179void fib_flush(fib_table_t *table, kernel_pid_t interface);
180
202 uint8_t *next_hop, size_t *next_hop_size,
203 uint32_t* next_hop_flags, uint8_t *dst, size_t dst_size,
204 uint32_t dst_flags);
205
225int fib_get_destination_set(fib_table_t *table, uint8_t *prefix,
226 size_t prefix_size,
228 size_t *dst_set_size);
229
243int fib_sr_create(fib_table_t *table, fib_sr_t **fib_sr, kernel_pid_t sr_iface_id,
244 uint32_t sr_flags, uint32_t sr_lifetime);
245
259int fib_sr_read_head(fib_table_t *table, fib_sr_t *fib_sr, kernel_pid_t *sr_iface_id,
260 uint32_t *sr_flags, uint32_t *sr_lifetime);
261
277 uint8_t *dst, size_t *dst_size);
278
293int fib_sr_set(fib_table_t *table, fib_sr_t *fib_sr, kernel_pid_t *sr_iface_id,
294 uint32_t *sr_flags, uint32_t *sr_lifetime);
295
305int fib_sr_delete(fib_table_t *table, fib_sr_t *fib_sr);
306
319int fib_sr_next(fib_table_t *table, fib_sr_t *fib_sr, fib_sr_entry_t **sr_path_entry);
320
335int fib_sr_search(fib_table_t *table, fib_sr_t *fib_sr, uint8_t *addr, size_t addr_size,
336 fib_sr_entry_t **sr_path_entry);
337
352 uint8_t *dst, size_t dst_size);
353
371 fib_sr_entry_t *sr_path_entry, uint8_t *addr, size_t addr_size,
372 bool keep_remaining_route);
373
388int fib_sr_entry_delete(fib_table_t *table, fib_sr_t *fib_sr, uint8_t *addr, size_t addr_size,
389 bool keep_remaining_route);
390
408 uint8_t *addr_old, size_t addr_old_size,
409 uint8_t *addr_new, size_t addr_new_size);
410
426 uint8_t *addr, size_t *addr_size);
427
457int fib_sr_get_route(fib_table_t *table, uint8_t *dst, size_t dst_size, kernel_pid_t *sr_iface_id,
458 uint32_t *sr_flags,
459 uint8_t *addr_list, size_t *addr_list_size, size_t *element_size,
460 bool reverse, fib_sr_t **fib_sr);
461
468
473
480
487
495
496#if FIB_DEVEL_HELPER
508int fib_devel_get_lifetime(fib_table_t *table, uint64_t *lifetime, uint8_t *dst,
509 size_t dst_size);
510
511#endif
512
513#ifdef __cplusplus
514}
515#endif
516
517#endif /* NET_FIB_H */
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:139
void fib_init(fib_table_t *table)
initializes all FIB entries with 0
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
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
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.
void fib_print_fib_table(fib_table_t *table)
Prints the FIB content (does not print the entries)
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
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
void fib_print_sr(fib_table_t *table, fib_sr_t *sr)
Prints the given FIB sourceroute.
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
void fib_deinit(fib_table_t *table)
de-initializes the FIB entries and source route entries
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...
void fib_print_notify_rrp(void)
Prints the kernel_pid_t for all registered RRPs.
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...
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.
void fib_flush(fib_table_t *table, kernel_pid_t interface)
removes all entries from the corresponding FIB table and interface combination
void fib_print_routes(fib_table_t *table)
Prints the FIB content.
int fib_get_num_used_entries(fib_table_t *table)
returns the actual number of used FIB entries
int fib_register_rp(fib_table_t *table, uint8_t *prefix, size_t prefix_addr_type_size)
Registration of a routing protocol handler function.
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
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
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
int fib_sr_delete(fib_table_t *table, fib_sr_t *fib_sr)
deletes the sr
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.
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
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
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
void fib_remove_entry(fib_table_t *table, uint8_t *dst, size_t dst_size)
removes an entry from the corresponding FIB table
#define UNIVERSAL_ADDRESS_SIZE
size of the used addresses in bytes
Scheduler API definition.
entry used to collect available destinations
Definition fib.h:67
size_t dest_size
The destination address size.
Definition fib.h:69
Container descriptor for a FIB source route entry.
Definition table.h:59
Container descriptor for a FIB source route.
Definition table.h:69
Meta information of a FIB table.
Definition table.h:108
Routing Protocol (RP) message content to request/reply notification.
Definition fib.h:42
uint8_t address_size
The address size.
Definition fib.h:44
uint8_t * address
The pointer to the address.
Definition fib.h:43
uint32_t address_flags
The flags for the given address.
Definition fib.h:45
Types and functions for operating fib tables.