void UT_CTBCPFloorControlImpl::UT_CTBCPFloorControlImpl_ConnectionStarted2LL(  )
    {
    iPlugIn->SetIapId(KIAPID);
    TBuf<KBufLength> addressbuffer;
    TInetAddr addr;
    addr.Input(KAddr3);
    addr.Output(addressbuffer);
    iPlugIn->SetAddressL(addressbuffer, KPort1);
    iPlugIn->SetLocalPort(KPort2);
    iPlugIn->ConnectL( ETrue );
    iPlugIn->ConnectionStarted(0);
    
 	EUNIT_ASSERT(iError==0);

	TBuf<KBufLength> addressbuffer2;
	TInetAddr addr2;
    addr2.Input(KAddr2);
    addr2.Output(addressbuffer2);
    iPlugIn->SetAddressL(addressbuffer2, KPort1);
    iPlugIn->iConnection->Cancel();
    iPlugIn->iConnection->iStatus = KErrNone;
    iPlugIn->iConnection->RunL();
    
    FC_EUNIT_ASSERT_EQUALS( iError, KErrNone );
    }
// -----------------------------------------------------------------------------
// CSdpOriginField::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CSdpOriginField::ConstructL(
    const TDesC8& aUserName, 
    TInt64 aSessionId, 
    TInt64 aSessionVersion, 
    TInetAddr& aUnicastAddress )
	{
    iPool = SdpCodecStringPool::StringPoolL();

	__ASSERT_ALWAYS( 
                   IsValidUserName( aUserName )
				&& IsValidAddress( aUnicastAddress )
                && aSessionId >= 0 && aSessionVersion >= 0,
				User::Leave( KErrSdpCodecOriginField ) );

	iUserName = reinterpret_cast< HBufC8* >
		( CSdpOriginFieldPtrs::NewL( aSessionId, aSessionVersion ) );
	OriginFieldPtrs().SetUserNameL( aUserName );
	
    TBuf<KMaxIPDesLength> des;
    aUnicastAddress.Output( des );
	//if aUnicastAddress was IPv4-Mapped IPv6 address,
	// the result of Output is IPv4
	// the address is stored in IPv4 format, so the iAddressType 
	// must also be IPv4.    
    iAddress.Copy( des );
    SetIPAddressType( aUnicastAddress );

    iNetType = iPool.StringF( SdpCodecStringConstants::ENetType, 
                              SdpCodecStringConstants::Table ).Copy();
       
	__TEST_INVARIANT;
	}
void UT_CTBCPFloorControlImpl::UT_CTBCPFloorControlImpl_CancelSendL(  )
    {
    iPlugIn->SetIapId(KIAPID);
    TBuf<KBufLength> addressbuffer;
    TInetAddr addr;
    addr.Input(KAddr2);
    addr.Output(addressbuffer);
    iPlugIn->SetAddressL(addressbuffer, KPort1);
    iPlugIn->SetLocalPort(KPort2);
    iPlugIn->ConnectL(ETrue);
    
    iPlugIn->iConnection->Cancel();
    iPlugIn->iConnection->RunL();
    EUNIT_PRINT( _L( "DigiaEunit::Socket has open and start Listen!" ) ); 	
	HBufC8* data = HBufC8::NewLC(KLength);
	data->Des().Copy(KHello);

	EUNIT_PRINT( _L( "DigiaEunit::BeforeSendToNetL" ) ); 
	iPlugIn ->SendToNetL(data);
	CleanupStack::Pop( data );
	
	iPlugIn->ConnectL(ETrue); 
	iPlugIn->iConnection->Cancel();
    iPlugIn->iConnection->RunL();
    
	iPlugIn->CancelSend();
	EUNIT_PRINT( _L( "DigiaEunit::After Cancel Send" ) ); 
	EUNIT_ASSERT( iError==0);
	}
Example #4
0
// ---------------------------------------------------------------------------
// SdpUtil::SetDefaultNetTypeAndAddrType
// Sets network type and address type to their "default" values
// ---------------------------------------------------------------------------
//
void SdpUtil::SetDefaultNetTypeAndAddrType( 
    RStringPool aPool, 
    const TInetAddr& aAddress,
    RStringF& aNetType, 
    RStringF& aAddressType )
    {
     // Sets network type to IN
    aNetType.Close();
    aNetType = aPool.StringF( SdpCodecStringConstants::ENetType,
                              SdpCodecStringConstants::Table ).Copy();
    // Address type       
    aAddressType.Close();

    TBuf16 <KMaxAddressLength> output;
    aAddress.Output(output);


    //addresstype for IPv4    
	if((aAddress.Address() &&  !aAddress.IsV4Mapped()) ||
       (!aAddress.Address() && aAddress.IsWildAddr() && 
        output.Match(KWildAddr) == 0))
        {
        aAddressType = aPool.StringF( SdpCodecStringConstants::EAddressTypeIP4,
                                      SdpCodecStringConstants::Table ).Copy();
        }
    else
        {
		//addresstype for IPv4-Mapped IPv6 && IPv6
        aAddressType = aPool.StringF( SdpCodecStringConstants::EAddressType,
                                      SdpCodecStringConstants::Table ).Copy();
        }
    }
