wlantest: Maintain STA state based on auth/assoc/deauth/disassoc
[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
21 struct wlantest_sta {
22         struct dl_list list;
23         u8 addr[ETH_ALEN];
24         enum {
25                 STATE1 /* not authenticated */,
26                 STATE2 /* authenticated */,
27                 STATE3 /* associated */
28         } state;
29         u16 aid;
30 };
31
32 struct wlantest_bss {
33         struct dl_list list;
34         u8 bssid[ETH_ALEN];
35         u16 capab_info;
36         u8 ssid[32];
37         size_t ssid_len;
38         int proberesp_seen;
39         int parse_error_reported;
40         u8 wpaie[257];
41         u8 rsnie[257];
42         struct dl_list sta; /* struct wlantest_sta */
43 };
44
45 struct wlantest {
46         int monitor_sock;
47
48         struct dl_list bss; /* struct wlantest_bss */
49
50         unsigned int rx_mgmt;
51         unsigned int rx_ctrl;
52         unsigned int rx_data;
53         unsigned int fcs_error;
54 };
55
56 int read_cap_file(struct wlantest *wt, const char *fname);
57 void wlantest_process(struct wlantest *wt, const u8 *data, size_t len);
58 u32 crc32(const u8 *frame, size_t frame_len);
59 int monitor_init(struct wlantest *wt, const char *ifname);
60 void monitor_deinit(struct wlantest *wt);
61
62 struct wlantest_bss * bss_get(struct wlantest *wt, const u8 *bssid);
63 void bss_deinit(struct wlantest_bss *bss);
64
65 struct wlantest_sta * sta_get(struct wlantest_bss *bss, const u8 *addr);
66 void sta_deinit(struct wlantest_sta *sta);
67
68 #endif /* WLANTEST_H */