include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[linux-2.6-block.git] / drivers / staging / batman-adv / main.h
CommitLineData
5beef3c9
AL
1/*
2 * Copyright (C) 2007-2009 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.1-beta"
30
31
32/* B.A.T.M.A.N. parameters */
33
34#define TQ_MAX_VALUE 255
35#define JITTER 20
bad2239e
AL
36#define TTL 50 /* Time To Live of broadcast messages */
37#define MAX_ADDR 16 /* number of interfaces which can be added to
5beef3c9
AL
38 * batman. */
39
bad2239e 40#define PURGE_TIMEOUT 200000 /* purge originators after time in ms if no
5beef3c9
AL
41 * valid packet comes in -> TODO: check
42 * influence on TQ_LOCAL_WINDOW_SIZE */
43#define LOCAL_HNA_TIMEOUT 3600000
44
bad2239e 45#define TQ_LOCAL_WINDOW_SIZE 64 /* sliding packet range of received originator
5beef3c9
AL
46 * messages in squence numbers (should be a
47 * multiple of our word size) */
48#define TQ_GLOBAL_WINDOW_SIZE 5
49#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
50#define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1
51#define TQ_TOTAL_BIDRECT_LIMIT 1
52
53#define TQ_HOP_PENALTY 10
54
55#define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE)
56
57#define PACKBUFF_SIZE 2000
58#define LOG_BUF_LEN 8192 /* has to be a power of 2 */
59#define ETH_STR_LEN 20
60
61#define MAX_AGGREGATION_BYTES 512 /* should not be bigger than 512 bytes or
62 * change the size of
63 * forw_packet->direct_link_flags */
64#define MAX_AGGREGATION_MS 100
65
66#define MODULE_INACTIVE 0
67#define MODULE_ACTIVE 1
68#define MODULE_DEACTIVATING 2
69
70
71/*
bad2239e 72 * Debug Messages
5beef3c9
AL
73 */
74
bad2239e
AL
75#define DBG_BATMAN 1 /* all messages related to routing / flooding /
76 * broadcasting / etc */
77#define DBG_ROUTES 2 /* route or hna added / changed / deleted */
78
734cc82a 79#ifdef CONFIG_BATMAN_ADV_DEBUG
bad2239e
AL
80extern int debug;
81
82extern int bat_debug_type(int type);
83#define bat_dbg(type, fmt, arg...) do { \
84 if (bat_debug_type(type)) \
85 printk(KERN_DEBUG "batman-adv:" fmt, ## arg); \
86 } \
87 while (0)
734cc82a 88#else /* !CONFIG_BATMAN_ADV_DEBUG */
bad2239e
AL
89#define bat_dbg(type, fmt, arg...) do { \
90 } \
91 while (0)
92#endif
5beef3c9
AL
93
94/*
95 * Vis
96 */
97
98/* #define VIS_SUBCLUSTERS_DISABLED */
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/if_ether.h> /* ethernet header */
108#include <linux/poll.h> /* poll_table */
109#include <linux/kthread.h> /* kernel threads */
110#include <linux/pkt_sched.h> /* schedule types */
111#include <linux/workqueue.h> /* workqueue */
5a0e3ad6 112#include <linux/slab.h>
5beef3c9
AL
113#include <net/sock.h> /* struct sock */
114#include <linux/jiffies.h>
115#include "types.h"
116
117#ifndef REVISION_VERSION
118#define REVISION_VERSION_STR ""
119#else
120#define REVISION_VERSION_STR " "REVISION_VERSION
121#endif
122
123extern struct list_head if_list;
124extern struct hlist_head forw_bat_list;
125extern struct hlist_head forw_bcast_list;
126extern struct hashtable_t *orig_hash;
127
128extern spinlock_t orig_hash_lock;
129extern spinlock_t forw_bat_list_lock;
130extern spinlock_t forw_bcast_list_lock;
131
132extern atomic_t originator_interval;
133extern atomic_t vis_interval;
837b8248 134extern atomic_t vis_mode;
5beef3c9
AL
135extern atomic_t aggregation_enabled;
136extern int16_t num_hna;
137extern int16_t num_ifs;
138
139extern struct net_device *soft_device;
140
141extern unsigned char broadcastAddr[];
142extern atomic_t module_state;
143extern struct workqueue_struct *bat_event_workqueue;
144
145void activate_module(void);
146void shutdown_module(void);
147void inc_module_count(void);
148void dec_module_count(void);
149int addr_to_string(char *buff, uint8_t *addr);
150int compare_orig(void *data1, void *data2);
151int choose_orig(void *data, int32_t size);
152int is_my_mac(uint8_t *addr);
153int is_bcast(uint8_t *addr);
154int is_mcast(uint8_t *addr);