Staging: batman-adv: convert multiple /proc files to use sysfs
[safe/jmp/linux-2.6] / 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>, Simon Wunderlich <siwu@hrz.tu-chemnitz.de>"
26 #define DRIVER_DESC   "B.A.T.M.A.N. advanced"
27 #define DRIVER_DEVICE "batman-adv"
28
29 #define SOURCE_VERSION "0.2.2-beta"
30
31
32 /* B.A.T.M.A.N. parameters */
33
34 #define TQ_MAX_VALUE 255
35 #define JITTER 20
36 #define TTL 50                    /* Time To Live of broadcast messages */
37
38 #define PURGE_TIMEOUT 200000      /* purge originators after time in ms if no
39                                    * valid packet comes in -> TODO: check
40                                    * influence on TQ_LOCAL_WINDOW_SIZE */
41 #define LOCAL_HNA_TIMEOUT 3600000
42
43 #define TQ_LOCAL_WINDOW_SIZE 64   /* sliding packet range of received originator
44                                    * messages in squence numbers (should be a
45                                    * multiple of our word size) */
46 #define TQ_GLOBAL_WINDOW_SIZE 5
47 #define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
48 #define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1
49 #define TQ_TOTAL_BIDRECT_LIMIT 1
50
51 #define TQ_HOP_PENALTY 10
52
53 #define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE)
54
55 #define PACKBUFF_SIZE 2000
56 #define LOG_BUF_LEN 8192          /* has to be a power of 2 */
57 #define ETH_STR_LEN 20
58
59 #define MAX_AGGREGATION_BYTES 512 /* should not be bigger than 512 bytes or
60                                    * change the size of
61                                    * forw_packet->direct_link_flags */
62 #define MAX_AGGREGATION_MS 100
63
64 #define MODULE_INACTIVE 0
65 #define MODULE_ACTIVE 1
66 #define MODULE_DEACTIVATING 2
67
68
69 /*
70  * Debug Messages
71  */
72
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
77 #ifdef CONFIG_BATMAN_ADV_DEBUG
78 extern int debug;
79
80 extern int bat_debug_type(int type);
81 #define bat_dbg(type, fmt, arg...) do {                                 \
82                 if (bat_debug_type(type))                               \
83                         printk(KERN_DEBUG "batman-adv:" fmt, ## arg);   \
84         }                                                               \
85         while (0)
86 #else /* !CONFIG_BATMAN_ADV_DEBUG */
87 #define bat_dbg(type, fmt, arg...) do {         \
88         }                                       \
89         while (0)
90 #endif
91
92 /*
93  *  Vis
94  */
95
96 /* #define VIS_SUBCLUSTERS_DISABLED */
97
98 /*
99  * Kernel headers
100  */
101
102 #include <linux/mutex.h>        /* mutex */
103 #include <linux/module.h>       /* needed by all modules */
104 #include <linux/netdevice.h>    /* netdevice */
105 #include <linux/if_ether.h>     /* ethernet header */
106 #include <linux/poll.h>         /* poll_table */
107 #include <linux/kthread.h>      /* kernel threads */
108 #include <linux/pkt_sched.h>    /* schedule types */
109 #include <linux/workqueue.h>    /* workqueue */
110 #include <linux/slab.h>
111 #include <net/sock.h>           /* struct sock */
112 #include <linux/jiffies.h>
113 #include "types.h"
114
115 #ifndef REVISION_VERSION
116 #define REVISION_VERSION_STR ""
117 #else
118 #define REVISION_VERSION_STR " "REVISION_VERSION
119 #endif
120
121 extern struct list_head if_list;
122 extern struct hlist_head forw_bat_list;
123 extern struct hlist_head forw_bcast_list;
124 extern struct hashtable_t *orig_hash;
125
126 extern spinlock_t orig_hash_lock;
127 extern spinlock_t forw_bat_list_lock;
128 extern spinlock_t forw_bcast_list_lock;
129
130 extern atomic_t originator_interval;
131 extern atomic_t vis_interval;
132 extern atomic_t vis_mode;
133 extern int16_t num_hna;
134 extern int16_t num_ifs;
135
136 extern struct net_device *soft_device;
137
138 extern unsigned char broadcastAddr[];
139 extern atomic_t module_state;
140 extern struct workqueue_struct *bat_event_workqueue;
141
142 void activate_module(void);
143 void shutdown_module(void);
144 void inc_module_count(void);
145 void dec_module_count(void);
146 int addr_to_string(char *buff, uint8_t *addr);
147 int compare_orig(void *data1, void *data2);
148 int choose_orig(void *data, int32_t size);
149 int is_my_mac(uint8_t *addr);
150 int is_bcast(uint8_t *addr);
151 int is_mcast(uint8_t *addr);