wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
xdpmac.h
1#ifndef XDPMAC_XDPMAC_H
2#define XDPMAC_XDPMAC_H
3
5
6/* ip -> mac reflect cache for the AF_XDP TX path. The server never initiates
7 * a flow, so every peer's MAC is learned from a received frame first; a TX
8 * lookup miss means "drop and let QUIC retransmit". Keys are IPv4 addresses
9 * kept in network byte order so the send hot path never byte-swaps. */
10
12#define XDPMAC_CAP 64
13
17typedef struct {
19 u32 ip[XDPMAC_CAP];
21 u8 mac[XDPMAC_CAP][6];
23 u8 used[XDPMAC_CAP];
26} xdpmac;
27
29void xdpmac_init(xdpmac* c);
30
34void xdpmac_learn(xdpmac* c, u32 ip_be, const u8 mac[6]);
35
38int xdpmac_lookup(const xdpmac* c, u32 ip_be, u8 mac_out[6]);
39
40#endif
Fixed-capacity ip -> mac cache.
Definition xdpmac.h:17
u32 ip[XDPMAC_CAP]
IPv4 key, network byte order; valid if used.
Definition xdpmac.h:19
u32 clock
next round-robin eviction victim
Definition xdpmac.h:25
u8 used[XDPMAC_CAP]
1 if the slot holds an entry
Definition xdpmac.h:23
u8 mac[XDPMAC_CAP][6]
Ethernet MAC learned for ip.
Definition xdpmac.h:21
Linux direct syscalls.
unsigned int u32
unsigned 32-bit integer
Definition types.h:15
unsigned char u8
unsigned 8-bit integer / byte
Definition types.h:18