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 (*req_scan
)(void *ctx
, int sec
, int usec
);
63 void (*deauthenticate
)(void * ctx
, int reason_code
);
64 void (*disassociate
)(void *ctx
, int reason_code
);
65 int (*set_key
)(void *ctx
, wpa_alg alg
,
66 const u8
*addr
, int key_idx
, int set_tx
,
67 const u8
*seq
, size_t seq_len
,
68 const u8
*key
, size_t key_len
);
69 void (*scan
)(void *eloop_ctx
, void *timeout_ctx
);
70 struct wpa_ssid
* (*get_ssid
)(void *ctx
);
71 int (*get_bssid
)(void *ctx
, u8
*bssid
);
72 int (*ether_send
)(void *ctx
, const u8
*dest
, u16 proto
, const u8
*buf
,
74 int (*get_beacon_ie
)(void *ctx
);
75 void (*cancel_auth_timeout
)(void *ctx
);
76 u8
* (*alloc_eapol
)(void *ctx
, u8 type
, const void *data
, u16 data_len
,
77 size_t *msg_len
, void **data_pos
);
78 int (*add_pmkid
)(void *ctx
, const u8
*bssid
, const u8
*pmkid
);
79 int (*remove_pmkid
)(void *ctx
, const u8
*bssid
, const u8
*pmkid
);
80 void (*set_config_blob
)(void *ctx
, struct wpa_config_blob
*blob
);
81 const struct wpa_config_blob
* (*get_config_blob
)(void *ctx
,
83 int (*mlme_setprotection
)(void *ctx
, const u8
*addr
,
84 int protection_type
, int key_type
);
88 enum wpa_sm_conf_params
{
89 RSNA_PMK_LIFETIME
/* dot11RSNAConfigPMKLifetime */,
90 RSNA_PMK_REAUTH_THRESHOLD
/* dot11RSNAConfigPMKReauthThreshold */,
91 RSNA_SA_TIMEOUT
/* dot11RSNAConfigSATimeout */,
107 int mgmt_group_cipher
;
110 #ifndef CONFIG_NO_WPA
112 struct wpa_sm
* wpa_sm_init(struct wpa_sm_ctx
*ctx
);
113 void wpa_sm_deinit(struct wpa_sm
*sm
);
114 void wpa_sm_notify_assoc(struct wpa_sm
*sm
, const u8
*bssid
);
115 void wpa_sm_notify_disassoc(struct wpa_sm
*sm
);
116 void wpa_sm_set_pmk(struct wpa_sm
*sm
, const u8
*pmk
, size_t pmk_len
);
117 void wpa_sm_set_pmk_from_pmksa(struct wpa_sm
*sm
);
118 void wpa_sm_set_fast_reauth(struct wpa_sm
*sm
, int fast_reauth
);
119 void wpa_sm_set_scard_ctx(struct wpa_sm
*sm
, void *scard_ctx
);
120 void wpa_sm_set_config(struct wpa_sm
*sm
, struct wpa_ssid
*config
);
121 void wpa_sm_set_own_addr(struct wpa_sm
*sm
, const u8
*addr
);
122 void wpa_sm_set_ifname(struct wpa_sm
*sm
, const char *ifname
,
123 const char *bridge_ifname
);
124 void wpa_sm_set_eapol(struct wpa_sm
*sm
, struct eapol_sm
*eapol
);
125 int wpa_sm_set_assoc_wpa_ie(struct wpa_sm
*sm
, const u8
*ie
, size_t len
);
126 int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm
*sm
, u8
*wpa_ie
,
128 int wpa_sm_set_ap_wpa_ie(struct wpa_sm
*sm
, const u8
*ie
, size_t len
);
129 int wpa_sm_set_ap_rsn_ie(struct wpa_sm
*sm
, const u8
*ie
, size_t len
);
130 int wpa_sm_get_mib(struct wpa_sm
*sm
, char *buf
, size_t buflen
);
132 int wpa_sm_set_param(struct wpa_sm
*sm
, enum wpa_sm_conf_params param
,
134 unsigned int wpa_sm_get_param(struct wpa_sm
*sm
,
135 enum wpa_sm_conf_params param
);
137 int wpa_sm_get_status(struct wpa_sm
*sm
, char *buf
, size_t buflen
,
140 void wpa_sm_key_request(struct wpa_sm
*sm
, int error
, int pairwise
);
142 int wpa_sm_stkstart(struct wpa_sm
*sm
, const u8
*peer
);
144 int wpa_parse_wpa_ie(const u8
*wpa_ie
, size_t wpa_ie_len
,
145 struct wpa_ie_data
*data
);
147 void wpa_sm_aborted_cached(struct wpa_sm
*sm
);
148 int wpa_sm_rx_eapol(struct wpa_sm
*sm
, const u8
*src_addr
,
149 const u8
*buf
, size_t len
);
150 int wpa_sm_parse_own_wpa_ie(struct wpa_sm
*sm
, struct wpa_ie_data
*data
);
152 #else /* CONFIG_NO_WPA */
154 static inline struct wpa_sm
* wpa_sm_init(struct wpa_sm_ctx
*ctx
)
156 return (struct wpa_sm
*) 1;
159 static inline void wpa_sm_deinit(struct wpa_sm
*sm
)
163 static inline void wpa_sm_notify_assoc(struct wpa_sm
*sm
, const u8
*bssid
)
167 static inline void wpa_sm_notify_disassoc(struct wpa_sm
*sm
)
171 static inline void wpa_sm_set_pmk(struct wpa_sm
*sm
, const u8
*pmk
,
176 static inline void wpa_sm_set_pmk_from_pmksa(struct wpa_sm
*sm
)
180 static inline void wpa_sm_set_fast_reauth(struct wpa_sm
*sm
, int fast_reauth
)
184 static inline void wpa_sm_set_scard_ctx(struct wpa_sm
*sm
, void *scard_ctx
)
188 static inline void wpa_sm_set_config(struct wpa_sm
*sm
,
189 struct wpa_ssid
*config
)
193 static inline void wpa_sm_set_own_addr(struct wpa_sm
*sm
, const u8
*addr
)
197 static inline void wpa_sm_set_ifname(struct wpa_sm
*sm
, const char *ifname
,
198 const char *bridge_ifname
)
202 static inline void wpa_sm_set_eapol(struct wpa_sm
*sm
, struct eapol_sm
*eapol
)
206 static inline int wpa_sm_set_assoc_wpa_ie(struct wpa_sm
*sm
, const u8
*ie
,
212 static inline int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm
*sm
,
219 static inline int wpa_sm_set_ap_wpa_ie(struct wpa_sm
*sm
, const u8
*ie
,
225 static inline int wpa_sm_set_ap_rsn_ie(struct wpa_sm
*sm
, const u8
*ie
,
231 static inline int wpa_sm_get_mib(struct wpa_sm
*sm
, char *buf
, size_t buflen
)
236 static inline int wpa_sm_set_param(struct wpa_sm
*sm
,
237 enum wpa_sm_conf_params param
,
243 static inline unsigned int wpa_sm_get_param(struct wpa_sm
*sm
,
244 enum wpa_sm_conf_params param
)
249 static inline int wpa_sm_get_status(struct wpa_sm
*sm
, char *buf
,
250 size_t buflen
, int verbose
)
255 static inline void wpa_sm_key_request(struct wpa_sm
*sm
, int error
,
260 static inline int wpa_sm_stkstart(struct wpa_sm
*sm
, const u8
*peer
)
265 static inline int wpa_parse_wpa_ie(const u8
*wpa_ie
, size_t wpa_ie_len
,
266 struct wpa_ie_data
*data
)
271 static inline void wpa_sm_aborted_cached(struct wpa_sm
*sm
)
275 static inline int wpa_sm_rx_eapol(struct wpa_sm
*sm
, const u8
*src_addr
,
276 const u8
*buf
, size_t len
)
281 static inline int wpa_sm_parse_own_wpa_ie(struct wpa_sm
*sm
,
282 struct wpa_ie_data
*data
)
287 #endif /* CONFIG_NO_WPA */