// -----------------------------------------------------------------------------
// CUpnpHttpServer::ConnectionAcceptedL
//
// -----------------------------------------------------------------------------
//
CUpnpTcpSession* CUpnpHttpServer::ConnectionAcceptedL( RSocket aSocket )
    {
    LOG_FUNC_NAME;

    #ifdef _DEBUG
    TInetAddr tempAddr;
    aSocket.RemoteName( tempAddr );
    tempAddr.ConvertToV4();

    const TInt KMaxAdressLength = 20;
    TBuf<KMaxAdressLength> addrBuf;
    tempAddr.Output( addrBuf );

    HBufC8* addrBuf8 = UpnpString::FromUnicodeL( addrBuf );
    CleanupStack::PushL( addrBuf8 );

    LOGS( "CUpnpHttpServer::ConnectionAcceptedL - Remote socket connected" );
    LOGT( addrBuf8->Des() );

    LOGS1("CUpnpHttpServer::ConnectionAcceptedL - Creating a new Http session. Session count: %i", iSessionList.Count());

    CleanupStack::PopAndDestroy(addrBuf8);
    #endif //_DEBUG
    CUpnpHttpSession* sess = CUpnpHttpSession::NewL( aSocket, this,
        CUpnpHttpMessage::NewSessionIdL(), EPriorityNormal );

    return sess;
    }
// -----------------------------------------------------------------------------
// CUpnpDeviceLibraryElement::SetDescriptionUrlL
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CUpnpDeviceLibraryElement::SetDescriptionUrlL(
    const TDesC8& aDescriptionURL, const TInetAddr& aAddr, const TDesC8& aPort )
    {
    TBuf<UpnpSSDP::KIPAddBuffLen> addrBuf;
    aAddr.Output( addrBuf );

    HBufC8* addrBuf8 = UpnpString::FromUnicodeL( addrBuf );
    CleanupStack::PushL( addrBuf8 );

    HBufC8* url = HBufC8::NewLC( (UpnpHTTP::KHTTPUrl().Length( ))
            + aDescriptionURL.Length( ) + addrBuf8->Length( )
            + aPort.Length( )+ 2 );//+2 reserved for colon and slashes in url

    url->Des().Append( UpnpHTTP::KHTTPUrl( ) );
    url->Des().Append( *addrBuf8 );
    if ( aPort.Length( ) > 0 )
        {
        url->Des().Append( UpnpString::KColon( ) );
        url->Des().Append( aPort );
        }
    // After Ip address there should be slash and device Url so device url
    // must start with slash
    ASSERT( aDescriptionURL.Find( UpnpString::KSlash) == 0 ); 
   	
    url->Des().Append( aDescriptionURL );

    SetDescriptionUrlL( *url );

    CleanupStack::PopAndDestroy( url );
    CleanupStack::PopAndDestroy( addrBuf8 );
    }
/**
 * Function that takes an IP address from user input, accesses the
 * Bluetooth PAN Profile table in the CommDb and updates the IpAddr
 * field with the supplied address.
 */		
void CPanConnections::SetLocalIpAddrL(TUint32 addr)
	{
	iLocalIpAddr = addr;
	iSrcAddr.SetAddress(iLocalIpAddr);
	CCommsDatabase* db = CCommsDatabase::NewL();
	CleanupStack::PushL(db);
	// Get the LAN service table
	CCommsDbTableView* tableView = db->OpenTableLC(TPtrC(LAN_SERVICE));

	TBuf<KMaxBufferSize> tableName;
	TInt err = tableView->GotoFirstRecord();
	if(err == KErrNone)
		{
		// Get the name of the table
		tableView->ReadTextL(TPtrC(COMMDB_NAME), tableName);
		if(tableName == TPtrC(_S("BluetoothPANProfile")))
			{
			TInetAddr tempAddr;
			TBuf<KMaxBufferSize> dispBuf;
			tempAddr.SetAddress(iLocalIpAddr);
			tempAddr.Output(dispBuf);
			
			User::LeaveIfError(tableView->UpdateRecord());	
			tableView->WriteTextL(_L("IpAddr"), dispBuf);
		
			User::LeaveIfError(tableView->PutRecordChanges());
			User::LeaveIfError(db->CommitTransaction());	
			}
		}
	else
		{
		User::Leave(KErrNotFound);
		}
	CleanupStack::PopAndDestroy(2);//db & tableView 
	}
void UT_CTBCPFloorControlImpl::UT_CTBCPFloorControlImpl_SetAddressLL(  )
    {
    TBuf<KBufLength> addressbuffer;
    TInetAddr addr;
    addr.Input(KAddr2);
    addr.Output(addressbuffer);
    iPlugIn->SetAddressL(addressbuffer, KPort1);
    EUNIT_ASSERT( iPlugIn->iRemoteAddr.Address()==addr.Address());
    }
/**
 * Function to print the current connections we have.
 */		
void CPanConnections::PrintConns()
	{
	iConsole.Printf(_L("\nRemotenames : %d\n"), iRemoteNames.Count());
	PrintTcpSocketConnections();
	iConsole.Printf(_L("--------------------------------------------------\n"));
	iConsole.Printf(_L("Listening Mode: "));
	iListening ? iConsole.Printf(_L("Enabled        ")) : iConsole.Printf(_L("Disabled        "));
	if(iIapStarted)
		{
		iConsole.Printf(_L("       IAP Started"));

		TInt err = UpdateCurrentConnections();
		if(err != KErrNone)
			{
			iConsole.Printf(_L("FAILED TO ENUMERATE CONNECTIONS. Err %d\n"), err);
			}
		else
			{
			iConsole.Printf(_L("\n------------------ CONNECTIONS -------------------\n"));
			iConsole.Printf(_L("Index  Remote Addr\n"));
			
			
			for(TInt i=0;i<iActiveConnections.Count();i++)
				{
				TBuf<KMaxBufferSize> dispBuf;
				iActiveConnections[i].GetReadable(dispBuf);

				if(iActivePanConn == i)
					{
					iConsole.Printf(_L("-> "));
					}
				else
					{
					iConsole.Printf(_L("   "));
					}
				iConsole.Printf(_L("%d   0x%S\n"), i, &dispBuf);				
				}
			}
		}
	
	if(iLocalIpAddr == 0)
		{
		iConsole.Printf(_L("\nNo local IP address set\n"));
		}
	else
		{
		TInetAddr tempAddr;
		TBuf<KMaxBufferSize> dispBuf;
		
		tempAddr.SetAddress(iLocalIpAddr);
		tempAddr.Output(dispBuf);
		
		iConsole.Printf(_L("\nLocal IP address: %S\n"), &dispBuf);
		}

	}
