]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/wpa/src/common/defs.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / wpa / src / common / defs.h
1 /*
2  * WPA Supplicant - Common definitions
3  * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
4  *
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.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #ifndef DEFS_H
16 #define DEFS_H
17
18 #ifdef FALSE
19 #undef FALSE
20 #endif
21 #ifdef TRUE
22 #undef TRUE
23 #endif
24 typedef enum { FALSE = 0, TRUE = 1 } Boolean;
25
26
27 #define WPA_CIPHER_NONE BIT(0)
28 #define WPA_CIPHER_WEP40 BIT(1)
29 #define WPA_CIPHER_WEP104 BIT(2)
30 #define WPA_CIPHER_TKIP BIT(3)
31 #define WPA_CIPHER_CCMP BIT(4)
32 #ifdef CONFIG_IEEE80211W
33 #define WPA_CIPHER_AES_128_CMAC BIT(5)
34 #endif /* CONFIG_IEEE80211W */
35
36 #define WPA_KEY_MGMT_IEEE8021X BIT(0)
37 #define WPA_KEY_MGMT_PSK BIT(1)
38 #define WPA_KEY_MGMT_NONE BIT(2)
39 #define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3)
40 #define WPA_KEY_MGMT_WPA_NONE BIT(4)
41 #define WPA_KEY_MGMT_FT_IEEE8021X BIT(5)
42 #define WPA_KEY_MGMT_FT_PSK BIT(6)
43 #define WPA_KEY_MGMT_IEEE8021X_SHA256 BIT(7)
44 #define WPA_KEY_MGMT_PSK_SHA256 BIT(8)
45 #define WPA_KEY_MGMT_WPS BIT(9)
46
47 static inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
48 {
49         return akm == WPA_KEY_MGMT_IEEE8021X ||
50                 akm == WPA_KEY_MGMT_FT_IEEE8021X ||
51                 akm == WPA_KEY_MGMT_IEEE8021X_SHA256;
52 }
53
54 static inline int wpa_key_mgmt_wpa_psk(int akm)
55 {
56         return akm == WPA_KEY_MGMT_PSK ||
57                 akm == WPA_KEY_MGMT_FT_PSK ||
58                 akm == WPA_KEY_MGMT_PSK_SHA256;
59 }
60
61 static inline int wpa_key_mgmt_ft(int akm)
62 {
63         return akm == WPA_KEY_MGMT_FT_PSK ||
64                 akm == WPA_KEY_MGMT_FT_IEEE8021X;
65 }
66
67 static inline int wpa_key_mgmt_sha256(int akm)
68 {
69         return akm == WPA_KEY_MGMT_PSK_SHA256 ||
70                 akm == WPA_KEY_MGMT_IEEE8021X_SHA256;
71 }
72
73
74 #define WPA_PROTO_WPA BIT(0)
75 #define WPA_PROTO_RSN BIT(1)
76
77 #define WPA_AUTH_ALG_OPEN BIT(0)
78 #define WPA_AUTH_ALG_SHARED BIT(1)
79 #define WPA_AUTH_ALG_LEAP BIT(2)
80 #define WPA_AUTH_ALG_FT BIT(3)
81
82
83 enum wpa_alg {
84         WPA_ALG_NONE,
85         WPA_ALG_WEP,
86         WPA_ALG_TKIP,
87         WPA_ALG_CCMP,
88         WPA_ALG_IGTK,
89         WPA_ALG_PMK
90 };
91
92 /**
93  * enum wpa_cipher - Cipher suites
94  */
95 enum wpa_cipher {
96         CIPHER_NONE,
97         CIPHER_WEP40,
98         CIPHER_TKIP,
99         CIPHER_CCMP,
100         CIPHER_WEP104
101 };
102
103 /**
104  * enum wpa_key_mgmt - Key management suites
105  */
106 enum wpa_key_mgmt {
107         KEY_MGMT_802_1X,
108         KEY_MGMT_PSK,
109         KEY_MGMT_NONE,
110         KEY_MGMT_802_1X_NO_WPA,
111         KEY_MGMT_WPA_NONE,
112         KEY_MGMT_FT_802_1X,
113         KEY_MGMT_FT_PSK,
114         KEY_MGMT_802_1X_SHA256,
115         KEY_MGMT_PSK_SHA256,
116         KEY_MGMT_WPS
117 };
118
119 /**
120  * enum wpa_states - wpa_supplicant state
121  *
122  * These enumeration values are used to indicate the current wpa_supplicant
123  * state (wpa_s->wpa_state). The current state can be retrieved with
124  * wpa_supplicant_get_state() function and the state can be changed by calling
125  * wpa_supplicant_set_state(). In WPA state machine (wpa.c and preauth.c), the
126  * wrapper functions wpa_sm_get_state() and wpa_sm_set_state() should be used
127  * to access the state variable.
128  */
129 enum wpa_states {
130         /**
131          * WPA_DISCONNECTED - Disconnected state
132          *
133          * This state indicates that client is not associated, but is likely to
134          * start looking for an access point. This state is entered when a
135          * connection is lost.
136          */
137         WPA_DISCONNECTED,
138
139         /**
140          * WPA_INACTIVE - Inactive state (wpa_supplicant disabled)
141          *
142          * This state is entered if there are no enabled networks in the
143          * configuration. wpa_supplicant is not trying to associate with a new
144          * network and external interaction (e.g., ctrl_iface call to add or
145          * enable a network) is needed to start association.
146          */
147         WPA_INACTIVE,
148
149         /**
150          * WPA_SCANNING - Scanning for a network
151          *
152          * This state is entered when wpa_supplicant starts scanning for a
153          * network.
154          */
155         WPA_SCANNING,
156
157         /**
158          * WPA_AUTHENTICATING - Trying to authenticate with a BSS/SSID
159          *
160          * This state is entered when wpa_supplicant has found a suitable BSS
161          * to authenticate with and the driver is configured to try to
162          * authenticate with this BSS. This state is used only with drivers
163          * that use wpa_supplicant as the SME.
164          */
165         WPA_AUTHENTICATING,
166
167         /**
168          * WPA_ASSOCIATING - Trying to associate with a BSS/SSID
169          *
170          * This state is entered when wpa_supplicant has found a suitable BSS
171          * to associate with and the driver is configured to try to associate
172          * with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
173          * state is entered when the driver is configured to try to associate
174          * with a network using the configured SSID and security policy.
175          */
176         WPA_ASSOCIATING,
177
178         /**
179          * WPA_ASSOCIATED - Association completed
180          *
181          * This state is entered when the driver reports that association has
182          * been successfully completed with an AP. If IEEE 802.1X is used
183          * (with or without WPA/WPA2), wpa_supplicant remains in this state
184          * until the IEEE 802.1X/EAPOL authentication has been completed.
185          */
186         WPA_ASSOCIATED,
187
188         /**
189          * WPA_4WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress
190          *
191          * This state is entered when WPA/WPA2 4-Way Handshake is started. In
192          * case of WPA-PSK, this happens when receiving the first EAPOL-Key
193          * frame after association. In case of WPA-EAP, this state is entered
194          * when the IEEE 802.1X/EAPOL authentication has been completed.
195          */
196         WPA_4WAY_HANDSHAKE,
197
198         /**
199          * WPA_GROUP_HANDSHAKE - WPA Group Key Handshake in progress
200          *
201          * This state is entered when 4-Way Key Handshake has been completed
202          * (i.e., when the supplicant sends out message 4/4) and when Group
203          * Key rekeying is started by the AP (i.e., when supplicant receives
204          * message 1/2).
205          */
206         WPA_GROUP_HANDSHAKE,
207
208         /**
209          * WPA_COMPLETED - All authentication completed
210          *
211          * This state is entered when the full authentication process is
212          * completed. In case of WPA2, this happens when the 4-Way Handshake is
213          * successfully completed. With WPA, this state is entered after the
214          * Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
215          * completed after dynamic keys are received (or if not used, after
216          * the EAP authentication has been completed). With static WEP keys and
217          * plaintext connections, this state is entered when an association
218          * has been completed.
219          *
220          * This state indicates that the supplicant has completed its
221          * processing for the association phase and that data connection is
222          * fully configured.
223          */
224         WPA_COMPLETED
225 };
226
227 #define MLME_SETPROTECTION_PROTECT_TYPE_NONE 0
228 #define MLME_SETPROTECTION_PROTECT_TYPE_RX 1
229 #define MLME_SETPROTECTION_PROTECT_TYPE_TX 2
230 #define MLME_SETPROTECTION_PROTECT_TYPE_RX_TX 3
231
232 #define MLME_SETPROTECTION_KEY_TYPE_GROUP 0
233 #define MLME_SETPROTECTION_KEY_TYPE_PAIRWISE 1
234
235
236 /**
237  * enum mfp_options - Management frame protection (IEEE 802.11w) options
238  */
239 enum mfp_options {
240         NO_MGMT_FRAME_PROTECTION = 0,
241         MGMT_FRAME_PROTECTION_OPTIONAL = 1,
242         MGMT_FRAME_PROTECTION_REQUIRED = 2
243 };
244
245 /**
246  * enum hostapd_hw_mode - Hardware mode
247  */
248 enum hostapd_hw_mode {
249         HOSTAPD_MODE_IEEE80211B,
250         HOSTAPD_MODE_IEEE80211G,
251         HOSTAPD_MODE_IEEE80211A,
252         NUM_HOSTAPD_MODES
253 };
254
255 #endif /* DEFS_H */