|
1 /* |
|
2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: EAP and WLAN authentication protocols. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #if !defined(_EAP_EXPANDED_TYPE_H_) |
|
23 #define _EAP_EXPANDED_TYPE_H_ |
|
24 |
|
25 |
|
26 #include "eap_general_header_base.h" |
|
27 |
|
28 |
|
29 /** @file */ |
|
30 |
|
31 //----------------------------------------------------------------------------------------- |
|
32 //----------------------------------------------------------------------------------------- |
|
33 //----------------------------------------------------------------------------------------- |
|
34 |
|
35 /// Enumeration of the EAP-Code values. |
|
36 enum eap_code_value_e |
|
37 { |
|
38 eap_code_none = 0, ///< This is internal value for no type case. |
|
39 eap_code_request = 1, ///< This is EAP-Request. |
|
40 eap_code_response = 2, ///< This is EAP-Response. |
|
41 eap_code_success = 3, ///< This is EAP-Success. |
|
42 eap_code_failure = 4, ///< This is EAP-Failure. |
|
43 }; |
|
44 |
|
45 |
|
46 #if defined(USE_EAP_EXPANDED_TYPES) |
|
47 /// Enumeration of the IETF defined EAP-Type values. |
|
48 enum eap_type_ietf_values_e |
|
49 #else |
|
50 /// This is the original enumeration of the EAP-Type values. |
|
51 enum eap_type_value_e |
|
52 #endif //#if defined(USE_EAP_EXPANDED_TYPES) |
|
53 { |
|
54 eap_type_none = 0, ///< This is internal value for no type case. |
|
55 eap_type_identity = 1, ///< This is Identity. |
|
56 eap_type_notification = 2, ///< This is Notification. |
|
57 eap_type_nak = 3, ///< This is Nak. |
|
58 eap_type_md5_challenge = 4, ///< This is EAP-MD5 type. |
|
59 eap_type_one_time_password = 5, ///< This is One Time Password (OTP) type. |
|
60 eap_type_generic_token_card = 6, ///< This is Generic Token Card (GTC) type. |
|
61 eap_type_tls = 13, ///< This is Transport Layer Security (TLS) type. |
|
62 eap_type_leap = 17, ///< This is LEAP type. |
|
63 eap_type_gsmsim = 18, ///< This is SIM type. |
|
64 eap_type_ttls = 21, ///< This is tunneled TLS. |
|
65 eap_type_aka = 23, ///< This is AKA type. |
|
66 eap_type_peap = 25, ///< This is PEAP type. |
|
67 eap_type_mschapv2 = 26, ///< This is MsChapv2 type. |
|
68 eap_type_securid = 32, ///< This is SecurID type. |
|
69 eap_type_tlv_extensions = 33, ///< This is type/length/value extension type for PEAP payloads. |
|
70 #if defined(USE_FAST_EAP_TYPE) |
|
71 eap_type_fast = 43, ///< This is EAP-FAST type. |
|
72 #endif //#if defined(USE_FAST_EAP_TYPE) |
|
73 |
|
74 eap_type_ttls_plain_pap = 98, // This is for TTLS/PAP. |
|
75 |
|
76 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK) |
|
77 eap_type_plain_mschapv2 = 99, ///< This is used to indicate plain MSChapv2 inside TTLS tunnel. |
|
78 #endif //#if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK) |
|
79 |
|
80 eap_type_saesim = 252, ///< This is just a test EAP-type. |
|
81 eap_type_dummy_sim = 253, ///< This is just a test EAP-type. |
|
82 |
|
83 eap_type_expanded_type = 254, ///< This is Expanded Type. |
|
84 eap_type_experimental_type = 255, ///< This is Experimental Type. |
|
85 }; |
|
86 |
|
87 |
|
88 #if !defined(USE_EAP_EXPANDED_TYPES) |
|
89 typedef eap_type_value_e eap_type_ietf_values_e; |
|
90 #endif //#if !defined(USE_EAP_EXPANDED_TYPES) |
|
91 |
|
92 |
|
93 |
|
94 enum eap_type_vendor_id_e |
|
95 { |
|
96 eap_type_vendor_id_ietf = 0, |
|
97 eap_type_vendor_id_broadcom = 0x0000113d, |
|
98 eap_type_vendor_id_WFA = 0x00372A, |
|
99 eap_type_vendor_id_hack = 0xFFFFFF, // This is for plain MCHAPv2 and TTLS |
|
100 }; |
|
101 |
|
102 enum eap_type_vendor_type_e |
|
103 { |
|
104 eap_type_vendor_type_secure_easy_setup = 10, |
|
105 eap_type_vendor_type_WFA_simple_config = 1, |
|
106 eap_type_vendor_type_ttls_plain_pap_hack = eap_type_ttls_plain_pap, // This is for TTLS/PAP. |
|
107 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK) |
|
108 eap_type_vendor_type_plain_MSCHAPv2_hack = eap_type_plain_mschapv2, // This is for plain MCHAPv2 and TTLS |
|
109 #endif //#if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK) |
|
110 }; |
|
111 |
|
112 //----------------------------------------------------------------------------------------- |
|
113 //----------------------------------------------------------------------------------------- |
|
114 //----------------------------------------------------------------------------------------- |
|
115 |
|
116 class EAP_EXPORT eap_expanded_type_c |
|
117 { |
|
118 |
|
119 public: |
|
120 |
|
121 enum sizes |
|
122 { |
|
123 m_ietf_type_size = sizeof(u8_t), |
|
124 m_vendor_id_size = 3ul*sizeof(u8_t), |
|
125 m_vendor_type_size = sizeof(u32_t), |
|
126 m_eap_expanded_type_size = m_ietf_type_size+m_vendor_id_size+m_vendor_type_size, |
|
127 }; |
|
128 |
|
129 EAP_FUNC_IMPORT ~eap_expanded_type_c(); |
|
130 |
|
131 EAP_FUNC_IMPORT eap_expanded_type_c(); |
|
132 |
|
133 EAP_FUNC_IMPORT eap_expanded_type_c( |
|
134 const eap_type_vendor_id_e vendor_id, |
|
135 const u32_t vendor_type); |
|
136 |
|
137 EAP_FUNC_IMPORT eap_expanded_type_c( |
|
138 const eap_type_ietf_values_e type); |
|
139 |
|
140 EAP_FUNC_IMPORT static bool is_expanded_type(const eap_type_ietf_values_e eap_type); |
|
141 |
|
142 #if defined(USE_EAP_EXPANDED_TYPES) |
|
143 EAP_FUNC_IMPORT static bool is_ietf_type(const eap_expanded_type_c eap_type); |
|
144 #else |
|
145 EAP_FUNC_IMPORT static bool is_ietf_type(const eap_type_ietf_values_e eap_type); |
|
146 #endif //#if defined(USE_EAP_EXPANDED_TYPES) |
|
147 |
|
148 EAP_FUNC_IMPORT eap_status_e get_type_data( |
|
149 abs_eap_am_tools_c * const am_tools, |
|
150 eap_type_ietf_values_e * const type); |
|
151 |
|
152 EAP_FUNC_IMPORT eap_status_e get_type_data( |
|
153 abs_eap_am_tools_c * const am_tools, |
|
154 eap_expanded_type_c * const type); |
|
155 |
|
156 EAP_FUNC_IMPORT eap_status_e get_expanded_type_data( |
|
157 abs_eap_am_tools_c * const am_tools, |
|
158 eap_variable_data_c * const data); |
|
159 |
|
160 EAP_FUNC_IMPORT eap_status_e set_expanded_type_data( |
|
161 abs_eap_am_tools_c * const am_tools, |
|
162 const eap_variable_data_c * const data); |
|
163 |
|
164 EAP_FUNC_IMPORT void set_eap_type_values( |
|
165 const eap_type_vendor_id_e vendor_id, |
|
166 const u32_t vendor_type); |
|
167 |
|
168 EAP_FUNC_IMPORT eap_type_vendor_id_e get_vendor_id() const; |
|
169 |
|
170 EAP_FUNC_IMPORT u32_t get_vendor_type() const; |
|
171 |
|
172 EAP_FUNC_IMPORT static u32_t get_eap_expanded_type_size(); |
|
173 |
|
174 EAP_FUNC_IMPORT bool operator == (const eap_type_ietf_values_e right_type_value) const; |
|
175 |
|
176 EAP_FUNC_IMPORT bool operator != (const eap_type_ietf_values_e right_type_value) const; |
|
177 |
|
178 EAP_FUNC_IMPORT bool operator == (const eap_expanded_type_c &right_type_value) const; |
|
179 |
|
180 EAP_FUNC_IMPORT bool operator != (const eap_expanded_type_c &right_type_value) const; |
|
181 |
|
182 EAP_FUNC_IMPORT eap_expanded_type_c &operator = (const eap_type_ietf_values_e right_type_value); |
|
183 |
|
184 EAP_FUNC_IMPORT eap_expanded_type_c &operator = (const eap_expanded_type_c &right_type_value); |
|
185 |
|
186 EAP_FUNC_IMPORT eap_expanded_type_c *operator & (); |
|
187 |
|
188 EAP_FUNC_IMPORT const eap_expanded_type_c *operator & () const; |
|
189 |
|
190 /// This function reads EAP-type from offset. |
|
191 EAP_FUNC_IMPORT static eap_status_e read_type( |
|
192 abs_eap_am_tools_c * const am_tools, |
|
193 const u32_t index, |
|
194 const void * const buffer, |
|
195 const u32_t buffer_length, |
|
196 #if defined(USE_EAP_EXPANDED_TYPES) |
|
197 eap_expanded_type_c * const type |
|
198 #else |
|
199 eap_type_ietf_values_e * const type |
|
200 #endif //#if defined(USE_EAP_EXPANDED_TYPES) |
|
201 ); |
|
202 |
|
203 /// This function writes EAP-type to offset. |
|
204 EAP_FUNC_IMPORT static eap_status_e write_type( |
|
205 abs_eap_am_tools_c * const am_tools, |
|
206 const u32_t index, ///< Index is from 0 to n. Index 0 is the first EAP type field after base EAP header. |
|
207 void * const buffer, |
|
208 const u32_t buffer_length, |
|
209 const bool write_extented_type_when_true, ///< True value writes always Extented Type. |
|
210 #if defined(USE_EAP_EXPANDED_TYPES) |
|
211 const eap_expanded_type_c p_type ///< The EAP type to be written. |
|
212 #else |
|
213 const eap_type_ietf_values_e p_type ///< The EAP type to be written. |
|
214 #endif //#if defined(USE_EAP_EXPANDED_TYPES) |
|
215 ); |
|
216 |
|
217 #if defined(USE_EAP_EXPANDED_TYPES) |
|
218 EAP_FUNC_IMPORT i32_t compare(const eap_expanded_type_c * const data) const; |
|
219 #endif //#if defined(USE_EAP_EXPANDED_TYPES) |
|
220 |
|
221 private: |
|
222 |
|
223 eap_type_vendor_id_e m_vendor_id; ///< Here we use only 24 least significant bits. |
|
224 u32_t m_vendor_type; |
|
225 }; |
|
226 |
|
227 //----------------------------------------------------------------------------------------- |
|
228 //----------------------------------------------------------------------------------------- |
|
229 //----------------------------------------------------------------------------------------- |
|
230 |
|
231 class EAP_EXPORT eap_static_expanded_type_c |
|
232 { |
|
233 public: |
|
234 |
|
235 EAP_FUNC_IMPORT const eap_expanded_type_c & get_type() const; |
|
236 |
|
237 public: |
|
238 |
|
239 eap_type_vendor_id_e m_vendor_id; ///< Here we use only 24 least significant bits. |
|
240 u32_t m_vendor_type; |
|
241 }; |
|
242 |
|
243 #define EAP_EXPANDED_TYPE(name, vendor_id, vendor_type) \ |
|
244 static const eap_static_expanded_type_c name={vendor_id, vendor_type} |
|
245 |
|
246 |
|
247 // EAP Expanded Types. |
|
248 EAP_EXPANDED_TYPE( |
|
249 eap_expanded_type_broadcom_secure_easy_setup, |
|
250 eap_type_vendor_id_broadcom, |
|
251 eap_type_vendor_type_secure_easy_setup); |
|
252 |
|
253 EAP_EXPANDED_TYPE( |
|
254 eap_expanded_type_nak, |
|
255 eap_type_vendor_id_ietf, |
|
256 eap_type_nak); |
|
257 |
|
258 EAP_EXPANDED_TYPE( |
|
259 eap_expanded_type_simple_config, |
|
260 eap_type_vendor_id_WFA, |
|
261 eap_type_vendor_type_WFA_simple_config); |
|
262 |
|
263 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK) |
|
264 EAP_EXPANDED_TYPE( |
|
265 eap_expanded_type_ttls_plain_mschapv2, |
|
266 eap_type_vendor_id_hack, |
|
267 eap_type_vendor_type_plain_MSCHAPv2_hack); |
|
268 #endif //#if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK) |
|
269 |
|
270 EAP_EXPANDED_TYPE( |
|
271 eap_expanded_type_ttls_plain_pap, |
|
272 eap_type_vendor_id_hack, |
|
273 eap_type_vendor_type_ttls_plain_pap_hack); |
|
274 |
|
275 //----------------------------------------------------------------------------------------- |
|
276 //----------------------------------------------------------------------------------------- |
|
277 //----------------------------------------------------------------------------------------- |
|
278 |
|
279 |
|
280 #if defined(USE_EAP_EXPANDED_TYPES) |
|
281 |
|
282 typedef eap_expanded_type_c eap_type_value_e; |
|
283 |
|
284 EAP_C_FUNC_IMPORT u32_t convert_eap_type_to_u32_t(eap_type_value_e type); |
|
285 |
|
286 EAP_C_FUNC_IMPORT u64_t convert_eap_type_to_u64_t(eap_type_value_e type); |
|
287 |
|
288 #else |
|
289 |
|
290 EAP_C_FUNC_IMPORT u32_t convert_eap_type_to_u32_t(eap_type_value_e type); |
|
291 |
|
292 EAP_C_FUNC_IMPORT u64_t convert_eap_type_to_u64_t(eap_type_value_e type); |
|
293 |
|
294 #endif //#if defined(USE_EAP_EXPANDED_TYPES) |
|
295 |
|
296 |
|
297 //----------------------------------------------------------------------------------------- |
|
298 //----------------------------------------------------------------------------------------- |
|
299 //----------------------------------------------------------------------------------------- |
|
300 |
|
301 #endif //#if !defined(_EAP_EXPANDED_TYPE_H_) |
|
302 |
|
303 //-------------------------------------------------- |
|
304 |
|
305 |
|
306 |
|
307 // End. |