TVerdict CIPEventNotifier1Step_ReceiveMFlag::doTestStepL() { SetTestStepResult(EFail); _LIT(KReadingConfig,"CIPEventNotifier1Step_ReceiveMFlag::doTestStepL() reading config.."); INFO_PRINTF1(KReadingConfig); if(!GetBoolFromConfig(ConfigSection(),KTe_IPENMFlagExpectedResultBool,iExpectedMFlagValue) || !GetStringFromConfig(ConfigSection(),KTe_IPENNetworkInterfacePrefixToMonitor, iNetworkInterfacePrefixToMonitor)) { User::Leave(KErrNotFound); } _LIT(KShowSettings,"The expected M flag is %d, on 1st interface starting with %S"); INFO_PRINTF3(KShowSettings,iExpectedMFlagValue,&iNetworkInterfacePrefixToMonitor); _LIT(KGetIfName,"Getting full interface name.."); INFO_PRINTF1(KGetIfName); TName fullName = GetFullInterfaceNameL(iNetworkInterfacePrefixToMonitor); _LIT(KDeclEv,"OK. declaring event.."); INFO_PRINTF1(KDeclEv); NetSubscribe::TEvent event( this, SignalHandler ); _LIT(KSubscribing,"OK. Subscribing.."); INFO_PRINTF1(KSubscribing); CDhcpSignal::SubscribeL( fullName, IPEvent::EMFlagReceived, event ); _LIT(KOkWaiting,"OK. Waiting for M flag.."); INFO_PRINTF1(KOkWaiting); CTimeout *timeout = CTimeout::NewLC(this); // a Router Advertisement is set to go out every 3 seconds on the test network // timeout->After(KFiveSecondDelayToCatchRouterAdvertisementEveryThreeSeconds); TRAPD(res,CActiveScheduler::Start()) if(res != KErrNone) { if(res == KErrTimedOut) { _LIT(KTimedOut,"Timed out! Subscriber isn't working or network isn't publishing Router Advertisements"); INFO_PRINTF1(KTimedOut); } else { _LIT(KUnexpectedErrCode,"Received unexpected error code: %d"); INFO_PRINTF2(KUnexpectedErrCode,res); } SetTestStepResult(EFail); } _LIT(KOkTidyingUp,"OK. Tidying up.."); INFO_PRINTF1(KOkTidyingUp); timeout->Cancel(); CleanupStack::PopAndDestroy(timeout); if (iQuery && iQuery->iHandle) { CDhcpSignal::UnsubscribeL( event ); } _LIT(KOkDone,"OK. Done."); INFO_PRINTF1(KOkDone); return TestStepResult(); }
TVerdict CIPEventNotifier3Step_LinkLocalAddress::doTestStepL() { SetTestStepResult(EFail); _LIT(KReadingConfig,"CIPEventNotifier3Step_LinkLocalAddress::doTestStepL() reading config.."); INFO_PRINTF1(KReadingConfig); TPtrC llAddr; if(!GetStringFromConfig(ConfigSection(),KTe_IPENAddressToPush, llAddr) || !GetStringFromConfig(ConfigSection(),KTe_IPENNetworkInterfacePrefixToMonitor, iNetworkInterfacePrefixToMonitor)) { User::Leave(KErrNotFound); } _LIT(KAddrToPush,"The address to be pushed is %S"); INFO_PRINTF2(KAddrToPush, &llAddr); if ( iLLAddr.Input(llAddr) != KErrNone ) { _LIT(KUnparsable,"Unparsable address in config!"); INFO_PRINTF1(KUnparsable); User::Leave(KErrArgument); } if(iLLAddr.IsLinkLocal() == false) { _LIT(KSpecifyLLAddr,"Please specify a linklocal address in config file! (169.254.x.x or fe80:...)!"); INFO_PRINTF1(KSpecifyLLAddr); User::Leave(KErrArgument); } _LIT(KSubscribing,"Subscribing.."); INFO_PRINTF1(KSubscribing); TName fullName = GetFullInterfaceNameL(iNetworkInterfacePrefixToMonitor); NetSubscribe::TEvent event( this, SignalHandler ); CDhcpSignal::SubscribeL( fullName, IPEvent::ELinklocalAddressKnown,event ); _LIT(KGettingDetails,"OK. Getting interface details.."); INFO_PRINTF1(KGettingDetails); // Now push the address.. Once we start the scheduler, the subscriber // should pick it up immediately! TPckgBuf<TSoInet6InterfaceInfo> originalCfg; const TSoInet6InterfaceInfo& originalCfgRef = originalCfg(); (void)originalCfgRef; // for debugging GetInterfaceInfoL(fullName,originalCfg); _LIT(KAddingLL,"OK. Adding a linklocal address.."); INFO_PRINTF1(KAddingLL); TInt err; TPckgBuf<TSoInet6InterfaceInfo> addConfig(originalCfg()); addConfig().iState = EIfUp; addConfig().iDoState = ETrue; addConfig().iDoId = ETrue; addConfig().iDoPrefix = ETrue; addConfig().iAlias = ETrue; // add another address addConfig().iDelete = EFalse; addConfig().iDoAnycast= EFalse; addConfig().iDoProxy = EFalse; addConfig().iAddress = iLLAddr; addConfig().iAddress.SetScope(2); err = iSocket->SetOpt(KSoInetConfigInterface, KSolInetIfCtrl, addConfig); User::LeaveIfError(err); _LIT(KWaitingForNotification,"OK. Waiting for notification.."); INFO_PRINTF1(KWaitingForNotification); CTimeout* timeout = CTimeout::NewLC(this); timeout->After(KTenSecondDADCompletionDelay); TRAPD(res,CActiveScheduler::Start()) if(res != KErrNone) { if(res == KErrTimedOut) { _LIT(KTimedOut,"Timed out! Subscriber isn't working"); INFO_PRINTF1(KTimedOut); } else { _LIT(KUnexpectedErrCode,"Received unexpected error code: %d"); INFO_PRINTF2(KUnexpectedErrCode,res); } return TestStepResult(); } _LIT(KRestoringAddress,"OK. Removing the address.."); INFO_PRINTF1(KRestoringAddress); addConfig().iDelete = ETrue; err = iSocket->SetOpt(KSoInetConfigInterface, KSolInetIfCtrl, addConfig); User::LeaveIfError(err); _LIT(KRestoredOk,"Restored OK. Clearing up.."); INFO_PRINTF1(KRestoredOk); timeout->Cancel(); CleanupStack::PopAndDestroy(timeout); if (iQuery && iQuery->iHandle) { CDhcpSignal::UnsubscribeL( event ); } _LIT(KOkDone,"OK. Done."); INFO_PRINTF1(KOkDone); return TestStepResult(); }