2 * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors:
4 * Marek Lindner, Simon Wunderlich
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.
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.
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
22 #ifndef _NET_BATMAN_ADV_MAIN_H_
23 #define _NET_BATMAN_ADV_MAIN_H_
25 /* Kernel Programming */
28 #define DRIVER_AUTHOR "Marek Lindner <lindner_marek@yahoo.de>, " \
29 "Simon Wunderlich <siwu@hrz.tu-chemnitz.de>"
30 #define DRIVER_DESC "B.A.T.M.A.N. advanced"
31 #define DRIVER_DEVICE "batman-adv"
33 #define SOURCE_VERSION "next"
36 /* B.A.T.M.A.N. parameters */
38 #define TQ_MAX_VALUE 255
40 #define TTL 50 /* Time To Live of broadcast messages */
42 #define PURGE_TIMEOUT 200 /* purge originators after time in seconds if no
43 * valid packet comes in -> TODO: check
44 * influence on TQ_LOCAL_WINDOW_SIZE */
45 #define LOCAL_HNA_TIMEOUT 3600 /* in seconds */
47 #define TQ_LOCAL_WINDOW_SIZE 64 /* sliding packet range of received originator
48 * messages in squence numbers (should be a
49 * multiple of our word size) */
50 #define TQ_GLOBAL_WINDOW_SIZE 5
51 #define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
52 #define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1
53 #define TQ_TOTAL_BIDRECT_LIMIT 1
55 #define TQ_HOP_PENALTY 10
57 #define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE)
59 #define PACKBUFF_SIZE 2000
60 #define LOG_BUF_LEN 8192 /* has to be a power of 2 */
62 #define VIS_INTERVAL 5000 /* 5 seconds */
64 /* how much worse secondary interfaces may be to
65 * to be considered as bonding candidates */
67 #define BONDING_TQ_THRESHOLD 50
69 #define MAX_AGGREGATION_BYTES 512 /* should not be bigger than 512 bytes or
71 * forw_packet->direct_link_flags */
72 #define MAX_AGGREGATION_MS 100
74 #define SOFTIF_NEIGH_TIMEOUT 180000 /* 3 minutes */
76 #define RESET_PROTECTION_MS 30000
77 #define EXPECTED_SEQNO_RANGE 65536
78 /* don't reset again within 30 seconds */
80 #define MESH_INACTIVE 0
82 #define MESH_DEACTIVATING 2
84 #define BCAST_QUEUE_LEN 256
85 #define BATMAN_QUEUE_LEN 256
90 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt /* Append 'batman-adv: ' before
93 #define DBG_BATMAN 1 /* all messages related to routing / flooding /
94 * broadcasting / etc */
95 #define DBG_ROUTES 2 /* route or hna added / changed / deleted */
98 #define LOG_BUF_LEN 8192 /* has to be a power of 2 */
105 /* #define VIS_SUBCLUSTERS_DISABLED */
111 #include <linux/mutex.h> /* mutex */
112 #include <linux/module.h> /* needed by all modules */
113 #include <linux/netdevice.h> /* netdevice */
114 #include <linux/if_ether.h> /* ethernet header */
115 #include <linux/poll.h> /* poll_table */
116 #include <linux/kthread.h> /* kernel threads */
117 #include <linux/pkt_sched.h> /* schedule types */
118 #include <linux/workqueue.h> /* workqueue */
119 #include <linux/slab.h>
120 #include <net/sock.h> /* struct sock */
121 #include <linux/jiffies.h>
122 #include <linux/seq_file.h>
125 #ifndef REVISION_VERSION
126 #define REVISION_VERSION_STR ""
128 #define REVISION_VERSION_STR " "REVISION_VERSION
131 extern struct list_head if_list;
133 extern unsigned char broadcast_addr[];
134 extern struct workqueue_struct *bat_event_workqueue;
136 int mesh_init(struct net_device *soft_iface);
137 void mesh_free(struct net_device *soft_iface);
138 void inc_module_count(void);
139 void dec_module_count(void);
140 int compare_orig(void *data1, void *data2);
141 int choose_orig(void *data, int32_t size);
142 int is_my_mac(uint8_t *addr);
143 int is_bcast(uint8_t *addr);
144 int is_mcast(uint8_t *addr);
146 #ifdef CONFIG_BATMAN_ADV_DEBUG
147 int debug_log(struct bat_priv *bat_priv, char *fmt, ...);
149 #define bat_dbg(type, bat_priv, fmt, arg...) \
151 if (atomic_read(&bat_priv->log_level) & type) \
152 debug_log(bat_priv, fmt, ## arg); \
155 #else /* !CONFIG_BATMAN_ADV_DEBUG */
156 static inline void bat_dbg(char type __attribute__((unused)),
157 struct bat_priv *bat_priv __attribute__((unused)),
158 char *fmt __attribute__((unused)), ...)
163 #define bat_warning(net_dev, fmt, arg...) \
165 struct net_device *_netdev = (net_dev); \
166 struct bat_priv *_batpriv = netdev_priv(_netdev); \
167 bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
168 pr_warning("%s: " fmt, _netdev->name, ## arg); \
170 #define bat_info(net_dev, fmt, arg...) \
172 struct net_device *_netdev = (net_dev); \
173 struct bat_priv *_batpriv = netdev_priv(_netdev); \
174 bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
175 pr_info("%s: " fmt, _netdev->name, ## arg); \
177 #define bat_err(net_dev, fmt, arg...) \
179 struct net_device *_netdev = (net_dev); \
180 struct bat_priv *_batpriv = netdev_priv(_netdev); \
181 bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
182 pr_err("%s: " fmt, _netdev->name, ## arg); \
185 #endif /* _NET_BATMAN_ADV_MAIN_H_ */