2 * wlantest - IEEE 802.11 protocol monitoring and testing tool
3 * Copyright (c) 2010, Jouni Malinen <j@w1.fi>
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.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
18 #include "utils/list.h"
19 #include "common/wpa_common.h"
20 #include "wlantest_ctrl.h"
22 struct ieee802_11_elems;
27 #define MAX_RADIUS_SECRET_LEN 128
29 struct wlantest_radius_secret {
31 char secret[MAX_RADIUS_SECRET_LEN];
34 struct wlantest_passphrase {
49 struct wlantest_bss *bss;
52 STATE1 /* not authenticated */,
53 STATE2 /* authenticated */,
54 STATE3 /* associated */
57 u8 rsnie[257]; /* WPA/RSN IE */
63 u8 anonce[32]; /* ANonce from the previous EAPOL-Key msg 1/4 or 3/4 */
64 u8 snonce[32]; /* SNonce from the previous EAPOL-Key msg 2/4 */
65 struct wpa_ptk ptk; /* Derived PTK */
67 u8 rsc_tods[16 + 1][6];
68 u8 rsc_fromds[16 + 1][6];
70 u8 sta_sa_query_tr[2];
71 u32 counters[NUM_WLANTEST_STA_COUNTER];
81 int parse_error_reported;
87 int mgmt_group_cipher;
90 struct dl_list sta; /* struct wlantest_sta */
91 struct dl_list pmk; /* struct wlantest_pmk */
98 u32 counters[NUM_WLANTEST_BSS_COUNTER];
101 struct wlantest_radius {
105 struct radius_msg *last_req;
109 #define MAX_CTRL_CONNECTIONS 10
116 int ctrl_socks[MAX_CTRL_CONNECTIONS];
118 struct dl_list passphrase; /* struct wlantest_passphrase */
119 struct dl_list bss; /* struct wlantest_bss */
120 struct dl_list secret; /* struct wlantest_radius_secret */
121 struct dl_list radius; /* struct wlantest_radius */
122 struct dl_list pmk; /* struct wlantest_pmk */
124 unsigned int rx_mgmt;
125 unsigned int rx_ctrl;
126 unsigned int rx_data;
127 unsigned int fcs_error;
129 void *write_pcap; /* pcap_t* */
130 void *write_pcap_dumper; /* pcpa_dumper_t */
131 struct timeval write_pcap_time;
134 int read_cap_file(struct wlantest *wt, const char *fname);
135 int read_wired_cap_file(struct wlantest *wt, const char *fname);
136 int write_pcap_init(struct wlantest *wt, const char *fname);
137 void write_pcap_deinit(struct wlantest *wt);
138 void write_pcap_captured(struct wlantest *wt, const u8 *buf, size_t len);
139 void write_pcap_decrypted(struct wlantest *wt, const u8 *buf1, size_t len1,
140 const u8 *buf2, size_t len2);
141 void wlantest_process(struct wlantest *wt, const u8 *data, size_t len);
142 void wlantest_process_wired(struct wlantest *wt, const u8 *data, size_t len);
143 u32 crc32(const u8 *frame, size_t frame_len);
144 int monitor_init(struct wlantest *wt, const char *ifname);
145 int monitor_init_wired(struct wlantest *wt, const char *ifname);
146 void monitor_deinit(struct wlantest *wt);
147 void rx_mgmt(struct wlantest *wt, const u8 *data, size_t len);
148 void rx_data(struct wlantest *wt, const u8 *data, size_t len);
150 struct wlantest_bss * bss_get(struct wlantest *wt, const u8 *bssid);
151 void bss_deinit(struct wlantest_bss *bss);
152 void bss_update(struct wlantest *wt, struct wlantest_bss *bss,
153 struct ieee802_11_elems *elems);
154 void bss_flush(struct wlantest *wt);
155 void pmk_deinit(struct wlantest_pmk *pmk);
157 struct wlantest_sta * sta_get(struct wlantest_bss *bss, const u8 *addr);
158 void sta_deinit(struct wlantest_sta *sta);
159 void sta_update_assoc(struct wlantest_sta *sta,
160 struct ieee802_11_elems *elems);
162 u8 * ccmp_decrypt(const u8 *tk, const struct ieee80211_hdr *hdr,
163 const u8 *data, size_t data_len, size_t *decrypted_len);
164 u8 * ccmp_encrypt(const u8 *tk, u8 *frame, size_t len, size_t hdrlen, u8 *qos,
165 u8 *pn, int keyid, size_t *encrypted_len);
166 void ccmp_get_pn(u8 *pn, const u8 *data);
168 u8 * tkip_decrypt(const u8 *tk, const struct ieee80211_hdr *hdr,
169 const u8 *data, size_t data_len, size_t *decrypted_len);
170 u8 * tkip_encrypt(const u8 *tk, u8 *frame, size_t len, size_t hdrlen, u8 *qos,
171 u8 *pn, int keyid, size_t *encrypted_len);
172 void tkip_get_pn(u8 *pn, const u8 *data);
174 int ctrl_init(struct wlantest *wt);
175 void ctrl_deinit(struct wlantest *wt);
177 int wlantest_inject(struct wlantest *wt, struct wlantest_bss *bss,
178 struct wlantest_sta *sta, u8 *frame, size_t len,
179 enum wlantest_inject_protection prot);
181 #endif /* WLANTEST_H */