// -----------------------------------------------------------------------------
// CSdpOriginField::IsValidAddress
// Checks if the address is valid
// -----------------------------------------------------------------------------
//
TBool CSdpOriginField::IsValidAddress( 
    const TInetAddr& addr ) const
    {
    TBuf<KMaxIPDesLength> buf16;
    TBuf8<KMaxIPDesLength> buf;
	//if addr is IPv4-Mapped IPv6, buf value will be IPv4 after Output
    addr.Output( buf16 );
    buf.Copy( buf16 );

    return IsValidAddress( buf );
    }
void UT_CTBCPFloorControlImpl::UT_CTBCPFloorControlImpl_ConnectionStartedLL()
    {
    iPlugIn->SetIapId(KIAPID);
    TBuf<KBufLength> addressbuffer;
    TInetAddr addr;
    addr.Input(KAddr2);
    addr.Output(addressbuffer);
    iPlugIn->SetAddressL(addressbuffer, KPort1);
    iPlugIn->SetLocalPort(KPort2);
    iPlugIn->ConnectionStarted(1);
    EUNIT_ASSERT( iError==1);
    }
void CApConnectEngine::FetchIpAddressL()
{
	RSocket socket;
	CleanupClosePushL( socket);
	while (socket.Open(iSocketServ, KAfInet, KSockDatagram, KProtocolInetUdp,
			iConnect)!= KErrNone)
	{
	};
	TSoInetInterfaceInfo inf;
	TPckg<TSoInetInterfaceInfo> opt( inf);
	TRAPD(err, socket.SetOpt (KSoInetEnumInterfaces, KSolInetIfCtrl ))
	;
	if (err != KErrNone)
	{
		return;
	}

	while ( socket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, opt)== KErrNone)
	{
		if ( inf.iAddress.Address()==0) // if the stored address is not an IPv4 address
		{
		}
		else
		{
			if ( inf.iAddress.IsUnspecified())
			{
				// Interface inf.iName has no address        	
			}
			else
			{
				// have to do this, strange
				TInetAddr addr;
				addr.SetAddress( inf.iAddress.Address());
				addr.Output(iConnInfo.ipAddress);
				// have to do this, strange

				if ( iConnInfo.ipAddress.Compare(KZeroIP)!= 0 && iConnInfo.ipAddress.Compare(KLocalIP)!= 0)
				{
					if ( iConnInfo.ipAddress.Left(3).Compare(_L("169"))!= 0)
					{
						CleanupStack::PopAndDestroy(); // socket
						return;
					}
				}
			}
		}
	}
	CleanupStack::PopAndDestroy(); // socket	
}
// ---------------------------------------------------------------------------
// CStunTurnTests::TestOutgoingAddrL
// ---------------------------------------------------------------------------
//    
void CStunTurnTests::TestOutgoingAddrL()
    {
    TInetAddr inetAddr;
    TBuf<40> buffer;
    
    RDebug::Print( _L( "\nTEST CASE: Get outgoing address" ) );
    iWrapper->OutgoingAddr( inetAddr );
    
    inetAddr.Output( buffer );
    
    RDebug::Print( _L("TEST PRINT: CStunTurnTests::TestOutgoingAddrL, wrapper outgoing Address: %S:%d "), &buffer, inetAddr.Port() );
    if ( buffer.Length() == 0 )
        {
        User::Leave( KErrCompletion );
        }
    }
void UT_CTBCPFloorControlImpl::UT_CTBCPFloorControlImpl_ConnectLL(  )
    {
	iPlugIn->SetIapId(KIAPID);
    TBuf<KBufLength> addressbuffer;
    TInetAddr addr;
    addr.Input(KAddr2);
    addr.Output(addressbuffer);
    iPlugIn->SetAddressL(addressbuffer, KPort1);
    iPlugIn->SetLocalPort(KPort2);
    FC_EUNIT_ASSERT_NO_LEAVE(iPlugIn->ConnectL(ETrue) );
    
    iPlugIn->iConnection->Cancel();
    iPlugIn->iConnection->RunL();
	EUNIT_PRINT( _L( "DigiaEunit::Socket has open and start Listen!" ) ); 	
	EUNIT_ASSERT( iError==0);
	}
