|
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 // PARAM_MESS_NAME_CStep.CPP |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 //Test Step header |
|
21 #include "PARAM_MESS_NAME_CStep.h" |
|
22 |
|
23 |
|
24 //TO BE SAFE |
|
25 IMPORT_C TInt StartDialogThread(); |
|
26 |
|
27 const TUint KMagicConfigDaemonTestLevel = 777; |
|
28 const TUint KMagicConfigDaemonTestOption = 778; |
|
29 |
|
30 CPARAM_MESS_NAMEStep::CPARAM_MESS_NAMEStep(TBool aUpsAuthorisationGranted) |
|
31 /** Each test step initialises it's own name |
|
32 */ |
|
33 { |
|
34 // store the name of this test case |
|
35 // this is the name that is used by the script file |
|
36 //DEF iTestStepName = _L("CPARAM_MESS_NAMEStep"); |
|
37 |
|
38 //The server name and IPC number is obtained and all messages are checked Sync |
|
39 SR_ServerName = _L("PARAM_SVR_NAME"); |
|
40 SR_MESSAGE_TYPE = 2; |
|
41 SR_MESSAGE_ID = PARAM_MESS_VALUE; |
|
42 SR_MESSAGE_MASK = PARAM_MESS_CAPMASK; |
|
43 |
|
44 // ECNControl level and name. |
|
45 iControlLevel = PARAM_MESS_OPTLEVEL; |
|
46 iControlOption = PARAM_MESS_OPTNAME; |
|
47 |
|
48 if(PARAM_MESS_OPTLEVEL == KMagicConfigDaemonTestLevel && PARAM_MESS_OPTNAME == KMagicConfigDaemonTestOption) |
|
49 { |
|
50 // For this particular case, NetworkServices capability is not controlled by the UPS (it is enforced |
|
51 // by the DHCP server). |
|
52 aUpsAuthorisationGranted = EFalse; |
|
53 } |
|
54 |
|
55 //The iServer_Panic is a unique name from Server,but always truncated to KMaxExitCategoryName |
|
56 |
|
57 iServer_Panic = _L("PARAM_SVR_T16_PANIC"); |
|
58 |
|
59 TCapability cap[] = {ECapabilityPARAM_MESS_NAMECAP, ECapability_Limit}; |
|
60 |
|
61 TSecurityInfo info; |
|
62 info.Set(RProcess()); |
|
63 TBool result = EFalse; |
|
64 |
|
65 for (TInt i = 0; cap[i] != ECapability_Limit; i++) |
|
66 { |
|
67 if ((!aUpsAuthorisationGranted || cap[i] != ECapabilityNetworkServices) && |
|
68 !(info.iCaps.HasCapability(cap[i]))) |
|
69 { |
|
70 result=ETrue; |
|
71 |
|
72 } |
|
73 |
|
74 } |
|
75 |
|
76 |
|
77 iExpect_Rejection = result; |
|
78 |
|
79 iStepCap = (TUint32)PARAM_MESS_CAPMASK; |
|
80 |
|
81 //Get a unique thread name |
|
82 ChildThread_SR.Format(_L("ChildThread_%S_%d"),&SR_ServerName,SR_MESSAGE_ID); |
|
83 |
|
84 } |
|
85 |
|
86 |
|
87 TInt CPARAM_MESS_NAMEStep::Exec_SendReceive() |
|
88 { |
|
89 _LIT(KEsockSessStartMutex,"KESSMTX"); //Keep the descriptor short |
|
90 RMutex mutex; |
|
91 TInt r; |
|
92 // Protect the openning of the session |
|
93 // with a mutex to stop thread collision |
|
94 FOREVER |
|
95 { |
|
96 r = mutex.CreateGlobal(KEsockSessStartMutex()); |
|
97 if (r == KErrNone) |
|
98 break; |
|
99 if (r != KErrAlreadyExists) |
|
100 return r; |
|
101 r=mutex.OpenGlobal(KEsockSessStartMutex()); |
|
102 if (r == KErrNone) |
|
103 break; |
|
104 if (r != KErrNotFound) |
|
105 return r; |
|
106 } |
|
107 mutex.Wait(); // the exclusion ensures the session is started atomically |
|
108 iResult_Server=CreateSession(SOCKET_SERVER_NAME,Version()); |
|
109 // Because ESock is now loaded by the Comms Root Server which is generally started during |
|
110 // the boot this should commonly succeed; however for test code this is still a possibility |
|
111 // Hence here we try starting it; this is an atomic operation (and cheap if it's already started) |
|
112 if (iResult_Server==KErrNotFound) |
|
113 { |
|
114 r=StartC32(); |
|
115 if (r==KErrNone || r==KErrAlreadyExists) |
|
116 { |
|
117 iResult_Server=CreateSession(SOCKET_SERVER_NAME,Version()); |
|
118 } |
|
119 } |
|
120 mutex.Signal(); |
|
121 mutex.Close(); |
|
122 |
|
123 if (iResult_Server == KErrNone) |
|
124 { |
|
125 iSessionCreated = ETrue; |
|
126 |
|
127 const TInt test_id = dispatch_num<PARAM_MESS_VALUE>::result; |
|
128 |
|
129 iResult_SR = do_execute(Int2Type<test_id>()); |
|
130 |
|
131 // This is essentially an RSocketServ, so must be closed |
|
132 Close(); |
|
133 } |
|
134 else |
|
135 { |
|
136 iSessionCreated = EFalse; |
|
137 return 0; |
|
138 } |
|
139 return r; |
|
140 } |
|
141 |
|
142 //------------------------------------------------------------------------------------------------------ |
|
143 // testing |
|
144 // RConnection::ESCPSStop |
|
145 // Requires alive connection. Uses Ethernet one |
|
146 //------------------------------------------------------------------------------------------------------ |
|
147 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESCPSStop>) |
|
148 { |
|
149 TInt result; |
|
150 |
|
151 //-- 1. Create and start a connection. |
|
152 result = CreateStartDefaultConnection(); |
|
153 if(result != KErrNone) |
|
154 return result; |
|
155 |
|
156 result =SendReceive(ESCPSStop,TIpcArgs(1, 0, 0, iSSRef)); |
|
157 |
|
158 //-- stop and close connection |
|
159 StopCloseConnection(); |
|
160 |
|
161 return result; |
|
162 } |
|
163 |
|
164 //------------------------------------------------------------------------------------------------------ |
|
165 // testing |
|
166 // RConnection::ESCPSProgressNotification and ESCPSCancelProgressNotification |
|
167 // Requires alive connection. Uses Ethernet one |
|
168 //------------------------------------------------------------------------------------------------------ |
|
169 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESCPSProgressNotification>) |
|
170 { |
|
171 TInt result; |
|
172 |
|
173 //-- 1. Create and start a connection. |
|
174 result = CreateStartDefaultConnection(); |
|
175 if(result != KErrNone) |
|
176 return result; |
|
177 |
|
178 TNifProgressBuf nifProgrBuf; |
|
179 TRequestStatus rqStat; |
|
180 const TSubConnectionUniqueId subConnId = 1; |
|
181 |
|
182 //-- subscribe to the progress notification |
|
183 SendReceive(ESCPSProgressNotification,TIpcArgs(subConnId, &nifProgrBuf, KConnProgressDefault, iSSRef), rqStat); |
|
184 result = rqStat.Int(); |
|
185 if((result != KErrNone) && (result != KRequestPending)) |
|
186 { |
|
187 StopCloseConnection(); |
|
188 return result; |
|
189 } |
|
190 |
|
191 //-- now cancel the progress notification |
|
192 result = SendReceive(ESCPSCancelProgressNotification,TIpcArgs(subConnId, 0, 0, iSSRef)); |
|
193 User::WaitForRequest(rqStat); |
|
194 |
|
195 //-- stop and close connection |
|
196 StopCloseConnection(); |
|
197 |
|
198 return result; |
|
199 } |
|
200 |
|
201 |
|
202 //------------------------------------------------------------------------------------------------------ |
|
203 // testing |
|
204 // RConnection::ECNGetIntSetting |
|
205 // Requires alive connection. Uses Ethernet one |
|
206 //------------------------------------------------------------------------------------------------------ |
|
207 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNGetIntSetting>) |
|
208 { |
|
209 TInt result; |
|
210 |
|
211 //-- 1. Create and start a connection. |
|
212 result = CreateStartDefaultConnection(); |
|
213 if(result != KErrNone) |
|
214 return result; |
|
215 |
|
216 // read an integer value from commdb (IAP\Id chosen) |
|
217 _LIT(KName, "IAP\\id"); |
|
218 TBufC<7> name(KName); |
|
219 TUint32 intval= 0; |
|
220 TPckg<TUint32> intPckg(intval); |
|
221 |
|
222 result =SendReceive(ECNGetIntSetting,TIpcArgs(&name, &intPckg, 0, iSSRef)); |
|
223 |
|
224 //-- stop and close connection |
|
225 StopCloseConnection(); |
|
226 |
|
227 return result; |
|
228 } |
|
229 |
|
230 |
|
231 //------------------------------------------------------------------------------------------------------ |
|
232 // testing |
|
233 // RConnection::ECNGetBoolSetting |
|
234 // Requires alive connection. Uses Ethernet one |
|
235 //------------------------------------------------------------------------------------------------------ |
|
236 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNGetBoolSetting>) |
|
237 { |
|
238 TInt result; |
|
239 |
|
240 //-- 1. Create and start a connection. |
|
241 result = CreateStartDefaultConnection(); |
|
242 if(result != KErrNone) |
|
243 return result; |
|
244 |
|
245 // read a bool value from commdb (DialOutISP\IfPromptForAuth chosen) |
|
246 _LIT(KName, "LANService\\IpAddrFromServer"); |
|
247 TBufC<27> name(KName); |
|
248 TBool boolval=EFalse; |
|
249 TPckg<TBool> boolPckg(boolval); |
|
250 |
|
251 result =SendReceive(ECNGetBoolSetting,TIpcArgs(&name, &boolPckg, 0, iSSRef)); |
|
252 |
|
253 //-- stop and close connection |
|
254 StopCloseConnection(); |
|
255 |
|
256 return result; |
|
257 } |
|
258 |
|
259 //------------------------------------------------------------------------------------------------------ |
|
260 // testing |
|
261 // RConnection::ECNGetDes8Setting |
|
262 // Requires alive connection. Uses Ethernet one |
|
263 //------------------------------------------------------------------------------------------------------ |
|
264 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNGetDes8Setting>) |
|
265 { |
|
266 TInt result; |
|
267 |
|
268 |
|
269 //-- 1. Create and start a connection. |
|
270 result = CreateStartDefaultConnection(); |
|
271 if(result != KErrNone) |
|
272 return result; |
|
273 |
|
274 _LIT(KName, "LANBearer\\Agent"); |
|
275 TBufC<21> name(KName); |
|
276 TBuf8<128> desval8; |
|
277 |
|
278 result =SendReceive(ECNGetDes8Setting,TIpcArgs(&name, &desval8, 0, iSSRef)); |
|
279 |
|
280 //-- stop and close connection |
|
281 StopCloseConnection(); |
|
282 |
|
283 return result; |
|
284 } |
|
285 |
|
286 //------------------------------------------------------------------------------------------------------ |
|
287 // testing |
|
288 // RConnection::ECNGetDes16Setting |
|
289 // Requires alive connection. Uses Ethernet one |
|
290 //------------------------------------------------------------------------------------------------------ |
|
291 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNGetDes16Setting>) |
|
292 { |
|
293 TInt result; |
|
294 |
|
295 //-- 1. Create and start a connection. |
|
296 result = CreateStartDefaultConnection(); |
|
297 if(result != KErrNone) |
|
298 return result; |
|
299 |
|
300 _LIT(KName, "LANBearer\\Agent"); |
|
301 TBufC<21> name(KName); |
|
302 TBuf16<128> desval16; |
|
303 |
|
304 result =SendReceive(ECNGetDes16Setting,TIpcArgs(&name, &desval16, 0, iSSRef)); |
|
305 |
|
306 //-- stop and close connection |
|
307 StopCloseConnection(); |
|
308 |
|
309 return result; |
|
310 } |
|
311 |
|
312 //------------------------------------------------------------------------------------------------------ |
|
313 // testing |
|
314 // RConnection::ECNGetLongDesSetting |
|
315 // Requires alive connection. Uses Ethernet one |
|
316 //------------------------------------------------------------------------------------------------------ |
|
317 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNGetLongDesSetting>) |
|
318 { |
|
319 TInt result; |
|
320 |
|
321 //-- 1. Create and start a connection. |
|
322 result = CreateStartDefaultConnection(); |
|
323 if(result != KErrNone) |
|
324 return result; |
|
325 |
|
326 _LIT(KName, "LANBearer\\Agent"); |
|
327 TBufC<23> name(KName); |
|
328 TBuf<128> longdesval; |
|
329 |
|
330 result =SendReceive(ECNGetLongDesSetting,TIpcArgs(&name, &longdesval, 0, iSSRef)); |
|
331 |
|
332 //-- stop and close connection |
|
333 StopCloseConnection(); |
|
334 |
|
335 return result; |
|
336 } |
|
337 |
|
338 //------------------------------------------------------------------------------------------------------ |
|
339 // testing |
|
340 // RConnection::ECNStart |
|
341 //------------------------------------------------------------------------------------------------------ |
|
342 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNCreate>) |
|
343 { |
|
344 TInt result; |
|
345 |
|
346 //-- 1. Create (Open) a connection |
|
347 const TUint KConnectionType = KAfInet; |
|
348 TPckgBuf<TInt> session(iSSRef); |
|
349 |
|
350 result = SendReceive(ECNCreate,TIpcArgs(KConnectionType, 0, 0, &session)); |
|
351 iSSRef = session(); //-- this is the esock subsession handle |
|
352 |
|
353 //-- close connection |
|
354 CloseConnection(); |
|
355 |
|
356 return result; |
|
357 } |
|
358 |
|
359 //------------------------------------------------------------------------------------------------------ |
|
360 // testing |
|
361 // RConnection::ECNCreate |
|
362 //------------------------------------------------------------------------------------------------------ |
|
363 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNCreateWithName>) |
|
364 { |
|
365 TInt result; |
|
366 |
|
367 //-- 1. Create a connection. |
|
368 result = CreateConnection(); |
|
369 if(result != KErrNone) |
|
370 return result; |
|
371 |
|
372 TName connName; |
|
373 result =SendReceive(ECNReference,TIpcArgs(&connName, 0, 0, iSSRef)); |
|
374 if (result != KErrNone) |
|
375 return result; |
|
376 |
|
377 result = SendReceive(ECNCreateWithName,TIpcArgs(&connName, 0, 0, iSSRef)); |
|
378 |
|
379 //-- close connection |
|
380 CloseConnection(); |
|
381 |
|
382 return result; |
|
383 } |
|
384 //------------------------------------------------------------------------------------------------------ |
|
385 // testing |
|
386 // RConnection::ECNStart |
|
387 //------------------------------------------------------------------------------------------------------ |
|
388 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNStart>) |
|
389 { |
|
390 TInt result; |
|
391 |
|
392 //-- 1. Create a connection. |
|
393 result = CreateConnection(); |
|
394 if(result != KErrNone) |
|
395 return result; |
|
396 |
|
397 //-- 2. start the connection |
|
398 result = SendReceive(ECNStart,TIpcArgs(0,0,0,iSSRef)); |
|
399 |
|
400 //-- stop and close connection |
|
401 StopCloseConnection(); |
|
402 |
|
403 return result; |
|
404 } |
|
405 |
|
406 //------------------------------------------------------------------------------------------------------ |
|
407 // testing |
|
408 // RConnection::ECNSetStartPrefs |
|
409 //------------------------------------------------------------------------------------------------------ |
|
410 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNSetStartPrefs>) |
|
411 { |
|
412 TInt result; |
|
413 |
|
414 //-- 1. Create a connection. |
|
415 result = CreateConnection(); |
|
416 if(result != KErrNone) |
|
417 return result; |
|
418 |
|
419 //-- 2. start connection with preferences |
|
420 TCommDbConnPref prefs; |
|
421 prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); |
|
422 |
|
423 result =SendReceive(ECNSetStartPrefs,TIpcArgs(&prefs, 0, 0, iSSRef)); |
|
424 if (result == KErrNone) |
|
425 { |
|
426 // Continue starting connection so that session is not left in a half-started state |
|
427 // Note this may fail, but the test succeeds based on "result" since that is the IPC being tested |
|
428 TInt err = SendReceive(ECNStart,TIpcArgs(0,0,0,iSSRef)); |
|
429 } |
|
430 |
|
431 //-- stop and close connection |
|
432 StopCloseConnection(); |
|
433 |
|
434 return result; |
|
435 } |
|
436 |
|
437 //------------------------------------------------------------------------------------------------------ |
|
438 // testing |
|
439 // RConnection::ECNStop |
|
440 //------------------------------------------------------------------------------------------------------ |
|
441 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNStop>) |
|
442 { |
|
443 TInt result; |
|
444 |
|
445 //-- 1. Create and start a connection. |
|
446 result = CreateStartDefaultConnection(); |
|
447 if(result != KErrNone) |
|
448 return result; |
|
449 |
|
450 //-- 2. start the connection |
|
451 result = SendReceive(ECNStop,TIpcArgs(RConnection::EStopAuthoritative,0,0,iSSRef)); |
|
452 |
|
453 //-- stop and close connection |
|
454 CloseConnection(); |
|
455 |
|
456 return result; |
|
457 } |
|
458 |
|
459 //------------------------------------------------------------------------------------------------------ |
|
460 // testing |
|
461 // RConnection::ECNReference |
|
462 //------------------------------------------------------------------------------------------------------ |
|
463 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNCancelIoctl>) |
|
464 { |
|
465 TInt result; |
|
466 |
|
467 //-- 1. Create a connection. |
|
468 result = CreateConnection(); |
|
469 if(result != KErrNone) |
|
470 return result; |
|
471 |
|
472 result =SendReceive(ECNCancelIoctl,TIpcArgs(0, 0, 0, iSSRef)); |
|
473 |
|
474 //-- close connection |
|
475 CloseConnection(); |
|
476 |
|
477 return result; |
|
478 } |
|
479 |
|
480 |
|
481 //------------------------------------------------------------------------------------------------------ |
|
482 // testing |
|
483 // RConnection::ECNReference |
|
484 //------------------------------------------------------------------------------------------------------ |
|
485 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNReference>) |
|
486 { |
|
487 TInt result; |
|
488 |
|
489 //-- 1. Create a connection. |
|
490 result = CreateConnection(); |
|
491 if(result != KErrNone) |
|
492 return result; |
|
493 |
|
494 TName connName; |
|
495 result =SendReceive(ECNReference,TIpcArgs(&connName, 0, 0, iSSRef)); |
|
496 |
|
497 //-- close connection |
|
498 CloseConnection(); |
|
499 |
|
500 return result; |
|
501 } |
|
502 |
|
503 //------------------------------------------------------------------------------------------------------ |
|
504 // testing |
|
505 // RConnection::ECNProgress |
|
506 //------------------------------------------------------------------------------------------------------ |
|
507 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNProgress>) |
|
508 { |
|
509 TInt result; |
|
510 |
|
511 //-- 1. Create a connection. |
|
512 result = CreateConnection(); |
|
513 if(result != KErrNone) |
|
514 return result; |
|
515 |
|
516 TNifProgress progr; |
|
517 TPckg<TNifProgress> progrPckg(progr); |
|
518 |
|
519 result =SendReceive(ECNProgress,TIpcArgs(&progrPckg, 0, 0, iSSRef)); |
|
520 |
|
521 //-- close connection |
|
522 CloseConnection(); |
|
523 |
|
524 return result; |
|
525 |
|
526 } |
|
527 |
|
528 |
|
529 //------------------------------------------------------------------------------------------------------ |
|
530 // testing |
|
531 // RConnection::ECNLastProgressError |
|
532 //------------------------------------------------------------------------------------------------------ |
|
533 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNLastProgressError>) |
|
534 { |
|
535 TInt result; |
|
536 |
|
537 //-- 1. Create a connection. |
|
538 result = CreateConnection(); |
|
539 if(result != KErrNone) |
|
540 return result; |
|
541 |
|
542 TNifProgress progr; |
|
543 TPckg<TNifProgress> progrPckg(progr); |
|
544 |
|
545 result =SendReceive(ECNLastProgressError,TIpcArgs(&progrPckg, 0, 0, iSSRef)); |
|
546 |
|
547 //-- close connection |
|
548 CloseConnection(); |
|
549 |
|
550 return result; |
|
551 } |
|
552 |
|
553 //------------------------------------------------------------------------------------------------------ |
|
554 // testing |
|
555 // RConnection::ECNEnnumerateConnections |
|
556 // Requires alive connection. Uses Ethernet one |
|
557 //------------------------------------------------------------------------------------------------------ |
|
558 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNEnumerateConnections>) |
|
559 { |
|
560 TInt result; |
|
561 |
|
562 //-- 1. Create (Open) a connection |
|
563 result = CreateConnection(); |
|
564 |
|
565 if(result != KErrNone) |
|
566 return result; |
|
567 |
|
568 TUint count=0; |
|
569 TPckg<TUint> countPckg(count); |
|
570 |
|
571 //-- enumerate connections |
|
572 result = SendReceive(ECNEnumerateConnections,TIpcArgs(&countPckg, 0, 0, iSSRef)); |
|
573 |
|
574 //-- close connection |
|
575 CloseConnection(); |
|
576 |
|
577 return result; |
|
578 } |
|
579 |
|
580 //------------------------------------------------------------------------------------------------------ |
|
581 // testing |
|
582 // RConnection::ECNGetConnectionInfo |
|
583 // Requires alive connection. Uses Ethernet one |
|
584 //------------------------------------------------------------------------------------------------------ |
|
585 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNGetConnectionInfo>) |
|
586 { |
|
587 TInt result; |
|
588 |
|
589 //-- 1. Create and start a connection. |
|
590 result = CreateStartDefaultConnection(); |
|
591 if(result != KErrNone) |
|
592 return result; |
|
593 |
|
594 TPckgBuf<TConnectionInfo> connInfoBuf; |
|
595 |
|
596 //-- get connection info |
|
597 result =SendReceive(ECNGetConnectionInfo,TIpcArgs(1, &connInfoBuf, 0, iSSRef)); |
|
598 |
|
599 //-- stop and close connection |
|
600 StopCloseConnection(); |
|
601 |
|
602 return result; |
|
603 |
|
604 } |
|
605 |
|
606 //------------------------------------------------------------------------------------------------------ |
|
607 // testing |
|
608 // RConnection::ESCPSGetSubConnectionInfo |
|
609 // Requires alive connection. Uses Ethernet one |
|
610 //------------------------------------------------------------------------------------------------------ |
|
611 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESCPSGetSubConnectionInfo>) |
|
612 { |
|
613 |
|
614 TInt result; |
|
615 |
|
616 //-- 1. Create and start a connection. |
|
617 result = CreateStartDefaultConnection(); |
|
618 if(result != KErrNone) |
|
619 return result; |
|
620 |
|
621 TPckgBuf<TSubConnectionInfo> subConnInfoBuf; |
|
622 |
|
623 //-- get subconnection info |
|
624 result =SendReceive(ESCPSGetSubConnectionInfo,TIpcArgs(1, &subConnInfoBuf, 0, iSSRef)); |
|
625 |
|
626 //-- stop and close connection |
|
627 StopCloseConnection(); |
|
628 |
|
629 return result; |
|
630 } |
|
631 |
|
632 |
|
633 |
|
634 //------------------------------------------------------------------------------------------------------ |
|
635 // testing |
|
636 // RConnection::ECNEnumerateSubConnections |
|
637 // Requires alive connection. Uses Ethernet one |
|
638 //------------------------------------------------------------------------------------------------------ |
|
639 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNEnumerateSubConnections>) |
|
640 { |
|
641 TInt result; |
|
642 |
|
643 //-- 1. Create and start a connection. |
|
644 result = CreateStartDefaultConnection(); |
|
645 if(result != KErrNone) |
|
646 return result; |
|
647 |
|
648 TUint count=0; |
|
649 TPckg<TUint> countPckg(count); |
|
650 |
|
651 //-- enumerate subconnections |
|
652 result =SendReceive(ECNEnumerateSubConnections,TIpcArgs(&countPckg, 0, 0, iSSRef)); |
|
653 |
|
654 //-- stop and close connection |
|
655 StopCloseConnection(); |
|
656 |
|
657 return result; |
|
658 } |
|
659 |
|
660 |
|
661 //------------------------------------------------------------------------------------------------------ |
|
662 // testing |
|
663 // RConnection::ESCPSIsSubConnectionActiveRequest and ESCPSIsSubConnectionActiveCancel |
|
664 // Requires alive connection. Uses Ethernet one |
|
665 //------------------------------------------------------------------------------------------------------ |
|
666 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESCPSIsSubConnectionActiveRequest>) |
|
667 { |
|
668 TInt result; |
|
669 |
|
670 //-- 1. Create and start a connection. |
|
671 result = CreateStartDefaultConnection(); |
|
672 if(result != KErrNone) |
|
673 return result; |
|
674 |
|
675 TRequestStatus rqStat; |
|
676 TBool state = EFalse; |
|
677 TPckg<TBool> stateDes(state); |
|
678 const TUint secs=2; |
|
679 const TUint KSubConnectionId = KAfInet; |
|
680 |
|
681 //-- make a request |
|
682 SendReceive(ESCPSIsSubConnectionActiveRequest,TIpcArgs(KSubConnectionId, secs, &stateDes, iSSRef), rqStat); |
|
683 result = rqStat.Int(); |
|
684 if((result != KErrNone) && (result != KRequestPending)) |
|
685 { |
|
686 StopCloseConnection(); |
|
687 return result; |
|
688 } |
|
689 |
|
690 //-- now cancel the notification subscription |
|
691 result = SendReceive(ESCPSIsSubConnectionActiveCancel,TIpcArgs(KSubConnectionId, 0, 0, iSSRef)); |
|
692 User::WaitForRequest(rqStat); |
|
693 |
|
694 //-- stop and close connection |
|
695 StopCloseConnection(); |
|
696 |
|
697 return result; |
|
698 } |
|
699 |
|
700 |
|
701 //------------------------------------------------------------------------------------------------------ |
|
702 // testing |
|
703 // RConnection::ESCPSDataReceivedNotificationRequest and ESCPSDataReceivedNotificationCancel |
|
704 // Requires alive connection. Uses Ethernet one |
|
705 //------------------------------------------------------------------------------------------------------ |
|
706 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESCPSDataReceivedNotificationRequest>) |
|
707 { |
|
708 TInt result; |
|
709 |
|
710 //-- 1. Create and start a connection. |
|
711 result = CreateStartDefaultConnection(); |
|
712 if(result != KErrNone) |
|
713 return result; |
|
714 |
|
715 TRequestStatus rqStat; |
|
716 TUint vol = 0; |
|
717 TPckg<TUint> volPckg(vol); |
|
718 const TUint KLowThresholdSize = 1024; |
|
719 const TUint KSubConnectionId = KAfInet; |
|
720 |
|
721 //-- request data transferred values. |
|
722 SendReceive(ESCPSDataReceivedNotificationRequest,TIpcArgs(KSubConnectionId, KLowThresholdSize, &volPckg, iSSRef), rqStat); |
|
723 result = rqStat.Int(); |
|
724 if((result != KErrNone) && (result != KRequestPending)) |
|
725 { |
|
726 StopCloseConnection(); |
|
727 return result; |
|
728 } |
|
729 |
|
730 //-- now cancel the notification subscription |
|
731 result = SendReceive(ESCPSDataReceivedNotificationCancel,TIpcArgs(KSubConnectionId, 0, 0, iSSRef)); |
|
732 User::WaitForRequest(rqStat); |
|
733 |
|
734 //-- stop and close connection |
|
735 StopCloseConnection(); |
|
736 |
|
737 return result; |
|
738 |
|
739 } |
|
740 |
|
741 |
|
742 |
|
743 //------------------------------------------------------------------------------------------------------ |
|
744 // testing |
|
745 // RConnection::ESCPSDataSentNotificationRequest and ESCPSDataSentNotificationCancel |
|
746 // Requires alive connection. Uses Ethernet one |
|
747 //------------------------------------------------------------------------------------------------------ |
|
748 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESCPSDataSentNotificationRequest>) |
|
749 { |
|
750 TInt result; |
|
751 |
|
752 //-- 1. Create and start a connection. |
|
753 result = CreateStartDefaultConnection(); |
|
754 if(result != KErrNone) |
|
755 return result; |
|
756 |
|
757 TRequestStatus rqStat; |
|
758 TUint vol = 0; |
|
759 TPckg<TUint> volPckg(vol); |
|
760 const TUint KLowThresholdSize = 1024; |
|
761 const TUint KSubConnectionId = KAfInet; |
|
762 |
|
763 //-- request data sent notification. |
|
764 SendReceive(ESCPSDataSentNotificationRequest,TIpcArgs(KSubConnectionId, KLowThresholdSize, &volPckg, iSSRef), rqStat); |
|
765 result = rqStat.Int(); |
|
766 if((result != KErrNone) && (result != KRequestPending)) |
|
767 { |
|
768 StopCloseConnection(); |
|
769 return result; |
|
770 } |
|
771 |
|
772 //-- now cancel the notification subscription |
|
773 result = SendReceive(ESCPSDataSentNotificationCancel,TIpcArgs(KSubConnectionId, 0, 0, iSSRef)); |
|
774 User::WaitForRequest(rqStat); |
|
775 |
|
776 //-- stop and close connection |
|
777 StopCloseConnection(); |
|
778 |
|
779 return result; |
|
780 |
|
781 } |
|
782 |
|
783 //------------------------------------------------------------------------------------------------------ |
|
784 // testing |
|
785 // RConnection::ESCPSDataTransferred and ESCPSDataTransferredCancel |
|
786 // Requires alive connection. Uses Ethernet one |
|
787 //------------------------------------------------------------------------------------------------------ |
|
788 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ESCPSDataTransferred>) |
|
789 { |
|
790 TInt result; |
|
791 |
|
792 //-- 1. Create and start a connection. |
|
793 result = CreateStartDefaultConnection(); |
|
794 if(result != KErrNone) |
|
795 return result; |
|
796 |
|
797 TRequestStatus rqStat; |
|
798 TUint uplinkVol = 0; |
|
799 TUint downlinkVol = 0; |
|
800 |
|
801 TPckg<TUint> uplinkVolPckg(uplinkVol); |
|
802 TPckg<TUint> downlinkVolPckg(downlinkVol); |
|
803 |
|
804 //-- request data transferred values. |
|
805 SendReceive(ESCPSDataTransferred,TIpcArgs(0, &uplinkVolPckg, &downlinkVolPckg, iSSRef), rqStat); |
|
806 result = rqStat.Int(); |
|
807 if((result != KErrNone) && (result != KRequestPending)) |
|
808 { |
|
809 StopCloseConnection(); |
|
810 return result; |
|
811 } |
|
812 |
|
813 //-- now cancel the notification subscription |
|
814 result = SendReceive(ESCPSDataTransferredCancel,TIpcArgs(0, 0, 0, iSSRef)); |
|
815 User::WaitForRequest(rqStat); |
|
816 |
|
817 //-- stop and close connection |
|
818 StopCloseConnection(); |
|
819 |
|
820 return result; |
|
821 } |
|
822 |
|
823 //------------------------------------------------------------------------------------------------------ |
|
824 // testing |
|
825 // RConnection::ECNAllSubConnectionNotification and ECNCancelAllSubConnectionNotification |
|
826 //------------------------------------------------------------------------------------------------------ |
|
827 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNAllSubConnectionNotification>) |
|
828 { |
|
829 TInt result; |
|
830 |
|
831 //-- 1. Create a connection. |
|
832 result = CreateConnection(); |
|
833 if(result != KErrNone) |
|
834 return result; |
|
835 |
|
836 TRequestStatus rqStat; |
|
837 TSubConnectionNotificationBuf info; |
|
838 |
|
839 //-- subscribe to the all interfaces notification |
|
840 SendReceive(ECNAllSubConnectionNotification,TIpcArgs(&info, 0, 0, iSSRef), rqStat); |
|
841 result = rqStat.Int(); |
|
842 if((result != KErrNone) && (result != KRequestPending)) |
|
843 { |
|
844 CloseConnection(); |
|
845 return result; |
|
846 } |
|
847 |
|
848 //-- now cancel the notification subscription |
|
849 result = SendReceive(ECNCancelAllSubConnectionNotification,TIpcArgs(0, 0, 0, iSSRef)); |
|
850 User::WaitForRequest(rqStat); |
|
851 |
|
852 //-- close connection |
|
853 CloseConnection(); |
|
854 |
|
855 return result; |
|
856 } |
|
857 |
|
858 //------------------------------------------------------------------------------------------------------ |
|
859 // testing |
|
860 // RConnection::ECNAllInterfaceNotification and ECNCancelServiceChangeNotification |
|
861 //------------------------------------------------------------------------------------------------------ |
|
862 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNAllInterfaceNotification>) |
|
863 { |
|
864 TInt result; |
|
865 |
|
866 //-- 1. Create a connection. |
|
867 result = CreateConnection(); |
|
868 if(result != KErrNone) |
|
869 return result; |
|
870 |
|
871 TRequestStatus rqStat; |
|
872 TInterfaceNotificationBuf info; |
|
873 |
|
874 //-- subscribe to the all interfaces notification |
|
875 SendReceive(ECNAllInterfaceNotification,TIpcArgs(&info, 0, 0, iSSRef), rqStat); |
|
876 result = rqStat.Int(); |
|
877 if((result != KErrNone) && (result != KRequestPending)) |
|
878 { |
|
879 CloseConnection(); |
|
880 return result; |
|
881 } |
|
882 |
|
883 //-- now cancel the notification subscription |
|
884 result = SendReceive(ECNCancelAllInterfaceNotification,TIpcArgs(0, 0, 0, iSSRef)); |
|
885 User::WaitForRequest(rqStat); |
|
886 |
|
887 //-- close connection |
|
888 CloseConnection(); |
|
889 |
|
890 return result; |
|
891 } |
|
892 |
|
893 //------------------------------------------------------------------------------------------------------ |
|
894 // testing |
|
895 // RConnection::ECNServiceChangeNotification and ECNCancelServiceChangeNotification |
|
896 //------------------------------------------------------------------------------------------------------ |
|
897 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNServiceChangeNotification>) |
|
898 { |
|
899 TInt result; |
|
900 |
|
901 //-- 1. Create a connection. |
|
902 result = CreateConnection(); |
|
903 if(result != KErrNone) |
|
904 return result; |
|
905 |
|
906 TRequestStatus rqStat; |
|
907 TBuf<20> newServiceType; |
|
908 TUint32 isp=0; |
|
909 TPckg<TUint> ispPckg(isp); |
|
910 |
|
911 //-- subscribe to the service change notification |
|
912 SendReceive(ECNServiceChangeNotification,TIpcArgs(&ispPckg, &newServiceType, 0, iSSRef), rqStat); |
|
913 result = rqStat.Int(); |
|
914 if((result != KErrNone) && (result != KRequestPending)) |
|
915 { |
|
916 CloseConnection(); |
|
917 return result; |
|
918 } |
|
919 |
|
920 //-- now cancel the service change notification |
|
921 result = SendReceive(ECNCancelServiceChangeNotification,TIpcArgs(0, 0, 0, iSSRef)); |
|
922 User::WaitForRequest(rqStat); |
|
923 |
|
924 //-- close connection |
|
925 CloseConnection(); |
|
926 |
|
927 return result; |
|
928 } |
|
929 |
|
930 //------------------------------------------------------------------------------------------------------ |
|
931 // testing |
|
932 // RConnection::ECNProgressNotification and ECNCancelProgressNotification, |
|
933 //------------------------------------------------------------------------------------------------------ |
|
934 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNProgressNotification>) |
|
935 { |
|
936 TInt result; |
|
937 |
|
938 //-- 1. Create a connection. |
|
939 result = CreateConnection(); |
|
940 if(result != KErrNone) |
|
941 return result; |
|
942 |
|
943 TNifProgressBuf nifProgrBuf; |
|
944 TRequestStatus rqStat; |
|
945 |
|
946 //-- subscribe to the progress notification |
|
947 SendReceive(ECNProgressNotification,TIpcArgs(&nifProgrBuf, KConnProgressDefault, 0, iSSRef), rqStat); |
|
948 result = rqStat.Int(); |
|
949 if((result != KErrNone) && (result != KRequestPending)) |
|
950 { |
|
951 CloseConnection(); |
|
952 return result; |
|
953 } |
|
954 |
|
955 //-- now cancel the progress notification |
|
956 result = SendReceive(ECNCancelProgressNotification,TIpcArgs(0, 0, 0, iSSRef)); |
|
957 User::WaitForRequest(rqStat); |
|
958 |
|
959 //-- close connection |
|
960 CloseConnection(); |
|
961 |
|
962 return result; |
|
963 } |
|
964 |
|
965 |
|
966 //------------------------------------------------------------------------------------------------------ |
|
967 // testing |
|
968 // RConnection::ECNIoctl (DHCP stuff) at KCOLConfiguration level. |
|
969 // Requires alive connection. Uses Ethernet one |
|
970 //------------------------------------------------------------------------------------------------------ |
|
971 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNIoctl>) |
|
972 { |
|
973 |
|
974 TInt result; |
|
975 |
|
976 //-- 1. Create and start default connection |
|
977 result = CreateStartDefaultConnection(); |
|
978 if(result != KErrNone) |
|
979 { |
|
980 return result; |
|
981 } |
|
982 |
|
983 //------------------------------------------------------ |
|
984 //-- this part is for testing RConfigDaemon functionality. |
|
985 //-- Tests direct IOCTL calls to the DHCP server. |
|
986 //-- this is distinguished by using magin numbers in the message.csv file, look below. |
|
987 if(PARAM_MESS_OPTLEVEL == KMagicConfigDaemonTestLevel && PARAM_MESS_OPTNAME == KMagicConfigDaemonTestOption) |
|
988 { |
|
989 StopCloseConnection(); |
|
990 return test_RConfigDaemon(); |
|
991 } |
|
992 //------------------------------------------------------ |
|
993 |
|
994 //-- 2. perform the RConnection::IOCTL |
|
995 TBuf8<128> paramBuf; //-- buffer receiving IOCTL result data. No one cares about the actual result, so the buffer is generic. |
|
996 |
|
997 result = SendReceive(ECNIoctl,TIpcArgs(PARAM_MESS_OPTLEVEL, PARAM_MESS_OPTNAME, ¶mBuf, iSSRef)); |
|
998 |
|
999 //-- 3. close the connection |
|
1000 StopCloseConnection(); |
|
1001 |
|
1002 return result; |
|
1003 |
|
1004 } |
|
1005 |
|
1006 //------------------------------------------------------------------------------------------------------ |
|
1007 // testing |
|
1008 // RConnection::SetOpt() at KCOLProvider level. |
|
1009 // RConnection:Control() at KCOLConnection level. |
|
1010 // Requires alive connection. Uses Ethernet one |
|
1011 //------------------------------------------------------------------------------------------------------ |
|
1012 TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<ECNControl>) |
|
1013 { |
|
1014 |
|
1015 TInt result = KErrNone; |
|
1016 |
|
1017 //-- 1. Create and start default connection. Also performs connections enumeration |
|
1018 result = CreateStartDefaultConnection(); |
|
1019 if(result != KErrNone) |
|
1020 return result; |
|
1021 |
|
1022 //-- call test function depending on the option level and name. |
|
1023 //-- this looks messy because opt. values for differrent opt names can be the same. |
|
1024 if(PARAM_MESS_OPTLEVEL == KCOLProvider) |
|
1025 switch(PARAM_MESS_OPTNAME) |
|
1026 { |
|
1027 |
|
1028 case KConnDisableTimers: |
|
1029 result = test_KConnDisableTimers(); |
|
1030 break; |
|
1031 |
|
1032 case KConnGetInterfaceName: |
|
1033 result = test_KConnGetInterfaceName(); |
|
1034 break; |
|
1035 |
|
1036 default: |
|
1037 TESTL(EFalse); |
|
1038 break; |
|
1039 |
|
1040 } |
|
1041 |
|
1042 if(PARAM_MESS_OPTLEVEL == KCOLConnection) |
|
1043 switch(PARAM_MESS_OPTNAME) |
|
1044 { |
|
1045 case KCoEnumerateConnectionClients: |
|
1046 result = test_KCoEnumerateConnectionClients(); |
|
1047 break; |
|
1048 |
|
1049 case KCoGetConnectionClientInfo: |
|
1050 result = test_KCoGetConnectionClientInfo(); |
|
1051 break; |
|
1052 |
|
1053 case KCoEnumerateConnectionSockets: |
|
1054 result = test_KCoEnumerateConnectionSockets(); |
|
1055 break; |
|
1056 |
|
1057 case KCoGetConnectionSocketInfo: |
|
1058 result = test_KCoGetConnectionSocketInfo(); |
|
1059 break; |
|
1060 |
|
1061 default: |
|
1062 TESTL(EFalse); |
|
1063 break; |
|
1064 |
|
1065 } |
|
1066 |
|
1067 if(PARAM_MESS_OPTLEVEL == KCOLInterface) |
|
1068 result = test_KCOLInterface(); |
|
1069 |
|
1070 if(PARAM_MESS_OPTLEVEL == KCOLAgent) |
|
1071 result = test_KCOLAgent(); |
|
1072 |
|
1073 |
|
1074 |
|
1075 //-- close the connection |
|
1076 StopCloseConnection(); |
|
1077 |
|
1078 |
|
1079 return result; |
|
1080 } |
|
1081 |
|
1082 //------------------------------------------------------------------------------------------------------ |
|
1083 |
|
1084 TInt CPARAM_MESS_NAMEStep::test_KConnDisableTimers() |
|
1085 { |
|
1086 return ConnectionSetOpt(KCOLProvider, KConnDisableTimers, 1); |
|
1087 } |
|
1088 |
|
1089 TInt CPARAM_MESS_NAMEStep::test_KConnGetInterfaceName() |
|
1090 { |
|
1091 TConnInterfaceName name; |
|
1092 name.iIndex = 1; |
|
1093 TPckg<TConnInterfaceName> namePkg(name); |
|
1094 |
|
1095 return ConnectionControl(KCOLProvider, KConnGetInterfaceName, namePkg); |
|
1096 } |
|
1097 |
|
1098 |
|
1099 TInt CPARAM_MESS_NAMEStep::test_KCoEnumerateConnectionClients() |
|
1100 { |
|
1101 TConnEnumArgBuf connEnumBuf; |
|
1102 connEnumBuf().iIndex = 1; |
|
1103 return ConnectionControl(KCOLConnection, KCoEnumerateConnectionClients, connEnumBuf); |
|
1104 } |
|
1105 |
|
1106 TInt CPARAM_MESS_NAMEStep::test_KCoGetConnectionClientInfo() |
|
1107 { |
|
1108 TConnGetClientInfoArgBuf connCliInfoBuf; |
|
1109 connCliInfoBuf().iIndex = 1; |
|
1110 return ConnectionControl(KCOLConnection, KCoGetConnectionClientInfo, connCliInfoBuf); |
|
1111 } |
|
1112 |
|
1113 TInt CPARAM_MESS_NAMEStep::test_KCoEnumerateConnectionSockets() |
|
1114 { |
|
1115 TConnEnumArgBuf connEnumBuf; |
|
1116 connEnumBuf().iIndex = 1; |
|
1117 return ConnectionControl(KCOLConnection, KCoEnumerateConnectionSockets, connEnumBuf); |
|
1118 } |
|
1119 |
|
1120 TInt CPARAM_MESS_NAMEStep::test_KCoGetConnectionSocketInfo() |
|
1121 { |
|
1122 TConnGetSocketInfoArgBuf connSockInfoBuf; |
|
1123 |
|
1124 connSockInfoBuf().iIndex = 1; |
|
1125 TInt result = ConnectionControl(KCOLConnection, KCoGetConnectionSocketInfo, connSockInfoBuf); |
|
1126 if(result == KErrNotFound) |
|
1127 result = KErrNone; //-- no sockets found, but this is a positive result anyway. |
|
1128 |
|
1129 return result; |
|
1130 } |
|
1131 |
|
1132 TInt CPARAM_MESS_NAMEStep::test_KCOLInterface() |
|
1133 { |
|
1134 TInt value = 0; |
|
1135 TPckg<TInt> valueBuf(value); |
|
1136 |
|
1137 TInt nRes = ConnectionControl(KCOLInterface, 0, valueBuf); |
|
1138 if(nRes == KErrNotSupported) |
|
1139 nRes = KErrNone; //-- if thist option is not supported by nif and there is no capabilities conflict, then it's OK. |
|
1140 |
|
1141 return nRes; |
|
1142 |
|
1143 } |
|
1144 |
|
1145 TInt CPARAM_MESS_NAMEStep::test_KCOLAgent() |
|
1146 { |
|
1147 TInt value = 0; |
|
1148 TPckg<TInt> valueBuf(value); |
|
1149 |
|
1150 TInt nRes = ConnectionControl(KCOLAgent, 0, valueBuf); |
|
1151 if(nRes == KErrNotSupported) |
|
1152 nRes = KErrNone; //-- if thist option is not supported by nif and there is no capabilities conflict, then it's OK. |
|
1153 |
|
1154 return nRes; |
|
1155 } |
|
1156 |
|
1157 //------------------------------------------------------------------------------------------------------ |
|
1158 |
|
1159 /** |
|
1160 Performing ECNControl actions. |
|
1161 */ |
|
1162 TInt CPARAM_MESS_NAMEStep::ConnectionControl(TUint aOptionLevel, TUint aOptionName, TDes8& aOption) |
|
1163 { |
|
1164 return SendReceive(ECNControl, TIpcArgs(aOptionLevel, aOptionName, &aOption, iSSRef)); |
|
1165 } |
|
1166 |
|
1167 |
|
1168 /** |
|
1169 Performing ECNControl actions. |
|
1170 */ |
|
1171 TInt CPARAM_MESS_NAMEStep::ConnectionSetOpt(TUint aOptionLevel, TUint aOptionName, TInt aOption) |
|
1172 { |
|
1173 TPtr8 optionDes((TUint8*)&aOption, sizeof(TInt), sizeof(TInt)); |
|
1174 aOptionName &= ~KConnWriteUserDataBit; |
|
1175 return ConnectionControl(aOptionLevel, aOptionName, optionDes); |
|
1176 |
|
1177 } |
|
1178 |
|
1179 |
|
1180 |
|
1181 /** |
|
1182 Create a connection. |
|
1183 */ |
|
1184 TInt CPARAM_MESS_NAMEStep::CreateConnection() |
|
1185 { |
|
1186 TInt result; |
|
1187 |
|
1188 //-- 1. Create (Open) a connection |
|
1189 const TUint KConnectionType = KAfInet; |
|
1190 TPckgBuf<TInt> session(iSSRef); |
|
1191 |
|
1192 result = SendReceive(ECNCreate,TIpcArgs(KConnectionType, 0, 0, &session)); |
|
1193 iSSRef = session(); //-- this is the esock subsession handle |
|
1194 |
|
1195 return result; |
|
1196 } |
|
1197 |
|
1198 |
|
1199 /** |
|
1200 Create and start a default connection |
|
1201 Also enumerates existing connections. |
|
1202 */ |
|
1203 TInt CPARAM_MESS_NAMEStep::CreateStartDefaultConnection() |
|
1204 { |
|
1205 TInt result; |
|
1206 |
|
1207 //-- 1. Create (Open) a connection |
|
1208 result = CreateConnection(); |
|
1209 |
|
1210 if(result != KErrNone) |
|
1211 return result; |
|
1212 |
|
1213 //-- 2. start the connection |
|
1214 result = SendReceive(ECNStart,TIpcArgs(0,0,0,iSSRef)); |
|
1215 if(result != KErrNone) |
|
1216 { |
|
1217 CloseConnection(); |
|
1218 return result; |
|
1219 } |
|
1220 |
|
1221 |
|
1222 //-- 3. Enumerate connections, necessarily for further activity (e.g. KCoGetConnectionSocketInfo) |
|
1223 //-- and anyway we need to test it. |
|
1224 TUint cntConn = 0; |
|
1225 TPckg<TUint> count(cntConn); |
|
1226 result =SendReceive(ECNEnumerateConnections, TIpcArgs(&count,0,0,iSSRef)); |
|
1227 |
|
1228 return result; |
|
1229 } |
|
1230 |
|
1231 |
|
1232 /** |
|
1233 Stops and closes the active connection |
|
1234 */ |
|
1235 TInt CPARAM_MESS_NAMEStep::StopCloseConnection() |
|
1236 { |
|
1237 #if 0 |
|
1238 // Stopping the connection is not strictly necessary. The test may run faster if |
|
1239 // the interface remains up (in short timer mode) across tests. |
|
1240 TInt result; |
|
1241 result = SendReceive(ECNStop,TIpcArgs(RConnection::EStopAuthoritative,0,0,iSSRef)); |
|
1242 if(result != KErrNone) |
|
1243 return result; |
|
1244 #endif |
|
1245 |
|
1246 return CloseConnection(); |
|
1247 } |
|
1248 |
|
1249 /** |
|
1250 Close the connection |
|
1251 */ |
|
1252 TInt CPARAM_MESS_NAMEStep::CloseConnection() |
|
1253 { |
|
1254 TInt result; |
|
1255 |
|
1256 //-- close the connection |
|
1257 result = SendReceive(ECNClose,TIpcArgs(0,0,0,iSSRef)); |
|
1258 |
|
1259 // Before starting a new connection wait for any old ones to go away |
|
1260 // TInt ignore = WaitForDisconnection(); |
|
1261 |
|
1262 return result; |
|
1263 } |
|
1264 |
|
1265 /** |
|
1266 After a call to close, this can be called to wait for the connection to really close down |
|
1267 */ |
|
1268 TInt CPARAM_MESS_NAMEStep::WaitForDisconnection() |
|
1269 { |
|
1270 TInt error = KErrNone; |
|
1271 if (Handle()) |
|
1272 { |
|
1273 RSocketServ ss; |
|
1274 ss.SetHandle(Handle()); |
|
1275 ss.Duplicate(RThread()); |
|
1276 RConnection mon; |
|
1277 error = mon.Open(ss, KAfInet); |
|
1278 if (error == KErrNone) |
|
1279 { |
|
1280 TRAP(error, WaitForDisconnectionL(mon)); |
|
1281 // Clean up |
|
1282 mon.Close(); |
|
1283 } |
|
1284 } |
|
1285 return error; |
|
1286 } |
|
1287 |
|
1288 void CPARAM_MESS_NAMEStep::WaitForDisconnectionL(RConnection& aMon) |
|
1289 { |
|
1290 TUint count; |
|
1291 User::LeaveIfError(aMon.EnumerateConnections(count)); |
|
1292 if (count > 0) |
|
1293 { |
|
1294 // Get the connection info if there are any connections |
|
1295 TConnectionInfoBuf info; |
|
1296 User::LeaveIfError(aMon.GetConnectionInfo(1,info)); |
|
1297 |
|
1298 // Attach a monitoring connection |
|
1299 User::LeaveIfError(aMon.Attach(info, RConnection::EAttachTypeMonitor)); |
|
1300 TNifProgressBuf progBuf; |
|
1301 TRequestStatus progStatus; |
|
1302 aMon.ProgressNotification(progBuf, progStatus, KConnectionUninitialised); |
|
1303 |
|
1304 // Wait for KLinkLayerClosed stage (or error) |
|
1305 User::WaitForRequest(progStatus); |
|
1306 User::LeaveIfError(progStatus.Int()); |
|
1307 } |
|
1308 } |
|
1309 |
|
1310 |
|
1311 |
|
1312 //------------------------------------------------------------------------------------------------------ |
|
1313 |
|
1314 /** |
|
1315 Test DHCP server API policing. |
|
1316 Connects to the DHCP server (which is supposed to be started by opening a Ethernet-oriented connection). |
|
1317 Then tries to perform IOCTL calls, expecting KErrPermissionDenied. |
|
1318 |
|
1319 @return standard error code. |
|
1320 */ |
|
1321 TInt CPARAM_MESS_NAMEStep::test_RConfigDaemon() |
|
1322 { |
|
1323 TInt result = KErrNone; |
|
1324 |
|
1325 /** |
|
1326 define a local class to talk to the DHCP daemon. We need this becase |
|
1327 files like \networking\dhcp\include\DHCP_Std.h are not exported. |
|
1328 This class represents RConfigDaemon functionality and makes sense only within this function scope. |
|
1329 */ |
|
1330 class RTestDaemonClient : public RSessionBase |
|
1331 { |
|
1332 public: |
|
1333 /** |
|
1334 Create a session to the DHCP server. beware: we had to use local definition of the KDHCPServerName because |
|
1335 DHCP_Std.h isn't accessible here |
|
1336 |
|
1337 @return standard error code. |
|
1338 */ |
|
1339 TInt CreateSession() |
|
1340 { |
|
1341 _LIT(KDHCPServerName,"!DHCPServ"); // ugly! |
|
1342 return RSessionBase::CreateSession(KDHCPServerName, TVersion()); |
|
1343 } |
|
1344 |
|
1345 /** |
|
1346 Configure DHCP server. We need this for IOCTL calls. |
|
1347 @param aStatus request status |
|
1348 @param apDes pointer to the TConnectionInfoBuf with connection properties. |
|
1349 */ |
|
1350 void Configure(TRequestStatus& aStatus, TDes8* apDes) |
|
1351 { |
|
1352 SendReceive(EConfigDaemonConfigure, TIpcArgs(apDes, 0, 0, 0), aStatus); |
|
1353 } |
|
1354 |
|
1355 /** |
|
1356 IOCTL call to the DHCP server. |
|
1357 @param aOptionLevel Option level |
|
1358 @param aOptionName Option Name |
|
1359 @param aStatus request status |
|
1360 @param apDes pointer to the packaged IOCTL data descriptor |
|
1361 */ |
|
1362 void Ioctl(TUint aOptionLevel, TUint aOptionName, TRequestStatus& aStatus, TDes8* apDes=NULL) |
|
1363 { |
|
1364 SendReceive(EConfigDaemonIoctl, TIpcArgs(aOptionLevel, aOptionName, apDes, apDes ? apDes->MaxLength() : 0), aStatus); |
|
1365 } |
|
1366 |
|
1367 }; //RTestDaemonClient |
|
1368 |
|
1369 RTestDaemonClient testDaemon; |
|
1370 |
|
1371 //-- create session to the DHCP server |
|
1372 result = testDaemon.CreateSession(); |
|
1373 testDaemon.Close(); |
|
1374 return result; |
|
1375 |
|
1376 } |
|
1377 |
|
1378 |
|
1379 |
|
1380 //------------------------------------------------------------------------------------------------------ |
|
1381 |