|
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 #if !defined(_EAP_NETWORK_ID_H_) |
|
22 #define _EAP_NETWORK_ID_H_ |
|
23 |
|
24 #include "eap_tools.h" |
|
25 #include "abs_eap_am_tools.h" |
|
26 #include "eap_am_tools.h" |
|
27 #include "eap_am_export.h" |
|
28 |
|
29 /// This class stores the protocol layer network identity. |
|
30 /** |
|
31 * A eap_am_network_id_c class. |
|
32 * Network addresses are handled through eap_am_network_id_c class. |
|
33 * It includes source and destination addresses and the type of packet. |
|
34 * Addresses are mostly Ethernet addresses. Packet type is the type of Ethernet packet. |
|
35 * The eap_am_network_id class stores the addresses using the eap_variable_data objects. |
|
36 */ |
|
37 class EAP_EXPORT eap_am_network_id_c |
|
38 { |
|
39 |
|
40 private: |
|
41 |
|
42 /// This is pointer to the tools class. |
|
43 abs_eap_am_tools_c * const m_am_tools; |
|
44 |
|
45 /// This struct decreases the memory print of eap_am_network_id_c. |
|
46 class eap_am_network_id_impl_str |
|
47 { |
|
48 public: |
|
49 ~eap_am_network_id_impl_str(); |
|
50 |
|
51 eap_am_network_id_impl_str( |
|
52 abs_eap_am_tools_c * const tools); |
|
53 |
|
54 /// This is source address. |
|
55 eap_variable_data_c m_source; |
|
56 |
|
57 /// This is destination address. |
|
58 eap_variable_data_c m_destination; |
|
59 |
|
60 /// This is type of the packet. Mostly this is Ethernet type. |
|
61 u16_t m_type; |
|
62 |
|
63 /// This indicates whether this object was generated successfully. |
|
64 bool m_is_valid; |
|
65 }; |
|
66 |
|
67 /// This is pointer to data of eap_am_network_id_c. |
|
68 /// This decreases memory print of eap_am_network_id_c. |
|
69 /// This decreases stack usage of EAP_Core. |
|
70 eap_am_network_id_impl_str * m_data; |
|
71 |
|
72 eap_status_e initialize_members(); |
|
73 |
|
74 /** |
|
75 * The set_is_valid() function sets the state of the eap_core object valid. |
|
76 * The eap_core object calls this function after it is initialized. |
|
77 */ |
|
78 EAP_FUNC_IMPORT void set_is_valid(); |
|
79 |
|
80 public: |
|
81 |
|
82 /** |
|
83 * The destructor does nothing extra. The buffers of each address are |
|
84 * freed in the destructor of the eap_variable_data class. |
|
85 */ |
|
86 EAP_FUNC_IMPORT virtual ~eap_am_network_id_c(); |
|
87 |
|
88 /** |
|
89 * This version initializes the object. |
|
90 * @param tools parameter is pointer to the tools class. |
|
91 */ |
|
92 EAP_FUNC_IMPORT eap_am_network_id_c( |
|
93 abs_eap_am_tools_c * const tools); |
|
94 |
|
95 /** |
|
96 * This version takes addresses as pointers to any data. |
|
97 * This could be used to initialize addresses from the received packet. |
|
98 * @param tools parameter is pointer to the tools class. |
|
99 * @param source parameter is pointer to the source address. |
|
100 * @param source_length parameter is length of the source address. |
|
101 * @param destination parameter is pointer to the destination address. |
|
102 * @param destination_length parameter is length of the destination address. |
|
103 * @param type parameter is type of the packet. Mostly this is Ethernet type. |
|
104 * @param free_id parameter indicates whether the source and destination buffers must be freed in destructors. |
|
105 * @param writable_id parameter indicates whether the source and destination buffers are writable. |
|
106 * |
|
107 * NOTE the data buffers are NOT copied. |
|
108 */ |
|
109 EAP_FUNC_IMPORT eap_am_network_id_c( |
|
110 abs_eap_am_tools_c * const tools, |
|
111 const void * const source, |
|
112 const u32_t source_length, |
|
113 const void * const destination, |
|
114 const u32_t destination_length, |
|
115 const u16_t type, |
|
116 const bool free_id, |
|
117 const bool writable_id); |
|
118 |
|
119 /** |
|
120 * This version takes addresses as pointers to eap_variable_data_c. |
|
121 * @param tools parameter is pointer to the tools class. |
|
122 * @param source parameter is pointer to the source address. |
|
123 * @param destination parameter is pointer to the destination address. |
|
124 * @param type parameter is type of the packet. Mostly this is Ethernet type. |
|
125 * |
|
126 * NOTE the data buffers are NOT copied. This is used to swap addresses of existing |
|
127 * eap_am_network_id_c object and create a new object using existing addresses. |
|
128 */ |
|
129 EAP_FUNC_IMPORT eap_am_network_id_c( |
|
130 abs_eap_am_tools_c * const tools, |
|
131 const eap_variable_data_c * const source, |
|
132 const eap_variable_data_c * const destination, |
|
133 const u16_t type); |
|
134 |
|
135 /** |
|
136 * This version uses the data from existing object. |
|
137 * @param tools parameter is pointer to the tools class. |
|
138 * @param network_id parameter is pointer to the existing object. |
|
139 * |
|
140 * NOTE this copies the addresses. |
|
141 */ |
|
142 EAP_FUNC_IMPORT eap_am_network_id_c( |
|
143 abs_eap_am_tools_c * const tools, |
|
144 const eap_am_network_id_c * const network_id); |
|
145 |
|
146 /** |
|
147 * This function uses the data from existing object. |
|
148 * @param network_id parameter is pointer to the existing object. |
|
149 * |
|
150 * NOTE this copies the addresses. |
|
151 */ |
|
152 EAP_FUNC_IMPORT eap_status_e set_copy_of_network_id( |
|
153 const eap_am_network_id_c * const network_id); |
|
154 |
|
155 EAP_FUNC_IMPORT eap_status_e set_copy_of_am_network_id( |
|
156 const void * const source, |
|
157 const u32_t source_length, |
|
158 const void * const destination, |
|
159 const u32_t destination_length, |
|
160 const u16_t type); |
|
161 |
|
162 /** |
|
163 * The get_is_valid() function returns the status of the eap_core object. |
|
164 * True indicates the object is initialized succesfully. |
|
165 */ |
|
166 EAP_FUNC_IMPORT bool get_is_valid() const; |
|
167 |
|
168 /** |
|
169 * The get_is_valid_data() function returns the status of the eap_core object. |
|
170 * True indicates the object does include valid addresses. |
|
171 */ |
|
172 EAP_FUNC_IMPORT bool get_is_valid_data() const; |
|
173 |
|
174 /** |
|
175 * The get_source_id() function returns pointer to the source address. |
|
176 */ |
|
177 EAP_FUNC_IMPORT const eap_variable_data_c * get_source_id() const; |
|
178 |
|
179 /** |
|
180 * The get_destination_id() function returns pointer to the destination address. |
|
181 */ |
|
182 EAP_FUNC_IMPORT const eap_variable_data_c * get_destination_id() const; |
|
183 |
|
184 |
|
185 /** |
|
186 * The get_source() function returns pointer to the source data. |
|
187 */ |
|
188 EAP_FUNC_IMPORT const u8_t * get_source() const; |
|
189 |
|
190 /** |
|
191 * The get_destination() function returns pointer to the destination data. |
|
192 */ |
|
193 EAP_FUNC_IMPORT const u8_t * get_destination() const; |
|
194 |
|
195 |
|
196 /** |
|
197 * The get_source_length() function returns length of the source address. |
|
198 */ |
|
199 EAP_FUNC_IMPORT u32_t get_source_length() const; |
|
200 |
|
201 /** |
|
202 * The get_destination_length() function returns length of the destination address. |
|
203 */ |
|
204 EAP_FUNC_IMPORT u32_t get_destination_length() const; |
|
205 |
|
206 /** |
|
207 * The get_type() function returns type of the packet. |
|
208 */ |
|
209 EAP_FUNC_IMPORT u16_t get_type() const; |
|
210 |
|
211 /** |
|
212 * The get_network_id() function returns pointer to this. |
|
213 */ |
|
214 EAP_FUNC_IMPORT const eap_am_network_id_c * get_network_id() const; |
|
215 |
|
216 /** |
|
217 * The copy() function copies the eap_am_network_id object. |
|
218 * The data of addresses are copied to new buffers. |
|
219 */ |
|
220 EAP_FUNC_IMPORT eap_am_network_id_c * copy() const; |
|
221 |
|
222 /** |
|
223 * Compare the objects are identical. |
|
224 * @return false if data of objects differs. |
|
225 * @return true if data of objects are the same. |
|
226 */ |
|
227 EAP_FUNC_IMPORT bool compare_network_id(const eap_am_network_id_c * const network_id) const; |
|
228 |
|
229 /** |
|
230 * The get_type() function sets type of the packet. |
|
231 */ |
|
232 EAP_FUNC_IMPORT void set_type(const u16_t type); |
|
233 |
|
234 /** |
|
235 * Resets the object. |
|
236 */ |
|
237 EAP_FUNC_IMPORT void reset(); |
|
238 }; |
|
239 |
|
240 |
|
241 #endif //#if !defined(_EAP_NETWORK_ID_H_) |
|
242 |
|
243 //-------------------------------------------------- |
|
244 |
|
245 |
|
246 |
|
247 // End. |