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];
30
struct interface_conf {
32
unsigned hello_interval;
33
unsigned update_interval;
40
struct interface_conf *next;
43
#define CONFIG_DEFAULT 0
47
#define IF_UP (1 << 0)
48
#define IF_WIRED (1<<1)
49
#define IF_SPLIT_HORIZON (1 << 2)
50
#define IF_LQ (1 << 3)
51
#define IF_FARAWAY (1 << 4)
53
/* Only INTERFERING can appear on the wire. */
54
#define IF_CHANNEL_UNKNOWN 0
55
#define IF_CHANNEL_INTERFERING 255
56
#define IF_CHANNEL_NONINTERFERING -2
59
struct interface *next;
60
struct interface_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 name[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
time_t last_update_time;
90
unsigned short hello_seqno;
91
unsigned hello_interval;
92
unsigned update_interval;
95
#define IF_CONF(_ifp, _field) \
96
((_ifp)->conf ? (_ifp)->conf->_field : 0)
98
extern struct interface *interfaces;
100
#define FOR_ALL_INTERFACES(_ifp) for(_ifp = interfaces; _ifp; _ifp = _ifp->next)
103
if_up(struct interface *ifp)
105
return !!(ifp->flags & IF_UP);
108
struct interface *add_interface(char *ifname, struct interface_conf *if_conf);
109
int interface_idle(struct interface *ifp);
110
int update_hello_interval(struct interface *ifp);
111
unsigned jitter(struct interface *ifp, int urgent);
112
unsigned update_jitter(struct interface *ifp, int urgent);
113
void set_timeout(struct timeval *timeout, int msecs);
114
int interface_up(struct interface *ifp, int up);
115
int interface_ll_address(struct interface *ifp, const unsigned char *address);
116
void check_interfaces(void);