2 Copyright (c) 2007, 2008 by Juliusz Chroboczek
3 Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 #ifndef BABEL_BABELD_H
25 #define BABEL_BABELD_H
30 #define INFINITY ((unsigned short)(~0))
33 #define RTPROT_BABEL 42
36 #define RTPROT_BABEL_LOCAL -2
41 #define MAX(x,y) ((x)<=(y)?(y):(x))
42 #define MIN(x,y) ((x)<=(y)?(x):(y))
44 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
46 #elif defined(__GNUC__)
47 #define inline __inline
49 #define restrict __restrict
58 #if defined(__GNUC__) && (__GNUC__ >= 3)
59 #define ATTRIBUTE(x) __attribute__ (x)
60 #define LIKELY(_x) __builtin_expect(!!(_x), 1)
61 #define UNLIKELY(_x) __builtin_expect(!!(_x), 0)
63 #define ATTRIBUTE(x) /**/
64 #define LIKELY(_x) !!(_x)
65 #define UNLIKELY(_x) !!(_x)
68 #if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
69 #define COLD __attribute__ ((cold))
75 #include <sys/socket.h>
80 #include <valgrind/memcheck.h>
82 #ifndef VALGRIND_MAKE_MEM_UNDEFINED
83 #define VALGRIND_MAKE_MEM_UNDEFINED(a, b) do {} while(0)
85 #ifndef VALGRIND_CHECK_MEM_IS_DEFINED
86 #define VALGRIND_CHECK_MEM_IS_DEFINED(a, b) do {} while(0)
91 #define BABEL_VTY_PORT 2609
92 #define BABEL_DEFAULT_CONFIG "babeld.conf"
94 /* Values in milliseconds */
95 #define BABEL_DEFAULT_HELLO_INTERVAL 4000
96 #define BABEL_DEFAULT_UPDATE_INTERVAL 16000
97 #define BABEL_DEFAULT_RESEND_DELAY 2000
99 /* In units of seconds */
100 #define BABEL_DEFAULT_SMOOTHING_HALF_LIFE 4
102 /* In units of 1/256. */
103 #define BABEL_DEFAULT_DIVERSITY_FACTOR 256
105 #define BABEL_DEFAULT_RXCOST_WIRED 96
106 #define BABEL_DEFAULT_RXCOST_WIRELESS 256
108 /* Babel structure. */
112 struct thread
*t_read
; /* on Babel protocol's socket */
113 struct thread
*t_update
; /* timers */
115 struct distribute_ctx
*distribute_ctx
;
118 extern struct zebra_privs_t babeld_privs
;
120 extern void babeld_quagga_init(void);
121 extern int input_filter(const unsigned char *id
,
122 const unsigned char *prefix
, unsigned short plen
,
123 const unsigned char *neigh
, unsigned int ifindex
);
124 extern int output_filter(const unsigned char *id
, const unsigned char *prefix
,
125 unsigned short plen
, unsigned int ifindex
);
126 extern int redistribute_filter(const unsigned char *prefix
, unsigned short plen
,
127 unsigned int ifindex
, int proto
);
128 extern int resize_receive_buffer(int size
);
129 extern void schedule_neighbours_check(int msecs
, int override
);
130 extern struct babel
*babel_lookup(void);
132 #endif /* BABEL_BABELD_H */