|
1 // Copyright (c) 2005-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 // te_spudNetworkSideSteps.cpp |
|
15 // Implements the integration tests for the SPUD using RawIpNif |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 */ |
|
23 |
|
24 |
|
25 #include "te_spudRSubConnSteps.h" |
|
26 #include <simtsy.h> |
|
27 #include <commdbconnpref.h> |
|
28 #include <nifvar.h> // Nifman Progress notifications |
|
29 #include <es_enum.h> |
|
30 #include <c32comm.h> // uniquely for the call to StartC32WithCMISuppressions |
|
31 #include <e32property.h> |
|
32 #include <ip_subconparams.h> |
|
33 |
|
34 namespace |
|
35 { |
|
36 const TInt KMaxMsgLen = 128; |
|
37 } |
|
38 /** |
|
39 Implements the pure virtual doTestStepPreambleL defined in CTestStep. |
|
40 Used to disable the phone book synchronizer |
|
41 which may cause the tests to fail. |
|
42 |
|
43 |
|
44 @return EPass if successful. |
|
45 @leave If Phonebook synchronizer disabling fails. |
|
46 */ |
|
47 TVerdict CSpudRSubConnTestStepBase::doTestStepPreambleL() |
|
48 { |
|
49 _LIT(KPhbkSyncCMI, "phbsync.cmi"); |
|
50 TInt err = StartC32WithCMISuppressions(KPhbkSyncCMI); |
|
51 TESTL(KErrNone == err || KErrAlreadyExists == err); |
|
52 INFO_PRINTF1(_L("Test Step Preamble: disabled Phonebook Synchronizer.")); |
|
53 return EPass; |
|
54 } |
|
55 |
|
56 |
|
57 /** |
|
58 Implements the pure virtual doTestStepL defined in CTestStep. |
|
59 Allows the base class to execute before any of the derived |
|
60 tests is called. |
|
61 |
|
62 @leave If any of the called methods leaves. |
|
63 */ |
|
64 TVerdict CSpudRSubConnTestStepBase::doTestStepL() |
|
65 { |
|
66 // Tell SIM.TSY which test it should load. |
|
67 // If this is removed, SIM TSY will load test 0. |
|
68 |
|
69 TInt simTsyTestNum = -1; |
|
70 ASSERT(GetIntFromConfig(ConfigSection(), _L("SimTsyTestNum"), simTsyTestNum)); |
|
71 ASSERT(simTsyTestNum >= 0); |
|
72 |
|
73 TInt ret0 = RProperty::Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,simTsyTestNum); |
|
74 if (ret0 != KErrNone) |
|
75 { |
|
76 ret0 = RProperty::Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,simTsyTestNum); |
|
77 } |
|
78 |
|
79 |
|
80 TRAPD(esockConnErr, TestL(iESock.Connect(), _L("RSockeServ::Connect"))); |
|
81 if(KErrNone != esockConnErr) |
|
82 { |
|
83 INFO_PRINTF1(_L("ESock thread is dead. Most likely, it was crashed by the previous test case. Check the Root Server logs.")); |
|
84 SetTestStepResult(EInconclusive); |
|
85 return TestStepResult(); |
|
86 } |
|
87 |
|
88 |
|
89 ASSERT(!CActiveScheduler::Current()); // We should not have an AS at this point. |
|
90 CActiveScheduler* testSched = new(ELeave) CActiveScheduler; |
|
91 CleanupStack::PushL(testSched); |
|
92 CActiveScheduler::Install(testSched); |
|
93 |
|
94 |
|
95 // Test sequence itself: |
|
96 TVerdict testResult = EFail; |
|
97 TRAPD(err, testResult = RunTestStepL()); |
|
98 if(KErrNone == err) |
|
99 { |
|
100 INFO_PRINTF1(_L("Test Step Completion.")); |
|
101 SetTestStepResult(testResult); |
|
102 } |
|
103 else |
|
104 { |
|
105 ERR_PRINTF2(_L("Test Step Failure: the step left with [%d]"), err); |
|
106 SetTestStepResult(EFail); |
|
107 } |
|
108 |
|
109 // It's ok to close everything more than once, or if not opened... |
|
110 iPrimCtxSock1.Close(); |
|
111 iScndCtxSock1.Close(); |
|
112 iSpudScndCtx1.Close(); |
|
113 iSpud.Close(); // SPUD will linger, we don't care. |
|
114 iESock.Close(); |
|
115 |
|
116 CActiveScheduler::Install(NULL); // uninstall the test scheduler |
|
117 CleanupStack::PopAndDestroy(testSched); |
|
118 |
|
119 return TestStepResult(); |
|
120 } |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 /** |
|
131 Logs a message and leaves on error |
|
132 |
|
133 @param aErrCode error code to check |
|
134 @param aMsg message to log |
|
135 @leave if aError is other than KErrNone |
|
136 */ |
|
137 void CSpudRSubConnTestStepBase::TestL(TInt aErrCode, const TDesC& aMsg) |
|
138 { |
|
139 TestL(aErrCode, KErrNone, aMsg); |
|
140 } |
|
141 |
|
142 /** |
|
143 Used to verify that an error code is what expected, and log the associated comment |
|
144 |
|
145 @param aErrCode the error code to check |
|
146 @param aExpErrCode the expected error code |
|
147 @param aMsg the message to log before testing |
|
148 @leave if aErrCode != aExpErrCode |
|
149 */ |
|
150 void CSpudRSubConnTestStepBase::TestL(TInt aErrCode, TInt aExpErrCode, const TDesC& aMsg) |
|
151 { |
|
152 if(aExpErrCode == aErrCode) |
|
153 { |
|
154 INFO_PRINTF3(_L("%S: err[%d], as expected. OK."), &aMsg, aErrCode); |
|
155 } |
|
156 else |
|
157 { |
|
158 ERR_PRINTF5(_L("%S FAILED: err[%d], expected [%d]. Leaving with [%d])."), &aMsg, aErrCode, aExpErrCode, aErrCode); |
|
159 User::Leave(aErrCode); |
|
160 } |
|
161 } |
|
162 |
|
163 /** |
|
164 Used to verify that a boolean is as expected, and log the associated comment |
|
165 |
|
166 @param aBool the boolean to check |
|
167 @param aMsg the message to log before testing |
|
168 @leave if aBool == EFalse |
|
169 */ |
|
170 void CSpudRSubConnTestStepBase::TestBooleanTrueL(TBool aBool, const TDesC& aMsg) |
|
171 { |
|
172 if(aBool) |
|
173 { |
|
174 INFO_PRINTF2(_L("%S: Value is true, as expected. OK."), &aMsg); |
|
175 } |
|
176 else |
|
177 { |
|
178 ERR_PRINTF2(_L("Failed, %S: Value is false. Leaving with KErrGeneral)."), &aMsg); |
|
179 User::Leave(KErrGeneral); |
|
180 } |
|
181 } |
|
182 |
|
183 |
|
184 |
|
185 /** |
|
186 Open and Start an interface */ |
|
187 void CSpudRSubConnTestStepBase::OpenAndStartInterfaceL(RConnection& aConn, TCommDbConnPref& aPref, TRequestStatus& aSt, const TDesC& aLogMsg) |
|
188 { |
|
189 INFO_PRINTF3(_L("%S: Opening and Starting RConnection on IAP=%d."), &aLogMsg, aPref.IapId()); |
|
190 TInt openErr = aConn.Open(iESock, KAfInet); |
|
191 TestL(openErr, KErrNone, _L("Opening RConnection")); |
|
192 aConn.Start(aPref, aSt); |
|
193 } |
|
194 |
|
195 void CSpudRSubConnTestStepBase::WaitForCompletionL(TRequestStatus& aSt, TInt aExpErrCode, const TDesC& aLogMsg) |
|
196 { |
|
197 INFO_PRINTF3(_L("%S: Waiting for completion with %d"), &aLogMsg, aExpErrCode); |
|
198 User::WaitForRequest(aSt); |
|
199 INFO_PRINTF3(_L("%S completed with status= %d"), &aLogMsg, aSt.Int()); |
|
200 TestL(aSt.Int(), aExpErrCode, aLogMsg); |
|
201 } |
|
202 |
|
203 void CSpudRSubConnTestStepBase::ReceiveOnSocketL(RSocket& aSocket, const TDesC& aLogMsg) |
|
204 { |
|
205 INFO_PRINTF2(_L("%S: Waiting to receive."), &aLogMsg); |
|
206 TRequestStatus recvSt; |
|
207 TBuf8<256> recvBuf; |
|
208 TInetAddr srcAddr; |
|
209 aSocket.RecvFrom(recvBuf, srcAddr, 0x0, recvSt); |
|
210 WaitForCompletionL(recvSt, KErrNone, _L("Received on Socket")); |
|
211 } |
|
212 |
|
213 |
|
214 void CSpudRSubConnTestStepBase::VerifyBuffersEqualL(const TDesC8& aBuf1, const TDesC8& aBuf2) |
|
215 { |
|
216 if(0 != aBuf1.Compare(aBuf2)) |
|
217 { |
|
218 INFO_PRINTF1(_L("Buffer 1 is not equal to Buffer 2. FAILURE.")); |
|
219 User::Leave(KErrCorrupt); |
|
220 } |
|
221 } |
|
222 |
|
223 void CSpudRSubConnTestStepBase::WriteReadOnSocketL(RSocket& aSocket, const TDesC& aLogMsg) |
|
224 { |
|
225 INFO_PRINTF2(_L("%S: WriteReadOnSocketL"), &aLogMsg); |
|
226 |
|
227 TRequestStatus wSt1; |
|
228 TBuf8<KMaxMsgLen> writeBuf(_L8("WRITE READ")); |
|
229 |
|
230 aSocket.Write(writeBuf, wSt1); |
|
231 WaitForCompletionL(wSt1, KErrNone, _L("Write on Socket")); |
|
232 |
|
233 TBuf8<KMaxMsgLen> readBuf; |
|
234 TRequestStatus rSt; |
|
235 aSocket.Read(readBuf, rSt); |
|
236 WaitForCompletionL(rSt, KErrNone, _L("Read on Socket")); |
|
237 |
|
238 VerifyBuffersEqualL(writeBuf, readBuf); |
|
239 } |
|
240 |
|
241 |
|
242 void CSpudRSubConnTestStepBase::SendRecvOnSocketL(RSocket& aSocket, TInetAddr& aDstAddr, const TDesC& aLogMsg) |
|
243 { |
|
244 INFO_PRINTF2(_L("%S: SendRecvOnSocketL"), &aLogMsg); |
|
245 |
|
246 TBuf8<KMaxMsgLen> sendBuf(_L8("SEND RECEIVE")); |
|
247 TRequestStatus sendSt; |
|
248 aSocket.SendTo(sendBuf, aDstAddr, 0x0, sendSt); |
|
249 WaitForCompletionL(sendSt, KErrNone, _L("Send on Socket")); |
|
250 |
|
251 TBuf8<KMaxMsgLen> recvBuf; |
|
252 TRequestStatus recvSt; |
|
253 aSocket.RecvFrom(recvBuf, aDstAddr, 0x0, recvSt); |
|
254 WaitForCompletionL(recvSt, KErrNone, _L("Receive on Socket")); |
|
255 |
|
256 VerifyBuffersEqualL(recvBuf, sendBuf); |
|
257 } |
|
258 |
|
259 void CSpudRSubConnTestStepBase::RecvSendOnSocketL(RSocket& aSocket, const TDesC& aLogMsg) |
|
260 { |
|
261 INFO_PRINTF2(_L("%S: **Bounce: RecvSendOnSocket"), &aLogMsg); |
|
262 |
|
263 |
|
264 TRequestStatus st; |
|
265 TBuf8<KMaxMsgLen> recvBuf; |
|
266 TInetAddr srcAddr; |
|
267 aSocket.RecvFrom(recvBuf, srcAddr, 0x0, st); |
|
268 WaitForCompletionL(st, KErrNone, _L("**Bounce: Receive on Socket")); |
|
269 |
|
270 aSocket.SendTo(recvBuf, srcAddr, 0x0, st); |
|
271 WaitForCompletionL(st, KErrNone, _L("**Bounce: Send on Socket")); |
|
272 } |
|
273 |
|
274 |
|
275 void CSpudRSubConnTestStepBase::OpenAndBindSocketL(RSocket& aSock, RConnection& aIface, TUint aLocalPort, const TDesC& aLogMsg) |
|
276 { |
|
277 INFO_PRINTF3(_L("%S: Opening and Binding to port= %d"), &aLogMsg, aLocalPort); |
|
278 TInt ret = aSock.Open(iESock, |
|
279 KAfInet, |
|
280 KSockDatagram, |
|
281 KProtocolInetUdp, |
|
282 aIface); |
|
283 |
|
284 TestL(ret, KErrNone, _L("Open UDP Socket")); |
|
285 |
|
286 TInetAddr localAddr; |
|
287 localAddr.SetPort(aLocalPort); |
|
288 TestL(aSock.Bind(localAddr), KErrNone, _L("Bind Socket")); |
|
289 } |
|
290 // |
|
291 |
|
292 |
|
293 /** |
|
294 Used in lieu of proper network-based server |
|
295 Open an interface, opens a socket on this interface, receives-sends udp (bounces) */ |
|
296 TVerdict CLoopbackPpp1::RunTestStepL() |
|
297 { |
|
298 // Figure out our name, so that the logging makes sense: |
|
299 TBuf<64> ourName(_L("BOUNCE")); |
|
300 ourName.AppendFormat(_L("[%x]"), this); |
|
301 |
|
302 TInt iapId = -1; |
|
303 ASSERT(GetIntFromConfig(ConfigSection(), _L("IapId"), iapId)); |
|
304 ASSERT(iapId > 0); |
|
305 |
|
306 TCommDbConnPref pref; |
|
307 pref.SetIapId(iapId); |
|
308 |
|
309 RConnection iface; |
|
310 ASSERT(KErrNone == iface.Open(iESock, KAfInet)); |
|
311 TRequestStatus startSt; |
|
312 iface.Start(pref, startSt); |
|
313 User::WaitForRequest(startSt); |
|
314 INFO_PRINTF4(_L("%S: Interface on Iap ID =%d started with error=%d."), &ourName, iapId, startSt.Int()); |
|
315 User::LeaveIfError(startSt.Int()); |
|
316 |
|
317 TInt localPort = 0x0; |
|
318 ASSERT(GetIntFromConfig(ConfigSection(), _L("UdpEchoPort"), localPort)); |
|
319 ASSERT(localPort > 0x0); |
|
320 |
|
321 RSocket bounceSock; |
|
322 OpenAndBindSocketL(bounceSock, iface, static_cast<TUint>(localPort), ourName); |
|
323 |
|
324 TInt iterations = 0; |
|
325 ASSERT(GetIntFromConfig(ConfigSection(), _L("Iterations"), iterations)); |
|
326 ASSERT(iterations > 0); |
|
327 |
|
328 for(TInt iter = 0; iter < iterations; ++iter) |
|
329 { |
|
330 RecvSendOnSocketL(bounceSock, ourName); |
|
331 } |
|
332 |
|
333 bounceSock.Close(); |
|
334 iface.Close(); // Leave interface lingering, it will be nuked when the peer PPP terminates. |
|
335 return EPass; |
|
336 } |
|
337 |
|
338 |
|
339 TBool CSpudRSubConnTestStepBase::ApplyQoSParametersL(RSubConnection& aPdpContext) |
|
340 { |
|
341 TInt qosParamSet = 0; |
|
342 ASSERT(GetIntFromConfig(ConfigSection(), _L("QoSParamSet"), qosParamSet)); |
|
343 ASSERT(qosParamSet >= 0); |
|
344 |
|
345 switch(qosParamSet) |
|
346 { |
|
347 case 0: |
|
348 return EFalse; // no qos parameters specified |
|
349 case 2: |
|
350 ApplyQoSParametersSet2L(aPdpContext); |
|
351 return ETrue; |
|
352 default: |
|
353 ASSERT(EFalse); |
|
354 return EFalse; |
|
355 } |
|
356 } |
|
357 |
|
358 void CSpudRSubConnTestStepBase::ApplyQoSParametersSet2L(RSubConnection& aPdpContext) |
|
359 { |
|
360 RSubConParameterBundle qosParams; |
|
361 CleanupClosePushL(qosParams); |
|
362 |
|
363 // Create a container for QoS sub connection parameters (Param bundle takes ownership) |
|
364 CSubConParameterFamily* qosFamily = CSubConParameterFamily::NewL(qosParams, KSubConQoSFamily); |
|
365 |
|
366 // set class parameter |
|
367 CSubConQosIPLinkR99ParamSet* ipParamsReq = CSubConQosIPLinkR99ParamSet::NewL(*qosFamily, CSubConParameterFamily::ERequested); |
|
368 //The requested QoS parameters. |
|
369 ipParamsReq->SetTrafficClass(RPacketQoS::ETrafficClassBackground); |
|
370 ipParamsReq->SetMaxBitrateUplink(10); |
|
371 ipParamsReq->SetMaxBitrateDownlink(50); |
|
372 ipParamsReq->SetGuaBitrateDownlink(20); |
|
373 ipParamsReq->SetGuaBitrateUplink(10); |
|
374 ipParamsReq->SetMaxSduSize(1000); |
|
375 ipParamsReq->SetResidualBitErrorRatio(RPacketQoS::EBERFourPerThousand); |
|
376 ipParamsReq->SetSDUErrorRatio(RPacketQoS::ESDUErrorRatioOnePerThousand); |
|
377 ipParamsReq->SetErroneousSDUDelivery(RPacketQoS::EErroneousSDUDeliveryNotRequired); |
|
378 ipParamsReq->SetTrafficHandlingPriority(RPacketQoS::ETrafficPriorityUnspecified); |
|
379 ipParamsReq->SetTransferDelay(3000); |
|
380 ipParamsReq->SetDeliveryOrder(RPacketQoS::EDeliveryOrderNotRequired); |
|
381 |
|
382 //The minimum Requested params |
|
383 CSubConQosIPLinkR99ParamSet* ipParamsMinReq = CSubConQosIPLinkR99ParamSet::NewL(*qosFamily, CSubConParameterFamily::EAcceptable); |
|
384 |
|
385 ipParamsMinReq->SetTrafficClass(RPacketQoS::ETrafficClassBackground); |
|
386 ipParamsMinReq->SetGuaBitrateDownlink(20); |
|
387 ipParamsMinReq->SetGuaBitrateUplink(8); |
|
388 ipParamsMinReq->SetMaxBitrateDownlink(20); |
|
389 ipParamsMinReq->SetMaxBitrateUplink(10); |
|
390 ipParamsMinReq->SetMaxSduSize(200); |
|
391 ipParamsMinReq->SetResidualBitErrorRatio(RPacketQoS::EBERFivePerHundred); |
|
392 ipParamsMinReq->SetSDUErrorRatio(RPacketQoS::ESDUErrorRatioOnePerTen); |
|
393 ipParamsMinReq->SetErroneousSDUDelivery(RPacketQoS::EErroneousSDUDeliveryNotRequired); |
|
394 ipParamsMinReq->SetTrafficHandlingPriority(RPacketQoS::ETrafficPriorityUnspecified); |
|
395 ipParamsMinReq->SetTransferDelay(4000); |
|
396 ipParamsMinReq->SetDeliveryOrder(RPacketQoS::EDeliveryOrderNotRequired); |
|
397 |
|
398 TInt err = aPdpContext.SetParameters(qosParams); |
|
399 TestL(err, KErrNone, _L("Applied QoS Parameters")); |
|
400 CleanupStack::PopAndDestroy(&qosParams); |
|
401 } |
|
402 |
|
403 |
|
404 |
|
405 /** |
|
406 The test sequence: |
|
407 Create the primary & secondary PDP contexts. |
|
408 Send - Receive UDP over both of them. |
|
409 Close everything |
|
410 |
|
411 @leave if a test fails or there is an unexpected error */ |
|
412 TVerdict CUdp1::RunTestStepL() |
|
413 { |
|
414 TRequestStatus spudStartReq; |
|
415 TCommDbConnPref spudPref; |
|
416 spudPref.SetIapId(2); |
|
417 OpenAndStartInterfaceL(iSpud, spudPref, spudStartReq, _L(">>>>>Starting SPUD NIF")); |
|
418 WaitForCompletionL(spudStartReq, KErrNone, _L(">>>>>Starting SPUD NIF")); |
|
419 |
|
420 TInt ret = iScndCtxSock1.Open(iESock, |
|
421 KAfInet, |
|
422 KSockDatagram, |
|
423 KProtocolInetUdp, |
|
424 iSpud); |
|
425 TestL(ret, KErrNone, _L(">>>>>>>>Open UDP Socket, primary PDP context")); |
|
426 |
|
427 // KSoUdpSynchronousSend option causes the UDP send operation to block when dynamic |
|
428 // interface setup is in progress or when local flow control within the stack would otherwise |
|
429 // cause the packet to be dropped. This is not strictly necessary since we've waited for KLinkLayerOpen, |
|
430 // but who knows what's the timing between TCP/IP stack, Nifman, ESock is like... |
|
431 TestL(iScndCtxSock1.SetOpt(KSoUdpSynchronousSend, KSolInetUdp, 1), KErrNone, _L("SetOpt Sync Send")); |
|
432 |
|
433 // We must bind to a local address, and connect to a remote address, |
|
434 // so that TFT is always generated with the same destination - source ports. |
|
435 // Otherwise, SIM.TSY will reject TFT proposed. |
|
436 |
|
437 TInt scndCtxSockLocalPort = 0; |
|
438 ASSERT(GetIntFromConfig(ConfigSection(), _L("SecLocalPort"), scndCtxSockLocalPort)); |
|
439 ASSERT(scndCtxSockLocalPort > 0); |
|
440 |
|
441 TInetAddr localAddr; |
|
442 localAddr.SetPort(scndCtxSockLocalPort); |
|
443 TestL(iScndCtxSock1.Bind(localAddr), KErrNone, _L(">>>>>Bind the Secondary PDP ctx socket")); |
|
444 |
|
445 |
|
446 TInt scndCtxSockRemotePort = 0; |
|
447 ASSERT(GetIntFromConfig(ConfigSection(), _L("SecRemotePort"),scndCtxSockRemotePort)); |
|
448 ASSERT(scndCtxSockRemotePort > 0); |
|
449 |
|
450 TPtrC scndCtxSockRemoteAddr; |
|
451 ASSERT(GetStringFromConfig(ConfigSection(), _L("SecRemoteIpAddr"), scndCtxSockRemoteAddr)); |
|
452 |
|
453 |
|
454 TInetAddr dstAddr1; |
|
455 dstAddr1.SetPort(scndCtxSockRemotePort); |
|
456 dstAddr1.Input(scndCtxSockRemoteAddr); |
|
457 |
|
458 TRequestStatus connStatus; |
|
459 iScndCtxSock1.Connect(dstAddr1, connStatus); |
|
460 WaitForCompletionL(connStatus, KErrNone, _L(">>>>>>>Connect the Secondary PDP ctx socket")); |
|
461 |
|
462 |
|
463 TInt sockErr = iPrimCtxSock1.Open(iESock, |
|
464 KAfInet, |
|
465 KSockDatagram, |
|
466 KProtocolInetUdp, |
|
467 iSpud); |
|
468 TestL(sockErr, KErrNone, _L(">>>>>>Open Primary PDP ctx socket")); |
|
469 |
|
470 |
|
471 |
|
472 TInt openErr = iSpudScndCtx1.Open(iESock, |
|
473 RSubConnection::ECreateNew, |
|
474 iSpud); |
|
475 TestL(openErr, KErrNone, _L(">>>>>>>Open RSubConnection on SPUD")); |
|
476 |
|
477 TRequestStatus subconNotifyStat; |
|
478 TNotificationEventBuf eventBuf; |
|
479 iSpudScndCtx1.EventNotification(eventBuf, ETrue, subconNotifyStat); |
|
480 |
|
481 TBool waitForQos = ApplyQoSParametersL(iSpudScndCtx1); |
|
482 |
|
483 TRequestStatus subconAddStat; |
|
484 iSpudScndCtx1.Add(iScndCtxSock1, subconAddStat); |
|
485 WaitForCompletionL(subconAddStat, KErrNone, _L(">>>>>>Transfer the Socket to 2ndary context")); |
|
486 |
|
487 |
|
488 if(waitForQos) |
|
489 { |
|
490 WaitForCompletionL(subconNotifyStat, KErrNone, _L(">>>>>QoS Negotiation Completion on 2ndary context")); |
|
491 } |
|
492 else |
|
493 { |
|
494 iSpudScndCtx1.CancelEventNotification(); |
|
495 } |
|
496 //************************************************************************************************* |
|
497 User::After(3 * 1000000); // Give the loopback sockets a chance to bind & open, |
|
498 // else we can end up with ICMP Destination (port) Unreachable. |
|
499 // When used over WinTunnel, this is completely unnecessary. |
|
500 //************************************************************************************************* |
|
501 |
|
502 WriteReadOnSocketL(iScndCtxSock1, _L(">>>>>>>Secondary PDP Context, 1")); |
|
503 |
|
504 // Must address UDP on primary explicitly. |
|
505 TInt primCtxSockRemotePort = 0; |
|
506 ASSERT(GetIntFromConfig(ConfigSection(), _L("PrimRemotePort"),primCtxSockRemotePort)); |
|
507 ASSERT(primCtxSockRemotePort > 0); |
|
508 |
|
509 TPtrC primCtxSockRemoteAddr; |
|
510 ASSERT(GetStringFromConfig(ConfigSection(), _L("PrimRemoteIpAddr"), primCtxSockRemoteAddr)); |
|
511 |
|
512 TInetAddr primDstAddr1; |
|
513 primDstAddr1.SetPort(primCtxSockRemotePort); |
|
514 primDstAddr1.Input(primCtxSockRemoteAddr); |
|
515 |
|
516 SendRecvOnSocketL(iPrimCtxSock1, primDstAddr1, _L(">>>>>>>Send - Receive on Primary PDP Context, 1")); |
|
517 |
|
518 |
|
519 WriteReadOnSocketL(iScndCtxSock1, _L(">>>>>>>Secondary PDP Context, 2")); |
|
520 SendRecvOnSocketL(iPrimCtxSock1, primDstAddr1, _L(">>>>>>>Primary PDP Context, 2")); |
|
521 |
|
522 SendRecvOnSocketL(iPrimCtxSock1, primDstAddr1, _L(">>>>>>>Primary PDP Context, 3")); |
|
523 WriteReadOnSocketL(iScndCtxSock1, _L(">>>>>>>Secondary PDP Context, 3")); |
|
524 |
|
525 iSpud.Stop(); // nukes both contexts |
|
526 // Everything will be cleaned up later. |
|
527 return EPass; |
|
528 } |
|
529 |
|
530 /** |
|
531 The test sequence: |
|
532 Create the primary context |
|
533 Init secondary SubConnection |
|
534 Set up QoS params on secondary SubConnection |
|
535 Create the secondary PDP contexts on secondary SubConnection. |
|
536 Send - Receive UDP over both of them. |
|
537 Close everything |
|
538 |
|
539 @leave if a test fails or there is an unexpected error */ |
|
540 TVerdict CUdp2::RunTestStepL() |
|
541 { |
|
542 TRequestStatus spudStartReq; |
|
543 TCommDbConnPref spudPref; |
|
544 spudPref.SetIapId(2); |
|
545 OpenAndStartInterfaceL(iSpud, spudPref, spudStartReq, _L(">>>>>Starting SPUD NIF")); |
|
546 WaitForCompletionL(spudStartReq, KErrNone, _L(">>>>>Starting SPUD NIF")); |
|
547 |
|
548 TInt openErr = iSpudScndCtx1.Open(iESock, |
|
549 RSubConnection::ECreateNew, |
|
550 iSpud); |
|
551 TestL(openErr, KErrNone, _L(">>>>>>>Open RSubConnection on SPUD")); |
|
552 |
|
553 TRequestStatus subconNotifyStat; |
|
554 TNotificationEventBuf eventBuf; |
|
555 iSpudScndCtx1.EventNotification(eventBuf, ETrue, subconNotifyStat); |
|
556 |
|
557 TBool waitForQos = ApplyQoSParametersL(iSpudScndCtx1); |
|
558 |
|
559 // Socket Open on Secondary SubConnection |
|
560 TInt ret = iScndCtxSock1.Open(iESock, |
|
561 KAfInet, |
|
562 KSockDatagram, |
|
563 KProtocolInetUdp, |
|
564 iSpudScndCtx1); |
|
565 |
|
566 TestL(ret, KErrNone, _L(">>>>>>>>Open UDP Socket, primary PDP context")); |
|
567 |
|
568 // KSoUdpSynchronousSend option causes the UDP send operation to block when dynamic |
|
569 // interface setup is in progress or when local flow control within the stack would otherwise |
|
570 // cause the packet to be dropped. This is not strictly necessary since we've waited for KLinkLayerOpen, |
|
571 // but who knows what's the timing between TCP/IP stack, Nifman, ESock is like... |
|
572 TestL(iScndCtxSock1.SetOpt(KSoUdpSynchronousSend, KSolInetUdp, 1), KErrNone, _L("SetOpt Sync Send")); |
|
573 |
|
574 // We must bind to a local address, and connect to a remote address, |
|
575 // so that TFT is always generated with the same destination - source ports. |
|
576 // Otherwise, SIM.TSY will reject TFT proposed by GUQoS. |
|
577 |
|
578 TInt scndCtxSockLocalPort = 0; |
|
579 ASSERT(GetIntFromConfig(ConfigSection(), _L("SecLocalPort"), scndCtxSockLocalPort)); |
|
580 ASSERT(scndCtxSockLocalPort > 0); |
|
581 |
|
582 TInetAddr localAddr; |
|
583 localAddr.SetPort(scndCtxSockLocalPort); |
|
584 TestL(iScndCtxSock1.Bind(localAddr), KErrNone, _L(">>>>>Bind the Secondary PDP ctx socket")); |
|
585 |
|
586 |
|
587 TInt scndCtxSockRemotePort = 0; |
|
588 ASSERT(GetIntFromConfig(ConfigSection(), _L("SecRemotePort"),scndCtxSockRemotePort)); |
|
589 ASSERT(scndCtxSockRemotePort > 0); |
|
590 |
|
591 TPtrC scndCtxSockRemoteAddr; |
|
592 ASSERT(GetStringFromConfig(ConfigSection(), _L("SecRemoteIpAddr"), scndCtxSockRemoteAddr)); |
|
593 |
|
594 |
|
595 TInetAddr dstAddr1; |
|
596 dstAddr1.SetPort(scndCtxSockRemotePort); |
|
597 dstAddr1.Input(scndCtxSockRemoteAddr); |
|
598 |
|
599 TRequestStatus connStatus; |
|
600 iScndCtxSock1.Connect(dstAddr1, connStatus); |
|
601 WaitForCompletionL(connStatus, KErrNone, _L(">>>>>>>Connect the Secondary PDP ctx socket")); |
|
602 |
|
603 if(waitForQos) |
|
604 { |
|
605 WaitForCompletionL(subconNotifyStat, KErrNone, _L(">>>>>QoS Negotiation Completion on 2ndary context")); |
|
606 } |
|
607 else |
|
608 { |
|
609 iSpudScndCtx1.CancelEventNotification(); |
|
610 } |
|
611 |
|
612 TInt sockErr = iPrimCtxSock1.Open(iESock, |
|
613 KAfInet, |
|
614 KSockDatagram, |
|
615 KProtocolInetUdp, |
|
616 iSpud); |
|
617 TestL(sockErr, KErrNone, _L(">>>>>>Open Primary PDP ctx socket")); |
|
618 |
|
619 |
|
620 //************************************************************************************************* |
|
621 User::After(3 * 1000000); // Give the loopback sockets a chance to bind & open, |
|
622 // else we can end up with ICMP Destination (port) Unreachable. |
|
623 // When used over WinTunnel, this is completely unnecessary. |
|
624 //************************************************************************************************* |
|
625 |
|
626 WriteReadOnSocketL(iScndCtxSock1, _L(">>>>>>>Secondary PDP Context, 1")); |
|
627 |
|
628 // Must address UDP on primary explicitly. |
|
629 TInt primCtxSockRemotePort = 0; |
|
630 ASSERT(GetIntFromConfig(ConfigSection(), _L("PrimRemotePort"),primCtxSockRemotePort)); |
|
631 ASSERT(primCtxSockRemotePort > 0); |
|
632 |
|
633 TPtrC primCtxSockRemoteAddr; |
|
634 ASSERT(GetStringFromConfig(ConfigSection(), _L("PrimRemoteIpAddr"), primCtxSockRemoteAddr)); |
|
635 |
|
636 TInetAddr primDstAddr1; |
|
637 primDstAddr1.SetPort(primCtxSockRemotePort); |
|
638 primDstAddr1.Input(primCtxSockRemoteAddr); |
|
639 |
|
640 SendRecvOnSocketL(iPrimCtxSock1, primDstAddr1, _L(">>>>>>>Send - Receive on Primary PDP Context, 1")); |
|
641 |
|
642 |
|
643 WriteReadOnSocketL(iScndCtxSock1, _L(">>>>>>>Secondary PDP Context, 2")); |
|
644 SendRecvOnSocketL(iPrimCtxSock1, primDstAddr1, _L(">>>>>>>Primary PDP Context, 2")); |
|
645 |
|
646 SendRecvOnSocketL(iPrimCtxSock1, primDstAddr1, _L(">>>>>>>Primary PDP Context, 3")); |
|
647 WriteReadOnSocketL(iScndCtxSock1, _L(">>>>>>>Secondary PDP Context, 3")); |
|
648 |
|
649 iSpud.Stop(); // nukes both contexts |
|
650 // Everything will be cleaned up later. |
|
651 return EPass; |
|
652 } |
|
653 |
|
654 |
|
655 |
|
656 TVerdict CUpperFlowOnLowerNifDown::RunTestStepL() |
|
657 { |
|
658 // Start the primary |
|
659 TRequestStatus spudStartReq; |
|
660 TCommDbConnPref spudPref; |
|
661 spudPref.SetIapId(2); |
|
662 OpenAndStartInterfaceL(iSpud, spudPref, spudStartReq, _L(">>>>>Starting SPUD NIF")); |
|
663 |
|
664 // Start PPP peer for the primary |
|
665 RConnection primCtxPppPeer; |
|
666 TRequestStatus peerStartReq; |
|
667 TCommDbConnPref peerPref; |
|
668 peerPref.SetIapId(1); |
|
669 OpenAndStartInterfaceL(primCtxPppPeer, peerPref, peerStartReq, _L(">>>>Starting PPP Peer for the primary context")); |
|
670 |
|
671 WaitForCompletionL(spudStartReq, KErrNone, _L(">>>>>Starting SPUD NIF")); |
|
672 WaitForCompletionL(peerStartReq, KErrNone, _L(">>>>>Starting PPP Peer for SPUD primary context")); |
|
673 // Open socket on primary |
|
674 TInt sockErr = iPrimCtxSock1.Open(iESock, |
|
675 KAfInet, |
|
676 KSockDatagram, |
|
677 KProtocolInetUdp, |
|
678 iSpud); |
|
679 |
|
680 TestL(sockErr, KErrNone, _L(">>>>>>>>Open UDP Socket, primary PDP context")); |
|
681 |
|
682 User::After(2 * 10000); // Let everything settle down. |
|
683 // Stop PPP peer, triggerting LinkLayerDown on the primary |
|
684 TInt stopErr = primCtxPppPeer.Stop(); |
|
685 ASSERT(KErrNone == stopErr); // If there is an error, the test was not setup correctly. |
|
686 |
|
687 // At this point contxt deletion request is outstanding: SIM TSY will not complete it for a while. |
|
688 // Send on primary socket: no way to verify where it blocked. Must inspect the logs. |
|
689 |
|
690 User::After(5 * 1000000); |
|
691 |
|
692 TInetAddr primDstAddr1; |
|
693 primDstAddr1.SetPort(1060); |
|
694 primDstAddr1.Input(_L("192.168.3.1")); |
|
695 |
|
696 TBuf8<KMaxMsgLen> sendBuf(_L8("A packet to the La-La Land.")); |
|
697 TRequestStatus sendSt; |
|
698 |
|
699 iPrimCtxSock1.SendTo(sendBuf, primDstAddr1, 0x0, sendSt); |
|
700 WaitForCompletionL(sendSt, KErrNone, _L("Send on Socket")); // ESock completed the send, the packet |
|
701 // still needs to percolate through the tcp/ip stack - GUQoS - SPUD. |
|
702 User::After(30 * 1000000); |
|
703 // SPUD panics if the upper layer tries to send on a flowed-off context. |
|
704 |
|
705 return EPass; // If there was a failure, we'd leave or panic |
|
706 // Cleanup everything later |
|
707 } |
|
708 |
|
709 |
|
710 |
|
711 /** |
|
712 Brings up SPUD & PPP peer from the primary context, then stops Spud. |
|
713 This test step is intended to be used in a combination with other steps, (including itself), |
|
714 to verify how RConnection::Stop affects the behaviour of the system. */ |
|
715 TVerdict CSpudPppPrimaryStop::RunTestStepL() |
|
716 { |
|
717 TRequestStatus spudStartReq; |
|
718 TCommDbConnPref spudPref; |
|
719 spudPref.SetIapId(2); |
|
720 OpenAndStartInterfaceL(iSpud, spudPref, spudStartReq, _L(">>>>>Starting SPUD NIF")); |
|
721 |
|
722 |
|
723 RConnection primCtxPppPeer; |
|
724 TRequestStatus peerStartReq; |
|
725 TCommDbConnPref peerPref; |
|
726 peerPref.SetIapId(1); |
|
727 OpenAndStartInterfaceL(primCtxPppPeer, peerPref, peerStartReq, _L(">>>>Starting PPP Peer for the primary context")); |
|
728 |
|
729 |
|
730 WaitForCompletionL(spudStartReq, KErrNone, _L(">>>>>Starting SPUD NIF")); |
|
731 WaitForCompletionL(peerStartReq, KErrNone, _L(">>>>>Starting PPP Peer for SPUD primary context")); |
|
732 |
|
733 TInt stopTypeInt = -1; |
|
734 ASSERT(GetIntFromConfig(ConfigSection(), _L("StopType"), stopTypeInt)); |
|
735 RConnection::TConnStopType stopType = static_cast<RConnection::TConnStopType>(stopTypeInt); |
|
736 INFO_PRINTF2(_L("Stopping Spud with stop type= %d (0 = EStopNormal, 1 = EStopAuthoritative)"), stopType); |
|
737 ASSERT(RConnection::EStopNormal == stopType || RConnection::EStopAuthoritative == stopType); |
|
738 TInt stopErr = iSpud.Stop(stopType); |
|
739 INFO_PRINTF2(_L("Stopped Spud with error = %d"), stopErr); |
|
740 ASSERT(KErrNone == stopErr); // If we have an errror, test was not set up / executed correctly. |
|
741 |
|
742 // if stop was authoritative ppp wont do the leaving handshake, so peer also needs to be stopped |
|
743 if (stopType == RConnection::EStopAuthoritative) |
|
744 { |
|
745 TInt stopErr = primCtxPppPeer.Stop(stopType); |
|
746 INFO_PRINTF2(_L("Stopped peer with error = %d"), stopErr); |
|
747 ASSERT(KErrNone == stopErr); // If we have an errror, test was not set up / executed correctly. |
|
748 } |
|
749 else |
|
750 { |
|
751 primCtxPppPeer.Close(); // No need to stop, peer should be shutting down as a result of Stop on Spud. |
|
752 } |
|
753 return EPass; |
|
754 } |
|
755 |
|
756 |
|
757 |
|
758 |