|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <networking/umtsnifcontrolif.h> |
|
17 #include "umts_qos_variables.h" |
|
18 #include "parameters.h" |
|
19 #include "extension.h" |
|
20 #include "guqos_log.h" |
|
21 |
|
22 |
|
23 RExtensionData::RExtensionData() |
|
24 { |
|
25 SetUmtsType(); // Default to Umts type |
|
26 } |
|
27 |
|
28 |
|
29 RExtensionData::~RExtensionData() |
|
30 { |
|
31 Close(); |
|
32 } |
|
33 |
|
34 void RExtensionData::Close() |
|
35 { |
|
36 iBuf.Close(); |
|
37 } |
|
38 |
|
39 void RExtensionData::SetUmtsType() |
|
40 { |
|
41 #ifdef SYMBIAN_NETWORKING_UMTSR5 |
|
42 iType = KPfqosR5ExtensionUmts; |
|
43 #else |
|
44 iType = KPfqosExtensionUmts; |
|
45 #endif |
|
46 iData.Set(iBuf); |
|
47 } |
|
48 |
|
49 // SBLP |
|
50 void RExtensionData::SetSblpType() |
|
51 { |
|
52 iType = KPfqosExtensionSBLP; |
|
53 iData.Set(iBuf); |
|
54 } |
|
55 |
|
56 |
|
57 |
|
58 // Internal help function. |
|
59 static void SetIntValue(pfqos_configblock_int& data, TInt aValue, const TDesC& aName) |
|
60 { |
|
61 data.len = sizeof(pfqos_configblock_int)/8; |
|
62 data.padding = data.reserved = 0; |
|
63 data.type = KPfqosTypeInteger; |
|
64 data.value = aValue; |
|
65 TPtr8 ptr((TUint8*)data.id, 0, KPfqosMaxName); |
|
66 if (ptr.MaxLength() >= aName.Length()) |
|
67 ptr.Copy(aName); |
|
68 ptr.ZeroTerminate(); |
|
69 LOG(Log::Printf(_L("\t\t'%S' = %d"), &aName, aValue)); |
|
70 } |
|
71 |
|
72 |
|
73 TInt RExtensionData::SetErrorCode(TInt aErrorCode) |
|
74 { |
|
75 |
|
76 const int byte_len = (sizeof(pfqos_configure)+sizeof(pfqos_extension)+sizeof(pfqos_configblock_int)*1); |
|
77 const int real_len = ((byte_len + 7) / 8) * 8; |
|
78 LOG(Log::Printf(_L("\tSetErrorCode %d (size %d"), aErrorCode, real_len)); |
|
79 |
|
80 if (iBuf.MaxLength() < real_len) |
|
81 { |
|
82 TInt ret = iBuf.ReAlloc(real_len); |
|
83 if (ret != KErrNone) |
|
84 { |
|
85 LOG(Log::Printf(_L("\tSetErrorCode failed: out of memory %d"), ret)); |
|
86 return ret; |
|
87 } |
|
88 } |
|
89 |
|
90 iBuf.SetLength(0); |
|
91 pfqos_configure header; |
|
92 header.pfqos_configure_len = static_cast<TUint16>((byte_len + 7) / 8); |
|
93 header.pfqos_ext_type = EPfqosExtExtension; |
|
94 header.reserved = 0; |
|
95 header.protocol_id = 0; |
|
96 iBuf.Append((TUint8*)&header, sizeof(pfqos_configure)); |
|
97 |
|
98 pfqos_extension extensionType; |
|
99 extensionType.pfqos_ext_len = 0; |
|
100 extensionType.pfqos_ext_type = EPfqosExtExtension; |
|
101 extensionType.pfqos_extension_type = iType; |
|
102 iBuf.Append((TUint8*)&extensionType, sizeof(pfqos_extension)); |
|
103 LOG(Log::Printf(_L("\t\textensionType = %d"), (TInt)iType)); |
|
104 |
|
105 // Error code |
|
106 pfqos_configblock_int ext; |
|
107 SetIntValue(ext, aErrorCode, KDescErrorCode); |
|
108 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
109 |
|
110 iBuf.AppendFill(0, header.pfqos_configure_len * 8 - byte_len); |
|
111 iData.Set(iBuf); |
|
112 return KErrNone; |
|
113 } |
|
114 |
|
115 // |
|
116 // Create an extension data block to be sent to QoS API library. |
|
117 // |
|
118 TInt RExtensionData::CreateExtension(const TContextConfig& aRel99, TInt aErrorCode) |
|
119 { |
|
120 TQoSNegotiated qos; |
|
121 aRel99.GetUMTSQoSNeg(qos); |
|
122 |
|
123 TUint compression; |
|
124 aRel99.GetPdpCompression(compression); |
|
125 |
|
126 #ifdef SYMBIAN_NETWORKING_UMTSR5 |
|
127 const int byte_len = (sizeof(pfqos_configure)+sizeof(pfqos_extension)+sizeof(pfqos_configblock_int)*16); |
|
128 #else |
|
129 const int byte_len = (sizeof(pfqos_configure)+sizeof(pfqos_extension)+sizeof(pfqos_configblock_int)*14); |
|
130 #endif |
|
131 const int real_len = ((byte_len + 7) / 8) * 8; |
|
132 LOG(Log::Printf(_L("\tCreateExtension from TContextConfig (size %d)"), real_len)); |
|
133 |
|
134 if (iBuf.MaxLength() < real_len) |
|
135 { |
|
136 TInt ret = iBuf.ReAlloc(real_len); |
|
137 if (ret != KErrNone) |
|
138 { |
|
139 LOG(Log::Printf(_L("\tCreateExtension failed: out of memory %d"), ret)); |
|
140 return ret; |
|
141 } |
|
142 } |
|
143 |
|
144 |
|
145 iBuf.SetLength(0); |
|
146 pfqos_configure header; |
|
147 header.pfqos_configure_len = static_cast<TUint16>((byte_len + 7) / 8); |
|
148 header.pfqos_ext_type = EPfqosExtExtension; |
|
149 header.reserved = 0; |
|
150 header.protocol_id = 0; |
|
151 iBuf.Append((TUint8*)&header, sizeof(pfqos_configure)); |
|
152 |
|
153 pfqos_extension extensionType; |
|
154 extensionType.pfqos_ext_len = 0; |
|
155 extensionType.pfqos_ext_type = EPfqosExtExtension; |
|
156 #ifdef SYMBIAN_NETWORKING_UMTSR5 |
|
157 extensionType.pfqos_extension_type = KPfqosR5ExtensionUmts; |
|
158 #else |
|
159 extensionType.pfqos_extension_type = KPfqosExtensionUmts; |
|
160 #endif |
|
161 iBuf.Append((TUint8*)&extensionType, sizeof(pfqos_extension)); |
|
162 LOG(Log::Printf(_L("\t\textensionType = %d"), (TInt)KPfqosExtensionUmts)); |
|
163 |
|
164 // negotiated set |
|
165 pfqos_configblock_int ext; |
|
166 SetIntValue(ext, qos.iTrafficClass, KDescTrafficClassNegotiated); |
|
167 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
168 |
|
169 SetIntValue(ext, qos.iDeliveryOrderReqd, KDescDeliveryOrderNegotiated); |
|
170 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
171 |
|
172 SetIntValue(ext, qos.iDeliverErroneousSDU, KDescDeliveryOfErroneusSduNegotiated); |
|
173 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
174 |
|
175 SetIntValue(ext, qos.iBER, KDescResidualBerNegotiated); |
|
176 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
177 |
|
178 SetIntValue(ext, qos.iSDUErrorRatio, KDescErrorRatioNegotiated); |
|
179 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
180 |
|
181 SetIntValue(ext, qos.iTrafficHandlingPriority, KDescPriorityNegotiated); |
|
182 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
183 |
|
184 SetIntValue(ext, qos.iTransferDelay, KDescTransferDelayNegotiated); |
|
185 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
186 |
|
187 SetIntValue(ext, qos.iMaxSDUSize, KDescMaxSduSizeNegotiated); |
|
188 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
189 |
|
190 SetIntValue(ext, qos.iMaxRate.iUplinkRate, KDescMaxBitrateUplinkNegotiated); |
|
191 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
192 |
|
193 SetIntValue(ext, qos.iMaxRate.iDownlinkRate, KDescMaxBitrateDownlinkNegotiated); |
|
194 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
195 |
|
196 SetIntValue(ext, qos.iGuaranteedRate.iUplinkRate, KDescGuaBitrateUplinkNegotiated); |
|
197 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
198 |
|
199 SetIntValue(ext, qos.iGuaranteedRate.iDownlinkRate, KDescGuaBitrateDownlinkNegotiated); |
|
200 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
201 |
|
202 #ifdef SYMBIAN_NETWORKING_UMTSR5 |
|
203 SetIntValue(ext, qos.iSignallingIndication, KDescSignallingIndicatorNegotiated); |
|
204 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
205 |
|
206 SetIntValue(ext, qos.iSourceStatisticsDescriptor, KDescSrcStatDescNegotiated); |
|
207 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
208 #endif // SYMBIAN_NETWORKING_UMTSR5 |
|
209 |
|
210 // Header compression |
|
211 SetIntValue(ext, compression, KDescHeaderCompression); |
|
212 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
213 |
|
214 // Error code |
|
215 SetIntValue(ext, aErrorCode, KDescErrorCode); |
|
216 iBuf.Append((TUint8*)&ext, sizeof(pfqos_configblock_int)); |
|
217 iData.Set(iBuf); |
|
218 return KErrNone; |
|
219 } |