Пример #1
0
// ---------------------------------------------------------------------------
// Constructor with message identification parameter. Constructs object
// which should be used for matching with Match() method.
// ---------------------------------------------------------------------------
//
EXPORT_C TIkeSendQueueItem::TIkeSendQueueItem( HBufC8* aUdpData )
 :  iUdpData( aUdpData ),
    iDestAddr( TInetAddr() ),
    iLocalPort( 0 ),
    iDscp( 0 )
    {    
    }
Пример #2
0
// ---------------------------------------------------------------------------
// CStunTurnTests::TestSetIncomingAddrL
// ---------------------------------------------------------------------------
//
void CStunTurnTests::TestSetIncomingAddrL()
    {
    RDebug::Print( _L( "\nTEST CASE: Set Incoming Address" ) );
    
    if ( KProtocolInetTcp == iProtocol )
        {
        RDebug::Print( _L( "\nTEST CASE: Set Incoming Address - TCP" ) );
        iNotificationIsOn = EFalse; 
        CTestServer* server = CTestServer::NewLC( this );
        CTestClient* client = CTestClient::NewLC( this );
        
        TInetAddr addr( KInetAddrLoop, KTestServerPort );
        server->OpenL( addr, KTimeoutTime );
        
        iWrapper->SetIncomingAddrL( addr );
        //iWrapper->SetupTcpConnectionL( ETcpSetupActive, *this );
        
        iIfStub.StartActiveSchedulerL( KRunningTime );
        
        iNotificationIsOn = ETrue;
        CleanupStack::PopAndDestroy( client );
        CleanupStack::PopAndDestroy( server );
        }
    else
        {
        RDebug::Print( _L( "\nTEST CASE: Set Incoming Address - UDP" ) );
        iWrapper->SetIncomingAddrL( TInetAddr( KIncomingAddr, KIncomingPort ) );
        }
    }
void UT_CNATFWUNSAFUdpSender::SetupL()
    {
    User::LeaveIfError( iServer.Connect( 8 ) );
    User::LeaveIfError( iConn.Open( iServer, KConnectionTypeDefault ) );

    TCommDbConnPref prefs;
    prefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );
    prefs.SetDirection( ECommDbConnectionDirectionOutgoing );
    prefs.SetIapId(10);
    User::LeaveIfError( iConn.Start( prefs ) );

    User::LeaveIfError( iSocket.Open( iServer,
                                      KAfInet,
                                      KSockDatagram,
                                      KProtocolInetUdp,
                                      iConn ) );

    iMsg = NATFWUNSAFTransportTestUtils::CreateUNSAFBindingRequestL();

    iAddr = TInetAddr( INET_ADDR( 127, 0, 0, 1 ) );

    iSender = CNATFWUNSAFUdpSender::NewL( iSocket, *this );

    iIsMsgSent = EFalse;
    }
Пример #4
0
// -----------------------------------------------------------------------------
// CUpnpDevice::DescriptionUrlPort
// Retrun description URL port.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt CUpnpDevice::DescriptionUrlPort() const
    {
    if ( iAddress != TInetAddr( INET_ADDR( 0,0,0,0 ), 0) )
        {
        return iAddress.Port();
        }

    const TDesC8& url = DescriptionUrl();

    if ( url.Length()> KHttp().Length() )
        {
        TPtrC8 addrAndPath = url.Right( url.Length() - KHttp().Length() );

        TInt separIndex = addrAndPath.Find( KSepar() );

        if ( separIndex == KErrNotFound )
            {
            return KDefaultDescriptionUrlPort;
            }

        TInt slashIndex = addrAndPath.Find( KSlash8() );

        if ( slashIndex != KErrNotFound )
            {
            TPtrC8 port = addrAndPath.Mid(
                    separIndex + 1, slashIndex - separIndex
            );

            TLex8 lex( port );
            TInt prt;
            TInt err = lex.Val( prt );
            if( KErrNone != err )
                {
                return KErrNotFound;
                }

            return prt;
            }
        else
            {
            TPtrC8 port = addrAndPath.Right(
                    addrAndPath.Length() - ( separIndex + 1 )
            );

            TLex8 lex( port );
            TInt prt;
            TInt err = lex.Val( prt );
            if( KErrNone != err )
                {
                return KErrNotFound;
                }

            return prt;
            }
        }

    return KDefaultDescriptionUrlPort;
    }
