2 * wpa_supplicant - WPA definitions
3 * Copyright (c) 2003-2006, 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
12 * See README and COPYING for more details.
19 #include "wpa_common.h"
22 #define BIT(n) (1 << (n))
25 #define WPA_CAPABILITY_PREAUTH BIT(0)
26 #define WPA_CAPABILITY_MGMT_FRAME_PROTECTION BIT(6)
27 #define WPA_CAPABILITY_PEERKEY_ENABLED BIT(9)
29 #define GENERIC_INFO_ELEM 0xdd
30 #define RSN_INFO_ELEM 0x30
33 REASON_UNSPECIFIED = 1,
34 REASON_DEAUTH_LEAVING = 3,
35 REASON_INVALID_IE = 13,
36 REASON_MICHAEL_MIC_FAILURE = 14,
37 REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
38 REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,
39 REASON_IE_IN_4WAY_DIFFERS = 17,
40 REASON_GROUP_CIPHER_NOT_VALID = 18,
41 REASON_PAIRWISE_CIPHER_NOT_VALID = 19,
42 REASON_AKMP_NOT_VALID = 20,
43 REASON_UNSUPPORTED_RSN_IE_VERSION = 21,
44 REASON_INVALID_RSN_IE_CAPAB = 22,
45 REASON_IEEE_802_1X_AUTH_FAILED = 23,
46 REASON_CIPHER_SUITE_REJECTED = 24
55 struct wpa_config_blob;
58 void *ctx; /* pointer to arbitrary upper level context */
60 void (*set_state)(void *ctx, wpa_states state);
61 wpa_states (*get_state)(void *ctx);
62 void (*deauthenticate)(void * ctx, int reason_code);
63 void (*disassociate)(void *ctx, int reason_code);
64 int (*set_key)(void *ctx, wpa_alg alg,
65 const u8 *addr, int key_idx, int set_tx,
66 const u8 *seq, size_t seq_len,
67 const u8 *key, size_t key_len);
68 void (*scan)(void *eloop_ctx, void *timeout_ctx);
69 struct wpa_ssid * (*get_ssid)(void *ctx);
70 int (*get_bssid)(void *ctx, u8 *bssid);
71 int (*ether_send)(void *ctx, const u8 *dest, u16 proto, const u8 *buf,
73 int (*get_beacon_ie)(void *ctx);
74 void (*cancel_auth_timeout)(void *ctx);
75 u8 * (*alloc_eapol)(void *ctx, u8 type, const void *data, u16 data_len,
76 size_t *msg_len, void **data_pos);
77 int (*add_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid);
78 int (*remove_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid);
79 void (*set_config_blob)(void *ctx, struct wpa_config_blob *blob);
80 const struct wpa_config_blob * (*get_config_blob)(void *ctx,
82 int (*mlme_setprotection)(void *ctx, const u8 *addr,
83 int protection_type, int key_type);
87 enum wpa_sm_conf_params {
88 RSNA_PMK_LIFETIME /* dot11RSNAConfigPMKLifetime */,
89 RSNA_PMK_REAUTH_THRESHOLD /* dot11RSNAConfigPMKReauthThreshold */,
90 RSNA_SA_TIMEOUT /* dot11RSNAConfigSATimeout */,
106 int mgmt_group_cipher;
109 #ifndef CONFIG_NO_WPA
111 struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx);
112 void wpa_sm_deinit(struct wpa_sm *sm);
113 void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid);
114 void wpa_sm_notify_disassoc(struct wpa_sm *sm);
115 void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk, size_t pmk_len);
116 void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm);
117 void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth);
118 void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx);
119 void wpa_sm_set_config(struct wpa_sm *sm, struct wpa_ssid *config);
120 void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr);
121 void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname,
122 const char *bridge_ifname);
123 void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol);
124 int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
125 int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm, u8 *wpa_ie,
127 int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
128 int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
129 int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen);
131 int wpa_sm_set_param(struct wpa_sm *sm, enum wpa_sm_conf_params param,
133 unsigned int wpa_sm_get_param(struct wpa_sm *sm,
134 enum wpa_sm_conf_params param);
136 int wpa_sm_get_status(struct wpa_sm *sm, char *buf, size_t buflen,
139 void wpa_sm_key_request(struct wpa_sm *sm, int error, int pairwise);
141 int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer);
143 int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len,
144 struct wpa_ie_data *data);
146 void wpa_sm_aborted_cached(struct wpa_sm *sm);
147 int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
148 const u8 *buf, size_t len);
149 int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm, struct wpa_ie_data *data);
151 #else /* CONFIG_NO_WPA */
153 static inline struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx)
155 return (struct wpa_sm *) 1;
158 static inline void wpa_sm_deinit(struct wpa_sm *sm)
162 static inline void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
166 static inline void wpa_sm_notify_disassoc(struct wpa_sm *sm)
170 static inline void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk,
175 static inline void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm)
179 static inline void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth)
183 static inline void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx)
187 static inline void wpa_sm_set_config(struct wpa_sm *sm,
188 struct wpa_ssid *config)
192 static inline void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr)
196 static inline void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname,
197 const char *bridge_ifname)
201 static inline void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol)
205 static inline int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie,
211 static inline int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm,
218 static inline int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie,
224 static inline int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie,
230 static inline int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen)
235 static inline int wpa_sm_set_param(struct wpa_sm *sm,
236 enum wpa_sm_conf_params param,
242 static inline unsigned int wpa_sm_get_param(struct wpa_sm *sm,
243 enum wpa_sm_conf_params param)
248 static inline int wpa_sm_get_status(struct wpa_sm *sm, char *buf,
249 size_t buflen, int verbose)
254 static inline void wpa_sm_key_request(struct wpa_sm *sm, int error,
259 static inline int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer)
264 static inline int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len,
265 struct wpa_ie_data *data)
270 static inline void wpa_sm_aborted_cached(struct wpa_sm *sm)
274 static inline int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
275 const u8 *buf, size_t len)
280 static inline int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm,
281 struct wpa_ie_data *data)
286 #endif /* CONFIG_NO_WPA */