~ubuntu-branches/ubuntu/utopic/babeld/utopic

« back to all changes in this revision

Viewing changes to interface.h

  • Committer: Package Import Robot
  • Author(s): Stéphane Glondu
  • Date: 2011-12-08 20:49:12 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20111208204912-oiizndrm9va3aplf
Tags: 1.3.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 2007, 2008 by Juliusz Chroboczek
 
3
 
 
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:
 
10
 
 
11
The above copyright notice and this permission notice shall be included in
 
12
all copies or substantial portions of the Software.
 
13
 
 
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
 
20
THE SOFTWARE.
 
21
*/
 
22
 
 
23
struct buffered_update {
 
24
    unsigned char id[8];
 
25
    unsigned char prefix[16];
 
26
    unsigned char plen;
 
27
    unsigned char pad[3];
 
28
};
 
29
 
 
30
struct interface_conf {
 
31
    char *ifname;
 
32
    unsigned hello_interval;
 
33
    unsigned update_interval;
 
34
    unsigned short cost;
 
35
    char wired;
 
36
    char split_horizon;
 
37
    char lq;
 
38
    char faraway;
 
39
    int channel;
 
40
    struct interface_conf *next;
 
41
};
 
42
 
 
43
#define CONFIG_DEFAULT 0
 
44
#define CONFIG_NO 1
 
45
#define CONFIG_YES 2
 
46
 
 
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)
 
52
 
 
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
 
57
 
 
58
struct interface {
 
59
    struct interface *next;
 
60
    struct interface_conf *conf;
 
61
    unsigned int ifindex;
 
62
    unsigned short flags;
 
63
    unsigned short cost;
 
64
    int channel;
 
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];
 
70
    unsigned char *ipv4;
 
71
    int numll;
 
72
    unsigned char (*ll)[16];
 
73
    int buffered;
 
74
    int bufsize;
 
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;
 
85
    int update_bufsize;
 
86
    time_t bucket_time;
 
87
    unsigned int bucket;
 
88
    time_t activity_time;
 
89
    time_t last_update_time;
 
90
    unsigned short hello_seqno;
 
91
    unsigned hello_interval;
 
92
    unsigned update_interval;
 
93
};
 
94
 
 
95
#define IF_CONF(_ifp, _field) \
 
96
    ((_ifp)->conf ? (_ifp)->conf->_field : 0)
 
97
 
 
98
extern struct interface *interfaces;
 
99
 
 
100
#define FOR_ALL_INTERFACES(_ifp) for(_ifp = interfaces; _ifp; _ifp = _ifp->next)
 
101
 
 
102
static inline int
 
103
if_up(struct interface *ifp)
 
104
{
 
105
    return !!(ifp->flags & IF_UP);
 
106
}
 
107
 
 
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);