]> git.ipfire.org Git - thirdparty/hostap.git/blame - src/rsn_supp/wpa.h
Delete PTK SA on (re)association if this is not part of a Fast BSS
[thirdparty/hostap.git] / src / rsn_supp / wpa.h
CommitLineData
6fc6879b
JM
1/*
2 * wpa_supplicant - WPA definitions
3 * Copyright (c) 2003-2007, 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 WPA_H
16#define WPA_H
17
18#include "defs.h"
19#include "eapol_common.h"
20#include "wpa_common.h"
21
22#ifndef ETH_P_EAPOL
23#define ETH_P_EAPOL 0x888e
24#endif
25
26#ifndef ETH_P_RSN_PREAUTH
27#define ETH_P_RSN_PREAUTH 0x88c7
28#endif
29
30struct wpa_sm;
31struct eapol_sm;
32struct wpa_config_blob;
33
34struct wpa_sm_ctx {
35 void *ctx; /* pointer to arbitrary upper level context */
36
37 void (*set_state)(void *ctx, wpa_states state);
38 wpa_states (*get_state)(void *ctx);
39 void (*req_scan)(void *ctx, int sec, int usec);
40 void (*cancel_scan)(void *ctx);
41 void (*deauthenticate)(void * ctx, int reason_code);
42 void (*disassociate)(void *ctx, int reason_code);
43 int (*set_key)(void *ctx, wpa_alg alg,
44 const u8 *addr, int key_idx, int set_tx,
45 const u8 *seq, size_t seq_len,
46 const u8 *key, size_t key_len);
47 void * (*get_network_ctx)(void *ctx);
48 int (*get_bssid)(void *ctx, u8 *bssid);
49 int (*ether_send)(void *ctx, const u8 *dest, u16 proto, const u8 *buf,
50 size_t len);
51 int (*get_beacon_ie)(void *ctx);
52 void (*cancel_auth_timeout)(void *ctx);
53 u8 * (*alloc_eapol)(void *ctx, u8 type, const void *data, u16 data_len,
54 size_t *msg_len, void **data_pos);
55 int (*add_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid);
56 int (*remove_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid);
57 void (*set_config_blob)(void *ctx, struct wpa_config_blob *blob);
58 const struct wpa_config_blob * (*get_config_blob)(void *ctx,
59 const char *name);
60 int (*mlme_setprotection)(void *ctx, const u8 *addr,
61 int protection_type, int key_type);
62 int (*update_ft_ies)(void *ctx, const u8 *md, const u8 *ies,
63 size_t ies_len);
64 int (*send_ft_action)(void *ctx, u8 action, const u8 *target_ap,
65 const u8 *ies, size_t ies_len);
66};
67
68
69enum wpa_sm_conf_params {
70 RSNA_PMK_LIFETIME /* dot11RSNAConfigPMKLifetime */,
71 RSNA_PMK_REAUTH_THRESHOLD /* dot11RSNAConfigPMKReauthThreshold */,
72 RSNA_SA_TIMEOUT /* dot11RSNAConfigSATimeout */,
73 WPA_PARAM_PROTO,
74 WPA_PARAM_PAIRWISE,
75 WPA_PARAM_GROUP,
76 WPA_PARAM_KEY_MGMT,
77 WPA_PARAM_MGMT_GROUP,
78 WPA_PARAM_RSN_ENABLED
79};
80
81struct rsn_supp_config {
82 void *network_ctx;
83 int peerkey_enabled;
84 int allowed_pairwise_cipher; /* bitfield of WPA_CIPHER_* */
85 int proactive_key_caching;
86 int eap_workaround;
87 void *eap_conf_ctx;
88 const u8 *ssid;
89 size_t ssid_len;
90};
91
92#ifndef CONFIG_NO_WPA
93
94struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx);
95void wpa_sm_deinit(struct wpa_sm *sm);
96void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid);
97void wpa_sm_notify_disassoc(struct wpa_sm *sm);
98void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk, size_t pmk_len);
99void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm);
100void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth);
101void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx);
102void wpa_sm_set_config(struct wpa_sm *sm, struct rsn_supp_config *config);
103void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr);
104void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname,
105 const char *bridge_ifname);
106void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol);
107int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
108int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm, u8 *wpa_ie,
109 size_t *wpa_ie_len);
110int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
111int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
112int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen);
113
114int wpa_sm_set_param(struct wpa_sm *sm, enum wpa_sm_conf_params param,
115 unsigned int value);
116unsigned int wpa_sm_get_param(struct wpa_sm *sm,
117 enum wpa_sm_conf_params param);
118
119int wpa_sm_get_status(struct wpa_sm *sm, char *buf, size_t buflen,
120 int verbose);
121
122void wpa_sm_key_request(struct wpa_sm *sm, int error, int pairwise);
123
124int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len,
125 struct wpa_ie_data *data);
126
127void wpa_sm_aborted_cached(struct wpa_sm *sm);
128int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
129 const u8 *buf, size_t len);
130int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm, struct wpa_ie_data *data);
131
132#else /* CONFIG_NO_WPA */
133
134static inline struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx)
135{
136 return (struct wpa_sm *) 1;
137}
138
139static inline void wpa_sm_deinit(struct wpa_sm *sm)
140{
141}
142
143static inline void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
144{
145}
146
147static inline void wpa_sm_notify_disassoc(struct wpa_sm *sm)
148{
149}
150
151static inline void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk,
152 size_t pmk_len)
153{
154}
155
156static inline void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm)
157{
158}
159
160static inline void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth)
161{
162}
163
164static inline void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx)
165{
166}
167
168static inline void wpa_sm_set_config(struct wpa_sm *sm,
169 struct rsn_supp_config *config)
170{
171}
172
173static inline void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr)
174{
175}
176
177static inline void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname,
178 const char *bridge_ifname)
179{
180}
181
182static inline void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol)
183{
184}
185
186static inline int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie,
187 size_t len)
188{
189 return -1;
190}
191
192static inline int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm,
193 u8 *wpa_ie,
194 size_t *wpa_ie_len)
195{
196 return -1;
197}
198
199static inline int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie,
200 size_t len)
201{
202 return -1;
203}
204
205static inline int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie,
206 size_t len)
207{
208 return -1;
209}
210
211static inline int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen)
212{
213 return 0;
214}
215
216static inline int wpa_sm_set_param(struct wpa_sm *sm,
217 enum wpa_sm_conf_params param,
218 unsigned int value)
219{
220 return -1;
221}
222
223static inline unsigned int wpa_sm_get_param(struct wpa_sm *sm,
224 enum wpa_sm_conf_params param)
225{
226 return 0;
227}
228
229static inline int wpa_sm_get_status(struct wpa_sm *sm, char *buf,
230 size_t buflen, int verbose)
231{
232 return 0;
233}
234
235static inline void wpa_sm_key_request(struct wpa_sm *sm, int error,
236 int pairwise)
237{
238}
239
240static inline int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len,
241 struct wpa_ie_data *data)
242{
243 return -1;
244}
245
246static inline void wpa_sm_aborted_cached(struct wpa_sm *sm)
247{
248}
249
250static inline int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
251 const u8 *buf, size_t len)
252{
253 return -1;
254}
255
256static inline int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm,
257 struct wpa_ie_data *data)
258{
259 return -1;
260}
261
262#endif /* CONFIG_NO_WPA */
263
264#ifdef CONFIG_PEERKEY
265int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer);
266#else /* CONFIG_PEERKEY */
267static inline int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer)
268{
269 return -1;
270}
271#endif /* CONFIG_PEERKEY */
272
273#ifdef CONFIG_IEEE80211R
274
275int wpa_sm_set_ft_params(struct wpa_sm *sm, const u8 *mobility_domain,
276 const u8 *r0kh_id, size_t r0kh_id_len,
277 const u8 *r1kh_id);
278int wpa_ft_prepare_auth_request(struct wpa_sm *sm);
279int wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
280 int ft_action, const u8 *target_ap);
281int wpa_ft_is_completed(struct wpa_sm *sm);
282int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
283 size_t ies_len);
284int wpa_ft_start_over_ds(struct wpa_sm *sm, const u8 *target_ap);
285
286#else /* CONFIG_IEEE80211R */
287
288static inline int
289wpa_sm_set_ft_params(struct wpa_sm *sm, const u8 *mobility_domain,
290 const u8 *r0kh_id, const u8 *r1kh_id)
291{
292 return 0;
293}
294
295static inline int wpa_ft_prepare_auth_request(struct wpa_sm *sm)
296{
297 return 0;
298}
299
300static inline int
301wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
302 int ft_action, const u8 *target_ap)
303{
304 return 0;
305}
306
307static inline int wpa_ft_is_completed(struct wpa_sm *sm)
308{
309 return 0;
310}
311
312static inline int
313wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies, size_t ies_len)
314{
315 return -1;
316}
317
318#endif /* CONFIG_IEEE80211R */
319
320#endif /* WPA_H */