// -----------------------------------------------------------------------------
// CSdpConnectionField::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CSdpConnectionField::ConstructL(
    const TInetAddr& aAddress,
    TInt aTTL,
    TUint aNumOfAddress )
	{
    __ASSERT_ALWAYS( IsValidAddress(aAddress, aTTL, aNumOfAddress) == KErrNone,
                     User::Leave( KErrSdpCodecConnectionField ) );

    iPool = SdpCodecStringPool::StringPoolL();
    TBuf<KMaxIPDesLength> addr;
    //If aAddress is IPv4-Mapped IPv6,the result of Output is IPv4
    aAddress.Output( addr );

    // Copy address
    iAddress = HBufC8::NewL( addr.Length() );
    iAddress->Des().Copy( addr );

    // TTL
    iTTL = aTTL;
    // Num of addresses
    iNumOfAddress = aNumOfAddress;
    // Network type
    iNetType = iPool.StringF( SdpCodecStringConstants::ENetType,
                              SdpCodecStringConstants::Table ).Copy();
    // Address type
	if ( UriUtils::HostType( addr ) == UriUtils::EIPv4Host )
		{
		//addresstype for IPv4
			iAddressType = iPool.StringF( SdpCodecStringConstants::EAddressTypeIP4,
                                      SdpCodecStringConstants::Table ).Copy();
			}
	else if ( UriUtils::HostType( addr ) == UriUtils::EIPv6Host )
			{
			//addresstype IPv6
			iAddressType = iPool.StringF( SdpCodecStringConstants::EAddressType,
                                      SdpCodecStringConstants::Table ).Copy();
			}
	else
		{
		User::Leave(KErrArgument);
		}

	__TEST_INVARIANT;
	}
void UT_CTBCPFloorControlImpl::UT_CTBCPFloorControlImpl_StopL(  )
    {
    iPlugIn->SetIapId(KIAPID);
    TBuf<KBufLength> addressbuffer;
    TInetAddr addr;
    addr.Input(KAddr2);
    addr.Output(addressbuffer);
    iPlugIn->SetAddressL(addressbuffer, KPort1);
    iPlugIn->SetLocalPort(KPort2);
    iPlugIn->ConnectL(ETrue);
        
    iPlugIn->iConnection->Cancel();
    iPlugIn->iConnection->RunL();
    
 	iPlugIn->Stop();
	EUNIT_PRINT( _L( "DigiaEunit::connection and sender, receiver stoped" ) ); 
	iPlugIn->ConnectL(ETrue);
	EUNIT_ASSERT( iError==0);
	}
void UT_CTBCPFloorControlImpl::UT_CTBCPFloorControlImpl_ErrorNotifyL(  )
    {
    iPlugIn->SetIapId(KIAPID);
    TBuf<KBufLength> addressbuffer;
    TInetAddr addr;
    addr.Input(KAddr2);
    addr.Output(addressbuffer);
    iPlugIn->SetAddressL(addressbuffer, KPort1);
    iPlugIn->SetLocalPort(KPort2);
    iPlugIn->ConnectL(ETrue);
    iPlugIn->iConnection->Cancel();
    iPlugIn->iConnection->RunL();
    
    iPlugIn->ErrorNotify(1);
    EUNIT_ASSERT( iError==1 );
    iError=0;
    iPlugIn->ErrorNotify(0);
    EUNIT_ASSERT(iError==0);
    }
// -----------------------------------------------------------------------------
// CSdpOriginField::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CSdpOriginField::ConstructL( 
    const TDesC8& aUserName, 
    TInt64 aSessionId, 
    TInt64 aSessionVersion, 
    RStringF aNetType, 
    RStringF aAddressType, 
    const TDesC8& aAddress )
    {        
    iPool = SdpCodecStringPool::StringPoolL();
     
    __ASSERT_ALWAYS(
               IsValidUserName( aUserName )
            && IsValidAddress( aAddress ) &&
            TypeMatchesWithFormat( aAddress, aAddressType.DesC(), iPool )
            && ( SdpUtil::IsToken( aNetType.DesC() ) )
            && ( SdpUtil::IsToken( aAddressType.DesC() ) )
            && aSessionId >= 0 && aSessionVersion >= 0,
            User::Leave( KErrSdpCodecOriginField ) );
    
    iUserName = reinterpret_cast< HBufC8* >
		( CSdpOriginFieldPtrs::NewL( aSessionId, aSessionVersion ) );
	OriginFieldPtrs().SetUserNameL( aUserName );	

    iNetType = aNetType.Copy();
    	TInetAddr addr;
	TBuf<KMaxAddressLength> address;
	address.Copy(aAddress);
	TInt err = addr.Input(address);
	if ( err  == KErrNone )
		{
		// Valid IP address
		TBuf< KMaxIPDesLength > buf;
		addr.Output( buf );
		iAddress.Copy( buf );		
		SetIPAddressType( addr );
		}
	else
		{
		iAddress = aAddress;
    	iAddressType = aAddressType.Copy();	
		}
    __TEST_INVARIANT;    
    }
void UT_CTBCPFloorControlImpl::UT_CTBCPFloorControlImpl_ResetSocketLL(  )
    {
    iPlugIn->SetIapId(KIAPID);
    TBuf<KBufLength> addressbuffer;
    TInetAddr addr;
    addr.Input(KAddr);
    addr.Output(addressbuffer);
    iPlugIn->SetAddressL(addressbuffer, KPort1);
    iPlugIn->SetLocalPort(KPort2);
    iPlugIn->ConnectL(ETrue);
    iPlugIn->iConnection->Cancel();
    iPlugIn->iConnection->RunL();
    
    EUNIT_PRINT( _L( "DigiaEunit::Socket has open and start Listen!" ) ); 	
	iPlugIn->ResetSocketL();
	_LIT8(KOwnDesc, "iError Value = intvalue=%d" );
	EUNIT_PRINT(KOwnDesc, iError ); 
	EUNIT_ASSERT( iError==0);
	iPlugIn->Stop();
	}
