2
* Copyright (C) 2006 B.A.T.M.A.N. contributors:
3
* Thomas Lopatic, Corinna 'Elektra' Aichele, Axel Neumann, Marek Lindner
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of version 2 of the GNU General Public
6
* License as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22
#ifndef _BATMAN_BATMAN_H
23
#define _BATMAN_BATMAN_H
25
#include <sys/types.h>
26
#include <netinet/in.h>
38
#define SOURCE_VERSION "0.2" //put exactly one distinct word inside the string like "0.3-pre-alpha" or "0.3-rc1" or "0.3"
40
#ifndef REVISION_VERSION
41
#define REVISION_VERSION "0"
44
#define COMPAT_VERSION 3
46
#define UNIDIRECTIONAL 0x80
47
#define DIRECTLINK 0x40
48
#define ADDR_STR_LEN 16
50
#define UNIX_PATH "/var/run/batmand.socket"
52
/* #define PROFILE_DATA */
56
* No configuration files or fancy command line switches yet
57
* To experiment with B.A.T.M.A.N. settings change them here
58
* and recompile the code
59
* Here is the stuff you may want to play with:
63
#define TTL 50 /* Time To Live of broadcast messages */
64
#define BIDIRECT_TIMEOUT 2
65
#define PURGE_TIMEOUT 200000 /* purge originators after time in ms if no valid packet comes in -> TODO: check influence on SEQ_RANGE */
66
#define SEQ_RANGE 128 /* sliding packet range of received orginator messages in squence numbers (should be a multiple of our word size) */
70
#define NUM_WORDS ( SEQ_RANGE / WORD_BIT_SIZE ) + ( ( SEQ_RANGE % WORD_BIT_SIZE > 0)? 1 : 0 )
75
extern uint8_t debug_level;
76
extern uint8_t gateway_class;
77
extern uint8_t routing_class;
78
extern uint8_t num_hna;
79
extern int16_t orginator_interval;
80
extern uint32_t pref_gateway;
82
extern unsigned char *hna_buff;
84
extern struct gw_node *curr_gateway;
85
extern pthread_t curr_gateway_thread_id;
86
extern pthread_mutex_t curr_gw_mutex;
88
extern uint8_t found_ifs;
89
extern int32_t receive_max_sock;
90
extern fd_set receive_wait_set;
92
extern uint8_t unix_client;
94
extern struct hashtable_t *orig_hash;
96
extern struct list_head if_list;
97
extern struct list_head hna_list;
98
extern struct list_head gw_list;
99
extern struct list_head forw_list;
100
extern struct vis_if vis_if;
101
extern struct unix_if unix_if;
102
extern struct debug_clients debug_clients;
104
extern char *gw2string[];
109
uint8_t flags; /* 0x80: UNIDIRECTIONAL link, 0x40: DIRECTLINK flag, ... */
112
uint8_t gwflags; /* flags related to gateway functions: gateway class */
113
uint8_t version; /* batman version field */
114
} __attribute__((packed));
116
struct orig_node /* structure for orig_list maintaining nodes of mesh */
119
struct neigh_node *router;
120
struct batman_if *batman_if;
121
uint16_t *bidirect_link; /* if node is a bidrectional neighbour, when my originator packet was broadcasted (replied) by this node and received by me */
122
uint32_t last_valid; /* when last packet from this node was received */
123
uint8_t gwflags; /* flags related to gateway functions: gateway class */
124
unsigned char *hna_buff;
125
int16_t hna_buff_len;
126
uint16_t last_seqno; /* last and best known squence number */
127
struct list_head neigh_list;
132
struct list_head list;
134
uint8_t packet_count;
135
uint8_t last_ttl; /* ttl of last received packet */
136
uint32_t last_valid; /* when last packet via this neighbour was received */
137
TYPE_OF_WORD seq_bits[ NUM_WORDS ];
138
struct batman_if *if_incoming;
143
struct list_head list;
148
struct forw_node /* structure for forw_list maintaining packets to be send/forwarded */
150
struct list_head list;
153
unsigned char *pack_buff;
154
int32_t pack_buff_len;
155
struct batman_if *if_outgoing;
160
struct list_head list;
161
struct orig_node *orig_node;
162
uint16_t unavail_factor;
163
uint32_t last_failure;
169
struct list_head list;
171
int32_t udp_send_sock;
172
int32_t udp_recv_sock;
176
uint8_t if_rp_filter_old;
177
uint8_t if_send_redirects_old;
178
pthread_t listen_thread_id;
179
struct sockaddr_in addr;
180
struct sockaddr_in broad;
182
struct list_head client_list;
187
struct list_head list;
188
struct batman_if *batman_if;
190
uint32_t last_keep_alive;
191
struct sockaddr_in addr;
196
struct sockaddr_in addr;
201
pthread_t listen_thread_id;
202
struct sockaddr_un addr;
203
struct list_head client_list;
207
struct list_head list;
212
struct debug_clients {
214
int16_t clients_num[4];
215
pthread_mutex_t *mutex[4];
218
struct debug_level_info {
219
struct list_head list;
223
struct curr_gw_data {
225
struct gw_node *gw_node;
226
struct batman_if *batman_if;
230
int8_t batman( void );
232
void verbose_usage( void );
233
void update_routes( struct orig_node *orig_node, struct neigh_node *neigh_node, unsigned char *hna_recv_buff, int16_t hna_buff_len );
234
void update_gw_list( struct orig_node *orig_node, uint8_t new_gwflags );