wlantest: Add capturing and parsing of RADIUS messages
[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 #include "common/wpa_common.h"
20
21 struct ieee802_11_elems;
22
23
24 struct wlantest_passphrase {
25         struct dl_list list;
26         char passphrase[64];
27         u8 ssid[32];
28         size_t ssid_len;
29         u8 bssid[ETH_ALEN];
30 };
31
32 struct wlantest_pmk {
33         struct dl_list list;
34         u8 pmk[32];
35 };
36
37 struct wlantest_sta {
38         struct dl_list list;
39         u8 addr[ETH_ALEN];
40         enum {
41                 STATE1 /* not authenticated */,
42                 STATE2 /* authenticated */,
43                 STATE3 /* associated */
44         } state;
45         u16 aid;
46         u8 rsnie[257]; /* WPA/RSN IE */
47         u8 anonce[32]; /* ANonce from the previous EAPOL-Key msg 1/4 or 3/4 */
48         u8 snonce[32]; /* SNonce from the previous EAPOL-Key msg 2/4 */
49         struct wpa_ptk ptk; /* Derived PTK */
50         int ptk_set;
51 };
52
53 struct wlantest_bss {
54         struct dl_list list;
55         u8 bssid[ETH_ALEN];
56         u16 capab_info;
57         u8 ssid[32];
58         size_t ssid_len;
59         int proberesp_seen;
60         int parse_error_reported;
61         u8 wpaie[257];
62         u8 rsnie[257];
63         struct dl_list sta; /* struct wlantest_sta */
64         struct dl_list pmk; /* struct wlantest_pmk */
65 };
66
67 struct wlantest {
68         int monitor_sock;
69         int monitor_wired;
70
71         struct dl_list passphrase; /* struct wlantest_passphrase */
72         struct dl_list bss; /* struct wlantest_bss */
73
74         unsigned int rx_mgmt;
75         unsigned int rx_ctrl;
76         unsigned int rx_data;
77         unsigned int fcs_error;
78 };
79
80 int read_cap_file(struct wlantest *wt, const char *fname);
81 int read_wired_cap_file(struct wlantest *wt, const char *fname);
82 void wlantest_process(struct wlantest *wt, const u8 *data, size_t len);
83 void wlantest_process_wired(struct wlantest *wt, const u8 *data, size_t len);
84 u32 crc32(const u8 *frame, size_t frame_len);
85 int monitor_init(struct wlantest *wt, const char *ifname);
86 int monitor_init_wired(struct wlantest *wt, const char *ifname);
87 void monitor_deinit(struct wlantest *wt);
88 void rx_mgmt(struct wlantest *wt, const u8 *data, size_t len);
89 void rx_data(struct wlantest *wt, const u8 *data, size_t len);
90
91 struct wlantest_bss * bss_get(struct wlantest *wt, const u8 *bssid);
92 void bss_deinit(struct wlantest_bss *bss);
93 void bss_update(struct wlantest *wt, struct wlantest_bss *bss,
94                 struct ieee802_11_elems *elems);
95
96 struct wlantest_sta * sta_get(struct wlantest_bss *bss, const u8 *addr);
97 void sta_deinit(struct wlantest_sta *sta);
98 void sta_update_assoc(struct wlantest_sta *sta,
99                       struct ieee802_11_elems *elems);
100
101 #endif /* WLANTEST_H */