// -----------------------------------------------------------------------------
// CSdpOriginField::SetInetAddress
// Sets Internet Address
// -----------------------------------------------------------------------------
//
EXPORT_C void CSdpOriginField::SetInetAddress(
    const TInetAddr& aValue )
	{    
	__TEST_INVARIANT;
    
	if ( IsValidAddress( aValue ) )
        {                       
        TBuf<KMaxIPDesLength> buf;
        aValue.Output( buf );
        // Copy new address to safe
        iAddress.Copy( buf );
    
        // Copy network type and address type        
        SdpUtil::SetDefaultNetTypeAndAddrType( 
            iPool, aValue, iNetType, iAddressType );
        SetIPAddressType( aValue );
        }

    __TEST_INVARIANT;
	}
// -----------------------------------------------------------------------------
// TSIPRegistrationUtility::LocalAddressLC
// -----------------------------------------------------------------------------
//
HBufC8* TSIPRegistrationUtility::LocalAddressLC (const TUint       aIapId,
                                                 MTransactionUser& aTU)
	{
	// get local IP address by giving IAP id
	TInetAddr localAddress;
	aTU.GetLocalAddress(aIapId, localAddress);

	// create Local IP address
	const TInt KMaxIPAddrLength = 256;
	HBufC* ipAddressOutputBuf = HBufC::NewLC(KMaxIPAddrLength);
	TPtr ipAddressOutputPtr(ipAddressOutputBuf->Des());
	localAddress.Output(ipAddressOutputPtr);

	HBufC8* outPutBuf = HBufC8::NewL(ipAddressOutputPtr.Length());
	TPtr8 outPutPtr(outPutBuf->Des());
	outPutPtr.Copy(ipAddressOutputPtr);
	CleanupStack::PopAndDestroy(ipAddressOutputBuf);
    CleanupStack::PushL(outPutBuf);

	return outPutBuf;
	}
Example #22
0
void CFTPResolver::SetAddress(TInetAddr& aAddress)
{
	// Get the 1st entry resolved
	iNameRecord = iNameEntry();
	// Save the address (take care not to overwrite the port, might have been already set)
	if (TInetAddr::Cast(iNameRecord.iAddr).Family() == KAfInet)
		aAddress.SetAddress(TInetAddr::Cast(iNameRecord.iAddr).Address());
	else
		aAddress.SetAddress(TInetAddr::Cast(iNameRecord.iAddr).Ip6Address());

#if defined(__FTPPROTDEBUG__)
	TBuf<512> debugBuffer; // A Buffer to output the resolved IP 
	
	aAddress.Output(debugBuffer);
	debugBuffer.Append(_L(","));
	debugBuffer.AppendNum(aAddress.Port(), EDecimal); 
	debugBuffer.Append(_L("\n"));
#endif
	FTPPROTDEBUG(_DBGResolver,_L("Resolved address is:"));
	FTPPROTDEBUG(_DBGResolver,debugBuffer);
}
Example #23
0
SilcBool silc_net_check_local_by_sock(SilcSocket sock, char **hostname,
				      char **ip)
{
  SilcSymbianSocket *s = (SilcSymbianSocket *)sock;
  TInetAddr addr;
  char host[256];
  TBuf<64> tmp;

  if (hostname)
    *hostname = NULL;
  *ip = NULL;

  s->sock->LocalName(addr);
  addr.Output(tmp);

  *ip = (char *)silc_memdup(tmp.Ptr(), tmp.Length());
  if (*ip == NULL)
    return FALSE;

  /* Do reverse lookup if we want hostname too. */
  if (hostname) {
    /* Get host by address */
    if (!silc_net_gethostbyaddr(*ip, host, sizeof(host)))
      return FALSE;

    *hostname = (char *)silc_memdup(host, strlen(host));
    SILC_LOG_DEBUG(("Resolved hostname `%s'", *hostname));

    /* Reverse */
    if (!silc_net_gethostbyname(*hostname, TRUE, host, sizeof(host)))
      return FALSE;

    if (strcmp(*ip, host))
      return FALSE;
  }

  SILC_LOG_DEBUG(("Resolved IP address `%s'", *ip));
  return TRUE;
}
// -----------------------------------------------------------------------------
// CSdpConnectionField::SetInetAddressL
// Sets address from TInetAddr
// -----------------------------------------------------------------------------
//
EXPORT_C void CSdpConnectionField::SetInetAddressL(
    const TInetAddr& aAddress,
    TInt aTTL,
    TUint aNumOfAddress )
	{
	__TEST_INVARIANT;

    if ( IsValidAddress( aAddress, aTTL, aNumOfAddress ) == KErrNone )
        {
        TBuf<KMaxAddressLength> addr16;
       	//If aAddress IPv4-Mapped IPv6, result of Output IPv4
         aAddress.Output( addr16 );

        HBufC8* tempBuf = HBufC8::NewL( addr16.Length() );
        tempBuf->Des().Copy( addr16 );

        SdpUtil::SetDefaultNetTypeAndAddrType(
            iPool, aAddress, iNetType, iAddressType );
        if(aAddress.Address() && aAddress.IsV4Mapped())
			{
			iAddressType.Close();
			iAddressType = iPool.StringF( SdpCodecStringConstants::EAddressTypeIP4,
                                      SdpCodecStringConstants::Table ).Copy();
			}
        // Set address
        delete iAddress;
        iAddress = tempBuf;
        // Set attributes for address
        iTTL = aTTL;
        iNumOfAddress = aNumOfAddress;
        }
    else
        {
        User::Leave( KErrSdpCodecConnectionField );
        }

	__TEST_INVARIANT;
	}
