Blame view

babeld.h 2.82 KB
Juliusz Chroboczek committed
1
/*
Juliusz Chroboczek committed
2
Copyright (c) 2007, 2008 by Juliusz Chroboczek
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))

Juliusz Chroboczek committed
25 26 27 28
#ifndef RTPROT_BABEL
#define RTPROT_BABEL 42
#endif

Juliusz Chroboczek committed
29 30
#define RTPROT_BABEL_LOCAL -2

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 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 committed
51
#if defined(__GNUC__) && (__GNUC__ >= 3)
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 committed
55 56
#else
#define ATTRIBUTE(x) /**/
Juliusz Chroboczek committed
57
#define LIKELY(_x) !!(_x)
Juliusz Chroboczek committed
58
#define UNLIKELY(_x) !!(_x)
Juliusz Chroboczek committed
59 60
#endif

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

#ifndef IF_NAMESIZE
Grégoire Henry committed
68
#include <sys/socket.h>
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;
Juliusz Chroboczek committed
85
extern time_t reboot_time;
Juliusz Chroboczek committed
86 87
extern int wireless_hello_interval, wired_hello_interval, idle_hello_interval;
extern int idle_time;
Juliusz Chroboczek committed
88
extern int link_detect;
Juliusz Chroboczek committed
89
extern int all_wireless;
Juliusz Chroboczek committed
90
extern int local_socket;
Juliusz Chroboczek committed
91

Juliusz Chroboczek committed
92
extern unsigned char myid[8];
Juliusz Chroboczek committed
93

Juliusz Chroboczek committed
94
extern const unsigned char zeroes[16], ones[16];
Juliusz Chroboczek committed
95

Juliusz Chroboczek committed
96 97 98
extern int protocol_port;
extern unsigned char protocol_group[16];
extern int protocol_socket;
Juliusz Chroboczek committed
99
extern int kernel_socket;
Juliusz Chroboczek committed
100
extern int max_request_hopcount;
Juliusz Chroboczek committed
101

Juliusz Chroboczek committed
102
void schedule_neighbours_check(int msecs, int override);
Juliusz Chroboczek committed
103
int resize_receive_buffer(int size);