b453856bd33af62bd0e13e68dd4ea71d2647a954
[mech_eap.git] / wlantest / wlantest.h
1 /*
2  * wlantest - IEEE 802.11 protocol monitoring and testing tool
3  * Copyright (c) 2010, Jouni Malinen <j@w1.fi>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #ifndef WLANTEST_H
16 #define WLANTEST_H
17
18 #include "utils/list.h"
19
20 struct ieee802_11_elems;
21
22
23 struct wlantest_sta {
24         struct dl_list list;
25         u8 addr[ETH_ALEN];
26         enum {
27                 STATE1 /* not authenticated */,
28                 STATE2 /* authenticated */,
29                 STATE3 /* associated */
30         } state;
31         u16 aid;
32 };
33
34 struct wlantest_bss {
35         struct dl_list list;
36         u8 bssid[ETH_ALEN];
37         u16 capab_info;
38         u8 ssid[32];
39         size_t ssid_len;
40         int proberesp_seen;
41         int parse_error_reported;
42         u8 wpaie[257];
43         u8 rsnie[257];
44         struct dl_list sta; /* struct wlantest_sta */
45 };
46
47 struct wlantest {
48         int monitor_sock;
49
50         struct dl_list bss; /* struct wlantest_bss */
51
52         unsigned int rx_mgmt;
53         unsigned int rx_ctrl;
54         unsigned int rx_data;
55         unsigned int fcs_error;
56 };
57
58 int read_cap_file(struct wlantest *wt, const char *fname);
59 void wlantest_process(struct wlantest *wt, const u8 *data, size_t len);
60 u32 crc32(const u8 *frame, size_t frame_len);
61 int monitor_init(struct wlantest *wt, const char *ifname);
62 void monitor_deinit(struct wlantest *wt);
63
64 struct wlantest_bss * bss_get(struct wlantest *wt, const u8 *bssid);
65 void bss_deinit(struct wlantest_bss *bss);
66 void bss_update(struct wlantest_bss *bss, struct ieee802_11_elems *elems);
67
68 struct wlantest_sta * sta_get(struct wlantest_bss *bss, const u8 *addr);
69 void sta_deinit(struct wlantest_sta *sta);
70
71 #endif /* WLANTEST_H */