blob: 29bc5e8fd29b11af8881e6c29f3e787feaadb21c [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>
Matthieu Boutierd3351d12012-01-19 22:36:56 +010044#include "vty.h"
Paul Jakma57345092011-12-25 17:52:09 +010045
46#define INFINITY ((unsigned short)(~0))
47
48#ifndef RTPROT_BABEL
49#define RTPROT_BABEL 42
50#endif
51
52#define RTPROT_BABEL_LOCAL -2
53
54#undef MAX
55#undef MIN
56
57#define MAX(x,y) ((x)<=(y)?(y):(x))
58#define MIN(x,y) ((x)<=(y)?(x):(y))
59
60#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
61/* nothing */
62#elif defined(__GNUC__)
63#define inline __inline
64#if (__GNUC__ >= 3)
65#define restrict __restrict
66#else
67#define restrict /**/
68#endif
69#else
70#define inline /**/
71#define restrict /**/
72#endif
73
74#if defined(__GNUC__) && (__GNUC__ >= 3)
75#define ATTRIBUTE(x) __attribute__ (x)
76#define LIKELY(_x) __builtin_expect(!!(_x), 1)
77#define UNLIKELY(_x) __builtin_expect(!!(_x), 0)
78#else
79#define ATTRIBUTE(x) /**/
80#define LIKELY(_x) !!(_x)
81#define UNLIKELY(_x) !!(_x)
82#endif
83
84#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
85#define COLD __attribute__ ((cold))
86#else
87#define COLD /**/
88#endif
89
90#ifndef IF_NAMESIZE
91#include <sys/socket.h>
92#include <net/if.h>
93#endif
94
95#ifdef HAVE_VALGRIND
96#include <valgrind/memcheck.h>
97#else
98#ifndef VALGRIND_MAKE_MEM_UNDEFINED
99#define VALGRIND_MAKE_MEM_UNDEFINED(a, b) do {} while(0)
100#endif
101#ifndef VALGRIND_CHECK_MEM_IS_DEFINED
102#define VALGRIND_CHECK_MEM_IS_DEFINED(a, b) do {} while(0)
103#endif
104#endif
105
106
107#define BABEL_VTY_PORT 2609
108#define BABEL_DEFAULT_CONFIG "babeld.conf"
109#define BABEL_VERSION "0.1 for quagga"
110#define BABELD_DEFAULT_HELLO_INTERVAL 4000 /* miliseconds */
111
112
113/* Babel socket. */
114extern int protocol_socket;
115
116/* Babel structure. */
117struct babel
118{
119 /* Babel threads. */
120 struct thread *t_read; /* on Babel protocol's socket */
121 struct thread *t_update; /* timers */
122};
123
124
125extern void babeld_quagga_init(void);
126extern int input_filter(const unsigned char *id,
127 const unsigned char *prefix, unsigned short plen,
128 const unsigned char *neigh, unsigned int ifindex);
129extern int output_filter(const unsigned char *id, const unsigned char *prefix,
130 unsigned short plen, unsigned int ifindex);
131extern int redistribute_filter(const unsigned char *prefix, unsigned short plen,
132 unsigned int ifindex, int proto);
133extern int resize_receive_buffer(int size);
134extern void schedule_neighbours_check(int msecs, int override);
Matthieu Boutierd3351d12012-01-19 22:36:56 +0100135extern void show_babeld_configuration (struct vty *vty);
Paul Jakma57345092011-12-25 17:52:09 +0100136
137
138#endif /* BABEL_BABELD_H */