wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
wpa.h
Go to the documentation of this file.
1 
5 #ifndef WPA_H
6 #define WPA_H
7 
8 #include "common/defs.h"
9 #include "common/eapol_common.h"
10 #include "common/wpa_common.h"
11 #include "common/ieee802_11_defs.h"
12 
13 struct wpa_sm;
14 struct eapol_sm;
15 struct wpa_config_blob;
16 struct hostapd_freq_params;
17 
18 struct wpa_sm_ctx {
19  void *ctx; /* pointer to arbitrary upper level context */
20  void *msg_ctx; /* upper level context for wpa_msg() calls */
21 
22  void (*set_state)(void *ctx, enum wpa_states state);
23  enum wpa_states (*get_state)(void *ctx);
24  void (*deauthenticate)(void * ctx, int reason_code);
25  int (*set_key)(void *ctx, enum wpa_alg alg,
26  const u8 *addr, int key_idx, int set_tx,
27  const u8 *seq, size_t seq_len,
28  const u8 *key, size_t key_len);
29  void * (*get_network_ctx)(void *ctx);
30  int (*get_bssid)(void *ctx, u8 *bssid);
31  int (*ether_send)(void *ctx, const u8 *dest, u16 proto, const u8 *buf,
32  size_t len);
33  int (*get_beacon_ie)(void *ctx);
34  void (*cancel_auth_timeout)(void *ctx);
35  u8 * (*alloc_eapol)(void *ctx, u8 type, const void *data, u16 data_len,
36  size_t *msg_len, void **data_pos);
37  int (*add_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid);
38  int (*remove_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid);
39  void (*set_config_blob)(void *ctx, struct wpa_config_blob *blob);
40  const struct wpa_config_blob * (*get_config_blob)(void *ctx,
41  const char *name);
42  int (*mlme_setprotection)(void *ctx, const u8 *addr,
43  int protection_type, int key_type);
44  int (*update_ft_ies)(void *ctx, const u8 *md, const u8 *ies,
45  size_t ies_len);
46  int (*send_ft_action)(void *ctx, u8 action, const u8 *target_ap,
47  const u8 *ies, size_t ies_len);
48  int (*mark_authenticated)(void *ctx, const u8 *target_ap);
49 #ifdef CONFIG_TDLS
50  int (*tdls_get_capa)(void *ctx, int *tdls_supported,
51  int *tdls_ext_setup, int *tdls_chan_switch);
52  int (*send_tdls_mgmt)(void *ctx, const u8 *dst,
53  u8 action_code, u8 dialog_token,
54  u16 status_code, u32 peer_capab,
55  int initiator, const u8 *buf, size_t len);
56  int (*tdls_oper)(void *ctx, int oper, const u8 *peer);
57  int (*tdls_peer_addset)(void *ctx, const u8 *addr, int add, u16 aid,
58  u16 capability, const u8 *supp_rates,
59  size_t supp_rates_len,
60  const struct ieee80211_ht_capabilities *ht_capab,
61  const struct ieee80211_vht_capabilities *vht_capab,
62  u8 qosinfo, int wmm, const u8 *ext_capab,
63  size_t ext_capab_len, const u8 *supp_channels,
64  size_t supp_channels_len,
65  const u8 *supp_oper_classes,
66  size_t supp_oper_classes_len);
67  int (*tdls_enable_channel_switch)(
68  void *ctx, const u8 *addr, u8 oper_class,
69  const struct hostapd_freq_params *params);
70  int (*tdls_disable_channel_switch)(void *ctx, const u8 *addr);
71 #endif /* CONFIG_TDLS */
72  void (*set_rekey_offload)(void *ctx, const u8 *kek, size_t kek_len,
73  const u8 *kck, size_t kck_len,
74  const u8 *replay_ctr);
75  int (*key_mgmt_set_pmk)(void *ctx, const u8 *pmk, size_t pmk_len);
76 };
77 
78 
79 enum wpa_sm_conf_params {
80  RSNA_PMK_LIFETIME /* dot11RSNAConfigPMKLifetime */,
81  RSNA_PMK_REAUTH_THRESHOLD /* dot11RSNAConfigPMKReauthThreshold */,
82  RSNA_SA_TIMEOUT /* dot11RSNAConfigSATimeout */,
83  WPA_PARAM_PROTO,
84  WPA_PARAM_PAIRWISE,
85  WPA_PARAM_GROUP,
86  WPA_PARAM_KEY_MGMT,
87  WPA_PARAM_MGMT_GROUP,
88  WPA_PARAM_RSN_ENABLED,
89  WPA_PARAM_MFP
90 };
91 
93  void *network_ctx;
94  int peerkey_enabled;
95  int allowed_pairwise_cipher; /* bitfield of WPA_CIPHER_* */
96  int proactive_key_caching;
97  int eap_workaround;
98  void *eap_conf_ctx;
99  const u8 *ssid;
100  size_t ssid_len;
101  int wpa_ptk_rekey;
102  int p2p;
103 };
104 
105 #ifndef CONFIG_NO_WPA
106 
107 struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx);
108 void wpa_sm_deinit(struct wpa_sm *sm);
109 void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid);
110 void wpa_sm_notify_disassoc(struct wpa_sm *sm);
111 void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk, size_t pmk_len,
112  const u8 *bssid);
113 void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm);
114 void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth);
115 void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx);
116 void wpa_sm_set_config(struct wpa_sm *sm, struct rsn_supp_config *config);
117 void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr);
118 void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname,
119  const char *bridge_ifname);
120 void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol);
121 int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
122 int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm, u8 *wpa_ie,
123  size_t *wpa_ie_len);
124 int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
125 int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
126 int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen);
127 
128 int wpa_sm_set_param(struct wpa_sm *sm, enum wpa_sm_conf_params param,
129  unsigned int value);
130 
131 int wpa_sm_get_status(struct wpa_sm *sm, char *buf, size_t buflen,
132  int verbose);
133 int wpa_sm_pmf_enabled(struct wpa_sm *sm);
134 
135 void wpa_sm_key_request(struct wpa_sm *sm, int error, int pairwise);
136 
137 int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len,
138  struct wpa_ie_data *data);
139 
140 void wpa_sm_aborted_cached(struct wpa_sm *sm);
141 int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
142  const u8 *buf, size_t len);
143 int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm, struct wpa_ie_data *data);
144 int wpa_sm_pmksa_cache_list(struct wpa_sm *sm, char *buf, size_t len);
145 void wpa_sm_drop_sa(struct wpa_sm *sm);
146 int wpa_sm_has_ptk(struct wpa_sm *sm);
147 
148 void wpa_sm_update_replay_ctr(struct wpa_sm *sm, const u8 *replay_ctr);
149 
150 void wpa_sm_pmksa_cache_flush(struct wpa_sm *sm, void *network_ctx);
151 
152 int wpa_sm_get_p2p_ip_addr(struct wpa_sm *sm, u8 *buf);
153 
154 void wpa_sm_set_rx_replay_ctr(struct wpa_sm *sm, const u8 *rx_replay_counter);
155 void wpa_sm_set_ptk_kck_kek(struct wpa_sm *sm,
156  const u8 *ptk_kck, size_t ptk_kck_len,
157  const u8 *ptk_kek, size_t ptk_kek_len);
158 
159 #else /* CONFIG_NO_WPA */
160 
161 static inline struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx)
162 {
163  return (struct wpa_sm *) 1;
164 }
165 
166 static inline void wpa_sm_deinit(struct wpa_sm *sm)
167 {
168 }
169 
170 static inline void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
171 {
172 }
173 
174 static inline void wpa_sm_notify_disassoc(struct wpa_sm *sm)
175 {
176 }
177 
178 static inline void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk,
179  size_t pmk_len)
180 {
181 }
182 
183 static inline void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm)
184 {
185 }
186 
187 static inline void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth)
188 {
189 }
190 
191 static inline void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx)
192 {
193 }
194 
195 static inline void wpa_sm_set_config(struct wpa_sm *sm,
196  struct rsn_supp_config *config)
197 {
198 }
199 
200 static inline void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr)
201 {
202 }
203 
204 static inline void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname,
205  const char *bridge_ifname)
206 {
207 }
208 
209 static inline void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol)
210 {
211 }
212 
213 static inline int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie,
214  size_t len)
215 {
216  return -1;
217 }
218 
219 static inline int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm,
220  u8 *wpa_ie,
221  size_t *wpa_ie_len)
222 {
223  return -1;
224 }
225 
226 static inline int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie,
227  size_t len)
228 {
229  return -1;
230 }
231 
232 static inline int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie,
233  size_t len)
234 {
235  return -1;
236 }
237 
238 static inline int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen)
239 {
240  return 0;
241 }
242 
243 static inline int wpa_sm_set_param(struct wpa_sm *sm,
244  enum wpa_sm_conf_params param,
245  unsigned int value)
246 {
247  return -1;
248 }
249 
250 static inline int wpa_sm_get_status(struct wpa_sm *sm, char *buf,
251  size_t buflen, int verbose)
252 {
253  return 0;
254 }
255 
256 static inline int wpa_sm_pmf_enabled(struct wpa_sm *sm)
257 {
258  return 0;
259 }
260 
261 static inline void wpa_sm_key_request(struct wpa_sm *sm, int error,
262  int pairwise)
263 {
264 }
265 
266 static inline int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len,
267  struct wpa_ie_data *data)
268 {
269  return -1;
270 }
271 
272 static inline void wpa_sm_aborted_cached(struct wpa_sm *sm)
273 {
274 }
275 
276 static inline int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
277  const u8 *buf, size_t len)
278 {
279  return -1;
280 }
281 
282 static inline int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm,
283  struct wpa_ie_data *data)
284 {
285  return -1;
286 }
287 
288 static inline int wpa_sm_pmksa_cache_list(struct wpa_sm *sm, char *buf,
289  size_t len)
290 {
291  return -1;
292 }
293 
294 static inline void wpa_sm_drop_sa(struct wpa_sm *sm)
295 {
296 }
297 
298 static inline int wpa_sm_has_ptk(struct wpa_sm *sm)
299 {
300  return 0;
301 }
302 
303 static inline void wpa_sm_update_replay_ctr(struct wpa_sm *sm,
304  const u8 *replay_ctr)
305 {
306 }
307 
308 static inline void wpa_sm_pmksa_cache_flush(struct wpa_sm *sm,
309  void *network_ctx)
310 {
311 }
312 
313 static inline void wpa_sm_set_rx_replay_ctr(struct wpa_sm *sm,
314  const u8 *rx_replay_counter)
315 {
316 }
317 
318 static inline void wpa_sm_set_ptk_kck_kek(struct wpa_sm *sm, const u8 *ptk_kck,
319  const u8 *ptk_kek)
320 {
321 }
322 
323 #endif /* CONFIG_NO_WPA */
324 
325 #ifdef CONFIG_PEERKEY
326 int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer);
327 int wpa_sm_rx_eapol_peerkey(struct wpa_sm *sm, const u8 *src_addr,
328  const u8 *buf, size_t len);
329 #else /* CONFIG_PEERKEY */
330 static inline int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer)
331 {
332  return -1;
333 }
334 
335 static inline int wpa_sm_rx_eapol_peerkey(struct wpa_sm *sm, const u8 *src_addr,
336  const u8 *buf, size_t len)
337 {
338  return 0;
339 }
340 #endif /* CONFIG_PEERKEY */
341 
342 #ifdef CONFIG_IEEE80211R
343 
344 int wpa_sm_set_ft_params(struct wpa_sm *sm, const u8 *ies, size_t ies_len);
345 int wpa_ft_prepare_auth_request(struct wpa_sm *sm, const u8 *mdie);
346 int wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
347  int ft_action, const u8 *target_ap,
348  const u8 *ric_ies, size_t ric_ies_len);
349 int wpa_ft_is_completed(struct wpa_sm *sm);
350 void wpa_reset_ft_completed(struct wpa_sm *sm);
351 int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
352  size_t ies_len, const u8 *src_addr);
353 int wpa_ft_start_over_ds(struct wpa_sm *sm, const u8 *target_ap,
354  const u8 *mdie);
355 
356 #else /* CONFIG_IEEE80211R */
357 
358 static inline int
359 wpa_sm_set_ft_params(struct wpa_sm *sm, const u8 *ies, size_t ies_len)
360 {
361  return 0;
362 }
363 
364 static inline int wpa_ft_prepare_auth_request(struct wpa_sm *sm,
365  const u8 *mdie)
366 {
367  return 0;
368 }
369 
370 static inline int
371 wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
372  int ft_action, const u8 *target_ap)
373 {
374  return 0;
375 }
376 
377 static inline int wpa_ft_is_completed(struct wpa_sm *sm)
378 {
379  return 0;
380 }
381 
382 static inline void wpa_reset_ft_completed(struct wpa_sm *sm)
383 {
384 }
385 
386 static inline int
387 wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
388  const u8 *src_addr)
389 {
390  return -1;
391 }
392 
393 #endif /* CONFIG_IEEE80211R */
394 
395 
396 /* tdls.c */
397 void wpa_tdls_ap_ies(struct wpa_sm *sm, const u8 *ies, size_t len);
398 void wpa_tdls_assoc_resp_ies(struct wpa_sm *sm, const u8 *ies, size_t len);
399 int wpa_tdls_start(struct wpa_sm *sm, const u8 *addr);
400 void wpa_tdls_remove(struct wpa_sm *sm, const u8 *addr);
401 int wpa_tdls_teardown_link(struct wpa_sm *sm, const u8 *addr, u16 reason_code);
402 int wpa_tdls_send_discovery_request(struct wpa_sm *sm, const u8 *addr);
403 int wpa_tdls_init(struct wpa_sm *sm);
404 void wpa_tdls_teardown_peers(struct wpa_sm *sm);
405 void wpa_tdls_deinit(struct wpa_sm *sm);
406 void wpa_tdls_enable(struct wpa_sm *sm, int enabled);
407 void wpa_tdls_disable_unreachable_link(struct wpa_sm *sm, const u8 *addr);
408 const char * wpa_tdls_get_link_status(struct wpa_sm *sm, const u8 *addr);
409 int wpa_tdls_is_external_setup(struct wpa_sm *sm);
410 int wpa_tdls_enable_chan_switch(struct wpa_sm *sm, const u8 *addr,
411  u8 oper_class,
412  struct hostapd_freq_params *freq_params);
413 int wpa_tdls_disable_chan_switch(struct wpa_sm *sm, const u8 *addr);
414 
415 int wpa_wnmsleep_install_key(struct wpa_sm *sm, u8 subelem_id, u8 *buf);
416 
417 #endif /* WPA_H */
int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len, struct wpa_ie_data *data)
Parse WPA/RSN IE.
Definition: wpa_ie.c:24
void wpa_sm_key_request(struct wpa_sm *sm, int error, int pairwise)
Send EAPOL-Key Request.
Definition: wpa.c:85
int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, const u8 *buf, size_t len)
Process received WPA EAPOL frames.
Definition: wpa.c:1703
int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie, size_t len)
Set AP RSN IE from Beacon/ProbeResp.
Definition: wpa.c:2742
void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname, const char *bridge_ifname)
Set network interface name.
Definition: wpa.c:2470
void wpa_sm_deinit(struct wpa_sm *sm)
Deinitialize WPA state machine.
Definition: wpa.c:2220
void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm)
Set PMK based on the current PMKSA.
Definition: wpa.c:2368
WPA Supplicant - Common definitions.
int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm, struct wpa_ie_data *data)
Parse own WPA/RSN IE.
Definition: wpa.c:2776
void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol)
Set EAPOL state machine pointer.
Definition: wpa.c:2485
Definition: ieee802_11_defs.h:634
void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth)
Set fast reauthentication (EAP) enabled/disabled.
Definition: wpa.c:2388
int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len)
Set own WPA/RSN IE from (Re)AssocReq.
Definition: wpa.c:2672
void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx)
Set context pointer for smartcard callbacks.
Definition: wpa.c:2400
Definition: wpa.h:18
wpa_states
wpa_supplicant state
Definition: defs.h:161
int wpa_tdls_start(struct wpa_sm *sm, const u8 *addr)
Initiate TDLS handshake (send TPK Handshake Message 1)
Definition: tdls.c:2594
Definition: ieee802_11_defs.h:668
struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx)
Initialize WPA state machine.
Definition: wpa.c:2189
void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr)
Set own MAC address.
Definition: wpa.c:2457
Named configuration blob.
Definition: eap_config.h:812
int wpa_sm_get_status(struct wpa_sm *sm, char *buf, size_t buflen, int verbose)
Get WPA state machine.
Definition: wpa.c:2569
void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
Notify WPA state machine about association.
Definition: wpa.c:2248
WPA definitions shared between hostapd and wpa_supplicant.
Definition: wpa.h:92
void wpa_tdls_deinit(struct wpa_sm *sm)
Deinitialize driver interface parameters for TDLS.
Definition: tdls.c:2835
int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len)
Set AP WPA IE from Beacon/ProbeResp.
Definition: wpa.c:2707
size_t len
Length of binary data.
Definition: eap_config.h:829
int wpa_sm_set_param(struct wpa_sm *sm, enum wpa_sm_conf_params param, unsigned int value)
Set WPA state machine parameters.
Definition: wpa.c:2499
IEEE 802.11 Frame type definitions Copyright (c) 2007-2008 Intel Corporation.
int wpa_tdls_init(struct wpa_sm *sm)
Initialize driver interface parameters for TDLS.
Definition: tdls.c:2747
Internal data for EAPOL state machines.
Definition: eapol_supp_sm.c:28
EAPOL definitions shared between hostapd and wpa_supplicant.
Channel parameters.
Definition: driver.h:510
int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm, u8 *wpa_ie, size_t *wpa_ie_len)
Generate own WPA/RSN IE from configuration.
Definition: wpa.c:2627
void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk, size_t pmk_len, const u8 *bssid)
Set PMK.
Definition: wpa.c:2338
Internal WPA state machine data.
Definition: wpa_i.h:18
void wpa_sm_notify_disassoc(struct wpa_sm *sm)
Notify WPA state machine about disassociation.
Definition: wpa.c:2309
void wpa_sm_aborted_cached(struct wpa_sm *sm)
Notify WPA that PMKSA caching was aborted.
Definition: wpa.c:1640
int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen)
Dump text list of MIB entries.
Definition: wpa.c:2067
char * name
Blob name.
Definition: eap_config.h:817
void wpa_sm_set_config(struct wpa_sm *sm, struct rsn_supp_config *config)
Notification of current configration change.
Definition: wpa.c:2419
Definition: wpa_common.h:360