// -----------------------------------------------------------------------------
// CSdpConnectionField::IsValidAddress
// Checks if the given address is valid
// -----------------------------------------------------------------------------
//
TInt CSdpConnectionField::IsValidAddress(
    const TInetAddr& aAddress,
    TInt aTTL,
    TUint aNumOfAddress ) const
    {
    TInt err( KErrSdpCodecConnectionField );
    // 0 <= TTL <= 255 or KErrNotFound if not defined
    // Number of addresses > 0
    if ( ( aTTL == KErrNotFound || ( aTTL >= 0 && aTTL <= 255 ) ) &&
           aNumOfAddress > 0 )
        {
        TBuf16 <KMaxAddressLength> output;
        aAddress.Output(output);

        // Address has to be either of type IP4 or IP6
        // If IP4 and multicast then it must contain TTL attribute
        // If IP4 and unicast then it must NOT contain TTL and must have 1 address
        // If IP6 and multicast then it must NOT contain TTL
        // If IP6 and unicast then it must NOT contain TTL and must have 1 address
        if ( ( aAddress.Address() && 
               ( ( aAddress.IsMulticast() && aTTL != KErrNotFound ) ||
                 ( aAddress.IsUnicast() && aTTL == KErrNotFound &&
                   aNumOfAddress == 1 ) ) ) ||
             ( !aAddress.Address() &&
               ( ( aAddress.IsMulticast() && aTTL == KErrNotFound ) ||
                 ( aAddress.IsUnicast() && aTTL == KErrNotFound &&
                   aNumOfAddress == 1 ) )   ||
               ( aAddress.IsWildAddr() && 
               ( output.Match(KWildAddr) == 0||
               	 output.Match(KWildAddrIPv6) == 0 )) ) )
           {
           err = KErrNone;
           }
        }

    return err;
    }
