Get rid of duplicated cipher suite and AKM definitions
[mech_eap.git] / src / common / defs.h
1 /*
2  * WPA Supplicant - Common definitions
3  * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8
9 #ifndef DEFS_H
10 #define DEFS_H
11
12 #ifdef FALSE
13 #undef FALSE
14 #endif
15 #ifdef TRUE
16 #undef TRUE
17 #endif
18 typedef enum { FALSE = 0, TRUE = 1 } Boolean;
19
20
21 #define WPA_CIPHER_NONE BIT(0)
22 #define WPA_CIPHER_WEP40 BIT(1)
23 #define WPA_CIPHER_WEP104 BIT(2)
24 #define WPA_CIPHER_TKIP BIT(3)
25 #define WPA_CIPHER_CCMP BIT(4)
26 #ifdef CONFIG_IEEE80211W
27 #define WPA_CIPHER_AES_128_CMAC BIT(5)
28 #endif /* CONFIG_IEEE80211W */
29 #define WPA_CIPHER_GCMP BIT(6)
30 #define WPA_CIPHER_SMS4 BIT(7)
31 #define WPA_CIPHER_GCMP_256 BIT(8)
32 #define WPA_CIPHER_CCMP_256 BIT(9)
33 #define WPA_CIPHER_BIP_GMAC_128 BIT(11)
34 #define WPA_CIPHER_BIP_GMAC_256 BIT(12)
35 #define WPA_CIPHER_BIP_CMAC_256 BIT(13)
36 #define WPA_CIPHER_GTK_NOT_USED BIT(14)
37
38 #define WPA_KEY_MGMT_IEEE8021X BIT(0)
39 #define WPA_KEY_MGMT_PSK BIT(1)
40 #define WPA_KEY_MGMT_NONE BIT(2)
41 #define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3)
42 #define WPA_KEY_MGMT_WPA_NONE BIT(4)
43 #define WPA_KEY_MGMT_FT_IEEE8021X BIT(5)
44 #define WPA_KEY_MGMT_FT_PSK BIT(6)
45 #define WPA_KEY_MGMT_IEEE8021X_SHA256 BIT(7)
46 #define WPA_KEY_MGMT_PSK_SHA256 BIT(8)
47 #define WPA_KEY_MGMT_WPS BIT(9)
48 #define WPA_KEY_MGMT_SAE BIT(10)
49 #define WPA_KEY_MGMT_FT_SAE BIT(11)
50 #define WPA_KEY_MGMT_WAPI_PSK BIT(12)
51 #define WPA_KEY_MGMT_WAPI_CERT BIT(13)
52 #define WPA_KEY_MGMT_CCKM BIT(14)
53
54 static inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
55 {
56         return !!(akm & (WPA_KEY_MGMT_IEEE8021X |
57                          WPA_KEY_MGMT_FT_IEEE8021X |
58                          WPA_KEY_MGMT_CCKM |
59                          WPA_KEY_MGMT_IEEE8021X_SHA256));
60 }
61
62 static inline int wpa_key_mgmt_wpa_psk(int akm)
63 {
64         return !!(akm & (WPA_KEY_MGMT_PSK |
65                          WPA_KEY_MGMT_FT_PSK |
66                          WPA_KEY_MGMT_PSK_SHA256 |
67                          WPA_KEY_MGMT_SAE |
68                          WPA_KEY_MGMT_FT_SAE));
69 }
70
71 static inline int wpa_key_mgmt_ft(int akm)
72 {
73         return !!(akm & (WPA_KEY_MGMT_FT_PSK |
74                          WPA_KEY_MGMT_FT_IEEE8021X |
75                          WPA_KEY_MGMT_FT_SAE));
76 }
77
78 static inline int wpa_key_mgmt_sae(int akm)
79 {
80         return !!(akm & (WPA_KEY_MGMT_SAE |
81                          WPA_KEY_MGMT_FT_SAE));
82 }
83
84 static inline int wpa_key_mgmt_sha256(int akm)
85 {
86         return !!(akm & (WPA_KEY_MGMT_PSK_SHA256 |
87                          WPA_KEY_MGMT_IEEE8021X_SHA256));
88 }
89
90 static inline int wpa_key_mgmt_wpa(int akm)
91 {
92         return wpa_key_mgmt_wpa_ieee8021x(akm) ||
93                 wpa_key_mgmt_wpa_psk(akm) ||
94                 wpa_key_mgmt_sae(akm);
95 }
96
97 static inline int wpa_key_mgmt_wpa_any(int akm)
98 {
99         return wpa_key_mgmt_wpa(akm) || (akm & WPA_KEY_MGMT_WPA_NONE);
100 }
101
102 static inline int wpa_key_mgmt_cckm(int akm)
103 {
104         return akm == WPA_KEY_MGMT_CCKM;
105 }
106
107
108 #define WPA_PROTO_WPA BIT(0)
109 #define WPA_PROTO_RSN BIT(1)
110 #define WPA_PROTO_WAPI BIT(2)
111
112 #define WPA_AUTH_ALG_OPEN BIT(0)
113 #define WPA_AUTH_ALG_SHARED BIT(1)
114 #define WPA_AUTH_ALG_LEAP BIT(2)
115 #define WPA_AUTH_ALG_FT BIT(3)
116 #define WPA_AUTH_ALG_SAE BIT(4)
117
118
119 enum wpa_alg {
120         WPA_ALG_NONE,
121         WPA_ALG_WEP,
122         WPA_ALG_TKIP,
123         WPA_ALG_CCMP,
124         WPA_ALG_IGTK,
125         WPA_ALG_PMK,
126         WPA_ALG_GCMP,
127         WPA_ALG_SMS4,
128         WPA_ALG_KRK,
129         WPA_ALG_GCMP_256,
130         WPA_ALG_CCMP_256,
131         WPA_ALG_BIP_GMAC_128,
132         WPA_ALG_BIP_GMAC_256,
133         WPA_ALG_BIP_CMAC_256
134 };
135
136 /**
137  * enum wpa_states - wpa_supplicant state
138  *
139  * These enumeration values are used to indicate the current wpa_supplicant
140  * state (wpa_s->wpa_state). The current state can be retrieved with
141  * wpa_supplicant_get_state() function and the state can be changed by calling
142  * wpa_supplicant_set_state(). In WPA state machine (wpa.c and preauth.c), the
143  * wrapper functions wpa_sm_get_state() and wpa_sm_set_state() should be used
144  * to access the state variable.
145  */
146 enum wpa_states {
147         /**
148          * WPA_DISCONNECTED - Disconnected state
149          *
150          * This state indicates that client is not associated, but is likely to
151          * start looking for an access point. This state is entered when a
152          * connection is lost.
153          */
154         WPA_DISCONNECTED,
155
156         /**
157          * WPA_INTERFACE_DISABLED - Interface disabled
158          *
159          * This stat eis entered if the network interface is disabled, e.g.,
160          * due to rfkill. wpa_supplicant refuses any new operations that would
161          * use the radio until the interface has been enabled.
162          */
163         WPA_INTERFACE_DISABLED,
164
165         /**
166          * WPA_INACTIVE - Inactive state (wpa_supplicant disabled)
167          *
168          * This state is entered if there are no enabled networks in the
169          * configuration. wpa_supplicant is not trying to associate with a new
170          * network and external interaction (e.g., ctrl_iface call to add or
171          * enable a network) is needed to start association.
172          */
173         WPA_INACTIVE,
174
175         /**
176          * WPA_SCANNING - Scanning for a network
177          *
178          * This state is entered when wpa_supplicant starts scanning for a
179          * network.
180          */
181         WPA_SCANNING,
182
183         /**
184          * WPA_AUTHENTICATING - Trying to authenticate with a BSS/SSID
185          *
186          * This state is entered when wpa_supplicant has found a suitable BSS
187          * to authenticate with and the driver is configured to try to
188          * authenticate with this BSS. This state is used only with drivers
189          * that use wpa_supplicant as the SME.
190          */
191         WPA_AUTHENTICATING,
192
193         /**
194          * WPA_ASSOCIATING - Trying to associate with a BSS/SSID
195          *
196          * This state is entered when wpa_supplicant has found a suitable BSS
197          * to associate with and the driver is configured to try to associate
198          * with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
199          * state is entered when the driver is configured to try to associate
200          * with a network using the configured SSID and security policy.
201          */
202         WPA_ASSOCIATING,
203
204         /**
205          * WPA_ASSOCIATED - Association completed
206          *
207          * This state is entered when the driver reports that association has
208          * been successfully completed with an AP. If IEEE 802.1X is used
209          * (with or without WPA/WPA2), wpa_supplicant remains in this state
210          * until the IEEE 802.1X/EAPOL authentication has been completed.
211          */
212         WPA_ASSOCIATED,
213
214         /**
215          * WPA_4WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress
216          *
217          * This state is entered when WPA/WPA2 4-Way Handshake is started. In
218          * case of WPA-PSK, this happens when receiving the first EAPOL-Key
219          * frame after association. In case of WPA-EAP, this state is entered
220          * when the IEEE 802.1X/EAPOL authentication has been completed.
221          */
222         WPA_4WAY_HANDSHAKE,
223
224         /**
225          * WPA_GROUP_HANDSHAKE - WPA Group Key Handshake in progress
226          *
227          * This state is entered when 4-Way Key Handshake has been completed
228          * (i.e., when the supplicant sends out message 4/4) and when Group
229          * Key rekeying is started by the AP (i.e., when supplicant receives
230          * message 1/2).
231          */
232         WPA_GROUP_HANDSHAKE,
233
234         /**
235          * WPA_COMPLETED - All authentication completed
236          *
237          * This state is entered when the full authentication process is
238          * completed. In case of WPA2, this happens when the 4-Way Handshake is
239          * successfully completed. With WPA, this state is entered after the
240          * Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
241          * completed after dynamic keys are received (or if not used, after
242          * the EAP authentication has been completed). With static WEP keys and
243          * plaintext connections, this state is entered when an association
244          * has been completed.
245          *
246          * This state indicates that the supplicant has completed its
247          * processing for the association phase and that data connection is
248          * fully configured.
249          */
250         WPA_COMPLETED
251 };
252
253 #define MLME_SETPROTECTION_PROTECT_TYPE_NONE 0
254 #define MLME_SETPROTECTION_PROTECT_TYPE_RX 1
255 #define MLME_SETPROTECTION_PROTECT_TYPE_TX 2
256 #define MLME_SETPROTECTION_PROTECT_TYPE_RX_TX 3
257
258 #define MLME_SETPROTECTION_KEY_TYPE_GROUP 0
259 #define MLME_SETPROTECTION_KEY_TYPE_PAIRWISE 1
260
261
262 /**
263  * enum mfp_options - Management frame protection (IEEE 802.11w) options
264  */
265 enum mfp_options {
266         NO_MGMT_FRAME_PROTECTION = 0,
267         MGMT_FRAME_PROTECTION_OPTIONAL = 1,
268         MGMT_FRAME_PROTECTION_REQUIRED = 2,
269 };
270 #define MGMT_FRAME_PROTECTION_DEFAULT 3
271
272 /**
273  * enum hostapd_hw_mode - Hardware mode
274  */
275 enum hostapd_hw_mode {
276         HOSTAPD_MODE_IEEE80211B,
277         HOSTAPD_MODE_IEEE80211G,
278         HOSTAPD_MODE_IEEE80211A,
279         HOSTAPD_MODE_IEEE80211AD,
280         NUM_HOSTAPD_MODES
281 };
282
283 /**
284  * enum wpa_ctrl_req_type - Control interface request types
285  */
286 enum wpa_ctrl_req_type {
287         WPA_CTRL_REQ_UNKNOWN,
288         WPA_CTRL_REQ_EAP_IDENTITY,
289         WPA_CTRL_REQ_EAP_PASSWORD,
290         WPA_CTRL_REQ_EAP_NEW_PASSWORD,
291         WPA_CTRL_REQ_EAP_PIN,
292         WPA_CTRL_REQ_EAP_OTP,
293         WPA_CTRL_REQ_EAP_PASSPHRASE,
294         WPA_CTRL_REQ_SIM,
295         NUM_WPA_CTRL_REQS
296 };
297
298 /* Maximum number of EAP methods to store for EAP server user information */
299 #define EAP_MAX_METHODS 8
300
301 #endif /* DEFS_H */