31 lines
921 B
C
31 lines
921 B
C
#ifndef ROUTETABLE_H
|
|
#define ROUTETABLE_H
|
|
|
|
#include <stdint.h>
|
|
#include <libart/art.h>
|
|
|
|
typedef struct {
|
|
uint32_t destination;
|
|
uint32_t mask;
|
|
uint32_t nextHop;
|
|
} route_table_v4_entry_t;
|
|
|
|
typedef struct {
|
|
__uint128_t destination;
|
|
__uint128_t mask;
|
|
__uint128_t nextHop;
|
|
} route_table_v6_entry_t;
|
|
|
|
// General rule: 0 = success, -1 = failure (Note: per-function return values may vary, will be documented in the .c file)
|
|
int RouteTable_Init(void);
|
|
void RouteTable_Cleanup(void);
|
|
|
|
int RouteTable_AddRoute_v4(uint32_t destination, uint32_t mask, uint32_t nextHop);
|
|
int RouteTable_AddRoute_v6(__uint128_t destination, __uint128_t mask, __uint128_t nextHop);
|
|
|
|
// GetNextHop performs longest prefix match; writes best matching next hop into *nextHop
|
|
int RouteTable_GetNextHop_v4(uint32_t destination, uint32_t* nextHop);
|
|
int RouteTable_GetNextHop_v6(__uint128_t destination, __uint128_t* nextHop);
|
|
|
|
#endif
|