babeld.h 3.13 KB
Newer Older
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
1
/*
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
2
Copyright (c) 2007, 2008 by Juliusz Chroboczek
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#define INFINITY ((unsigned short)(~0))

25 26 27 28
#ifndef RTPROT_BABEL
#define RTPROT_BABEL 42
#endif

29 30
#define RTPROT_BABEL_LOCAL -2

Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
31 32 33 34 35 36
#undef MAX
#undef MIN

#define MAX(x,y) ((x)<=(y)?(y):(x))
#define MIN(x,y) ((x)<=(y)?(x):(y))

Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* nothing */
#elif defined(__GNUC__)
#define inline __inline
#if  (__GNUC__ >= 3)
#define restrict __restrict
#else
#define restrict /**/
#endif
#else
#define inline /**/
#define restrict /**/
#endif

Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
51
#if defined(__GNUC__) && (__GNUC__ >= 3)
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
52 53 54
#define ATTRIBUTE(x) __attribute__ (x)
#define LIKELY(_x) __builtin_expect(!!(_x), 1)
#define UNLIKELY(_x) __builtin_expect(!!(_x), 0)
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
55 56
#else
#define ATTRIBUTE(x) /**/
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
57
#define LIKELY(_x) !!(_x)
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
58
#define UNLIKELY(_x) !!(_x)
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
59 60
#endif

Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
61
#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
62 63 64
#define COLD __attribute__ ((cold))
#else
#define COLD /**/
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
65 66 67
#endif

#ifndef IF_NAMESIZE
68
#include <sys/socket.h>
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
#include <net/if.h>
#endif

#ifdef HAVE_VALGRIND
#include <valgrind/memcheck.h>
#else
#ifndef VALGRIND_MAKE_MEM_UNDEFINED
#define VALGRIND_MAKE_MEM_UNDEFINED(a, b) do {} while(0)
#endif
#ifndef VALGRIND_CHECK_MEM_IS_DEFINED
#define VALGRIND_CHECK_MEM_IS_DEFINED(a, b) do {} while(0)
#endif
#endif

extern struct timeval now;
extern int debug;
85
extern time_t reboot_time;
86
extern int default_wireless_hello_interval, default_wired_hello_interval;
87
extern int resend_delay;
88
extern int random_id;
89
extern int skip_kernel_setup;
90
extern int do_daemonise;
91
extern const char *logfile, *pidfile, *state_file;
92
extern int link_detect;
Juliusz Chroboczek's avatar
Add -w.  
Juliusz Chroboczek committed
93
extern int all_wireless;
94
extern int has_ipv6_subtrees;
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
95

96
extern unsigned char myid[8];
97
extern int have_id;
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
98

99
extern const unsigned char zeroes[16], ones[16];
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
100

101
extern int protocol_port, local_server_port;
102
extern char *local_server_path;
103
extern int local_server_write;
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
104 105
extern unsigned char protocol_group[16];
extern int protocol_socket;
106
extern int kernel_socket;
107
extern int max_request_hopcount;
108

109
void schedule_neighbours_check(int msecs, int override);
110
void schedule_interfaces_check(int msecs, int override);
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
111
int resize_receive_buffer(int size);
Juliusz Chroboczek's avatar
Juliusz Chroboczek committed
112
int reopen_logfile(void);