initial
This commit is contained in:
42
include/forward/if/interface.h
Normal file
42
include/forward/if/interface.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef INTERFACE_H
|
||||
#define INTERFACE_H
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct interface_v4 interface_v4_t;
|
||||
typedef struct interface_v6 interface_v6_t;
|
||||
|
||||
typedef struct interface_packet {
|
||||
sa_family_t family;
|
||||
const uint8_t* data;
|
||||
size_t length;
|
||||
struct sockaddr_storage source;
|
||||
struct sockaddr_storage destination;
|
||||
} interface_packet_t;
|
||||
|
||||
typedef void (*interface_packet_callback_t)(const interface_packet_t* packet, void* userData);
|
||||
|
||||
int Interface_Init(void);
|
||||
void Interface_Cleanup(void);
|
||||
|
||||
interface_v4_t* Interface_Create_v4(const char* localAddress, interface_packet_callback_t callback, void* userData);
|
||||
interface_v6_t* Interface_Create_v6(const char* localAddress, interface_packet_callback_t callback, void* userData);
|
||||
|
||||
int Interface_Listen_v4(interface_v4_t* iface);
|
||||
int Interface_Listen_v6(interface_v6_t* iface);
|
||||
|
||||
void Interface_Stop_v4(interface_v4_t* iface);
|
||||
void Interface_Stop_v6(interface_v6_t* iface);
|
||||
|
||||
void Interface_Destroy_v4(interface_v4_t* iface);
|
||||
void Interface_Destroy_v6(interface_v6_t* iface);
|
||||
|
||||
int Interface_SendRaw_v4(interface_v4_t* iface, const struct in_addr* destination, const void* packet, size_t packetLength);
|
||||
int Interface_SendRaw_v6(interface_v6_t* iface, const struct in6_addr* destination, const void* packet, size_t packetLength);
|
||||
|
||||
int Interface_SendFrame_v4(interface_v4_t* iface, const void* frame, size_t frameLength);
|
||||
int Interface_SendFrame_v6(interface_v6_t* iface, const void* frame, size_t frameLength);
|
||||
|
||||
#endif
|
||||
30
include/forward/routetable.h
Normal file
30
include/forward/routetable.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user