Example #26
0
/**
*   List existing network interfaces, IP addresses bound to them 
*   and fill up array of IP addresses for all interfaces.
*/
void CTestStepLLMNR_Init::ListInterfacesL()
    {
    
    RSocket socket;
    TInt    nRes;
    TInt    exceed;
    TInt    idx;
    TName   tmpBuf;
    TName   tmpBuf1;
    
    nRes = socket.Open(ipTestServer->iSocketServer, KAfInet, KSockStream, KProtocolInetTcp);
    TESTL(nRes == KErrNone);
    
    TUint   bufsize = 2048;
    
    HBufC8 *buffer =NULL;
    buffer = GetBuffer(buffer, bufsize);
    TESTL(buffer != NULL);
    
    TPtr8 bufdes = buffer->Des();
    
    //-- reset array of local addresses
    ipTestServer->iLocalAddrs.Reset();
    
    //-- list all available network interfaces
    INFO_PRINTF1(KNewLine);
    INFO_PRINTF1(_L("--- available network interfaces:"));
    
    do
        {//-- get list of network interfaces
        // if exceed>0, all interface could not fit into the buffer.
        // In that case allocate a bigger buffer and retry.
        // There should be no reason for this while loop to take more than 2 rounds.
        bufdes.Set(buffer->Des());
        exceed = socket.GetOpt(KSoInetInterfaceInfo, KSolInetIfQuery, bufdes);
        if(exceed > 0)
            {
            bufsize += exceed * sizeof(TInetInterfaceInfo);
            buffer = GetBuffer(buffer, bufsize);
            TESTL(buffer != NULL);
            }
        } while (exceed > 0);
        
        if (exceed < 0)
            {
            INFO_PRINTF1(_L("socket.GetOpt() error!"));
            TESTL(EFalse);
            }
        
        TOverlayArray<TInetInterfaceInfo> infoIface(bufdes);
        
        for(idx=0; idx < infoIface.Length(); ++idx)
            {
            TInetInterfaceInfo& iface = infoIface[idx];
            
            tmpBuf.Format(_L("index:%d, name: "),iface.iIndex);
            tmpBuf.Append(iface.iName );
            tmpBuf.AppendFormat(_L(" state:%d"), iface.iState);
            INFO_PRINTF1(tmpBuf);
            }
        
        //-- list all IP addresses, bound to the interfaces
        //-- and append this address to the array of host-local addresses
        INFO_PRINTF1(KNewLine);
        INFO_PRINTF1(_L("--- IP addresses bound to the interfaces:"));
        
        do
            {
            // if exceed>0, all interface could not fit into the buffer.
            // In that case allocate a bigger buffer and retry.
            // There should be no reason for this while loop to take more than 2 rounds.
	        bufdes.Set(buffer->Des());
            exceed = socket.GetOpt(KSoInetAddressInfo, KSolInetIfQuery, bufdes);
            if(exceed > 0)
                {
                bufsize += exceed * sizeof(TInetAddressInfo);
                buffer = GetBuffer(buffer, bufsize);
                }
            } while (exceed > 0);
            
            if (exceed < 0)
                {
                INFO_PRINTF1(_L("socket.GetOpt() error!"));
                TESTL(EFalse);
                }
            
            
            //-- print out IP addresses
            TOverlayArray<TInetAddressInfo> infoAddr(bufdes);
            TInetAddr inetAddr;
            
            for(idx=0; idx < infoAddr.Length(); ++idx)
                {
                TInetAddressInfo& addr = infoAddr[idx];
                
                tmpBuf.Format(_L("iface index: %d, scopeID: %d, state: %d, IP addr: "), addr.iInterface, addr.iScopeId, addr.iState);
                inetAddr.SetAddress(addr.iAddress);
                inetAddr.Output(tmpBuf1);
                tmpBuf.Append(tmpBuf1);
                INFO_PRINTF1(tmpBuf);
                
                //-- if obtained IP address is valid and not loopback, add it to the array.
                if(inetAddr.IsLoopback() || inetAddr.IsUnspecified())
                    {}
                else
                    ipTestServer->iLocalAddrs.Append(inetAddr);
                
                }
            
            
            delete buffer;
            socket.Close();
            
            INFO_PRINTF1(KNewLine);
}
Example #27
0
void CSTTorrentManager::OnLocalUDPReceiveL(TInetAddr aSender, const TDesC8& aData)
{
	HLWRITELN(iLog, _L("[TorrentManager] OnLocalUDPReceiveL begin"));
	
	TInetAddr localAddress;
	iNetworkManager->GetLocalAddress(1, localAddress);
	
	if (localAddress.Address() == aSender.Address())
	{
		HLWRITELN(iLog, _L("[TorrentManager] Throwing away own message"));
		return;
	}
	
#ifdef LOG_TO_FILE
	LWRITE(iLog, _L("[TorrentManager] UDP sender: "));
	TBuf<128> addressBuf;
	if (aSender.Address() == 0)
	{
		addressBuf = _L("? (could not get local address)");
	}
	else
	{
		aSender.Output(addressBuf);
		addressBuf.Append(_L(":"));
		TBuf<16> portBuf;
		portBuf.Num(localAddress.Port());
		addressBuf.Append(portBuf);
	}
	HLWRITELN(iLog, addressBuf);
#endif
	
	//HLWRITEL(iLog, _L("[TorrentManager] Data received: "));
	//HLWRITELN(iLog, aData);
	
	// TODO handle multiple torrents
	if (iTorrents.Count() == 0)
		return;
	
	if (aData.Size() >= 4)
	{
		TUint messageLength = NSTUtils::ReadInt32(aData);
		
		LWRITE(iLog, _L("[TorrentManager] Datagram length: "));
		LWRITELN(iLog, aData.Size());
				
		LWRITE(iLog, _L("[TorrentManager] Message length: "));
		LWRITELN(iLog, messageLength);
		
		if ((TUint(aData.Size()) >= (4 + messageLength)) && 
			(aData[4] == KMessageIdPiece))
		{
			TInt index = NSTUtils::ReadInt32(aData.Mid(5));
			TInt begin = NSTUtils::ReadInt32(aData.Mid(9));
			
			TBool pendingRequestFound = EFalse;
			
			// check if the incoming local piece is requested by this peer
			for (TInt i=0; i<iTorrents[0]->PeerCount(); i++)
			{
				if ((iTorrents[0]->Peer(i)->IsLocal()) && (iTorrents[0]->Peer(i)->Connection()) && (iTorrents[0]->Peer(i)->Connection()->State() == EPeerPwConnected))
				{
					pendingRequestFound = iTorrents[0]->Peer(i)->Connection()->HandleIncomingLocalPieceL(index, begin, aData.Mid(13, messageLength - 9));
					if (pendingRequestFound)
						break;
				}
			}
			
			if (!pendingRequestFound)
			{
				if ((iTorrents[0]->PieceCount() > index) && (!iTorrents[0]->Piece(index)->IsDownloaded()))
				{
					HLWRITELN(iLog, _L("[TorrentManager] Received unrequested piece"));
					
					CSTPiece* piece = iTorrents[0]->Piece(index);
					CSTPeer* peer = iTorrents[0]->GetPeer(aSender);
					
					if (piece->InsertBlockL(begin, aData.Mid(13, messageLength - 9), peer) != KErrNone)
					{
						LWRITELN(iLog, _L8("CRITICAL FAULT, Writing to piece failed")); // CRITICAL FAULT								
					}
					else
					{
						HLWRITELN(iLog, _L("[TorrentManager] Writing piece complete"));
						
						if (iTorrents[0]->EndGame())									
							iTorrents[0]->EndGamePieceReceivedL(piece, peer);
					}
					
					iTorrents[0]->iLocalSubPiecesNotRequested++;
					iTorrents[0]->iLocalSubPiecesNotRequestedSize += aData.Size();
					
					
					// TODO remove commented part if the code above is working
					/*if (piece->DownloadedSize() == begin)
					{
						CSTPeer* peer = iTorrents[0]->GetPeer(aSender);
						
						if (piece->AppendBlockL(aData, peer) != KErrNone)
						{
							LWRITELN(iLog, _L8("CRITICAL FAULT, Writing to piece failed")); // CRITICAL FAULT								
						}
						else
						{
							HLWRITELN(iLog, _L("[TorrentManager] Writing piece complete"));
							
							if (iTorrents[0]->EndGame())									
								iTorrents[0]->EndGamePieceReceivedL(piece, peer);
						}
						
						iTorrents[0]->iLocalSubPiecesNotRequested++;
					}
					else
						iTorrents[0]->iLocalSubPiecesReceivedNotMatchPieceBeginning++;*/
				}
				else
				{
					iTorrents[0]->iLocalSubPiecesReceivedAlreadyDownloaded++;
					iTorrents[0]->iLocalSubPiecesReceivedAlreadyDownloadedSize += aData.Size();
				}
			}
		}
	}
	
	HLWRITELN(iLog, _L("[TorrentManager] OnLocalUDPReceiveL end"));
}
void CEtelContextNotificationRequest::PrintContextConfig(
    const TContextConfig& aContextConfig)
    {
    LOG(Log::Printf(_L("** Context config data **")));

    RPacketContext::TContextConfigGPRS tempConfig;

    aContextConfig.GetContextConfig(tempConfig);

    RPacketContext::TProtocolAddress pdpAddress;
    aContextConfig.GetPdpAddress(pdpAddress);

    TInetAddr pdpAddr;
    pdpAddr.Copy(pdpAddress);

    TBuf<RPacketContext::KMaxPDPAddressLength> outBuf;
    pdpAddr.Output(outBuf);

    switch(tempConfig.iPdpType)
        {
        case RPacketContext::EPdpTypeIPv4:
            {
            LOG(Log::Printf(_L("\tPdpType: IPv4")));
            break;
            }
        case RPacketContext::EPdpTypeIPv6:
            {
            LOG(Log::Printf(_L("\tPdpType: IPv6")));
            break;
            }
        case RPacketContext::EPdpTypeX25:
            {
            LOG(Log::Printf(_L("\tPdpType: X25")));
            break;
            }
        default:
            {
            LOG(Log::Printf(_L("\tPdpType: UNRECOGNIZED")));
            break;
            }
        }

    LOG(Log::Printf(_L8("\tAccess Point Name: <%s>"), 
        tempConfig.iAccessPointName.PtrZ()));
    LOG(Log::Printf(_L("\tPdpAddress: <%s>"), 
        outBuf.PtrZ()));

    if((tempConfig.iPdpCompression == RPacketContext::KPdpDataCompression) &&
       (tempConfig.iPdpCompression == RPacketContext::KPdpHeaderCompression))
        {
        LOG(Log::Printf(_L("\tCompression: Header+Data")));
        }
    else if((tempConfig.iPdpCompression == 
        RPacketContext::KPdpDataCompression))
        {
        LOG(Log::Printf(_L("\tCompression: Data")));
        }
    else if((tempConfig.iPdpCompression == 
        RPacketContext::KPdpHeaderCompression))
        {
        LOG(Log::Printf(_L("\tCompression: Header")));
        }
    else if(tempConfig.iPdpCompression == 0)
        {
        LOG(Log::Printf(_L("\tCompression: None")));
        }
    else
        {
        LOG(Log::Printf(_L("\tCompression: UNRECOGNIZED")));
        }

    switch(tempConfig.iAnonymousAccessReqd)
        {
        case RPacketContext::ENotApplicable:
            {
            LOG(Log::Printf(
                _L("\tAnonymous access required: ENotApplicable")));
            break;
            }
        case RPacketContext::ERequired:
            {
            LOG(Log::Printf(_L("\tAnonymous access required: ERequired")));
            break;
            }
        case RPacketContext::ENotRequired:
            {
            LOG(Log::Printf(
                _L("\tAnonymous access required: ENotRequired")));
            break;
            }
        default:
            {
            LOG(Log::Printf(
                _L("\tAnonymous access required: UNRECOGNIZED")));
            break;
            }
        }
    }
