-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathstate.h
More file actions
119 lines (104 loc) · 3.52 KB
/
Copy pathstate.h
File metadata and controls
119 lines (104 loc) · 3.52 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
Copyright (c) 2015 by Juliusz Chroboczek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#define MAXINTERFACES 20
#define MAXNODES 100
#define MAXNEIGHS 40
enum interface_type {
INTERFACE_INTERNAL = 1,
INTERFACE_ADHOC,
INTERFACE_MESH,
INTERFACE_LEAF
};
struct interface {
char *ifname;
int ifindex;
enum interface_type type;
struct timespec last_request_sent;
struct timespec last_sent;
struct trickle_state trickle;
/* Prefix assignment */
struct assigned_prefix *assigned;
int numassigned;
/* Router advertisements */
struct timespec ra_timeout;
struct timespec last_ra_sent;
struct prefix_list *retractions;
};
struct node {
struct interface *interface;
unsigned char id[4];
unsigned char *data;
unsigned int datalen;
unsigned char datahash[8];
unsigned int seqno;
struct timespec orig_time;
/* From published node state */
unsigned char capabilities[2];
struct node_neighbour *neighs;
int numneighs;
struct prefix_list *assigned;
struct prefix_list *addresses;
struct external **exts;
int numexts;
};
struct neighbour {
struct interface *interface;
unsigned char id[4];
unsigned int eid;
unsigned short port;
struct in6_addr addr;
struct timespec last_contact;
unsigned keepalive_interval;
};
struct node_neighbour {
unsigned char neigh[4];
unsigned int nei;
unsigned int lei;
};
struct external {
struct prefix_list *delegated;
struct prefix_list *dns;
struct prefix_list *ntp;
};
extern struct interface interfaces[MAXINTERFACES];
extern int numinterfaces;
extern struct node nodes[MAXNODES];
extern int numnodes;
extern struct neighbour neighs[MAXNEIGHS];
extern int numneighs;
static inline int
id_eq(const unsigned char *id1, const unsigned char *id2)
{
return memcmp(id1, id2, 4) == 0;
}
void trickle_reset_all(void);
struct interface *find_interface(int ifindex);
const char *interface_type(struct interface *interface);
struct neighbour *
find_neighbour(struct interface *interface, const unsigned char *id,
unsigned int eid, const struct sockaddr_in6 *create);
void flush_neighbour(struct neighbour *neighbour);
struct node *find_node(const unsigned char *id, int create);
void flush_node(struct node *node);
int silly_walk(struct node *root);
int republish(int do_neighs, int reset);
void node_hash(unsigned char *h, const unsigned char *data, int len);
int network_hash(unsigned char *);
void destroy_external(struct external *e);
struct prefix_list *all_dhcp_data(int ntp, int v4, int v6);