// TESTS:
// ---------------------------------------------------------------------------
// UT_CNSPMediaStreamComponent::UT_ControlMediaLL
// ---------------------------------------------------------------------------
// 
void UT_CNSPMediaStreamComponent::UT_ControlMediaLL()
    {
    // test scenario where terminal is not behind NAT
    CNATFWCandidate* candidate = CNATFWCandidate::NewLC();
    candidate->SetType( CNATFWCandidate::EServerReflexive );
    candidate->SetBase( TInetAddr( INET_ADDR( 10, 36, 7, 6 ), 5000 ) );
    candidate->SetTransportAddrL( TInetAddr( INET_ADDR( 10, 36, 7, 6 ), 5000 ) );
    iStreamComponent->iLocalCandidates.AppendL( candidate );
    CleanupStack::Pop( candidate );
    
    TNatReturnStatus status = iStreamComponent->ControlMediaL(
        MNATFWConnectivityObserver::EFetchingCompleted, KErrNone, NULL );
    NSP_ASSERT( KNatNonFatalErrorLimit == status );
    
    // test scenario where terminal is behind NAT
    candidate->SetTransportAddrL( TInetAddr( INET_ADDR( 10, 36, 7, 6 ), 5002 ) );
    status = iStreamComponent->ControlMediaL(
        MNATFWConnectivityObserver::EFetchingCompleted, KErrNone, NULL );
    NSP_ASSERT( KNatReady == status );
    }
Пример #6
0
// -----------------------------------------------------------------------------
// CUpnpDevice::DescriptionUrlAddressL
// Return description URL address.
// -----------------------------------------------------------------------------
//
EXPORT_C TInetAddr CUpnpDevice::DescriptionUrlAddressL() const
    {
    if ( iAddress == TInetAddr( INET_ADDR( 0,0,0,0 ), 0) )
        {

        const TDesC8& url = DescriptionUrl();

        if ( url.Length()> KHttp().Length() )
            {
            TPtrC8 addrAndPath = url.Right( url.Length() - KHttp().Length() );

            TInt index = addrAndPath.Find( KSepar() );

            if ( index == KErrNotFound )
                {
                index = addrAndPath.Find( KSlash8() );
                }

            if ( index == KErrNotFound )
                {
                return TInetAddr( INET_ADDR( 0,0,0,0 ), 0 );
                }

            TPtrC8 addr = addrAndPath.Left( index );

            TInetAddr address;

            HBufC* addrBuf = HBufC::NewLC(addr.Length());
            addrBuf->Des().Copy(addr);
            address.Input(*addrBuf);
            CleanupStack::PopAndDestroy(addrBuf);

            return address;
            }

        return TInetAddr(INET_ADDR( 0,0,0,0 ), 0 );
        }

    return iAddress;
    }
int ILibSocketWrapper_bind(int socketObject, struct sockaddr *local)
{
	TInetAddr addr = TInetAddr(htonl(((struct in_addr*)local->sa_data)->s_addr),ntohs(local->sa_port));
	
	RSocket *s = (RSocket*)SocketArray[socketObject];
	
	if(s->Bind(addr)==KErrNone)
	{
		return(0);
	}
	else
	{
		return(-1);
	}
}
// -----------------------------------------------------------------------------
// CUpnpSecurityDbConnection::GetAllIpAddressesL
// Get all ips.
// -----------------------------------------------------------------------------
//
void CUpnpSecurityDbConnection::GetAllIpAddressesL(
    RArray<TInetAddr>& aAddressArray )
    {
    TInt err;
    RSqlStatement statement;
    User::LeaveIfError( statement.Prepare( iDatabase,
        KUpnpSecSqlSelectAllIpAddresses ) );
    CleanupClosePushL( statement );
    TInt columnIndex = statement.ColumnIndex( KUpnpSecSqlIp );

    while ( (err = statement.Next()) == KSqlAtRow )
        {
        TUint32 data = statement.ColumnInt( columnIndex );
        aAddressArray.AppendL( TInetAddr( data, 0 ) );
        }

    if ( err != KSqlAtEnd )
        {
        User::LeaveIfError( err );
        }

    CleanupStack::PopAndDestroy( &statement );
    }
