blob: 87b4de7b1fd32da894968c5e5ad8501368b86302 [file] [log] [blame]
Paul Jakma57345092011-12-25 17:52:09 +01001/*
2 * This file is free software: you may copy, redistribute and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation, either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * This file is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *
15 * This file incorporates work covered by the following copyright and
16 * permission notice:
17 *
18Copyright (c) 2007, 2008 by Juliusz Chroboczek
19Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
20
21Permission is hereby granted, free of charge, to any person obtaining a copy
22of this software and associated documentation files (the "Software"), to deal
23in the Software without restriction, including without limitation the rights
24to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25copies of the Software, and to permit persons to whom the Software is
26furnished to do so, subject to the following conditions:
27
28The above copyright notice and this permission notice shall be included in
29all copies or substantial portions of the Software.
30
31THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
37THE SOFTWARE.
38*/
39
40#ifndef BABEL_BABELD_H
41#define BABEL_BABELD_H
42
43#include <zebra.h>
44
45#define INFINITY ((unsigned short)(~0))
46
47#ifndef RTPROT_BABEL
48#define RTPROT_BABEL 42
49#endif
50
51#define RTPROT_BABEL_LOCAL -2
52
53#undef MAX
54#undef MIN
55
56#define MAX(x,y) ((x)<=(y)?(y):(x))
57#define MIN(x,y) ((x)<=(y)?(x):(y))
58
59#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
60/* nothing */
61#elif defined(__GNUC__)
62#define inline __inline
63#if (__GNUC__ >= 3)
64#define restrict __restrict
65#else
66#define restrict /**/
67#endif
68#else
69#define inline /**/
70#define restrict /**/
71#endif
72
73#if defined(__GNUC__) && (__GNUC__ >= 3)
74#define ATTRIBUTE(x) __attribute__ (x)
75#define LIKELY(_x) __builtin_expect(!!(_x), 1)
76#define UNLIKELY(_x) __builtin_expect(!!(_x), 0)
77#else
78#define ATTRIBUTE(x) /**/
79#define LIKELY(_x) !!(_x)
80#define UNLIKELY(_x) !!(_x)
81#endif
82
83#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
84#define COLD __attribute__ ((cold))
85#else
86#define COLD /**/
87#endif
88
89#ifndef IF_NAMESIZE
90#include <sys/socket.h>
91#include <net/if.h>
92#endif
93
94#ifdef HAVE_VALGRIND
95#include <valgrind/memcheck.h>
96#else
97#ifndef VALGRIND_MAKE_MEM_UNDEFINED
98#define VALGRIND_MAKE_MEM_UNDEFINED(a, b) do {} while(0)
99#endif
100#ifndef VALGRIND_CHECK_MEM_IS_DEFINED
101#define VALGRIND_CHECK_MEM_IS_DEFINED(a, b) do {} while(0)
102#endif
103#endif
104
105
106#define BABEL_VTY_PORT 2609
107#define BABEL_DEFAULT_CONFIG "babeld.conf"
108#define BABEL_VERSION "0.1 for quagga"
109#define BABELD_DEFAULT_HELLO_INTERVAL 4000 /* miliseconds */
110
111
112/* Babel socket. */
113extern int protocol_socket;
114
115/* Babel structure. */
116struct babel
117{
118 /* Babel threads. */
119 struct thread *t_read; /* on Babel protocol's socket */
120 struct thread *t_update; /* timers */
121};
122
123
124extern void babeld_quagga_init(void);
125extern int input_filter(const unsigned char *id,
126 const unsigned char *prefix, unsigned short plen,
127 const unsigned char *neigh, unsigned int ifindex);
128extern int output_filter(const unsigned char *id, const unsigned char *prefix,
129 unsigned short plen, unsigned int ifindex);
130extern int redistribute_filter(const unsigned char *prefix, unsigned short plen,
131 unsigned int ifindex, int proto);
132extern int resize_receive_buffer(int size);
133extern void schedule_neighbours_check(int msecs, int override);
134
135
136#endif /* BABEL_BABELD_H */