main.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors:
  3. *
  4. * Marek Lindner, Simon Wunderlich
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of version 2 of the GNU General Public
  8. * License as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA
  19. *
  20. */
  21. #ifndef _NET_BATMAN_ADV_MAIN_H_
  22. #define _NET_BATMAN_ADV_MAIN_H_
  23. /* Kernel Programming */
  24. #define LINUX
  25. #define DRIVER_AUTHOR "Marek Lindner <lindner_marek@yahoo.de>, " \
  26. "Simon Wunderlich <siwu@hrz.tu-chemnitz.de>"
  27. #define DRIVER_DESC "B.A.T.M.A.N. advanced"
  28. #define DRIVER_DEVICE "batman-adv"
  29. #define SOURCE_VERSION "next"
  30. /* B.A.T.M.A.N. parameters */
  31. #define TQ_MAX_VALUE 255
  32. #define JITTER 20
  33. #define TTL 50 /* Time To Live of broadcast messages */
  34. #define PURGE_TIMEOUT 200 /* purge originators after time in seconds if no
  35. * valid packet comes in -> TODO: check
  36. * influence on TQ_LOCAL_WINDOW_SIZE */
  37. #define LOCAL_HNA_TIMEOUT 3600 /* in seconds */
  38. #define TQ_LOCAL_WINDOW_SIZE 64 /* sliding packet range of received originator
  39. * messages in squence numbers (should be a
  40. * multiple of our word size) */
  41. #define TQ_GLOBAL_WINDOW_SIZE 5
  42. #define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
  43. #define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1
  44. #define TQ_TOTAL_BIDRECT_LIMIT 1
  45. #define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE)
  46. #define PACKBUFF_SIZE 2000
  47. #define LOG_BUF_LEN 8192 /* has to be a power of 2 */
  48. #define VIS_INTERVAL 5000 /* 5 seconds */
  49. /* how much worse secondary interfaces may be to
  50. * to be considered as bonding candidates */
  51. #define BONDING_TQ_THRESHOLD 50
  52. #define MAX_AGGREGATION_BYTES 512 /* should not be bigger than 512 bytes or
  53. * change the size of
  54. * forw_packet->direct_link_flags */
  55. #define MAX_AGGREGATION_MS 100
  56. #define SOFTIF_NEIGH_TIMEOUT 180000 /* 3 minutes */
  57. #define RESET_PROTECTION_MS 30000
  58. #define EXPECTED_SEQNO_RANGE 65536
  59. /* don't reset again within 30 seconds */
  60. #define MESH_INACTIVE 0
  61. #define MESH_ACTIVE 1
  62. #define MESH_DEACTIVATING 2
  63. #define BCAST_QUEUE_LEN 256
  64. #define BATMAN_QUEUE_LEN 256
  65. /*
  66. * Debug Messages
  67. */
  68. #ifdef pr_fmt
  69. #undef pr_fmt
  70. #endif
  71. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt /* Append 'batman-adv: ' before
  72. * kernel messages */
  73. #define DBG_BATMAN 1 /* all messages related to routing / flooding /
  74. * broadcasting / etc */
  75. #define DBG_ROUTES 2 /* route or hna added / changed / deleted */
  76. #define DBG_ALL 3
  77. #define LOG_BUF_LEN 8192 /* has to be a power of 2 */
  78. /*
  79. * Vis
  80. */
  81. /* #define VIS_SUBCLUSTERS_DISABLED */
  82. /*
  83. * Kernel headers
  84. */
  85. #include <linux/mutex.h> /* mutex */
  86. #include <linux/module.h> /* needed by all modules */
  87. #include <linux/netdevice.h> /* netdevice */
  88. #include <linux/etherdevice.h> /* ethernet address classifaction */
  89. #include <linux/if_ether.h> /* ethernet header */
  90. #include <linux/poll.h> /* poll_table */
  91. #include <linux/kthread.h> /* kernel threads */
  92. #include <linux/pkt_sched.h> /* schedule types */
  93. #include <linux/workqueue.h> /* workqueue */
  94. #include <linux/slab.h>
  95. #include <net/sock.h> /* struct sock */
  96. #include <linux/jiffies.h>
  97. #include <linux/seq_file.h>
  98. #include "types.h"
  99. #ifndef REVISION_VERSION
  100. #define REVISION_VERSION_STR ""
  101. #else
  102. #define REVISION_VERSION_STR " "REVISION_VERSION
  103. #endif
  104. extern struct list_head if_list;
  105. extern unsigned char broadcast_addr[];
  106. extern struct workqueue_struct *bat_event_workqueue;
  107. int mesh_init(struct net_device *soft_iface);
  108. void mesh_free(struct net_device *soft_iface);
  109. void inc_module_count(void);
  110. void dec_module_count(void);
  111. int is_my_mac(uint8_t *addr);
  112. #ifdef CONFIG_BATMAN_ADV_DEBUG
  113. int debug_log(struct bat_priv *bat_priv, char *fmt, ...);
  114. #define bat_dbg(type, bat_priv, fmt, arg...) \
  115. do { \
  116. if (atomic_read(&bat_priv->log_level) & type) \
  117. debug_log(bat_priv, fmt, ## arg); \
  118. } \
  119. while (0)
  120. #else /* !CONFIG_BATMAN_ADV_DEBUG */
  121. static inline void bat_dbg(char type __attribute__((unused)),
  122. struct bat_priv *bat_priv __attribute__((unused)),
  123. char *fmt __attribute__((unused)), ...)
  124. {
  125. }
  126. #endif
  127. #define bat_warning(net_dev, fmt, arg...) \
  128. do { \
  129. struct net_device *_netdev = (net_dev); \
  130. struct bat_priv *_batpriv = netdev_priv(_netdev); \
  131. bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
  132. pr_warning("%s: " fmt, _netdev->name, ## arg); \
  133. } while (0)
  134. #define bat_info(net_dev, fmt, arg...) \
  135. do { \
  136. struct net_device *_netdev = (net_dev); \
  137. struct bat_priv *_batpriv = netdev_priv(_netdev); \
  138. bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
  139. pr_info("%s: " fmt, _netdev->name, ## arg); \
  140. } while (0)
  141. #define bat_err(net_dev, fmt, arg...) \
  142. do { \
  143. struct net_device *_netdev = (net_dev); \
  144. struct bat_priv *_batpriv = netdev_priv(_netdev); \
  145. bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
  146. pr_err("%s: " fmt, _netdev->name, ## arg); \
  147. } while (0)
  148. #endif /* _NET_BATMAN_ADV_MAIN_H_ */