Sync usage with man page.
[netbsd-mini2440.git] / dist / wpa / hostapd / wpa.h
blob5bcb6a60f14c0f444c0f04dfa3229e805a74450a
1 /*
2 * hostapd - IEEE 802.11i-2004 / WPA Authenticator
3 * Copyright (c) 2004-2007, 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
10 * license.
12 * See README and COPYING for more details.
15 #ifndef WPA_AUTH_H
16 #define WPA_AUTH_H
18 #include "eapol_common.h"
19 #include "wpa_common.h"
21 #ifdef _MSC_VER
22 #pragma pack(push, 1)
23 #endif /* _MSC_VER */
25 /* IEEE 802.11r/D8.0, 11A.10.3 - Remote request/response frame definition */
26 struct ft_rrb_frame {
27 u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
28 u8 packet_type; /* FT_PACKET_REQUEST/FT_PACKET_RESPONSE */
29 u16 action_length; /* little endian length of action_frame */
30 u8 ap_address[ETH_ALEN];
32 * Followed by action_length bytes of FT Action frame (from Category
33 * field to the end of Action Frame body.
35 } STRUCT_PACKED;
37 #define RSN_REMOTE_FRAME_TYPE_FT_RRB 1
39 #define FT_PACKET_REQUEST 0
40 #define FT_PACKET_RESPONSE 1
41 /* Vendor-specific types for R0KH-R1KH protocol; not defined in 802.11r */
42 #define FT_PACKET_R0KH_R1KH_PULL 200
43 #define FT_PACKET_R0KH_R1KH_RESP 201
44 #define FT_PACKET_R0KH_R1KH_PUSH 202
46 #ifndef ETH_P_RRB
47 #define ETH_P_RRB 0x890D
48 #endif /* ETH_P_RRB */
50 #define FT_R0KH_R1KH_PULL_DATA_LEN 44
51 #define FT_R0KH_R1KH_RESP_DATA_LEN 76
52 #define FT_R0KH_R1KH_PUSH_DATA_LEN 80
54 struct ft_r0kh_r1kh_pull_frame {
55 u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
56 u8 packet_type; /* FT_PACKET_R0KH_R1KH_PULL */
57 u16 data_length; /* little endian length of data (44) */
58 u8 ap_address[ETH_ALEN];
60 u8 nonce[16];
61 u8 pmk_r0_name[WPA_PMK_NAME_LEN];
62 u8 r1kh_id[FT_R1KH_ID_LEN];
63 u8 s1kh_id[ETH_ALEN];
64 u8 pad[4]; /* 8-octet boundary for AES key wrap */
65 u8 key_wrap_extra[8];
66 } STRUCT_PACKED;
68 struct ft_r0kh_r1kh_resp_frame {
69 u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
70 u8 packet_type; /* FT_PACKET_R0KH_R1KH_RESP */
71 u16 data_length; /* little endian length of data (76) */
72 u8 ap_address[ETH_ALEN];
74 u8 nonce[16]; /* copied from pull */
75 u8 r1kh_id[FT_R1KH_ID_LEN]; /* copied from pull */
76 u8 s1kh_id[ETH_ALEN]; /* copied from pull */
77 u8 pmk_r1[PMK_LEN];
78 u8 pmk_r1_name[WPA_PMK_NAME_LEN];
79 u8 pad[4]; /* 8-octet boundary for AES key wrap */
80 u8 key_wrap_extra[8];
81 } STRUCT_PACKED;
83 struct ft_r0kh_r1kh_push_frame {
84 u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
85 u8 packet_type; /* FT_PACKET_R0KH_R1KH_PUSH */
86 u16 data_length; /* little endian length of data (80) */
87 u8 ap_address[ETH_ALEN];
89 /* Encrypted with AES key-wrap */
90 u8 timestamp[4]; /* current time in seconds since unix epoch, little
91 * endian */
92 u8 r1kh_id[FT_R1KH_ID_LEN];
93 u8 s1kh_id[ETH_ALEN];
94 u8 pmk_r0_name[WPA_PMK_NAME_LEN];
95 u8 pmk_r1[PMK_LEN];
96 u8 pmk_r1_name[WPA_PMK_NAME_LEN];
97 u8 key_wrap_extra[8];
98 } STRUCT_PACKED;
100 #ifdef _MSC_VER
101 #pragma pack(pop)
102 #endif /* _MSC_VER */
105 /* per STA state machine data */
107 struct wpa_authenticator;
108 struct wpa_state_machine;
109 struct rsn_pmksa_cache_entry;
110 struct eapol_state_machine;
113 struct ft_remote_r0kh {
114 struct ft_remote_r0kh *next;
115 u8 addr[ETH_ALEN];
116 u8 id[FT_R0KH_ID_MAX_LEN];
117 size_t id_len;
118 u8 key[16];
122 struct ft_remote_r1kh {
123 struct ft_remote_r1kh *next;
124 u8 addr[ETH_ALEN];
125 u8 id[FT_R1KH_ID_LEN];
126 u8 key[16];
130 struct wpa_auth_config {
131 int wpa;
132 int wpa_key_mgmt;
133 int wpa_pairwise;
134 int wpa_group;
135 int wpa_group_rekey;
136 int wpa_strict_rekey;
137 int wpa_gmk_rekey;
138 int rsn_pairwise;
139 int rsn_preauth;
140 int eapol_version;
141 int peerkey;
142 int wme_enabled;
143 int okc;
144 #ifdef CONFIG_IEEE80211W
145 enum {
146 WPA_NO_IEEE80211W = 0,
147 WPA_IEEE80211W_OPTIONAL = 1,
148 WPA_IEEE80211W_REQUIRED = 2
149 } ieee80211w;
150 #endif /* CONFIG_IEEE80211W */
151 #ifdef CONFIG_IEEE80211R
152 #define SSID_LEN 32
153 u8 ssid[SSID_LEN];
154 size_t ssid_len;
155 u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
156 u8 r0_key_holder[FT_R0KH_ID_MAX_LEN];
157 size_t r0_key_holder_len;
158 u8 r1_key_holder[FT_R1KH_ID_LEN];
159 u32 r0_key_lifetime;
160 u32 reassociation_deadline;
161 struct ft_remote_r0kh *r0kh_list;
162 struct ft_remote_r1kh *r1kh_list;
163 int pmk_r1_push;
164 #endif /* CONFIG_IEEE80211R */
167 typedef enum {
168 LOGGER_DEBUG, LOGGER_INFO, LOGGER_WARNING
169 } logger_level;
171 typedef enum {
172 WPA_EAPOL_portEnabled, WPA_EAPOL_portValid, WPA_EAPOL_authorized,
173 WPA_EAPOL_portControl_Auto, WPA_EAPOL_keyRun, WPA_EAPOL_keyAvailable,
174 WPA_EAPOL_keyDone, WPA_EAPOL_inc_EapolFramesTx
175 } wpa_eapol_variable;
177 struct wpa_auth_callbacks {
178 void *ctx;
179 void (*logger)(void *ctx, const u8 *addr, logger_level level,
180 const char *txt);
181 void (*disconnect)(void *ctx, const u8 *addr, u16 reason);
182 void (*mic_failure_report)(void *ctx, const u8 *addr);
183 void (*set_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var,
184 int value);
185 int (*get_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var);
186 const u8 * (*get_psk)(void *ctx, const u8 *addr, const u8 *prev_psk);
187 int (*get_msk)(void *ctx, const u8 *addr, u8 *msk, size_t *len);
188 int (*set_key)(void *ctx, int vlan_id, const char *alg, const u8 *addr,
189 int idx, u8 *key, size_t key_len);
190 int (*get_seqnum)(void *ctx, const u8 *addr, int idx, u8 *seq);
191 int (*get_seqnum_igtk)(void *ctx, const u8 *addr, int idx, u8 *seq);
192 int (*send_eapol)(void *ctx, const u8 *addr, const u8 *data,
193 size_t data_len, int encrypt);
194 int (*for_each_sta)(void *ctx, int (*cb)(struct wpa_state_machine *sm,
195 void *ctx), void *cb_ctx);
196 int (*for_each_auth)(void *ctx, int (*cb)(struct wpa_authenticator *a,
197 void *ctx), void *cb_ctx);
198 int (*send_ether)(void *ctx, const u8 *dst, u16 proto, const u8 *data,
199 size_t data_len);
200 #ifdef CONFIG_IEEE80211R
201 struct wpa_state_machine * (*add_sta)(void *ctx, const u8 *sta_addr);
202 int (*send_ft_action)(void *ctx, const u8 *dst,
203 const u8 *data, size_t data_len);
204 #endif /* CONFIG_IEEE80211R */
207 struct wpa_authenticator * wpa_init(const u8 *addr,
208 struct wpa_auth_config *conf,
209 struct wpa_auth_callbacks *cb);
210 void wpa_deinit(struct wpa_authenticator *wpa_auth);
211 int wpa_reconfig(struct wpa_authenticator *wpa_auth,
212 struct wpa_auth_config *conf);
214 enum {
215 WPA_IE_OK, WPA_INVALID_IE, WPA_INVALID_GROUP, WPA_INVALID_PAIRWISE,
216 WPA_INVALID_AKMP, WPA_NOT_ENABLED, WPA_ALLOC_FAIL,
217 WPA_MGMT_FRAME_PROTECTION_VIOLATION, WPA_INVALID_MGMT_GROUP_CIPHER,
218 WPA_INVALID_MDIE
221 int wpa_validate_wpa_ie(struct wpa_authenticator *wpa_auth,
222 struct wpa_state_machine *sm,
223 const u8 *wpa_ie, size_t wpa_ie_len,
224 const u8 *mdie, size_t mdie_len);
225 int wpa_auth_uses_mfp(struct wpa_state_machine *sm);
226 struct wpa_state_machine *
227 wpa_auth_sta_init(struct wpa_authenticator *wpa_auth, const u8 *addr);
228 void wpa_auth_sta_associated(struct wpa_authenticator *wpa_auth,
229 struct wpa_state_machine *sm);
230 void wpa_auth_sta_deinit(struct wpa_state_machine *sm);
231 void wpa_receive(struct wpa_authenticator *wpa_auth,
232 struct wpa_state_machine *sm,
233 u8 *data, size_t data_len);
234 typedef enum {
235 WPA_AUTH, WPA_ASSOC, WPA_DISASSOC, WPA_DEAUTH, WPA_REAUTH,
236 WPA_REAUTH_EAPOL, WPA_ASSOC_FT
237 } wpa_event;
238 void wpa_remove_ptk(struct wpa_state_machine *sm);
239 void wpa_auth_sm_event(struct wpa_state_machine *sm, wpa_event event);
240 void wpa_auth_sm_notify(struct wpa_state_machine *sm);
241 void wpa_gtk_rekey(struct wpa_authenticator *wpa_auth);
242 int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen);
243 int wpa_get_mib_sta(struct wpa_state_machine *sm, char *buf, size_t buflen);
244 void wpa_auth_countermeasures_start(struct wpa_authenticator *wpa_auth);
245 int wpa_auth_pairwise_set(struct wpa_state_machine *sm);
246 int wpa_auth_sta_key_mgmt(struct wpa_state_machine *sm);
247 int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm);
248 int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm,
249 struct rsn_pmksa_cache_entry *entry);
250 struct rsn_pmksa_cache_entry *
251 wpa_auth_sta_get_pmksa(struct wpa_state_machine *sm);
252 void wpa_auth_sta_local_mic_failure_report(struct wpa_state_machine *sm);
253 const u8 * wpa_auth_get_wpa_ie(struct wpa_authenticator *wpa_auth,
254 size_t *len);
255 int wpa_auth_pmksa_add(struct wpa_state_machine *sm, const u8 *pmk,
256 int session_timeout, struct eapol_state_machine *eapol);
257 int wpa_auth_pmksa_add_preauth(struct wpa_authenticator *wpa_auth,
258 const u8 *pmk, size_t len, const u8 *sta_addr,
259 int session_timeout,
260 struct eapol_state_machine *eapol);
261 int wpa_auth_sta_set_vlan(struct wpa_state_machine *sm, int vlan_id);
263 #ifdef CONFIG_IEEE80211R
264 u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos,
265 size_t max_len, int auth_alg);
266 void wpa_ft_process_auth(struct wpa_state_machine *sm, const u8 *bssid,
267 u16 auth_transaction, const u8 *ies, size_t ies_len,
268 void (*cb)(void *ctx, const u8 *dst, const u8 *bssid,
269 u16 auth_transaction, u16 resp,
270 const u8 *ies, size_t ies_len),
271 void *ctx);
272 u16 wpa_ft_validate_reassoc(struct wpa_state_machine *sm, const u8 *ies,
273 size_t ies_len);
274 int wpa_ft_action_rx(struct wpa_state_machine *sm, const u8 *data, size_t len);
275 int wpa_ft_rrb_rx(struct wpa_authenticator *wpa_auth, const u8 *src_addr,
276 const u8 *data, size_t data_len);
277 void wpa_ft_push_pmk_r1(struct wpa_authenticator *wpa_auth, const u8 *addr);
278 #endif /* CONFIG_IEEE80211R */
280 #endif /* WPA_AUTH_H */