-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdat.h
81 lines (71 loc) · 1.29 KB
/
dat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <inttypes.h>
#include <stddef.h>
#include <time.h>
typedef unsigned char octet;
typedef struct Bitvec Bitvec;
typedef struct IPMap IPMap;
typedef struct RIPPacket RIPPacket;
typedef struct RIPResponse RIPResponse;
typedef struct Route Route;
typedef struct Tunnel Tunnel;
enum {
MIN_RIP_PACKET_SIZE = 4,
};
/*
* We use a bit vector to keep track of allocated interfaces.
*/
struct Bitvec {
uint64_t *words;
size_t nwords;
size_t firstclr;
};
/*
* A PATRICIA trie mapping CIDR network numbers to a datum.
* The central data structure for maintaining lookup tables
* of active routes and tunnels.
*/
struct IPMap {
uint32_t key;
size_t keylen;
void *datum;
IPMap *left;
IPMap *right;
};
struct RIPPacket {
octet command;
octet version;
uint16_t nbz;
size_t datalen;
size_t nresponse;
const octet *data;
};
enum {
RIP_RESPONSE_SIZE = 20,
};
struct RIPResponse {
uint16_t addrfamily;
uint16_t routetag;
uint32_t ipaddr;
uint32_t subnetmask;
uint32_t nexthop;
uint32_t metric;
};
struct Route {
uint32_t ipnet;
uint32_t subnetmask;
uint32_t gateway;
time_t expires; // Seconds.
Route *rnext;
Tunnel *tunnel;
};
enum {
MAX_TUN_IFNAME = 16,
};
struct Tunnel {
Route *routes;
uint32_t local;
uint32_t remote;
int nref;
char ifname[MAX_TUN_IFNAME];
unsigned int ifnum;
};