-
Notifications
You must be signed in to change notification settings - Fork 6
/
wifi_statistics.h
132 lines (115 loc) · 3.71 KB
/
wifi_statistics.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
/*
* Copyright (C) 2013:
* Simon Wunderlich <[email protected]>
* Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* 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
*/
#include <linux/module.h> /* needed by all modules */
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/rtnetlink.h>
#include <linux/skbuff.h>
#include <linux/ieee80211.h>
#include <linux/debugfs.h>
#include <linux/etherdevice.h>
#include <linux/average.h>
#include <net/cfg80211.h>
#include <net/ieee80211_radiotap.h>
#include "average.h"
#include "compat.h" /* remove if sending this upstream */
#define WIFI_STATS_DRIVER_AUTHOR "Simon Wunderlich <[email protected]>"
#define WIFI_STATS_DRIVER_DESC "WiFi statistics"
#define WIFI_STATS_DRIVER_DEVICE "wifi_statistics"
#define WIFI_STATS_SOURCE_VERSION "broken"
#define WS_HASH_SIZE 64
#define WS_EWMA_FACTOR 2
#define WS_EWMA_WEIGHT 2
#define NUM_UCAST_TID IEEE80211_NUM_TIDS
#define BCAST_TID NUM_UCAST_TID
#define NUM_TIDS (NUM_UCAST_TID + 1)
DECLARE_EWMA(ewma, WS_EWMA_FACTOR, WS_EWMA_WEIGHT)
struct ws_sta_detailed {
int last, min, max, count, sum;
u64 sum_square;
struct ewma_ewma ewma;
};
enum ws_sta_type {
WS_TYPE_UNKNOWN,
WS_TYPE_AP,
WS_TYPE_CLIENT,
WS_TYPE_IBSS,
};
enum ws_mode {
MODE_READ,
MODE_RESET,
};
struct ws_hash {
struct hlist_head table[WS_HASH_SIZE];
spinlock_t list_locks[WS_HASH_SIZE]; /* protects table */
};
struct ws_monif {
struct net_device *net_dev;
atomic_t active;
enum ws_mode ws_mode;
struct ws_hash hash;
struct dentry *dir;
atomic_t refcount;
struct rcu_head rcu;
struct list_head list;
};
struct ws_sta {
u8 mac[ETH_ALEN];
long unsigned int last_seen;
u32 rx_packets;
u64 rx_bytes;
u32 bad_fcs;
u8 bssid[ETH_ALEN];
u8 type;
struct ws_sta_detailed signal;
struct ws_sta_detailed rate;
struct ws_sta_detailed interval;
s16 last_seqno[NUM_TIDS];
u8 last_dest[NUM_TIDS][ETH_ALEN];
struct ws_sta_detailed seqno_diff[NUM_TIDS];
atomic_t refcount;
struct rcu_head rcu;
struct hlist_node hash_entry;
};
extern struct list_head monif_list;
int ws_monif_activate(struct ws_monif *monif);
int ws_monif_deactivate(struct ws_monif *monif);
/* hash */
int ws_hash_init(struct ws_hash *hash);
int ws_hash_free(struct ws_hash *hash);
struct ws_sta *ws_hash_get(struct ws_hash *hash, u8 *mac);
/* station */
void ws_sta_free_ref(struct ws_sta *ws_sta);
void ws_sta_init(struct ws_sta *ws_sta);
int ws_sta_general(struct ws_sta *ws_sta, struct sk_buff *skb);
struct ws_sta *ws_hash_find(struct ws_hash *hash, u8 *mac);
int ws_sta_parse_ieee80211_hdr(struct ws_sta *ws_sta,
struct ieee80211_hdr *hdr, int len);
int ws_sta_parse_radiotap(struct ws_sta *ws_sta,
struct ieee80211_radiotap_header *rthdr, int len);
int ws_sta_seq_print(struct ws_sta *ws_sta, struct seq_file *seq, void *offset);
/* debugfs */
void ws_debugfs_init(void);
void ws_debugfs_destroy(void);
void ws_debugfs_monif_init(struct ws_monif *monif);
void ws_debugfs_monif_clean(struct ws_monif *monif);
int ws_sta_seq_print_head(struct seq_file *seq);
int ws_sta_seq_print_tail(struct seq_file *seq);
int ws_sta_seq_print_sep(struct seq_file *seq);