Files
miniroute/include/forward/if/interface.h
2026-06-05 14:03:02 +02:00

43 lines
1.5 KiB
C

#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