]> bbs.cooldavid.org Git - net-next-2.6.git/blob - drivers/staging/batman-adv/main.h
f6a1c043daae2c508871853440ac2008671cee83
[net-next-2.6.git] / drivers / staging / 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 /* Kernel Programming */
23 #define LINUX
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 "maint"
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 TQ_HOP_PENALTY 10
53
54 #define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE)
55
56 #define PACKBUFF_SIZE 2000
57 #define LOG_BUF_LEN 8192          /* has to be a power of 2 */
58 #define ETH_STR_LEN 20
59
60 #define VIS_INTERVAL 5000       /* 5 seconds */
61
62 /* how much worse secondary interfaces may be to
63  * to be considered as bonding candidates */
64
65 #define BONDING_TQ_THRESHOLD    50
66
67 #define MAX_AGGREGATION_BYTES 512 /* should not be bigger than 512 bytes or
68                                    * change the size of
69                                    * forw_packet->direct_link_flags */
70 #define MAX_AGGREGATION_MS 100
71
72 #define RESET_PROTECTION_MS 30000
73 #define EXPECTED_SEQNO_RANGE    65536
74 /* don't reset again within 30 seconds */
75
76 #define MODULE_INACTIVE 0
77 #define MODULE_ACTIVE 1
78 #define MODULE_DEACTIVATING 2
79
80 #define BCAST_QUEUE_LEN         256
81 #define BATMAN_QUEUE_LEN        256
82
83 /*
84  * Debug Messages
85  */
86
87 #define DBG_BATMAN 1    /* all messages related to routing / flooding /
88                          * broadcasting / etc */
89 #define DBG_ROUTES 2    /* route or hna added / changed / deleted */
90
91 #ifdef CONFIG_BATMAN_ADV_DEBUG
92 extern int debug;
93
94 extern int bat_debug_type(int type);
95 #define bat_dbg(type, fmt, arg...) do {                                 \
96                 if (bat_debug_type(type))                               \
97                         printk(KERN_DEBUG "batman-adv:" fmt, ## arg);   \
98         }                                                               \
99         while (0)
100 #else /* !CONFIG_BATMAN_ADV_DEBUG */
101 #define bat_dbg(type, fmt, arg...) do {         \
102         }                                       \
103         while (0)
104 #endif
105
106 /*
107  *  Vis
108  */
109
110 /* #define VIS_SUBCLUSTERS_DISABLED */
111
112 /*
113  * Kernel headers
114  */
115
116 #include <linux/mutex.h>        /* mutex */
117 #include <linux/module.h>       /* needed by all modules */
118 #include <linux/netdevice.h>    /* netdevice */
119 #include <linux/if_ether.h>     /* ethernet header */
120 #include <linux/poll.h>         /* poll_table */
121 #include <linux/kthread.h>      /* kernel threads */
122 #include <linux/pkt_sched.h>    /* schedule types */
123 #include <linux/workqueue.h>    /* workqueue */
124 #include <linux/slab.h>
125 #include <net/sock.h>           /* struct sock */
126 #include <linux/jiffies.h>
127 #include <linux/seq_file.h>
128 #include "types.h"
129
130 #ifndef REVISION_VERSION
131 #define REVISION_VERSION_STR ""
132 #else
133 #define REVISION_VERSION_STR " "REVISION_VERSION
134 #endif
135
136 extern struct list_head if_list;
137 extern struct hlist_head forw_bat_list;
138 extern struct hlist_head forw_bcast_list;
139 extern struct hashtable_t *orig_hash;
140
141 extern spinlock_t orig_hash_lock;
142 extern spinlock_t forw_bat_list_lock;
143 extern spinlock_t forw_bcast_list_lock;
144
145 extern atomic_t bcast_queue_left;
146 extern atomic_t batman_queue_left;
147 extern int16_t num_hna;
148
149 extern struct net_device *soft_device;
150
151 extern unsigned char broadcast_addr[];
152 extern atomic_t module_state;
153 extern struct workqueue_struct *bat_event_workqueue;
154
155 void activate_module(void);
156 void deactivate_module(void);
157 void inc_module_count(void);
158 void dec_module_count(void);
159 int addr_to_string(char *buff, uint8_t *addr);
160 int compare_orig(void *data1, void *data2);
161 int choose_orig(void *data, int32_t size);
162 int is_my_mac(uint8_t *addr);
163 int is_bcast(uint8_t *addr);
164 int is_mcast(uint8_t *addr);