1
#ifndef WPA_SUPPLICANT_I_H
2
#define WPA_SUPPLICANT_I_H
7
#include <netinet/in.h>
9
struct hostapd_radius_server {
13
size_t shared_secret_len;
15
#endif /* EAPOL_TEST */
18
struct rsn_pmksa_cache {
19
struct rsn_pmksa_cache *next;
24
int akmp; /* WPA_KEY_MGMT_* */
28
struct rsn_pmksa_candidate {
29
struct rsn_pmksa_candidate *next;
36
u8 mic_key[16]; /* EAPOL-Key MIC Key (MK) */
37
u8 encr_key[16]; /* EAPOL-Key Encryption Key (EK) */
38
u8 tk1[16]; /* Temporal Key 1 (TK1) */
40
u8 tk2[16]; /* Temporal Key 2 (TK2) */
46
} __attribute__ ((packed));
49
struct wpa_blacklist {
50
struct wpa_blacklist *next;
55
struct wpa_supplicant {
56
struct wpa_supplicant *head;
57
struct wpa_supplicant *next;
58
struct l2_packet_data *l2;
59
unsigned char own_addr[ETH_ALEN];
61
#ifdef CONFIG_XSUPPLICANT_IFACE
62
int dot1x_s; /* socket for connection to Xsupplicant */
63
int ext_pmk_received; /* 1 = PMK was received from Xsupplicant */
64
#endif /* CONFIG_XSUPPLICANT_IFACE */
68
u8 snonce[WPA_NONCE_LEN];
69
u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */
70
struct wpa_ptk ptk, tptk;
71
int ptk_set, tptk_set;
74
struct wpa_config *conf;
75
u8 request_counter[WPA_REPLAY_COUNTER_LEN];
77
time_t last_michael_mic_error;
78
u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN];
79
int rx_replay_counter_set;
81
int reassociate; /* reassociation requested */
82
struct wpa_ssid *current_ssid;
83
u8 *ap_wpa_ie, *ap_rsn_ie;
84
size_t ap_wpa_ie_len, ap_rsn_ie_len;
86
size_t assoc_wpa_ie_len;
88
/* Selected configuration (based on Beacon/ProbeResp WPA IE) */
94
void *drv_priv; /* private data used by driver_ops */
96
struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
97
* NULL = not yet initialized (start
98
* with broadcast SSID)
99
* BROADCAST_SSID_SCAN = broadcast
100
* SSID was used in the previous scan
102
#define BROADCAST_SSID_SCAN ((struct wpa_ssid *) 1)
104
struct wpa_scan_result *scan_results;
105
int num_scan_results;
107
struct wpa_driver_ops *driver;
108
int interface_removed; /* whether the network interface has been
110
struct eapol_sm *eapol;
112
int ctrl_sock; /* UNIX domain socket for control interface or -1 if
114
struct wpa_ctrl_dst *ctrl_dst;
117
WPA_DISCONNECTED, WPA_SCANNING, WPA_ASSOCIATING,
118
WPA_ASSOCIATED, WPA_4WAY_HANDSHAKE, WPA_GROUP_HANDSHAKE,
122
struct rsn_pmksa_cache *pmksa; /* PMKSA cache */
123
int pmksa_count; /* number of entries in PMKSA cache */
124
struct rsn_pmksa_cache *cur_pmksa; /* current PMKSA entry */
125
struct rsn_pmksa_candidate *pmksa_candidates;
127
struct l2_packet_data *l2_preauth;
128
u8 preauth_bssid[ETH_ALEN]; /* current RSN pre-auth peer or
129
* 00:00:00:00:00:00 if no pre-auth is
131
struct eapol_sm *preauth_eapol;
133
int eapol_received; /* number of EAPOL packets received after the
134
* previous association event */
138
struct scard_data *scard;
140
unsigned char last_eapol_src[ETH_ALEN];
144
struct wpa_blacklist *blacklist;
147
u8 radius_identifier;
148
struct radius_msg *last_recv_radius;
149
struct in_addr own_ip_addr;
150
struct radius_client_data *radius;
152
/* RADIUS Authentication and Accounting servers in priority order */
153
struct hostapd_radius_server *auth_servers, *auth_server;
154
int num_auth_servers;
155
struct hostapd_radius_server *acct_servers, *acct_server;
156
int num_acct_servers;
158
int radius_retry_primary_interval;
159
int radius_acct_interim_interval;
161
u8 *last_eap_radius; /* last received EAP Response from Authentication
163
size_t last_eap_radius_len;
165
u8 authenticator_pmk[PMK_LEN];
166
size_t authenticator_pmk_len;
167
int radius_access_accept_received;
168
int radius_access_reject_received;
172
size_t eap_identity_len;
173
#endif /* EAPOL_TEST */
177
/* wpa_supplicant.c */
178
void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx);
180
void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
182
void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
184
void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
186
void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
189
void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
192
void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
194
int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
196
int wpa_supplicant_get_beacon_ie(struct wpa_supplicant *wpa_s);
200
void wpa_supplicant_key_request(struct wpa_supplicant *wpa_s,
201
int error, int pairwise);
213
int wpa_parse_wpa_ie(struct wpa_supplicant *wpa_s, u8 *wpa_ie,
214
size_t wpa_ie_len, struct wpa_ie_data *data);
216
int wpa_gen_wpa_ie(struct wpa_supplicant *wpa_s, u8 *wpa_ie);
218
void wpa_supplicant_rx_eapol(void *ctx, unsigned char *src_addr,
219
unsigned char *buf, size_t len);
221
struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
223
void pmksa_cache_free(struct wpa_supplicant *wpa_s);
224
struct rsn_pmksa_cache * pmksa_cache_get(struct wpa_supplicant *wpa_s,
226
int pmksa_cache_list(struct wpa_supplicant *wpa_s, char *buf, size_t len);
227
void pmksa_candidate_free(struct wpa_supplicant *wpa_s);
229
int wpa_get_mib(struct wpa_supplicant *wpa_s, char *buf, size_t buflen);
231
struct wpa_scan_result;
232
#ifdef IEEE8021X_EAPOL
233
int rsn_preauth_init(struct wpa_supplicant *wpa_s, u8 *dst);
234
void rsn_preauth_deinit(struct wpa_supplicant *wpa_s);
235
void rsn_preauth_scan_results(struct wpa_supplicant *wpa_s,
236
struct wpa_scan_result *results, int count);
237
void pmksa_candidate_add(struct wpa_supplicant *wpa_s, const u8 *bssid,
239
#else /* IEEE8021X_EAPOL */
240
static inline int rsn_preauth_init(struct wpa_supplicant *wpa_s, u8 *dst)
245
static inline void rsn_preauth_deinit(struct wpa_supplicant *wpa_s)
248
static inline void rsn_preauth_scan_results(struct wpa_supplicant *wpa_s,
249
struct wpa_scan_result *results,
254
static inline void pmksa_candidate_add(struct wpa_supplicant *wpa_s,
259
#endif /* IEEE8021X_EAPOL */
261
void wpa_supplicant_notify_eapol_done(void *ctx);
264
* wpa_eapol_send - send IEEE 802.1X EAPOL packet to the Authenticator
265
* @ctx: pointer to wpa_supplicant data
266
* @type: IEEE 802.1X packet type (IEEE802_1X_TYPE_*)
267
* @buf: EAPOL payload (after IEEE 802.1X header)
268
* @len: EAPOL payload length
270
* This function adds Ethernet and IEEE 802.1X header and sends the EAPOL frame
271
* to the current Authenticator or in case of pre-authentication, to the peer
272
* of the authentication.
274
int wpa_eapol_send(void *ctx, int type, u8 *buf, size_t len);
275
int wpa_eapol_send_preauth(void *ctx, int type, u8 *buf, size_t len);
279
static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
282
if (wpa_s->driver->init) {
283
return wpa_s->driver->init(wpa_s, ifname);
288
static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
290
if (wpa_s->driver->deinit)
291
wpa_s->driver->deinit(wpa_s->drv_priv);
294
static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
297
if (wpa_s->driver->set_drop_unencrypted) {
298
return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
304
static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
307
if (wpa_s->driver->set_countermeasures) {
308
return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
314
static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
317
if (wpa_s->driver->set_auth_alg) {
318
return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
324
static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
326
if (wpa_s->driver->set_wpa) {
327
return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
332
static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
333
struct wpa_driver_associate_params *params)
335
if (wpa_s->driver->associate) {
336
return wpa_s->driver->associate(wpa_s->drv_priv, params);
341
static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid,
344
if (wpa_s->driver->scan) {
345
return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len);
350
static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
351
struct wpa_scan_result *results,
354
if (wpa_s->driver->get_scan_results) {
355
return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
361
static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
363
if (wpa_s->driver->get_bssid) {
364
return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
369
static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
371
if (wpa_s->driver->get_ssid) {
372
return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
377
static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
378
const u8 *addr, int key_idx, int set_tx,
379
const u8 *seq, size_t seq_len,
380
const u8 *key, size_t key_len)
382
if (wpa_s->driver->set_key) {
383
return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
384
key_idx, set_tx, seq, seq_len,
390
static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
391
const u8 *addr, int reason_code)
393
if (wpa_s->driver->deauthenticate) {
394
return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
400
static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
401
const u8 *addr, int reason_code)
403
if (wpa_s->driver->disassociate) {
404
return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
410
static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
411
const u8 *bssid, const u8 *pmkid)
413
if (wpa_s->driver->add_pmkid) {
414
return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
419
static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
420
const u8 *bssid, const u8 *pmkid)
422
if (wpa_s->driver->remove_pmkid) {
423
return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
429
static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
431
if (wpa_s->driver->flush_pmkid) {
432
return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
437
static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
438
struct wpa_driver_capa *capa)
440
if (wpa_s->driver->get_capa) {
441
return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
446
static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
448
if (wpa_s->driver->poll) {
449
wpa_s->driver->poll(wpa_s->drv_priv);
453
static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
455
if (wpa_s->driver->get_ifname) {
456
return wpa_s->driver->get_ifname(wpa_s->drv_priv);
461
static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
463
if (wpa_s->driver->get_mac_addr) {
464
return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
469
#endif /* WPA_SUPPLICANT_I_H */