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;
56 struct wpa_supplicant {
57 struct wpa_supplicant *head;
58 struct wpa_supplicant *next;
59 struct l2_packet_data *l2;
60 unsigned char own_addr[ETH_ALEN];
62 #ifdef CONFIG_XSUPPLICANT_IFACE
63 int dot1x_s; /* socket for connection to Xsupplicant */
64 int ext_pmk_received; /* 1 = PMK was received from Xsupplicant */
65 #endif /* CONFIG_XSUPPLICANT_IFACE */
69 u8 snonce[WPA_NONCE_LEN];
70 u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */
71 struct wpa_ptk ptk, tptk;
72 int ptk_set, tptk_set;
75 struct wpa_config *conf;
76 u8 request_counter[WPA_REPLAY_COUNTER_LEN];
78 time_t last_michael_mic_error;
79 u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN];
80 int rx_replay_counter_set;
82 int reassociate; /* reassociation requested */
83 struct wpa_ssid *current_ssid;
84 u8 *ap_wpa_ie, *ap_rsn_ie;
85 size_t ap_wpa_ie_len, ap_rsn_ie_len;
87 size_t assoc_wpa_ie_len;
89 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
95 void *drv_priv; /* private data used by driver_ops */
97 struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
98 * NULL = not yet initialized (start
99 * with broadcast SSID)
100 * BROADCAST_SSID_SCAN = broadcast
101 * SSID was used in the previous scan
103 #define BROADCAST_SSID_SCAN ((struct wpa_ssid *) 1)
105 struct wpa_scan_result *scan_results;
106 int num_scan_results;
108 struct wpa_driver_ops *driver;
109 int interface_removed; /* whether the network interface has been
111 struct eapol_sm *eapol;
113 int ctrl_sock; /* UNIX domain socket for control interface or -1 if
115 struct wpa_ctrl_dst *ctrl_dst;
118 WPA_DISCONNECTED, WPA_SCANNING, WPA_ASSOCIATING,
119 WPA_ASSOCIATED, WPA_4WAY_HANDSHAKE, WPA_GROUP_HANDSHAKE,
123 struct rsn_pmksa_cache *pmksa; /* PMKSA cache */
124 int pmksa_count; /* number of entries in PMKSA cache */
125 struct rsn_pmksa_cache *cur_pmksa; /* current PMKSA entry */
126 struct rsn_pmksa_candidate *pmksa_candidates;
128 struct l2_packet_data *l2_preauth;
129 u8 preauth_bssid[ETH_ALEN]; /* current RSN pre-auth peer or
130 * 00:00:00:00:00:00 if no pre-auth is
132 struct eapol_sm *preauth_eapol;
134 int eapol_received; /* number of EAPOL packets received after the
135 * previous association event */
139 struct scard_data *scard;
141 unsigned char last_eapol_src[ETH_ALEN];
145 struct wpa_blacklist *blacklist;
148 u8 radius_identifier;
149 struct radius_msg *last_recv_radius;
150 struct in_addr own_ip_addr;
151 struct radius_client_data *radius;
153 /* RADIUS Authentication and Accounting servers in priority order */
154 struct hostapd_radius_server *auth_servers, *auth_server;
155 int num_auth_servers;
156 struct hostapd_radius_server *acct_servers, *acct_server;
157 int num_acct_servers;
159 int radius_retry_primary_interval;
160 int radius_acct_interim_interval;
162 u8 *last_eap_radius; /* last received EAP Response from Authentication
164 size_t last_eap_radius_len;
166 u8 authenticator_pmk[PMK_LEN];
167 size_t authenticator_pmk_len;
168 int radius_access_accept_received;
169 int radius_access_reject_received;
173 size_t eap_identity_len;
174 #endif /* EAPOL_TEST */
178 /* wpa_supplicant.c */
179 void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx);
181 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
183 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
185 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
187 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
190 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
193 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
195 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
197 int wpa_supplicant_get_beacon_ie(struct wpa_supplicant *wpa_s);
201 void wpa_supplicant_key_request(struct wpa_supplicant *wpa_s,
202 int error, int pairwise);
214 int wpa_parse_wpa_ie(struct wpa_supplicant *wpa_s, u8 *wpa_ie,
215 size_t wpa_ie_len, struct wpa_ie_data *data);
217 int wpa_gen_wpa_ie(struct wpa_supplicant *wpa_s, u8 *wpa_ie);
219 void wpa_supplicant_rx_eapol(void *ctx, unsigned char *src_addr,
220 unsigned char *buf, size_t len);
222 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
224 void pmksa_cache_free(struct wpa_supplicant *wpa_s);
225 struct rsn_pmksa_cache * pmksa_cache_get(struct wpa_supplicant *wpa_s,
227 int pmksa_cache_list(struct wpa_supplicant *wpa_s, char *buf, size_t len);
228 void pmksa_candidate_free(struct wpa_supplicant *wpa_s);
230 int wpa_get_mib(struct wpa_supplicant *wpa_s, char *buf, size_t buflen);
232 struct wpa_scan_result;
233 #ifdef IEEE8021X_EAPOL
234 int rsn_preauth_init(struct wpa_supplicant *wpa_s, u8 *dst);
235 void rsn_preauth_deinit(struct wpa_supplicant *wpa_s);
236 void rsn_preauth_scan_results(struct wpa_supplicant *wpa_s,
237 struct wpa_scan_result *results, int count);
238 void pmksa_candidate_add(struct wpa_supplicant *wpa_s, const u8 *bssid,
240 #else /* IEEE8021X_EAPOL */
241 static inline int rsn_preauth_init(struct wpa_supplicant *wpa_s, u8 *dst)
246 static inline void rsn_preauth_deinit(struct wpa_supplicant *wpa_s)
249 static inline void rsn_preauth_scan_results(struct wpa_supplicant *wpa_s,
250 struct wpa_scan_result *results,
255 static inline void pmksa_candidate_add(struct wpa_supplicant *wpa_s,
260 #endif /* IEEE8021X_EAPOL */
262 void wpa_supplicant_notify_eapol_done(void *ctx);
265 * wpa_eapol_send - send IEEE 802.1X EAPOL packet to the Authenticator
266 * @ctx: pointer to wpa_supplicant data
267 * @type: IEEE 802.1X packet type (IEEE802_1X_TYPE_*)
268 * @buf: EAPOL payload (after IEEE 802.1X header)
269 * @len: EAPOL payload length
271 * This function adds Ethernet and IEEE 802.1X header and sends the EAPOL frame
272 * to the current Authenticator or in case of pre-authentication, to the peer
273 * of the authentication.
275 int wpa_eapol_send(void *ctx, int type, u8 *buf, size_t len);
276 int wpa_eapol_send_preauth(void *ctx, int type, u8 *buf, size_t len);
280 static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
283 if (wpa_s->driver->init) {
284 return wpa_s->driver->init(wpa_s, ifname);
289 static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
291 if (wpa_s->driver->deinit)
292 wpa_s->driver->deinit(wpa_s->drv_priv);
295 static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
298 if (wpa_s->driver->set_drop_unencrypted) {
299 return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
305 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
308 if (wpa_s->driver->set_countermeasures) {
309 return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
315 static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
318 if (wpa_s->driver->set_auth_alg) {
319 return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
325 static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
327 if (wpa_s->driver->set_wpa) {
328 return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
333 static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
334 struct wpa_driver_associate_params *params)
336 if (wpa_s->driver->associate) {
337 return wpa_s->driver->associate(wpa_s->drv_priv, params);
342 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid,
345 if (wpa_s->driver->scan) {
346 return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len);
351 static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
352 struct wpa_scan_result *results,
355 if (wpa_s->driver->get_scan_results) {
356 return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
362 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
364 if (wpa_s->driver->get_bssid) {
365 return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
370 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
372 if (wpa_s->driver->get_ssid) {
373 return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
378 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
379 const u8 *addr, int key_idx, int set_tx,
380 const u8 *seq, size_t seq_len,
381 const u8 *key, size_t key_len)
383 if (wpa_s->driver->set_key) {
384 return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
385 key_idx, set_tx, seq, seq_len,
391 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
392 const u8 *addr, int reason_code)
394 if (wpa_s->driver->deauthenticate) {
395 return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
401 static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
402 const u8 *addr, int reason_code)
404 if (wpa_s->driver->disassociate) {
405 return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
411 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
412 const u8 *bssid, const u8 *pmkid)
414 if (wpa_s->driver->add_pmkid) {
415 return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
420 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
421 const u8 *bssid, const u8 *pmkid)
423 if (wpa_s->driver->remove_pmkid) {
424 return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
430 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
432 if (wpa_s->driver->flush_pmkid) {
433 return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
438 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
439 struct wpa_driver_capa *capa)
441 if (wpa_s->driver->get_capa) {
442 return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
447 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
449 if (wpa_s->driver->poll) {
450 wpa_s->driver->poll(wpa_s->drv_priv);
454 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
456 if (wpa_s->driver->get_ifname) {
457 return wpa_s->driver->get_ifname(wpa_s->drv_priv);
462 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
464 if (wpa_s->driver->get_mac_addr) {
465 return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
470 #endif /* WPA_SUPPLICANT_I_H */