equal
deleted
inserted
replaced
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
19 // |
19 // |
20 |
20 |
21 |
21 |
22 |
22 |
23 // Include Files |
23 // Include Files |
24 #include "tflogger.h" // For logging |
24 |
|
25 #include "OstTraceDefinitions.h" |
|
26 #ifdef OST_TRACE_COMPILER_IN_USE |
|
27 #include "ctlvTraces.h" |
|
28 #endif |
|
29 |
25 #include "CTlv.h" // Header of this class |
30 #include "CTlv.h" // Header of this class |
26 #include "TSatUtility.h" // Utility methods |
31 #include "TSatUtility.h" // Utility methods |
27 |
32 |
28 // ----------------------------------------------------------------------------- |
33 // ----------------------------------------------------------------------------- |
29 // CTlvBase::CTlvBase |
34 // CTlvBase::CTlvBase |
46 EXPORT_C TPtrC8 CTlvBase::Data |
51 EXPORT_C TPtrC8 CTlvBase::Data |
47 ( |
52 ( |
48 // None |
53 // None |
49 ) const |
54 ) const |
50 { |
55 { |
51 TFLOGSTRING("UTILITY: CTlvBase::Data"); |
56 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLVBASE_DATA_1, "UTILITY: CTlvBase::Data"); |
52 return iData; |
57 return iData; |
53 } |
58 } |
54 |
59 |
55 |
60 |
56 // ----------------------------------------------------------------------------- |
61 // ----------------------------------------------------------------------------- |
61 EXPORT_C void CTlvBase::SetData |
66 EXPORT_C void CTlvBase::SetData |
62 ( |
67 ( |
63 TPtrC8 aData |
68 TPtrC8 aData |
64 ) |
69 ) |
65 { |
70 { |
66 TFLOGSTRING("UTILITY: CTlvBase::SetData"); |
71 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLVBASE_SETDATA_1, "UTILITY: CTlvBase::SetData"); |
67 iData.Set( aData ); |
72 iData.Set( aData ); |
68 } |
73 } |
69 |
74 |
70 // ----------------------------------------------------------------------------- |
75 // ----------------------------------------------------------------------------- |
71 // CTlvBase::GetSize |
76 // CTlvBase::GetSize |
75 EXPORT_C TInt CTlvBase::GetSize |
80 EXPORT_C TInt CTlvBase::GetSize |
76 ( |
81 ( |
77 // None |
82 // None |
78 ) const |
83 ) const |
79 { |
84 { |
80 TFLOGSTRING("UTILITY: CTlvBase::GetSize"); |
85 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLVBASE_GETSIZE_1, "UTILITY: CTlvBase::GetSize"); |
81 return iData.Length(); |
86 return iData.Length(); |
82 } |
87 } |
83 |
88 |
84 // ----------------------------------------------------------------------------- |
89 // ----------------------------------------------------------------------------- |
85 // CTlvBase::GetTag |
90 // CTlvBase::GetTag |
89 EXPORT_C TUint8 CTlvBase::GetTag |
94 EXPORT_C TUint8 CTlvBase::GetTag |
90 ( |
95 ( |
91 // None |
96 // None |
92 ) const |
97 ) const |
93 { |
98 { |
94 TFLOGSTRING("UTILITY: CTlvBase::GetTag"); |
99 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLVBASE_GETTAG_1, "UTILITY: CTlvBase::GetTag"); |
95 return TUint8(iData[0] & KTagValueMask); |
100 return TUint8(iData[0] & KTagValueMask); |
96 } |
101 } |
97 |
102 |
98 // ----------------------------------------------------------------------------- |
103 // ----------------------------------------------------------------------------- |
99 // CTlvBase::GetComprehensionRequired |
104 // CTlvBase::GetComprehensionRequired |
103 EXPORT_C TBool CTlvBase::GetComprehensionRequired |
108 EXPORT_C TBool CTlvBase::GetComprehensionRequired |
104 ( |
109 ( |
105 // None |
110 // None |
106 ) const |
111 ) const |
107 { |
112 { |
108 TFLOGSTRING("UTILITY: CTlvBase::GetComprehensionRequired"); |
113 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLVBASE_GETCOMPREHENSIONREQUIRED_1, "UTILITY: CTlvBase::GetComprehensionRequired"); |
109 return (iData[0] & KTagCrMask) ? ETrue : EFalse; |
114 return (iData[0] & KTagCrMask) ? ETrue : EFalse; |
110 } |
115 } |
111 |
116 |
112 // ----------------------------------------------------------------------------- |
117 // ----------------------------------------------------------------------------- |
113 // CTlvBase::GetLength |
118 // CTlvBase::GetLength |
117 EXPORT_C TUint8 CTlvBase::GetLength |
122 EXPORT_C TUint8 CTlvBase::GetLength |
118 ( |
123 ( |
119 // None |
124 // None |
120 ) const |
125 ) const |
121 { |
126 { |
122 TFLOGSTRING("UTILITY: CTlvBase::GetLength"); |
127 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLVBASE_GETLENGTH_1, "UTILITY: CTlvBase::GetLength"); |
123 return (KTwoByteLengthCoding == iData[KTlvLengthStartPosition]) ? |
128 return (KTwoByteLengthCoding == iData[KTlvLengthStartPosition]) ? |
124 iData[KTlvLengthStartPosition + 1] : |
129 iData[KTlvLengthStartPosition + 1] : |
125 iData[KTlvLengthStartPosition]; |
130 iData[KTlvLengthStartPosition]; |
126 } |
131 } |
127 |
132 |
133 EXPORT_C TPtrC8 CTlvBase::GetValue |
138 EXPORT_C TPtrC8 CTlvBase::GetValue |
134 ( |
139 ( |
135 // None |
140 // None |
136 ) const |
141 ) const |
137 { |
142 { |
138 TFLOGSTRING("UTILITY: CTlvBase::GetValue"); |
143 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLVBASE_GETVALUE_1, "UTILITY: CTlvBase::GetValue"); |
139 TInt offset = (KTwoByteLengthCoding == iData[1]) ? 1 : 0; |
144 TInt offset = (KTwoByteLengthCoding == iData[1]) ? 1 : 0; |
140 return iData.Mid(2+offset, iData[1+offset]); |
145 return iData.Mid(2+offset, iData[1+offset]); |
141 } |
146 } |
142 |
147 |
143 // ----------------------------------------------------------------------------- |
148 // ----------------------------------------------------------------------------- |
161 EXPORT_C TUint8 CTlv::GetShortInfo |
166 EXPORT_C TUint8 CTlv::GetShortInfo |
162 ( |
167 ( |
163 TTlvSpesificDataType aType // Info spesific data type |
168 TTlvSpesificDataType aType // Info spesific data type |
164 ) |
169 ) |
165 { |
170 { |
166 TFLOGSTRING2("UTILITY: CTlv::GetShortInfo, type: %d", aType); |
171 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLV_GETSHORTINFO_1, "UTILITY: CTlv::GetShortInfo, type: %d", aType); |
167 // Information is generally at index 2. |
172 // Information is generally at index 2. |
168 TInt ind ( KTlvDataAreaStartPosition ); |
173 TInt ind ( KTlvDataAreaStartPosition ); |
169 TUint8 offset( 0 ); |
174 TUint8 offset( 0 ); |
170 |
175 |
171 // First determine if the length of the TLV is coded with 1 or 2 bytes to |
176 // First determine if the length of the TLV is coded with 1 or 2 bytes to |
265 ind = KTlvDataAreaStartPosition + offset + GetLength() - 2 + 2; |
270 ind = KTlvDataAreaStartPosition + offset + GetLength() - 2 + 2; |
266 break; |
271 break; |
267 } |
272 } |
268 default: |
273 default: |
269 { |
274 { |
270 TFLOGSTRING("UTILITY: CTlv::GetShortInfo, Type unknown"); |
275 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLV_GETSHORTINFO_2, "UTILITY: CTlv::GetShortInfo, Type unknown"); |
271 break; |
276 break; |
272 } |
277 } |
273 } |
278 } |
274 |
279 |
275 return iData[ind]; |
280 return iData[ind]; |
283 EXPORT_C TPtrC8 CTlv::GetData |
288 EXPORT_C TPtrC8 CTlv::GetData |
284 ( |
289 ( |
285 TTlvSpesificDataType aType //Info spesific data type |
290 TTlvSpesificDataType aType //Info spesific data type |
286 ) |
291 ) |
287 { |
292 { |
288 TFLOGSTRING2("UTILITY: CTlv::GetData, Data length: %d", iData.Length()); |
293 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLV_GETDATA_1, "UTILITY: CTlv::GetData, Data length: %d", iData.Length()); |
289 // Information is generally at index 2. |
294 // Information is generally at index 2. |
290 TInt ind ( 2 ); |
295 TInt ind ( 2 ); |
291 TUint8 offset( 0 ); |
296 TUint8 offset( 0 ); |
292 TInt length( 1 ); |
297 TInt length( 1 ); |
293 |
298 |
377 ind = KTlvDataAreaStartPosition + offset + 5; |
382 ind = KTlvDataAreaStartPosition + offset + 5; |
378 length = dataLength; |
383 length = dataLength; |
379 } |
384 } |
380 else |
385 else |
381 { |
386 { |
382 TFLOGSTRING("UTILITY: CTlv::GetData, Data length 0"); |
387 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLV_GETDATA_2, "UTILITY: CTlv::GetData, Data length 0"); |
383 return 0; |
388 return 0; |
384 } |
389 } |
385 break; |
390 break; |
386 } |
391 } |
387 default: |
392 default: |
388 { |
393 { |
389 TFLOGSTRING("UTILITY: CTlv::GetData, Type unknown"); |
394 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLV_GETDATA_3, "UTILITY: CTlv::GetData, Type unknown"); |
390 break; |
395 break; |
391 } |
396 } |
392 } |
397 } |
393 |
398 |
394 TFLOGSTRING3("UTILITY: CTlv::GetData, length: %d, ind: %d", |
399 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLV_GETDATA_4, "UTILITY: CTlv::GetData, length: %d, ind: %d", length, ind); |
395 length, ind); |
|
396 return iData.Mid( ind, length ); |
400 return iData.Mid( ind, length ); |
397 } |
401 } |
398 |
402 |
399 // ----------------------------------------------------------------------------- |
403 // ----------------------------------------------------------------------------- |
400 // CTlv::GetLongInfo |
404 // CTlv::GetLongInfo |
404 EXPORT_C TUint16 CTlv::GetLongInfo |
408 EXPORT_C TUint16 CTlv::GetLongInfo |
405 ( |
409 ( |
406 TTlvSpesificDataType aType // Info spesific data type |
410 TTlvSpesificDataType aType // Info spesific data type |
407 ) |
411 ) |
408 { |
412 { |
409 TFLOGSTRING2("UTILITY: CTlv::GetLongInfo, type: %d", aType); |
413 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLV_GETLONGINFO_1, "UTILITY: CTlv::GetLongInfo, type: %d", aType); |
410 TUint16 ret( 0x0000 ); |
414 TUint16 ret( 0x0000 ); |
411 |
415 |
412 switch( aType ) |
416 switch( aType ) |
413 { |
417 { |
414 case ETLV_LocationAreaCode: |
418 case ETLV_LocationAreaCode: |
448 KTlvDataAreaStartPosition + 1 ); |
452 KTlvDataAreaStartPosition + 1 ); |
449 break; |
453 break; |
450 } |
454 } |
451 default: |
455 default: |
452 { |
456 { |
453 TFLOGSTRING("UTILITY: CTlv::GetLongInfo, Type unknown"); |
457 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CTLV_GETLONGINFO_2, "UTILITY: CTlv::GetLongInfo, Type unknown"); |
454 break; |
458 break; |
455 } |
459 } |
456 } |
460 } |
457 |
461 |
458 return ret; |
462 return ret; |