Пример #9
0
TVerdict CTestConnectStep::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 * Demonstrates reading configuration parameters fom an ini file section
 */
	{
	if(TestStepResult()==EPass)
		{
		INFO_PRINTF1(_L("In Test Step ConnectWithOverrides"));
		// When bootstrapping C32 we have to avoid the PhBkSyncServer being started, since
 		// it needs a different CommDB
		TInt ret = StartC32WithCMISuppressions(KPhbkSyncCMI);
		
		if((ret!=KErrNone) && (ret!=KErrAlreadyExists))
			{
			INFO_PRINTF2(_L("error is : %d \n"),ret);
			}
		else
			{
			INFO_PRINTF1(_L("Started C32\n"));
			}

		RHostResolver hr;

		INFO_PRINTF1(_L("Connect to RSocketServ"));			
		User::LeaveIfError(iSocketServ.Connect());

		// Set up the connections, both overridden as host resolver won't work 
		// on the default interface
		INFO_PRINTF1(_L("Open the RConnection interface"));			
		User::LeaveIfError(iConnection.Open(iSocketServ));

		// get the IapNumber value from the ini file
		if(!GetIntFromConfig(ConfigSection(), KIapNumber, iIapNumber))
			{
			if(!GetIntFromConfig(KIap, KIapNumber, iIapNumber))
				{
				iIapNumber=1;
				INFO_PRINTF1(_L("Failed to read Iap from ini file, using default"));
				}
			}
		INFO_PRINTF2((_L("IapNumber = %d")), iIapNumber);

		TRequestStatus status;
#ifdef SIROCCO_CODE_MIGRATION
	TCommDbConnPref prefs;
	prefs.SetIapId(iIapNumber);
	prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
		const TUid KMyPropertyCat = {0x101FD9C5};
        const TUint32 KMyPropertyDestPortv4 = 67;
        TInt err = RProperty::Define(KMyPropertyCat, KMyPropertyDestPortv4, RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
		     TSecurityPolicy(ECapabilityWriteDeviceData));
        User::LeaveIfError(RProperty::Set(KMyPropertyCat, KMyPropertyDestPortv4, 93));
#else

		TInt rank = 1;

		// Create a multiple connection preference object
		TCommDbMultiConnPref prefs;

		for(TInt i=0;i<iapCount;i++)
			{
			TCommDbConnPref pref;
			// Set the direction
			pref.SetDirection(ECommDbConnectionDirectionOutgoing);
			// Set the bear ser
			pref.SetBearerSet(KCommDbBearerPSD | KCommDbBearerCSD);
			// Set the IAP
			pref.SetIapId(iIapNumber + i);
			// Set the dialog preference to Do Not Prompt
			pref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
			// Set the rank
			User::LeaveIfError(prefs.SetPreference(rank, pref));

			rank++;
			}

		prefs.SetConnectionAttempts(rank-1);
#endif 

		// Start the connection
		iConnection.Start(prefs, status);

		
		User::WaitForRequest(status);

		TInt result = status.Int();

		if(result!=KErrNone)
			{
			ERR_PRINTF2(_L("Failed to start connection. Error %d"), result);
			SetTestStepResult(EFail);
			User::Leave(EFail);
			}
		else
			{
			INFO_PRINTF1(_L("Connection started with overrides"));
			}

		// Set up the host resolver
		INFO_PRINTF1(_L("Initialise a host resolver service"));			
		User::LeaveIfError(hr.Open(iSocketServ, KAfInet, KProtocolInetTcp, iConnection));
		CleanupClosePushL(hr);


		// Test the interfaces conn, host resolution should work ok
		TBuf<64> hostname;
		TRequestStatus status1;
		TNameEntry nameEntry;

		TPtrC temphost;
		if(GetStringFromConfig(KTCPConfig, KHostName, temphost))
			{
			INFO_PRINTF2(_L("Hostname is : %S"), &temphost);
			}
		else
			{
			ERR_PRINTF1(_L("No hostname"));
			SetTestStepResult(EFail);
			User::Leave(EFail);
			}
		hostname = temphost;

		hr.GetByName(hostname, nameEntry, status1);
		User::WaitForRequest(status1);

		TInt result1 = status1.Int();

		if(result1!=KErrNone)
			{
			ERR_PRINTF2(_L("Failed to resolve the name. Error %d"), result1);
			SetTestStepResult(EFail);
			User::Leave(EFail);
			}
		else
			{
			INFO_PRINTF1(_L("Resolved the name successfully"));
			}

		// open socket
		INFO_PRINTF1(_L("Open the socket"));			
		User::LeaveIfError(iSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp, iConnection));
		CleanupClosePushL(iSocket);

		// print the host resolver's ip address
		TInetAddr inetAddr;
		inetAddr = TInetAddr(nameEntry().iAddr);
		TBuf<50> addr;
		inetAddr.Output(addr);
		INFO_PRINTF2(_L("The host resolver's ip address is: %S"), &addr);
		
		// get the port number from the ini file
		if(!GetIntFromConfig(KTCPConfig, KPort, iPort))
			{
			ERR_PRINTF1(_L("Failed to read Port from ini file"));
			SetTestStepResult(EFail);
			User::Leave(EFail);
			}
		INFO_PRINTF2((_L("Port = %d")), iPort);

		// connect to the socket
		inetAddr.SetPort(iPort);
		//nameEntry().iAddr.SetPort(iPort);
		TRequestStatus status2;
		//iSocket.Connect(nameEntry().iAddr,status2);
		iSocket.Connect(inetAddr,status2);
		User::WaitForRequest(status2);

		TInt result2 = status2.Int();

		if(result2!=KErrNone)
			{
			ERR_PRINTF2(_L("Failed to connect to the socket. Error %d"), result2);
			SetTestStepResult(EFail);
			User::Leave(EFail);
			}
		else
			{
			INFO_PRINTF1(_L("Connect to the socket successfully"));
			}


		TPtrC ptrDNSName;
		if(GetStringFromConfig(KTCPConfig, KDNSName, ptrDNSName))
			{
			INFO_PRINTF2(_L("DNSName is : %S"), &ptrDNSName);
			}
		else
			{
			ERR_PRINTF1(_L("No DNSName"));
			SetTestStepResult(EFail);
			User::Leave(EFail);
			}
		TBuf8<256>	bufDnsName;
		bufDnsName.Copy(ptrDNSName);

		// connect to the secure socket
		CTestSecureSocket* iTestSecureSocket = CTestSecureSocket::NewL(*this, iSocket, bufDnsName);
		CleanupStack::PushL(iTestSecureSocket);
		iTestSecureSocket->StartHandshake();
		CActiveScheduler::Start();

		CleanupStack::PopAndDestroy(3); //iTestSecureSocket, iSocket, hr
		}
	
	return TestStepResult();
	}
Пример #10
0
// ---------------------------------------------------------------------------
//  CNATFWCandidate::ConstructL
// ---------------------------------------------------------------------------
//
void CNATFWCandidate::ConstructL()
    {
    iFoundation.Assign( KNullDesC8().AllocL() );
    iTransportDomainAddr.Assign( KNullDesC8().AllocL() );
    iTransportAddr = TInetAddr();
    }
Пример #11
0
// -----------------------------------------------------------------------------
// CUpnpDevice::Init
// Initialisation.
// -----------------------------------------------------------------------------
//
void CUpnpDevice::Init()
    {
    iAddress = TInetAddr( INET_ADDR( 0,0,0,0 ), 0 );
    iIconReceiveState = EAllIconsAdded;
    }