babeld.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. Copyright (c) 2007, 2008 by Juliusz Chroboczek
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #define INFINITY ((unsigned short)(~0))
  20. #ifndef RTPROT_BABEL
  21. #define RTPROT_BABEL 42
  22. #endif
  23. #define RTPROT_BABEL_LOCAL -2
  24. #undef MAX
  25. #undef MIN
  26. #define MAX(x,y) ((x)<=(y)?(y):(x))
  27. #define MIN(x,y) ((x)<=(y)?(x):(y))
  28. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  29. /* nothing */
  30. #elif defined(__GNUC__)
  31. #define inline __inline
  32. #if (__GNUC__ >= 3)
  33. #define restrict __restrict
  34. #else
  35. #define restrict /**/
  36. #endif
  37. #else
  38. #define inline /**/
  39. #define restrict /**/
  40. #endif
  41. #if defined(__GNUC__) && (__GNUC__ >= 3)
  42. #define ATTRIBUTE(x) __attribute__ (x)
  43. #define LIKELY(_x) __builtin_expect(!!(_x), 1)
  44. #define UNLIKELY(_x) __builtin_expect(!!(_x), 0)
  45. #else
  46. #define ATTRIBUTE(x) /**/
  47. #define LIKELY(_x) !!(_x)
  48. #define UNLIKELY(_x) !!(_x)
  49. #endif
  50. #if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
  51. #define COLD __attribute__ ((cold))
  52. #else
  53. #define COLD /**/
  54. #endif
  55. #ifndef IF_NAMESIZE
  56. #include <sys/socket.h>
  57. #include <net/if.h>
  58. #endif
  59. #ifdef HAVE_VALGRIND
  60. #include <valgrind/memcheck.h>
  61. #else
  62. #ifndef VALGRIND_MAKE_MEM_UNDEFINED
  63. #define VALGRIND_MAKE_MEM_UNDEFINED(a, b) do {} while(0)
  64. #endif
  65. #ifndef VALGRIND_CHECK_MEM_IS_DEFINED
  66. #define VALGRIND_CHECK_MEM_IS_DEFINED(a, b) do {} while(0)
  67. #endif
  68. #endif
  69. #include <time.h> // to fix error: unknown type name 'time_t'
  70. extern struct timeval now;
  71. extern int debug;
  72. extern time_t reboot_time;
  73. extern int default_wireless_hello_interval, default_wired_hello_interval;
  74. extern int resend_delay;
  75. extern int random_id;
  76. extern int skip_kernel_setup;
  77. extern int do_daemonise;
  78. extern const char *logfile, *pidfile, *state_file;
  79. extern int link_detect;
  80. extern int all_wireless;
  81. extern int has_ipv6_subtrees;
  82. extern unsigned char myid[8];
  83. extern int have_id;
  84. extern const unsigned char zeroes[16], ones[16];
  85. extern int protocol_port, local_server_port;
  86. extern char *local_server_path;
  87. extern int local_server_write;
  88. extern unsigned char protocol_group[16];
  89. extern int protocol_socket;
  90. extern int kernel_socket;
  91. extern int max_request_hopcount;
  92. void schedule_neighbours_check(int msecs, int override);
  93. void schedule_interfaces_check(int msecs, int override);
  94. int resize_receive_buffer(int size);
  95. int reopen_logfile(void);