|
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: % |
|
20 */ |
|
21 |
|
22 #include "EapExpandedType.h" |
|
23 #include "EapTraceSymbian.h" |
|
24 #include "eap_expanded_type.h" |
|
25 |
|
26 //-------------------------------------------------- |
|
27 |
|
28 EAP_FUNC_EXPORT TEapExpandedType::TEapExpandedType() |
|
29 { |
|
30 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
31 (EAPL("TEapExpandedType::TEapExpandedType(): EapExpandedTypeNone"), |
|
32 &EapExpandedTypeNone, |
|
33 sizeof(EapExpandedTypeNone))); |
|
34 |
|
35 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::TEapExpandedType()\n")); |
|
36 |
|
37 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
38 (EAPL("TEapExpandedType::TEapExpandedType(): EapExpandedTypeNone.GetType()"), |
|
39 EapExpandedTypeNone.GetType(), |
|
40 sizeof(*(EapExpandedTypeNone.GetType())))); |
|
41 |
|
42 iValue.Copy(*(EapExpandedTypeNone.GetType())); |
|
43 |
|
44 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
45 (EAPL("TEapExpandedType::TEapExpandedType()"), |
|
46 iValue.Ptr(), |
|
47 iValue.Length())); |
|
48 } |
|
49 |
|
50 //-------------------------------------------------- |
|
51 |
|
52 EAP_FUNC_EXPORT TEapExpandedType::~TEapExpandedType() |
|
53 { |
|
54 EAP_STATIC_ASSERT(sizeof(TConstEapExpandedTypeTemplate<KEapExpandedTypeLength>) == sizeof(TBufC8<KEapExpandedTypeLength>)); |
|
55 } |
|
56 |
|
57 //-------------------------------------------------- |
|
58 |
|
59 EAP_FUNC_EXPORT TEapExpandedType::TEapExpandedType(const TEapExpandedType * const init) |
|
60 { |
|
61 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::TEapExpandedType(const TEapExpandedType * const init)\n")); |
|
62 |
|
63 iValue.Copy(init->GetValue()); |
|
64 |
|
65 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
66 (EAPL("TEapExpandedType::TEapExpandedType()"), |
|
67 iValue.Ptr(), |
|
68 iValue.Length())); |
|
69 } |
|
70 |
|
71 //-------------------------------------------------- |
|
72 |
|
73 EAP_FUNC_EXPORT TEapExpandedType::TEapExpandedType(const TEapExpandedType & init) |
|
74 { |
|
75 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::TEapExpandedType(const TEapExpandedType & init)\n")); |
|
76 |
|
77 iValue.Copy(init.GetValue()); |
|
78 |
|
79 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
80 (EAPL("TEapExpandedType::TEapExpandedType()"), |
|
81 iValue.Ptr(), |
|
82 iValue.Length())); |
|
83 } |
|
84 |
|
85 //-------------------------------------------------- |
|
86 |
|
87 EAP_FUNC_EXPORT TEapExpandedType::TEapExpandedType(const TBufC8<KEapExpandedTypeLength> & init) |
|
88 { |
|
89 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::TEapExpandedType(const TBufC8<KEapExpandedTypeLength> & init)\n")); |
|
90 |
|
91 iValue.Copy(init); |
|
92 |
|
93 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
94 (EAPL("TEapExpandedType::TEapExpandedType()"), |
|
95 iValue.Ptr(), |
|
96 iValue.Length())); |
|
97 } |
|
98 |
|
99 //-------------------------------------------------- |
|
100 |
|
101 EAP_FUNC_EXPORT TEapExpandedType::TEapExpandedType(const TDesC8 & init) |
|
102 { |
|
103 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::TEapExpandedType(const TDesC8 & init)\n")); |
|
104 |
|
105 iValue.Copy(init); |
|
106 |
|
107 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
108 (EAPL("TEapExpandedType::TEapExpandedType()"), |
|
109 iValue.Ptr(), |
|
110 iValue.Length())); |
|
111 } |
|
112 |
|
113 //-------------------------------------------------- |
|
114 |
|
115 EAP_FUNC_EXPORT const TBuf8<KEapExpandedTypeLength> & TEapExpandedType::GetValue() const |
|
116 { |
|
117 //EAP_TRACE_DEBUG_SYMBIAN((_L("TEapExpandedType::GetValue()\n"))); |
|
118 |
|
119 //EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::GetValue()\n")); |
|
120 |
|
121 return iValue; |
|
122 } |
|
123 |
|
124 //-------------------------------------------------- |
|
125 |
|
126 EAP_FUNC_EXPORT TInt TEapExpandedType::SetValue( |
|
127 const void * const data, |
|
128 const TUint data_length) |
|
129 { |
|
130 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
131 (EAPL("TEapExpandedType::SetValue(const void * const data, const TUint data_length)"), |
|
132 data, |
|
133 data_length)); |
|
134 |
|
135 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::SetValue()\n")); |
|
136 |
|
137 iValue.Copy(reinterpret_cast<const TUint8 *> (data), static_cast<TInt>(data_length)); |
|
138 |
|
139 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
140 (EAPL("TEapExpandedType::SetValue(const void * const data, const TUint data_length)"), |
|
141 iValue.Ptr(), |
|
142 iValue.Length())); |
|
143 |
|
144 return KErrNone; |
|
145 } |
|
146 |
|
147 //-------------------------------------------------- |
|
148 |
|
149 EAP_FUNC_EXPORT TInt TEapExpandedType::SetValue( |
|
150 const TUint vendor_id, |
|
151 const TUint vendor_type) |
|
152 { |
|
153 const u32_t expanded_vendor = (0xfe000000 | static_cast<u32_t>(vendor_id)); |
|
154 const TUint net_ord_vendor = eap_htonl(expanded_vendor); |
|
155 const TUint net_ord_type = eap_htonl(vendor_type); |
|
156 |
|
157 EAP_TRACE_DEBUG_SYMBIAN((_L("TEapExpandedType::SetValue(): vendor_id=0x%08x, vendor_type=0x%08x, expanded_vendor=0x%08x, net_ord_vendor=0x%08x, net_ord_type=0x%08x\n"), |
|
158 vendor_id, |
|
159 vendor_type, |
|
160 expanded_vendor, |
|
161 net_ord_vendor, |
|
162 net_ord_type)); |
|
163 |
|
164 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::SetValue()\n")); |
|
165 |
|
166 iValue.Copy(reinterpret_cast<const TUint8 *>(&net_ord_vendor), sizeof(net_ord_vendor)); |
|
167 iValue.Append(reinterpret_cast<const TUint8 *>(&net_ord_type), sizeof(net_ord_type)); |
|
168 |
|
169 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
170 (EAPL("TEapExpandedType::SetValue()"), |
|
171 iValue.Ptr(), |
|
172 iValue.Length())); |
|
173 |
|
174 return KErrNone; |
|
175 } |
|
176 |
|
177 //-------------------------------------------------- |
|
178 |
|
179 EAP_FUNC_EXPORT TUint TEapExpandedType::GetVendorId() const |
|
180 { |
|
181 //EAP_TRACE_DEBUG_SYMBIAN((_L("TEapExpandedType::GetVendorId()\n"))); |
|
182 |
|
183 //EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::GetVendorId()\n")); |
|
184 |
|
185 const TUint * const aHostOrderVendorId = reinterpret_cast<const TUint *>(iValue.Ptr()); |
|
186 |
|
187 // Masks off the leading octet 0xfe. |
|
188 return eap_ntohl(*aHostOrderVendorId) & 0x00ffffff; |
|
189 } |
|
190 |
|
191 //-------------------------------------------------- |
|
192 |
|
193 EAP_FUNC_EXPORT TUint TEapExpandedType::GetVendorType() const |
|
194 { |
|
195 //EAP_TRACE_DEBUG_SYMBIAN((_L("TEapExpandedType::GetVendorType()\n"))); |
|
196 |
|
197 //EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::GetVendorType()\n")); |
|
198 |
|
199 const TUint * const aHostOrderVendorType = reinterpret_cast<const TUint *>(iValue.Ptr() + sizeof(TUint)); |
|
200 |
|
201 return eap_ntohl(*aHostOrderVendorType); |
|
202 } |
|
203 |
|
204 //-------------------------------------------------- |
|
205 |
|
206 EAP_FUNC_EXPORT TEapExpandedType &TEapExpandedType::operator = (const TEapExpandedType &right_type_value) |
|
207 { |
|
208 //EAP_TRACE_DEBUG_SYMBIAN((_L("TEapExpandedType::operator =(const TEapExpandedType &right_type_value)\n"))); |
|
209 |
|
210 //EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::operator =(const TEapExpandedType &right_type_value)\n")); |
|
211 |
|
212 iValue.Copy(right_type_value.GetValue()); |
|
213 |
|
214 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
215 (EAPL("TEapExpandedType::operator ="), |
|
216 iValue.Ptr(), |
|
217 iValue.Length())); |
|
218 |
|
219 return *this; |
|
220 } |
|
221 |
|
222 //-------------------------------------------------- |
|
223 |
|
224 EAP_FUNC_EXPORT TEapExpandedType &TEapExpandedType::operator = (const TBufC8<KEapExpandedTypeLength> &right_type_value) |
|
225 { |
|
226 //EAP_TRACE_DEBUG_SYMBIAN((_L("TEapExpandedType::operator =(const TBufC8<KEapExpandedTypeLength> &right_type_value)\n"))); |
|
227 |
|
228 //EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::operator =(const TBufC8<KEapExpandedTypeLength> &right_type_value)\n")); |
|
229 |
|
230 iValue.Copy(right_type_value); |
|
231 |
|
232 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
233 (EAPL("TEapExpandedType::operator ="), |
|
234 iValue.Ptr(), |
|
235 iValue.Length())); |
|
236 |
|
237 return *this; |
|
238 } |
|
239 |
|
240 //-------------------------------------------------- |
|
241 |
|
242 EAP_FUNC_EXPORT TEapExpandedType &TEapExpandedType::operator = (const TDesC8 &right_type_value) |
|
243 { |
|
244 //EAP_TRACE_DEBUG_SYMBIAN((_L("TEapExpandedType::operator =(const TDesC8 &right_type_value)\n"))); |
|
245 |
|
246 //EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::operator =(const TDesC8 &right_type_value)\n")); |
|
247 |
|
248 ASSERT(right_type_value.Length() == KEapExpandedTypeLength); |
|
249 |
|
250 iValue.Copy(right_type_value); |
|
251 |
|
252 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
253 (EAPL("TEapExpandedType::operator ="), |
|
254 iValue.Ptr(), |
|
255 iValue.Length())); |
|
256 |
|
257 return *this; |
|
258 } |
|
259 |
|
260 //-------------------------------------------------- |
|
261 |
|
262 EAP_FUNC_EXPORT TInt TEapExpandedType::Compare(const TEapExpandedType &right_type_value) const |
|
263 { |
|
264 //EAP_TRACE_DEBUG_SYMBIAN((_L("TEapExpandedType::Compare()\n"))); |
|
265 |
|
266 //EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::Compare()\n")); |
|
267 |
|
268 for (TUint ind = 0ul; ind < KEapExpandedTypeLength; ++ind) |
|
269 { |
|
270 const TUint8 left = iValue[ind]; |
|
271 const TUint8 right = right_type_value.GetValue()[ind]; |
|
272 |
|
273 if (left != right) |
|
274 { |
|
275 return iValue[ind] - right_type_value.GetValue()[ind]; |
|
276 } |
|
277 } |
|
278 |
|
279 return 0; |
|
280 } |
|
281 |
|
282 //-------------------------------------------------- |
|
283 |
|
284 EAP_FUNC_EXPORT bool TEapExpandedType::operator == (const TEapExpandedType &right_type_value) const |
|
285 { |
|
286 //EAP_TRACE_DEBUG_SYMBIAN((_L("TEapExpandedType::operator ==()\n"))); |
|
287 |
|
288 //EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::operator ==()\n")); |
|
289 |
|
290 return Compare(right_type_value) == 0; |
|
291 } |
|
292 |
|
293 //-------------------------------------------------- |
|
294 |
|
295 EAP_FUNC_EXPORT bool TEapExpandedType::operator != (const TEapExpandedType &right_type_value) const |
|
296 { |
|
297 //EAP_TRACE_DEBUG_SYMBIAN((_L("TEapExpandedType::operator !=()\n"))); |
|
298 |
|
299 //EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: TEapExpandedType::operator !=()\n")); |
|
300 |
|
301 return Compare(right_type_value) != 0; |
|
302 } |
|
303 |
|
304 //-------------------------------------------------- |
|
305 // End of file |