2
Copyright (c) 2007, 2008 by Juliusz Chroboczek
4
Permission is hereby granted, free of charge, to any person obtaining a copy
5
of this software and associated documentation files (the "Software"), to deal
6
in the Software without restriction, including without limitation the rights
7
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
copies of the Software, and to permit persons to whom the Software is
9
furnished to do so, subject to the following conditions:
11
The above copyright notice and this permission notice shall be included in
12
all copies or substantial portions of the Software.
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
struct buffered_update {
25
unsigned char prefix[16];
32
unsigned hello_interval;
33
unsigned update_interval;
40
struct network_conf *next;
43
#define CONFIG_DEFAULT 0
47
#define NET_UP (1 << 0)
48
#define NET_WIRED (1<<1)
49
#define NET_SPLIT_HORIZON (1 << 2)
50
#define NET_LQ (1 << 3)
51
#define NET_FARAWAY (1 << 4)
53
/* Only INTERFERING can appear on the wire. */
54
#define NET_CHANNEL_UNKNOWN 0
55
#define NET_CHANNEL_INTERFERING 255
56
#define NET_CHANNEL_NONINTERFERING -2
60
struct network_conf *conf;
65
struct timeval hello_timeout;
66
struct timeval update_timeout;
67
struct timeval flush_timeout;
68
struct timeval update_flush_timeout;
69
char ifname[IF_NAMESIZE];
72
unsigned char (*ll)[16];
75
char have_buffered_hello;
76
char have_buffered_id;
77
char have_buffered_nh;
78
char have_buffered_prefix;
79
unsigned char buffered_id[16];
80
unsigned char buffered_nh[4];
81
unsigned char buffered_prefix[16];
82
unsigned char *sendbuf;
83
struct buffered_update *buffered_updates;
84
int num_buffered_updates;
89
unsigned short hello_seqno;
90
unsigned hello_interval;
91
unsigned update_interval;
94
#define NET_CONF(_net, _field) \
95
((_net)->conf ? (_net)->conf->_field : 0)
97
extern struct network *networks;
100
#define FOR_ALL_NETS(_net) for(_net = networks; _net; _net = _net->next)
103
net_up(struct network *net)
105
return !!(net->flags & NET_UP);
108
struct network *add_network(char *ifname, struct network_conf *conf);
109
int network_idle(struct network *net);
110
int update_hello_interval(struct network *net);
111
unsigned jitter(struct network *net, int urgent);
112
unsigned update_jitter(struct network *net, int urgent);
113
void set_timeout(struct timeval *timeout, int msecs);
114
int network_up(struct network *net, int up);
115
int network_ll_address(struct network *net, const unsigned char *address);
116
void check_networks(void);