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