Example #29
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();
	}
// -----------------------------------------------------------------------------
// CSdpConnectionField::ParseAddressFieldL
// Format the address field
// -----------------------------------------------------------------------------
//
HBufC8* CSdpConnectionField::ParseAddressFieldL(
    TBool aAddressTypeIP4,
    const TDesC8& aAddress,
    TInt& aTTL,
    TUint& aNumberOfAddresses ) const
    {
    HBufC8* address = NULL;

    if ( aAddress.Length() > 0 && aAddress.Length() <= KMaxAddressLength )
        {
        // IP4 address
        TInetAddr addr;
        TBuf<KMaxAddressLength> buf16;

        // IP address lasts till first separator mark
        TInt pos = aAddress.Locate( KSlashChar );
        if ( pos == KErrNotFound )
            {
            pos = aAddress.Length();
            }
        buf16.Copy( aAddress.Left( pos ) );

        // Try to convert the string to TInetAddr
        TInt err = addr.Input( buf16 );

   		//Type and address check
        TBuf16 <KMaxAddressLength> output;
        addr.Output(output);
        if (err == KErrNone)
	        {
            if (addr.Address() )
                {
                if ( (addr.IsV4Mapped() && aAddressTypeIP4) ||
                     (!addr.IsV4Mapped() && !aAddressTypeIP4) )
                    {
                    User::Leave( KErrSdpCodecConnectionField );
                    }
                else
                    {
                    // IP4 address
                    address = ParseIP4AddressL( pos, addr, aAddress, aTTL,
                                            aNumberOfAddresses );
                    }
                }
            else
                {
                if ( !aAddressTypeIP4)
                    {
                    // IP6 address
                    address = ParseIP6AddressL( pos, addr, aAddress, aTTL,
                                        aNumberOfAddresses );
                    }
                else if ( addr.IsWildAddr() && output.Match(KWildAddr) == 0 )
                    {
                    // 0.0.0.0
                    address = ParseIP4AddressL( pos, addr, aAddress, aTTL,
                                            aNumberOfAddresses );
                    }
                else
                    {
                    User::Leave( KErrSdpCodecConnectionField );
                    }
		        }
	        }
        else
	        {   
            // FQDN
	        // Clarify that the address contains only valid FQDN chars
            // This is always unicast
            for ( TInt i( 0 ); i < aAddress.Length(); i++ )
		        {
                if ( KValidFQDNChars().Locate( aAddress[i] ) ==
			        KErrNotFound )
                    {
                    User::Leave( KErrSdpCodecConnectionField );
                    }
                }
            address = aAddress.AllocL();
            aTTL = KErrNotFound;
            aNumberOfAddresses = 1;
	        }

        }
    else
        {
        User::Leave( KErrSdpCodecConnectionField );
        }

    return address;
    }