2 Copyright 2011 by Matthieu Boutier and 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 #ifndef BABEL_INTERFACE_H
24 #define BABEL_INTERFACE_H
29 #include "distribute.h"
31 #define CONFIG_DEFAULT 0
35 /* babeld interface information */
36 struct babel_interface
{
37 unsigned short flags
; /* see below */
40 struct timeval hello_timeout
;
41 struct timeval update_timeout
;
42 struct timeval flush_timeout
;
43 struct timeval update_flush_timeout
;
47 /* Relative position of the Hello message in the send buffer, or
48 (-1) if there is none. */
50 char have_buffered_id
;
51 char have_buffered_nh
;
52 char have_buffered_prefix
;
53 unsigned char buffered_id
[8];
54 unsigned char buffered_nh
[4];
55 unsigned char buffered_prefix
[16];
56 unsigned char *sendbuf
;
57 struct buffered_update
*buffered_updates
;
58 int num_buffered_updates
;
62 time_t last_update_time
;
63 unsigned short hello_seqno
;
64 unsigned hello_interval
;
65 unsigned update_interval
;
66 /* A higher value means we forget old RTT samples faster. Must be
67 between 1 and 256, inclusive. */
68 unsigned int rtt_decay
;
69 /* Parameters for computing the cost associated to RTT. */
72 unsigned int max_rtt_penalty
;
74 /* For filter type slot. */
75 struct access_list
*list
[DISTRIBUTE_MAX
]; /* Access-list. */
76 struct prefix_list
*prefix
[DISTRIBUTE_MAX
]; /* Prefix-list. */
79 typedef struct babel_interface babel_interface_nfo
;
80 static inline babel_interface_nfo
* babel_get_if_nfo(struct interface
*ifp
)
82 return ((babel_interface_nfo
*) ifp
->info
);
85 /* babel_interface_nfo flags */
86 #define BABEL_IF_IS_UP (1 << 0)
87 #define BABEL_IF_WIRED (1 << 1)
88 #define BABEL_IF_SPLIT_HORIZON (1 << 2)
89 #define BABEL_IF_LQ (1 << 3)
90 #define BABEL_IF_FARAWAY (1 << 4)
91 #define BABEL_IF_TIMESTAMPS (1 << 5)
93 /* Only INTERFERING can appear on the wire. */
94 #define BABEL_IF_CHANNEL_UNKNOWN 0
95 #define BABEL_IF_CHANNEL_INTERFERING 255
96 #define BABEL_IF_CHANNEL_NONINTERFERING -2
99 if_up(struct interface
*ifp
)
101 return (if_is_operative(ifp
) &&
102 ifp
->connected
!= NULL
&&
103 (babel_get_if_nfo(ifp
)->flags
& BABEL_IF_IS_UP
));
106 struct buffered_update
{
108 unsigned char prefix
[16];
110 unsigned char pad
[3];
114 void babel_if_init(void);
116 /* Callback functions for zebra client */
117 int babel_interface_up (int, struct zclient
*, zebra_size_t
, vrf_id_t
);
118 int babel_interface_down (int, struct zclient
*, zebra_size_t
, vrf_id_t
);
119 int babel_interface_add (int, struct zclient
*, zebra_size_t
, vrf_id_t
);
120 int babel_interface_delete (int, struct zclient
*, zebra_size_t
, vrf_id_t
);
121 int babel_interface_address_add (int, struct zclient
*, zebra_size_t
, vrf_id_t
);
122 int babel_interface_address_delete (int, struct zclient
*, zebra_size_t
, vrf_id_t
);
124 int babel_ifp_create(struct interface
*ifp
);
125 int babel_ifp_up(struct interface
*ifp
);
126 int babel_ifp_down(struct interface
*ifp
);
127 int babel_ifp_destroy(struct interface
*ifp
);
129 unsigned jitter(babel_interface_nfo
*, int);
130 unsigned update_jitter(babel_interface_nfo
*babel_ifp
, int urgent
);
131 /* return "true" if "address" is one of our ipv6 addresses */
132 int is_interface_ll_address(struct interface
*ifp
, const unsigned char *address
);
133 /* Send retraction to all, and reset all interfaces statistics. */
134 void babel_interface_close_all(void);
135 extern int babel_enable_if_config_write (struct vty
*);