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 * %version: 17 % |
|
20 */ |
|
21 |
|
22 #if !defined(_EAP_CORE_SERVER_MESSAGE_IF_H_) |
|
23 #define _EAP_CORE_SERVER_MESSAGE_IF_H_ |
|
24 |
|
25 #include "eap_tools.h" |
|
26 #include "eap_am_export.h" |
|
27 #include "abs_eap_session_core.h" |
|
28 #include "eap_variable_data.h" |
|
29 #include "abs_eap_am_mutex.h" |
|
30 #include "eap_session_core_base.h" |
|
31 #include "abs_eap_am_message_if.h" |
|
32 #include "eap_am_message_if.h" |
|
33 #include "eap_process_tlv_message_data.h" |
|
34 #include "abs_eap_am_stack.h" |
|
35 #include "eap_am_stack.h" |
|
36 |
|
37 #if defined(USE_EAP_SIMPLE_CONFIG) |
|
38 #include "simple_config_types.h" |
|
39 #include "simple_config_credential.h" |
|
40 #include "simple_config_payloads.h" |
|
41 #include "abs_eap_configuration_if.h" |
|
42 #endif // #if defined(USE_EAP_SIMPLE_CONFIG) |
|
43 |
|
44 |
|
45 /** @file */ |
|
46 |
|
47 |
|
48 /// A eap_core_server_message_if_c class implements the basic functionality of EAPOL. |
|
49 class EAP_EXPORT eap_core_server_message_if_c |
|
50 : public abs_eap_session_core_c |
|
51 , public eap_am_message_if_c |
|
52 , public abs_eap_base_timer_c |
|
53 , public abs_eap_am_stack_c |
|
54 { |
|
55 |
|
56 private: |
|
57 //-------------------------------------------------- |
|
58 |
|
59 /// This is back pointer to object which created this object. |
|
60 abs_eap_am_message_if_c * m_partner; |
|
61 |
|
62 /// This is pointer to the eap_core object. The eapol_core object gives |
|
63 /// the received packets to the eap_core object. The eap_core object sends |
|
64 /// packets through the eapol_core object. |
|
65 eap_session_core_base_c * const m_eap_core; |
|
66 |
|
67 eap_am_stack_c * const m_am_stack; |
|
68 |
|
69 /// This is pointer to the tools class. |
|
70 abs_eap_am_tools_c * const m_am_tools; |
|
71 |
|
72 /// This is offset in bytes of the EAP header. |
|
73 u32_t m_eap_header_offset; |
|
74 |
|
75 /// This is maximum transfer unit in bytes. |
|
76 u32_t m_MTU; |
|
77 |
|
78 /// This is length of the trailer in bytes. |
|
79 u32_t m_trailer_length; |
|
80 |
|
81 eap_status_e m_error_code; |
|
82 |
|
83 eap_tlv_message_type_function_e m_error_function; |
|
84 |
|
85 /// This indicates whether this object is client (true) or server (false). |
|
86 /// In terms of EAP-protocol whether this network entity is EAP-supplicant (true) or EAP-authenticator (false). |
|
87 bool m_is_client; |
|
88 |
|
89 /// This indicates whether this object was generated successfully. |
|
90 bool m_is_valid; |
|
91 |
|
92 bool m_shutdown_was_called; |
|
93 |
|
94 eap_status_e send_error_message( |
|
95 const eap_status_e error_code, |
|
96 const eap_tlv_message_type_function_e function); |
|
97 |
|
98 eap_status_e send_message(eap_process_tlv_message_data_c * const message); |
|
99 |
|
100 eap_status_e process_message_type_error( |
|
101 EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters); |
|
102 |
|
103 eap_status_e process_message(eap_process_tlv_message_data_c * const message); |
|
104 |
|
105 eap_status_e create_eap_session( |
|
106 EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters); |
|
107 |
|
108 eap_status_e remove_eap_session( |
|
109 EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters); |
|
110 |
|
111 eap_status_e send_eap_identity_request( |
|
112 EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters); |
|
113 |
|
114 eap_status_e packet_process( |
|
115 EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters); |
|
116 |
|
117 eap_status_e eap_acknowledge( |
|
118 EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters); |
|
119 |
|
120 eap_status_e set_eap_database_reference_values( |
|
121 EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters); |
|
122 |
|
123 eap_status_e eap_mtu( |
|
124 EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters); |
|
125 |
|
126 eap_status_e get_802_11_authentication_mode( |
|
127 EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters); |
|
128 |
|
129 |
|
130 eap_status_e complete_remove_eap_session( |
|
131 const bool complete_to_lower_layer, |
|
132 const eap_am_network_id_c * const receive_network_id); |
|
133 |
|
134 |
|
135 //-------------------------------------------------- |
|
136 protected: |
|
137 //-------------------------------------------------- |
|
138 |
|
139 //-------------------------------------------------- |
|
140 public: |
|
141 //-------------------------------------------------- |
|
142 |
|
143 /** |
|
144 * The destructor deletes the m_eap_core object. |
|
145 */ |
|
146 EAP_FUNC_IMPORT virtual ~eap_core_server_message_if_c(); |
|
147 |
|
148 /** |
|
149 * The constructor creates the eap_core object and initializes the m_eap_core |
|
150 * to point the eap_core object. |
|
151 * @param tools is pointer to the tools class. @see abs_eap_am_tools_c. |
|
152 * @param partner is back pointer to object which created this object. |
|
153 * @param is_client_when_true indicates whether the network entity should act |
|
154 * as a client (true) or server (false), in terms of EAP-protocol whether |
|
155 * this network entity is EAP-supplicant (true) or EAP-authenticator (false). |
|
156 */ |
|
157 EAP_FUNC_IMPORT eap_core_server_message_if_c( |
|
158 abs_eap_am_tools_c * const tools, |
|
159 const bool is_client_when_true, |
|
160 const u32_t MTU); |
|
161 |
|
162 EAP_FUNC_IMPORT void set_partner(abs_eap_am_message_if_c * const partner); |
|
163 |
|
164 EAP_FUNC_IMPORT eap_status_e process_data(const void * const data, const u32_t length); |
|
165 |
|
166 /** |
|
167 * The class could send packets to partner class with this function. |
|
168 * eap_core_server_message_if_c adds EAPOL header to the send packet. |
|
169 * @param send_network_id carries the addresses (network identity) and type of the packet. |
|
170 * @param sent_packet includes the buffer for the whole packet and initialized |
|
171 * EAP-packet in correct offset. |
|
172 * @param header_offset is offset of the EAP-header within the sent_packet. |
|
173 * @param data_length is length in bytes of the EAP-packet. |
|
174 * @param buffer_length is length in bytes of the whole packet buffer. |
|
175 */ |
|
176 EAP_FUNC_IMPORT eap_status_e packet_send( |
|
177 const eap_am_network_id_c * const send_network_id, |
|
178 eap_buf_chain_wr_c * const sent_packet, |
|
179 const u32_t header_offset, |
|
180 const u32_t data_length, |
|
181 const u32_t buffer_length); |
|
182 |
|
183 /** |
|
184 * The get_header_offset() function obtains the header offset of EAP-packet. |
|
185 * @param MTU_length is pointer to variable to store the maximum transfer unit (MTU). |
|
186 * MTU is the maximum EAP-packet length in bytes |
|
187 * @param trailer_length is pointer to the variable to store length |
|
188 * of trailer needed by lower levels. |
|
189 * @return Function returns the offset of EAP-header. |
|
190 * @see abs_eap_core_c::get_header_offset(). |
|
191 */ |
|
192 EAP_FUNC_IMPORT u32_t get_header_offset( |
|
193 u32_t * const MTU, |
|
194 u32_t * const trailer_length); |
|
195 |
|
196 /** |
|
197 * The load_module() function function indicates the lower level to |
|
198 * load new module of EAP-type. |
|
199 * @see abs_eap_core_c::load_module(). |
|
200 */ |
|
201 EAP_FUNC_IMPORT eap_status_e load_module( |
|
202 const eap_type_value_e type, |
|
203 const eap_type_value_e /* tunneling_type */, |
|
204 abs_eap_base_type_c * const partner, |
|
205 eap_base_type_c ** const eap_type, |
|
206 const bool is_client_when_true, |
|
207 const eap_am_network_id_c * const receive_network_id); |
|
208 |
|
209 /** |
|
210 * The unload_module() function unloads the module of a EAP-type. |
|
211 * @see abs_eap_core_c::unload_module(). |
|
212 */ |
|
213 EAP_FUNC_IMPORT eap_status_e unload_module( |
|
214 const eap_type_value_e type); |
|
215 |
|
216 /** |
|
217 * Note this function is just an example. Parameters will change later. |
|
218 * The packet_data_crypto_keys() function gives the generated keys to lower level. |
|
219 * After EAP-authentication has generated the keys it calls this function |
|
220 * to offer the keys to lower level. |
|
221 * @see abs_eap_base_type_c::packet_data_crypto_keys(). |
|
222 */ |
|
223 EAP_FUNC_IMPORT eap_status_e packet_data_crypto_keys( |
|
224 const eap_am_network_id_c * const send_network_id, |
|
225 const eap_master_session_key_c * const master_session_key |
|
226 ); |
|
227 |
|
228 // This is documented in abs_eap_stack_interface_c::configure(). |
|
229 EAP_FUNC_IMPORT eap_status_e configure( |
|
230 const eap_variable_data_c * const client_configuration); |
|
231 |
|
232 // This is documented in abs_eap_stack_interface_c::shutdown(). |
|
233 EAP_FUNC_IMPORT eap_status_e shutdown(); |
|
234 |
|
235 /** |
|
236 * The read_configure() function reads the configuration data identified |
|
237 * by the field string of field_length bytes length. Adaptation module must direct |
|
238 * the query to some persistent store. |
|
239 * @see abs_eap_base_type_c::read_configure(). |
|
240 */ |
|
241 EAP_FUNC_IMPORT eap_status_e read_configure( |
|
242 const eap_configuration_field_c * const field, |
|
243 eap_variable_data_c * const data); |
|
244 |
|
245 /** |
|
246 * The write_configure() function writes the configuration data identified |
|
247 * by the field string of field_length bytes length. Adaptation module must direct |
|
248 * the action to some persistent store. |
|
249 * @see abs_eap_base_type_c::write_configure(). |
|
250 */ |
|
251 EAP_FUNC_IMPORT eap_status_e write_configure( |
|
252 const eap_configuration_field_c * const field, |
|
253 eap_variable_data_c * const data); |
|
254 |
|
255 // This is documented in abs_eap_stack_interface_c::set_is_valid(). |
|
256 EAP_FUNC_IMPORT void set_is_valid(); |
|
257 |
|
258 // This is documented in abs_eap_stack_interface_c::get_is_valid(). |
|
259 EAP_FUNC_IMPORT bool get_is_valid(); |
|
260 |
|
261 // See abs_eap_base_type_c::state_notification(). |
|
262 EAP_FUNC_IMPORT void state_notification( |
|
263 const abs_eap_state_notification_c * const state); |
|
264 |
|
265 // See abs_eap_base_timer_c::timer_expired(). |
|
266 EAP_FUNC_IMPORT eap_status_e timer_expired( |
|
267 const u32_t id, void *data); |
|
268 |
|
269 // See abs_eap_base_timer_c::timer_delete_data(). |
|
270 EAP_FUNC_IMPORT eap_status_e timer_delete_data( |
|
271 const u32_t id, void *data); |
|
272 |
|
273 /** |
|
274 * This function tells lower layer to remove EAP session object asyncronously. |
|
275 * @param send_network_id is pointer to network id that identifies the removed EAP session. |
|
276 */ |
|
277 EAP_FUNC_IMPORT eap_status_e asynchronous_init_remove_eap_session( |
|
278 const eap_am_network_id_c * const send_network_id); |
|
279 |
|
280 /** |
|
281 * The upper layer calls the asynchronous_start_authentication() function |
|
282 * when EAP-authentication is needed with another peer. |
|
283 * @see abs_eap_core_c::asynchronous_start_authentication(). |
|
284 */ |
|
285 EAP_FUNC_IMPORT eap_status_e asynchronous_start_authentication( |
|
286 const eap_am_network_id_c * const /* receive_network_id */, |
|
287 const bool /* is_client_when_true */); |
|
288 |
|
289 EAP_FUNC_IMPORT eap_status_e restart_authentication( |
|
290 const eap_am_network_id_c * const send_network_id, |
|
291 const bool is_client_when_true, |
|
292 const bool force_clean_restart, |
|
293 const bool from_timer = false); |
|
294 |
|
295 // |
|
296 EAP_FUNC_IMPORT eap_status_e set_timer( |
|
297 abs_eap_base_timer_c * const p_initializer, |
|
298 const u32_t p_id, |
|
299 void * const p_data, |
|
300 const u32_t p_time_ms); |
|
301 |
|
302 EAP_FUNC_IMPORT eap_status_e cancel_timer( |
|
303 abs_eap_base_timer_c * const p_initializer, |
|
304 const u32_t p_id); |
|
305 |
|
306 // |
|
307 EAP_FUNC_IMPORT eap_status_e check_is_valid_eap_type(const eap_type_value_e eap_type); |
|
308 |
|
309 // See abs_eap_core_c::get_eap_type_list(). |
|
310 EAP_FUNC_IMPORT eap_status_e get_eap_type_list( |
|
311 eap_array_c<eap_type_value_e> * const eap_type_list); |
|
312 |
|
313 /// @see abs_eap_core_c::add_rogue_ap(). |
|
314 EAP_FUNC_IMPORT eap_status_e add_rogue_ap(eap_array_c<eap_rogue_ap_entry_c> & rogue_ap_list); |
|
315 |
|
316 // This is documented in abs_eap_core_c::set_session_timeout(). |
|
317 EAP_FUNC_IMPORT eap_status_e set_session_timeout( |
|
318 const u32_t session_timeout_ms); |
|
319 |
|
320 #if defined(USE_EAP_SIMPLE_CONFIG) |
|
321 |
|
322 EAP_FUNC_IMPORT eap_status_e save_simple_config_session( |
|
323 const simple_config_state_e state, |
|
324 EAP_TEMPLATE_CONST eap_array_c<simple_config_credential_c> * const credential_array, |
|
325 const eap_variable_data_c * const new_password, |
|
326 const simple_config_Device_Password_ID_e Device_Password_ID, |
|
327 const simple_config_payloads_c * const other_configuration); |
|
328 |
|
329 #endif // #if defined(USE_EAP_SIMPLE_CONFIG) |
|
330 |
|
331 EAP_FUNC_IMPORT eap_status_e complete_get_802_11_authentication_mode( |
|
332 const eap_status_e completion_status, |
|
333 const eap_am_network_id_c * const receive_network_id, |
|
334 const eapol_key_802_11_authentication_mode_e mode); |
|
335 |
|
336 //-------------------------------------------------- |
|
337 }; // class eap_core_server_message_if_c |
|
338 |
|
339 #endif //#if !defined(_EAP_CORE_SERVER_MESSAGE_IF_H_) |
|
340 |
|
341 //-------------------------------------------------- |
|
342 |
|
343 |
|
344 |
|
345 // End. |
|