c1ace85db36f92c5080911dd48ed64532d72cda1
[deliverable/linux.git] / net / batman-adv / main.h
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
22 #ifndef _NET_BATMAN_ADV_MAIN_H_
23 #define _NET_BATMAN_ADV_MAIN_H_
24
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
30 #define SOURCE_VERSION "next"
31
32
33 /* B.A.T.M.A.N. parameters */
34
35 #define TQ_MAX_VALUE 255
36 #define JITTER 20
37 #define TTL 50 /* Time To Live of broadcast messages */
38
39 #define PURGE_TIMEOUT 200 /* purge originators after time in seconds if no
40 * valid packet comes in -> TODO: check
41 * influence on TQ_LOCAL_WINDOW_SIZE */
42 #define LOCAL_HNA_TIMEOUT 3600 /* in seconds */
43
44 #define TQ_LOCAL_WINDOW_SIZE 64 /* sliding packet range of received originator
45 * messages in squence numbers (should be a
46 * multiple of our word size) */
47 #define TQ_GLOBAL_WINDOW_SIZE 5
48 #define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
49 #define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1
50 #define TQ_TOTAL_BIDRECT_LIMIT 1
51
52 #define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE)
53
54 #define LOG_BUF_LEN 8192 /* has to be a power of 2 */
55
56 #define VIS_INTERVAL 5000 /* 5 seconds */
57
58 /* how much worse secondary interfaces may be to
59 * to be considered as bonding candidates */
60
61 #define BONDING_TQ_THRESHOLD 50
62
63 #define MAX_AGGREGATION_BYTES 512 /* should not be bigger than 512 bytes or
64 * change the size of
65 * forw_packet->direct_link_flags */
66 #define MAX_AGGREGATION_MS 100
67
68 #define SOFTIF_NEIGH_TIMEOUT 180000 /* 3 minutes */
69
70 #define RESET_PROTECTION_MS 30000
71 #define EXPECTED_SEQNO_RANGE 65536
72 /* don't reset again within 30 seconds */
73
74 #define MESH_INACTIVE 0
75 #define MESH_ACTIVE 1
76 #define MESH_DEACTIVATING 2
77
78 #define BCAST_QUEUE_LEN 256
79 #define BATMAN_QUEUE_LEN 256
80
81 /*
82 * Debug Messages
83 */
84 #ifdef pr_fmt
85 #undef pr_fmt
86 #endif
87 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt /* Append 'batman-adv: ' before
88 * kernel messages */
89
90 #define DBG_BATMAN 1 /* all messages related to routing / flooding /
91 * broadcasting / etc */
92 #define DBG_ROUTES 2 /* route or hna added / changed / deleted */
93 #define DBG_ALL 3
94
95
96 /*
97 * Vis
98 */
99
100 /*
101 * Kernel headers
102 */
103
104 #include <linux/mutex.h> /* mutex */
105 #include <linux/module.h> /* needed by all modules */
106 #include <linux/netdevice.h> /* netdevice */
107 #include <linux/etherdevice.h> /* ethernet address classifaction */
108 #include <linux/if_ether.h> /* ethernet header */
109 #include <linux/poll.h> /* poll_table */
110 #include <linux/kthread.h> /* kernel threads */
111 #include <linux/pkt_sched.h> /* schedule types */
112 #include <linux/workqueue.h> /* workqueue */
113 #include <linux/slab.h>
114 #include <net/sock.h> /* struct sock */
115 #include <linux/jiffies.h>
116 #include <linux/seq_file.h>
117 #include "types.h"
118
119 #ifndef REVISION_VERSION
120 #define REVISION_VERSION_STR ""
121 #else
122 #define REVISION_VERSION_STR " "REVISION_VERSION
123 #endif
124
125 extern struct list_head if_list;
126
127 extern unsigned char broadcast_addr[];
128 extern struct workqueue_struct *bat_event_workqueue;
129
130 int mesh_init(struct net_device *soft_iface);
131 void mesh_free(struct net_device *soft_iface);
132 void inc_module_count(void);
133 void dec_module_count(void);
134 int is_my_mac(uint8_t *addr);
135
136 #ifdef CONFIG_BATMAN_ADV_DEBUG
137 int debug_log(struct bat_priv *bat_priv, char *fmt, ...);
138
139 #define bat_dbg(type, bat_priv, fmt, arg...) \
140 do { \
141 if (atomic_read(&bat_priv->log_level) & type) \
142 debug_log(bat_priv, fmt, ## arg); \
143 } \
144 while (0)
145 #else /* !CONFIG_BATMAN_ADV_DEBUG */
146 static inline void bat_dbg(char type __always_unused,
147 struct bat_priv *bat_priv __always_unused,
148 char *fmt __always_unused, ...)
149 {
150 }
151 #endif
152
153 #define bat_info(net_dev, fmt, arg...) \
154 do { \
155 struct net_device *_netdev = (net_dev); \
156 struct bat_priv *_batpriv = netdev_priv(_netdev); \
157 bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
158 pr_info("%s: " fmt, _netdev->name, ## arg); \
159 } while (0)
160 #define bat_err(net_dev, fmt, arg...) \
161 do { \
162 struct net_device *_netdev = (net_dev); \
163 struct bat_priv *_batpriv = netdev_priv(_netdev); \
164 bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
165 pr_err("%s: " fmt, _netdev->name, ## arg); \
166 } while (0)
167
168 #endif /* _NET_BATMAN_ADV_MAIN_H_ */
This page took 0.03837 seconds and 4 git commands to generate.