2 * wpa_supplicant - WPA definitions
3 * Copyright (c) 2003-2005, Jouni Malinen <jkmaline@cc.hut.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.
20 #define BIT(n) (1 << (n))
22 struct ieee802_1x_hdr
{
26 /* followed by length octets of data */
27 } __attribute__ ((packed
));
29 #define EAPOL_VERSION 2
31 enum { IEEE802_1X_TYPE_EAP_PACKET
= 0,
32 IEEE802_1X_TYPE_EAPOL_START
= 1,
33 IEEE802_1X_TYPE_EAPOL_LOGOFF
= 2,
34 IEEE802_1X_TYPE_EAPOL_KEY
= 3,
35 IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT
= 4
38 enum { EAPOL_KEY_TYPE_RC4
= 1, EAPOL_KEY_TYPE_RSN
= 2,
39 EAPOL_KEY_TYPE_WPA
= 254 };
42 #define WPA_CAPABILITY_PREAUTH BIT(0)
44 #define GENERIC_INFO_ELEM 0xdd
45 #define RSN_INFO_ELEM 0x30
48 REASON_UNSPECIFIED
= 1,
49 REASON_DEAUTH_LEAVING
= 3,
50 REASON_INVALID_IE
= 13,
51 REASON_MICHAEL_MIC_FAILURE
= 14,
52 REASON_4WAY_HANDSHAKE_TIMEOUT
= 15,
53 REASON_GROUP_KEY_UPDATE_TIMEOUT
= 16,
54 REASON_IE_IN_4WAY_DIFFERS
= 17,
55 REASON_GROUP_CIPHER_NOT_VALID
= 18,
56 REASON_PAIRWISE_CIPHER_NOT_VALID
= 19,
57 REASON_AKMP_NOT_VALID
= 20,
58 REASON_UNSUPPORTED_RSN_IE_VERSION
= 21,
59 REASON_INVALID_RSN_IE_CAPAB
= 22,
60 REASON_IEEE_802_1X_AUTH_FAILED
= 23,
61 REASON_CIPHER_SUITE_REJECTED
= 24
70 struct wpa_config_blob
;
73 void *ctx
; /* pointer to arbitrary upper level context */
75 void (*set_state
)(void *ctx
, wpa_states state
);
76 wpa_states (*get_state
)(void *ctx
);
77 void (*req_scan
)(void *ctx
, int sec
, int usec
);
78 void (*deauthenticate
)(void * ctx
, int reason_code
);
79 void (*disassociate
)(void *ctx
, int reason_code
);
80 int (*set_key
)(void *ctx
, wpa_alg alg
,
81 const u8
*addr
, int key_idx
, int set_tx
,
82 const u8
*seq
, size_t seq_len
,
83 const u8
*key
, size_t key_len
);
84 void (*scan
)(void *eloop_ctx
, void *timeout_ctx
);
85 struct wpa_ssid
* (*get_ssid
)(void *ctx
);
86 int (*get_bssid
)(void *ctx
, u8
*bssid
);
87 int (*ether_send
)(void *ctx
, const u8
*dest
, u16 proto
, const u8
*buf
,
89 int (*get_beacon_ie
)(void *ctx
);
90 void (*cancel_auth_timeout
)(void *ctx
);
91 u8
* (*alloc_eapol
)(void *ctx
, u8 type
, const void *data
, u16 data_len
,
92 size_t *msg_len
, void **data_pos
);
93 int (*add_pmkid
)(void *ctx
, const u8
*bssid
, const u8
*pmkid
);
94 int (*remove_pmkid
)(void *ctx
, const u8
*bssid
, const u8
*pmkid
);
95 void (*set_config_blob
)(void *ctx
, struct wpa_config_blob
*blob
);
96 const struct wpa_config_blob
* (*get_config_blob
)(void *ctx
,
101 enum wpa_sm_conf_params
{
102 RSNA_PMK_LIFETIME
/* dot11RSNAConfigPMKLifetime */,
103 RSNA_PMK_REAUTH_THRESHOLD
/* dot11RSNAConfigPMKReauthThreshold */,
104 RSNA_SA_TIMEOUT
/* dot11RSNAConfigSATimeout */,
121 #ifndef CONFIG_NO_WPA
123 struct wpa_sm
* wpa_sm_init(struct wpa_sm_ctx
*ctx
);
124 void wpa_sm_deinit(struct wpa_sm
*sm
);
125 void wpa_sm_notify_assoc(struct wpa_sm
*sm
, const u8
*bssid
);
126 void wpa_sm_notify_disassoc(struct wpa_sm
*sm
);
127 void wpa_sm_set_pmk(struct wpa_sm
*sm
, const u8
*pmk
, size_t pmk_len
);
128 void wpa_sm_set_pmk_from_pmksa(struct wpa_sm
*sm
);
129 void wpa_sm_set_fast_reauth(struct wpa_sm
*sm
, int fast_reauth
);
130 void wpa_sm_set_scard_ctx(struct wpa_sm
*sm
, void *scard_ctx
);
131 void wpa_sm_set_config(struct wpa_sm
*sm
, struct wpa_ssid
*config
);
132 void wpa_sm_set_own_addr(struct wpa_sm
*sm
, const u8
*addr
);
133 void wpa_sm_set_ifname(struct wpa_sm
*sm
, const char *ifname
);
134 void wpa_sm_set_eapol(struct wpa_sm
*sm
, struct eapol_sm
*eapol
);
135 int wpa_sm_set_assoc_wpa_ie(struct wpa_sm
*sm
, const u8
*ie
, size_t len
);
136 int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm
*sm
, u8
*wpa_ie
,
138 int wpa_sm_set_ap_wpa_ie(struct wpa_sm
*sm
, const u8
*ie
, size_t len
);
139 int wpa_sm_set_ap_rsn_ie(struct wpa_sm
*sm
, const u8
*ie
, size_t len
);
140 int wpa_sm_get_mib(struct wpa_sm
*sm
, char *buf
, size_t buflen
);
142 int wpa_sm_set_param(struct wpa_sm
*sm
, enum wpa_sm_conf_params param
,
144 unsigned int wpa_sm_get_param(struct wpa_sm
*sm
,
145 enum wpa_sm_conf_params param
);
147 int wpa_sm_get_status(struct wpa_sm
*sm
, char *buf
, size_t buflen
,
150 void wpa_sm_key_request(struct wpa_sm
*sm
, int error
, int pairwise
);
152 int wpa_parse_wpa_ie(const u8
*wpa_ie
, size_t wpa_ie_len
,
153 struct wpa_ie_data
*data
);
155 void wpa_sm_aborted_cached(struct wpa_sm
*sm
);
156 int wpa_sm_rx_eapol(struct wpa_sm
*sm
, const u8
*src_addr
,
157 const u8
*buf
, size_t len
);
158 int wpa_sm_parse_own_wpa_ie(struct wpa_sm
*sm
, struct wpa_ie_data
*data
);
160 #else /* CONFIG_NO_WPA */
162 static inline struct wpa_sm
* wpa_sm_init(struct wpa_sm_ctx
*ctx
)
164 return (struct wpa_sm
*) 1;
167 static inline void wpa_sm_deinit(struct wpa_sm
*sm
)
171 static inline void wpa_sm_notify_assoc(struct wpa_sm
*sm
, const u8
*bssid
)
175 static inline void wpa_sm_notify_disassoc(struct wpa_sm
*sm
)
179 static inline void wpa_sm_set_pmk(struct wpa_sm
*sm
, const u8
*pmk
,
184 static inline void wpa_sm_set_pmk_from_pmksa(struct wpa_sm
*sm
)
188 static inline void wpa_sm_set_fast_reauth(struct wpa_sm
*sm
, int fast_reauth
)
192 static inline void wpa_sm_set_scard_ctx(struct wpa_sm
*sm
, void *scard_ctx
)
196 static inline void wpa_sm_set_config(struct wpa_sm
*sm
,
197 struct wpa_ssid
*config
)
201 static inline void wpa_sm_set_own_addr(struct wpa_sm
*sm
, const u8
*addr
)
205 static inline void wpa_sm_set_ifname(struct wpa_sm
*sm
, const char *ifname
)
209 static inline void wpa_sm_set_eapol(struct wpa_sm
*sm
, struct eapol_sm
*eapol
)
213 static inline int wpa_sm_set_assoc_wpa_ie(struct wpa_sm
*sm
, const u8
*ie
,
219 static inline int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm
*sm
,
226 static inline int wpa_sm_set_ap_wpa_ie(struct wpa_sm
*sm
, const u8
*ie
,
232 static inline int wpa_sm_set_ap_rsn_ie(struct wpa_sm
*sm
, const u8
*ie
,
238 static inline int wpa_sm_get_mib(struct wpa_sm
*sm
, char *buf
, size_t buflen
)
243 static inline int wpa_sm_set_param(struct wpa_sm
*sm
,
244 enum wpa_sm_conf_params param
,
250 static inline unsigned int wpa_sm_get_param(struct wpa_sm
*sm
,
251 enum wpa_sm_conf_params param
)
256 static inline int wpa_sm_get_status(struct wpa_sm
*sm
, char *buf
,
257 size_t buflen
, int verbose
)
262 static inline void wpa_sm_key_request(struct wpa_sm
*sm
, int error
,
267 static inline int wpa_parse_wpa_ie(const u8
*wpa_ie
, size_t wpa_ie_len
,
268 struct wpa_ie_data
*data
)
273 static inline void wpa_sm_aborted_cached(struct wpa_sm
*sm
)
277 static inline int wpa_sm_rx_eapol(struct wpa_sm
*sm
, const u8
*src_addr
,
278 const u8
*buf
, size_t len
)
283 static inline int wpa_sm_parse_own_wpa_ie(struct wpa_sm
*sm
,
284 struct wpa_ie_data
*data
)
289 #endif /* CONFIG_NO_WPA */