|
1 // Copyright (c) 1997-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 /** |
|
17 @file |
|
18 */ |
|
19 |
|
20 #include "IF_DEF.H" |
|
21 #include "NI_STD.H" |
|
22 #include "Ni_Log.h" |
|
23 #include "NIFPRVAR.H" |
|
24 #include <in_sock.h> |
|
25 #include <es_prot.h> |
|
26 #include <agenterrors.h> |
|
27 #include "NIFConfigurationControl.h" |
|
28 #include <comms-infras/es_config.h> |
|
29 #include <es_panic.h> |
|
30 |
|
31 #ifdef _DEBUG |
|
32 #include <in_iface.h> |
|
33 #endif |
|
34 |
|
35 using namespace ESock; |
|
36 #include <comms-infras/ss_subconnprov.h> |
|
37 #include <ss_glob.h> |
|
38 #include <comms-infras/ss_protflow.h> |
|
39 #include <comms-infras/ss_subconnflow.h> |
|
40 |
|
41 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
42 #include <networking/cfbearers.h> |
|
43 #endif //SYMBIAN_ADAPTIVE_TCP_WINDOW_RECEIVE |
|
44 |
|
45 |
|
46 // Security policies |
|
47 _LIT_SECURITY_POLICY_C1(NifAgentPolicyNetworkControl, ECapabilityNetworkControl); |
|
48 |
|
49 // Diagnostic string identifying this module when calling security policy checking methods |
|
50 |
|
51 const char * const NifAgentPolicyDiagnostic = "CNifAgentBase"; |
|
52 |
|
53 /** |
|
54 Constructor |
|
55 */ |
|
56 EXPORT_C CNifAgentBase::CNifAgentBase() |
|
57 { |
|
58 } |
|
59 |
|
60 |
|
61 /** |
|
62 This version of the Control() function is now deprecated. |
|
63 Use the version of CNifAgentBase::Control() that takes four parameters |
|
64 */ |
|
65 EXPORT_C TInt CNifAgentBase::Control(TUint, TUint, TDes8&) |
|
66 { |
|
67 return KErrNotSupported; |
|
68 } |
|
69 |
|
70 /** |
|
71 Control() with capability checking |
|
72 */ |
|
73 EXPORT_C TInt CNifAgentBase::Control(TUint aOptionLevel, TUint aOptionName, TDes8& aOption, const RProcess& aProcess) |
|
74 { |
|
75 TBool result( CheckControlPolicy(aOptionLevel, aOptionName, aProcess) ); |
|
76 |
|
77 //if we got Permission (ETrue i.e. TRUE i.e. 1) then return call to Control(), else return KErrPermissionDenied |
|
78 return ( result? Control(aOptionLevel, aOptionName, aOption) : KErrPermissionDenied ); |
|
79 } |
|
80 |
|
81 |
|
82 /** |
|
83 Read an integer |
|
84 @param aField The field name |
|
85 @param aValue Returned value |
|
86 @param aMessage For capability checking |
|
87 @return One of the system-wide error codes |
|
88 */ |
|
89 EXPORT_C TInt CNifAgentBase::ReadInt(const TDesC& aField, TUint32& aValue,const RMessagePtr2* aMessage) |
|
90 { |
|
91 return DoReadInt( aField, aValue, aMessage ); |
|
92 } |
|
93 |
|
94 |
|
95 /** |
|
96 Read an integer |
|
97 @param aField The field name |
|
98 @param aValue Returned value |
|
99 @return One of the system-wide error codes |
|
100 */ |
|
101 EXPORT_C TInt CNifAgentBase::ReadInt(const TDesC& aField, TUint32& aValue ) |
|
102 { |
|
103 return ReadInt( aField, aValue, NULL ); |
|
104 } |
|
105 |
|
106 |
|
107 /** |
|
108 Write an integer |
|
109 @param aField The field name |
|
110 @param aValue The value |
|
111 @param aMessage For capability checking |
|
112 @return One of the system-wide error codes |
|
113 */ |
|
114 EXPORT_C TInt CNifAgentBase::WriteInt(const TDesC& aField, TUint32 aValue,const RMessagePtr2* aMessage) |
|
115 { |
|
116 return DoWriteInt( aField, aValue, aMessage ); |
|
117 } |
|
118 |
|
119 |
|
120 /** |
|
121 Write an integer |
|
122 @param aField The field name |
|
123 @param aValue The value |
|
124 @return One of the system-wide error codes |
|
125 */ |
|
126 EXPORT_C TInt CNifAgentBase::WriteInt(const TDesC& aField, TUint32 aValue ) |
|
127 { |
|
128 return WriteInt( aField, aValue, NULL ); |
|
129 } |
|
130 |
|
131 |
|
132 /** |
|
133 Read a descriptor |
|
134 @param aField The field name |
|
135 @param aValue Returned value |
|
136 @param aMessage For capability checking |
|
137 @return One of the system-wide error codes |
|
138 */ |
|
139 EXPORT_C TInt CNifAgentBase::ReadDes(const TDesC& aField, TDes8& aValue,const RMessagePtr2* aMessage) |
|
140 { |
|
141 return DoReadDes( aField, aValue, aMessage ); |
|
142 } |
|
143 |
|
144 |
|
145 /** |
|
146 Read a descriptor |
|
147 @param aField The field name |
|
148 @param aValue Returned value |
|
149 @param aMessage For capability checking |
|
150 @return One of the system-wide error codes |
|
151 */ |
|
152 EXPORT_C TInt CNifAgentBase::ReadDes(const TDesC& aField, TDes8& aValue ) |
|
153 { |
|
154 return ReadDes( aField, aValue, NULL ); |
|
155 } |
|
156 |
|
157 |
|
158 /** |
|
159 Write a descriptor |
|
160 @param aField The field name |
|
161 @param aValue value to write |
|
162 @param aMessage For capability checking |
|
163 @return One of the system-wide error codes |
|
164 */ |
|
165 EXPORT_C TInt CNifAgentBase::WriteDes(const TDesC& aField, const TDesC8& aValue,const RMessagePtr2* aMessage) |
|
166 { |
|
167 return DoWriteDes( aField, aValue, aMessage ); |
|
168 } |
|
169 |
|
170 |
|
171 /** |
|
172 Write a descriptor |
|
173 @param aField The field name |
|
174 @param aValue value to write |
|
175 @return One of the system-wide error codes |
|
176 */ |
|
177 EXPORT_C TInt CNifAgentBase::WriteDes(const TDesC& aField, const TDesC8& aValue ) |
|
178 { |
|
179 return WriteDes( aField, aValue, NULL ); |
|
180 } |
|
181 |
|
182 |
|
183 /** |
|
184 Read a descriptor |
|
185 @param aField The field name |
|
186 @param aValue Returned value |
|
187 @param aMessage For capability checking |
|
188 @return One of the system-wide error codes |
|
189 */ |
|
190 EXPORT_C TInt CNifAgentBase::ReadDes(const TDesC& aField, TDes16& aValue,const RMessagePtr2* aMessage) |
|
191 { |
|
192 return DoReadDes( aField, aValue, aMessage ); |
|
193 } |
|
194 |
|
195 |
|
196 /** |
|
197 Read a descriptor |
|
198 @param aField The field name |
|
199 @param aValue Returned value |
|
200 @return One of the system-wide error codes |
|
201 */ |
|
202 EXPORT_C TInt CNifAgentBase::ReadDes(const TDesC& aField, TDes16& aValue ) |
|
203 { |
|
204 return ReadDes( aField, aValue, NULL ); |
|
205 } |
|
206 |
|
207 |
|
208 /** |
|
209 Write a descriptor |
|
210 @param aField The field name |
|
211 @param aValue value to write |
|
212 @param aMessage For capability checking |
|
213 @return One of the system-wide error codes |
|
214 */ |
|
215 EXPORT_C TInt CNifAgentBase::WriteDes(const TDesC& aField, const TDesC16& aValue,const RMessagePtr2* aMessage) |
|
216 { |
|
217 return DoWriteDes( aField, aValue, aMessage ); |
|
218 } |
|
219 |
|
220 |
|
221 /** |
|
222 Write a descriptor |
|
223 @param aField The field name |
|
224 @param aValue value to write |
|
225 @return One of the system-wide error codes |
|
226 */ |
|
227 EXPORT_C TInt CNifAgentBase::WriteDes(const TDesC& aField, const TDesC16& aValue ) |
|
228 { |
|
229 return WriteDes( aField, aValue, NULL ); |
|
230 } |
|
231 |
|
232 |
|
233 /** |
|
234 Read a boolean value |
|
235 @param aField Field name |
|
236 @param aValue Returned value |
|
237 @param aMessage For capability checking |
|
238 @return one of the system-wide error codes |
|
239 */ |
|
240 EXPORT_C TInt CNifAgentBase::ReadBool(const TDesC& aField, TBool& aValue,const RMessagePtr2* aMessage) |
|
241 { |
|
242 return DoReadBool( aField, aValue, aMessage ); |
|
243 } |
|
244 |
|
245 |
|
246 /** |
|
247 Read a boolean value |
|
248 @param aField Field name |
|
249 @param aValue Returned value |
|
250 @return one of the system-wide error codes |
|
251 */ |
|
252 EXPORT_C TInt CNifAgentBase::ReadBool(const TDesC& aField, TBool& aValue ) |
|
253 { |
|
254 return ReadBool( aField, aValue, NULL ); |
|
255 } |
|
256 |
|
257 |
|
258 /** |
|
259 Write a boolean value |
|
260 @param aField Field name |
|
261 @param aValue Value to write |
|
262 @param aMessage for capability checking |
|
263 @return one of the system-wide error codes |
|
264 */ |
|
265 EXPORT_C TInt CNifAgentBase::WriteBool(const TDesC& aField, TBool aValue,const RMessagePtr2* aMessage) |
|
266 { |
|
267 return DoWriteBool( aField, aValue, aMessage ); |
|
268 } |
|
269 |
|
270 |
|
271 /** |
|
272 Write a boolean value |
|
273 @param aField Field name |
|
274 @param aValue Value to write |
|
275 @return one of the system-wide error codes |
|
276 */ |
|
277 EXPORT_C TInt CNifAgentBase::WriteBool(const TDesC& aField, TBool aValue ) |
|
278 { |
|
279 return WriteBool( aField, aValue, NULL ); |
|
280 } |
|
281 |
|
282 |
|
283 /** |
|
284 Read a long descriptor value |
|
285 @param aField Field name |
|
286 @param aMessage For capability checking |
|
287 @return HBufC containing value |
|
288 */ |
|
289 EXPORT_C HBufC* CNifAgentBase::ReadLongDesLC(const TDesC& aField,const RMessagePtr2* aMessage) |
|
290 { |
|
291 return DoReadLongDesLC( aField, aMessage ); |
|
292 } |
|
293 |
|
294 |
|
295 /** |
|
296 Read a long descriptor value |
|
297 @param aField Field name |
|
298 @return HBufC containing value |
|
299 */ |
|
300 EXPORT_C HBufC* CNifAgentBase::ReadLongDesLC(const TDesC& aField ) |
|
301 { |
|
302 return ReadLongDesLC( aField, NULL ); |
|
303 } |
|
304 |
|
305 |
|
306 /** |
|
307 Ensure that a client has the required capabilites to read a field |
|
308 @param aField Field Name |
|
309 @param aMessage Contains client capabilites to validate |
|
310 @return One of the system-wide error codes |
|
311 */ |
|
312 EXPORT_C TInt CNifAgentBase::CheckReadCapability( const TDesC& aField, const RMessagePtr2* aMessage ) |
|
313 { |
|
314 if( aMessage ) |
|
315 { |
|
316 return DoCheckReadCapability( aField, aMessage ); |
|
317 } |
|
318 else |
|
319 { |
|
320 return KErrNone; |
|
321 } |
|
322 } |
|
323 |
|
324 |
|
325 /** |
|
326 Ensure that a client has the required capabilites to write a field |
|
327 @param aField Field Name |
|
328 @param aMessage Contains client capabilites to validate |
|
329 @return One of the system-wide error codes |
|
330 */ |
|
331 EXPORT_C TInt CNifAgentBase::CheckWriteCapability( const TDesC& aField, const RMessagePtr2* aMessage ) |
|
332 { |
|
333 if( aMessage ) |
|
334 { |
|
335 return DoCheckWriteCapability( aField, aMessage ); |
|
336 } |
|
337 else |
|
338 { |
|
339 return KErrNone; |
|
340 } |
|
341 } |
|
342 |
|
343 |
|
344 /** |
|
345 Ensure that a client has the required capabilites to read a field |
|
346 @param aField Field Name |
|
347 @param aMessage Contains client capabilites to validate |
|
348 @return One of the system-wide error codes |
|
349 */ |
|
350 EXPORT_C TInt CNifAgentBase::DoCheckReadCapability( const TDesC& /*aField*/, const RMessagePtr2* /*aMessage*/ ) |
|
351 { |
|
352 return KErrNone; |
|
353 } |
|
354 |
|
355 |
|
356 /** |
|
357 Ensure that a client has the required capabilites to write a field |
|
358 @param aField Field Name |
|
359 @param aMessage Contains client capabilites to validate |
|
360 @return One of the system-wide error codes |
|
361 */ |
|
362 EXPORT_C TInt CNifAgentBase::DoCheckWriteCapability( const TDesC& /*aField*/, const RMessagePtr2* /*aMessage*/ ) |
|
363 { |
|
364 return KErrNone; |
|
365 } |
|
366 |
|
367 |
|
368 /** |
|
369 Check that a client has the required capabilties |
|
370 @param aOptionLevel |
|
371 @param aOptionName |
|
372 @param aOption |
|
373 @param aMessage |
|
374 @returns KErrNone, if the client has the required capabilites, otherwise one of the standard Symbian OS error codes |
|
375 */ |
|
376 TBool CNifAgentBase::CheckControlPolicy(TUint aLevel, TUint /*aOption*/, const RProcess& aProcess) |
|
377 { |
|
378 TBool result; |
|
379 |
|
380 switch (aLevel) |
|
381 { |
|
382 case KCOLAgent: |
|
383 result = NifAgentPolicyNetworkControl.CheckPolicy(aProcess, NifAgentPolicyDiagnostic); |
|
384 break; |
|
385 |
|
386 default: |
|
387 result = EFalse; |
|
388 break; |
|
389 } |
|
390 |
|
391 return result; |
|
392 } |
|
393 |
|
394 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
395 /* |
|
396 Retrieve the default bearer information to the Agent CPR |
|
397 @return default bearer information to the Agent CPR. |
|
398 */ |
|
399 EXPORT_C TUint32 CNifAgentBase::GetBearerInfo() const |
|
400 { |
|
401 //Return the default value, if the agent |
|
402 //has not overridden this function |
|
403 return KDefaultBearer; |
|
404 } |
|
405 #endif //SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
406 |
|
407 |