-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathmain.h
180 lines (150 loc) · 4.71 KB
/
main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/* horst - Highly Optimized Radio Scanning Tool
*
* Copyright (C) 2005-2016 Bruno Randolf (br1@einfach.org)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _MAIN_H_
#define _MAIN_H_
#include <stdlib.h>
#include <time.h>
#undef LIST_HEAD
#include <uwifi/cc_list.h>
#include <uwifi/average.h>
#include <uwifi/channel.h>
#include <uwifi/wlan80211.h>
#include <uwifi/wlan_parser.h>
#include <uwifi/conf.h>
#include <uwifi/platform.h>
#define CONFIG_FILE "/etc/horst.conf"
#define MAX_HISTORY 255
#define MAX_RATES 44 /* 12 legacy rates and 32 MCS */
#define MAX_FSTYPE 0xff
#define MAX_NODE_NAME_STRLEN 18
#define MAX_NODE_NAMES 64
/* higher level packet types */
#define PKT_TYPE_ARP BIT(0)
#define PKT_TYPE_IP BIT(1)
#define PKT_TYPE_ICMP BIT(2)
#define PKT_TYPE_UDP BIT(3)
#define PKT_TYPE_TCP BIT(4)
#define PKT_TYPE_OLSR BIT(5)
#define PKT_TYPE_BATMAN BIT(6)
#define PKT_TYPE_MESHZ BIT(7)
#define PKT_TYPE_ALL (PKT_TYPE_ARP | PKT_TYPE_IP | PKT_TYPE_ICMP | \
PKT_TYPE_UDP | PKT_TYPE_TCP | \
PKT_TYPE_OLSR | PKT_TYPE_BATMAN | PKT_TYPE_MESHZ)
#define DEFAULT_MAC_NAME_FILE "/tmp/dhcp.leases"
#define MAX_CONF_VALUE_STRLEN 200
#define MAX_CONF_NAME_STRLEN 32
#define MAX_FILTERMAC 9
struct config {
struct uwifi_interface intf;
int port;
int quiet;
int display_interval;
char display_view;
char dumpfile[MAX_CONF_VALUE_STRLEN + 1];
int recv_buffer_size;
char serveraddr[MAX_CONF_VALUE_STRLEN + 1];
char control_pipe[MAX_CONF_VALUE_STRLEN + 1];
char mac_name_file[MAX_CONF_VALUE_STRLEN + 1];
unsigned char filtermac[MAX_FILTERMAC][WLAN_MAC_LEN];
char filtermac_enabled[MAX_FILTERMAC];
unsigned char filterbssid[WLAN_MAC_LEN];
unsigned int filter_pkt;
uint16_t filter_stype[WLAN_NUM_TYPES]; /* one for MGMT, CTRL, DATA */
unsigned int filter_mode;
unsigned int filter_off:1,
filter_badfcs:1,
allow_client:1,
allow_control:1,
debug:1,
mac_name_lookup:1,
add_monitor:1,
/* this isn't exactly config, but wtf... */
do_macfilter:1,
display_initialized:1,
monitor_added:1;
int paused;
unsigned int node_timeout;
};
extern struct config conf;
struct history {
int signal[MAX_HISTORY];
int rate[MAX_HISTORY];
unsigned int type[MAX_HISTORY];
unsigned int retry[MAX_HISTORY];
unsigned int index;
};
extern struct history hist;
struct statistics {
unsigned long packets;
unsigned long retries;
unsigned long bytes;
unsigned long duration;
unsigned long packets_per_rate[MAX_RATES];
unsigned long bytes_per_rate[MAX_RATES];
unsigned long duration_per_rate[MAX_RATES];
unsigned long packets_per_type[MAX_FSTYPE];
unsigned long bytes_per_type[MAX_FSTYPE];
unsigned long duration_per_type[MAX_FSTYPE];
unsigned long filtered_packets;
struct timespec stats_time;
};
extern struct statistics stats;
struct channel_info {
int signal;
struct ewma signal_avg;
unsigned long packets;
unsigned long bytes;
unsigned long durations;
unsigned long durations_last;
struct ewma durations_avg;
struct cc_list_head nodes;
unsigned int num_nodes;
};
extern struct channel_info spectrum[MAX_CHANNELS];
/* helper for keeping lists of nodes for each channel
* (a node can be on more than one channel) */
struct chan_node {
struct uwifi_node* node;
struct channel_info* chan;
struct cc_list_node chan_list; /* list for nodes per channel */
struct cc_list_node node_list; /* list for channels per node */
int sig;
struct ewma sig_avg;
unsigned long packets;
};
struct node_names_info {
struct node_name {
unsigned char mac[WLAN_MAC_LEN];
char name[MAX_NODE_NAME_STRLEN + 1];
} entry[MAX_NODE_NAMES];
int count;
};
extern struct node_names_info node_names;
extern struct timespec time_mono;
extern struct timespec time_real;
extern struct cc_list_head essids;
void free_lists(void);
void init_spectrum(void);
void update_spectrum_durations(void);
void handle_packet(struct uwifi_packet* p);
void main_pause(int pause);
void main_reset(void);
void dumpfile_open(const char* name);
const char* mac_name_lookup(const unsigned char* mac, int shorten_mac);
#endif