本文整理汇总了C++中TInetAddr::Input方法的典型用法代码示例。如果您正苦于以下问题:C++ TInetAddr::Input方法的具体用法?C++ TInetAddr::Input怎么用?C++ TInetAddr::Input使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TInetAddr
的用法示例。
在下文中一共展示了TInetAddr::Input方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
/**
* Called when the context has been activated to set our IP address and get
* any other required settings from CommDB.
*
* @param aConfig The new context config
*/
void CIPv4Binder::UpdateContextConfigL(const TPacketDataConfigBase& aConfig)
{
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_1, "CIPv4Binder::UpdateContextConfig");
// Get our IP address from the GPRS context config.
TInetAddr address;
TBuf<RPacketContext::KMaxPDPAddressLength> tempAddr;
const RPacketContext::TProtocolConfigOptionV2* pco;
TInt rel = const_cast<TPacketDataConfigBase&>(aConfig).ExtensionId();
if (rel == TPacketDataConfigBase::KConfigGPRS)
{
tempAddr.Copy(static_cast<const RPacketContext::TContextConfigGPRS&>(aConfig).iPdpAddress);
pco = &static_cast<const RPacketContext::TContextConfigGPRS&>(aConfig).iProtocolConfigOption;
}
else
{
ASSERT(rel == TPacketDataConfigBase::KConfigRel99Rel4 || rel == TPacketDataConfigBase::KConfigRel5);
tempAddr.Copy(static_cast<const RPacketContext::TContextConfigR99_R4&>(aConfig).iPdpAddress);
pco = &static_cast<const RPacketContext::TContextConfigR99_R4&>(aConfig).iProtocolConfigOption;
}
TInt ret = address.Input(tempAddr);
// We've got our IP address! Let's save it.
if (ret == KErrNone)
{
iSettings.iLocalAddr = address.Address();
OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_2, "Got local IP address from context = %u.%u.%u.%u",iSettings.iLocalAddr >> 24, (iSettings.iLocalAddr >> 16) & 0xFF, (iSettings.iLocalAddr >> 8) & 0xFF, iSettings.iLocalAddr & 0xFF);
iSettings.iDefGateway = address.Address();
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_3, "Set Default Gateway to local IP address");
}
示例2: UT_CTBCPFloorControlImpl_CancelSendL
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);
}
示例3:
enum TVerdict CEsockTest19_7::easyTestStepL()
{
TInetAddr addr;
TBuf<39> buf;
// set IP address using a prefix length
// set IP address
addr.PrefixMask(60);
// check it has been set correctly
addr.OutputWithScope(buf);
TESTL(buf==_L("ffff:ffff:ffff:fff0::"));
// change the IP address
addr.Input(_L("1.1.1.1.1.1.1.1"));
// set the IP address using a different prefisx length
addr.PrefixMask(58);
// check it has been set correctly
addr.OutputWithScope(buf);
TESTL(buf==_L("ffff:ffff:ffff:ffc0::"));
return EPass;
}
示例4: ConstructL
void CSender::ConstructL()
{
// Connect to socket server
User::LeaveIfError(iSocketServ.Connect());
User::LeaveIfError(iSocketServ.ShareAuto()); // allow other threads to use
iSendSocket.Close();
User::LeaveIfError(iSendSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp));
TRequestStatus status;
// Request the Socket to connect to the destination address (implicit Connection)
TInetAddr destAddr;
destAddr.Input(KRemoteAddr);
destAddr.SetPort(KRemotePort);
iSendSocket.Connect(destAddr, status);
RDEBUGPRINTLOGGER1(_L("RPS: Waiting for Send socket to connect to remote destination ..."));
User::WaitForRequest(status);
RDEBUGPRINTLOGGER2(_L("RPS: Wait over. Status returned: %d\n"), status.Int());
if(status != KErrNone)
{
RDEBUGPRINTLOGGER1(_L("RPS: Socket could not Connect!!"));
User::Leave(KErrCouldNotConnect);
}
else
{
RDEBUGPRINTLOGGER1(_L("RPS: Send socket connected to remote destination "));
}
}
示例5: StartL
TBool CTcpTestConsole::StartL()
{
TLex args(iChars);
// args are separated by spaces
args.SkipSpace();
TInetAddr addr;
TInt size;
if(!iMode)
{
//Get ip addr
TPtrC cmdAddr = args.NextToken();
if(!args.Eos())
{
if(KErrNone == addr.Input(cmdAddr))
{
args.Inc();
}
else
{
return EFalse;
}
}
else
{
return EFalse;
}
}
//Get port
TInt port;
if(KErrNone != args.Val(port))
{
return EFalse;
}
addr.SetPort(port);
//Get pkg size
args.Inc();
if(KErrNone != args.Val(size))
{
return EFalse;
}
iCommandMode = ECommandRunning;
if (iIsTcp)
{
iConsole->Printf(_L("Test for TCP...\n"));
iTcp = CTcpProcess::NewL(*iConsole, addr, port, size, iMode);
}
else
{
iConsole->Printf(_L("Test for UDP...\n"));
iUdp = CUdpProcess::NewL(*iConsole, addr, port, size, iMode);
}
return ETrue;
}
示例6: do_execute
//------------------------------------------------------------------------------------------------------
// testing
// EHRGetByAddress
// Requires alive connection. Uses Ethernet one
//------------------------------------------------------------------------------------------------------
TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<EHRGetByAddress>)
{
TInt result;
//-- 1. Create a connection.
result = OpenHostResolver();
if(result != KErrNone)
{
//-- close connection
SendReceive(EHRClose,TIpcArgs(0,0,0,iSSRes));
return result;
}
_LIT(KName, "127.0.0.1");
TBufC<20> aName(KName);
TInetAddr addr;
addr.Input(aName);
TNameEntry aResult;
result =SendReceive(EHRGetByAddress,TIpcArgs(&addr,&aResult,0, iSSRes));
if(result != KErrNone)
return result;
//-- stop connection
result = SendReceive(EHRClose,TIpcArgs(0,0,0,iSSRes));
return result;
}
示例7:
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 );
}
示例8: parser
int
TcpipComm::Open(CConsoleBase *cons, TDes &name, TDesC &destination,
TRequestStatus &st)
{
int r;
TInetAddr addr;
TPtrC servername;
int port = 0;
if((r = iServ.Connect()) != KErrNone)
return r;
if((r = iSock.Open(iServ,KAfInet,KSockStream,KProtocolInetTcp)) != KErrNone)
return r;
//////////////
// Parse the destination, which is of the form ip.adress:port
for(r = 0; r < destination.Length(); r++)
if(destination[r] == ':')
break;
servername.Set(destination.Left(r)); // Wont include ':'
TLex parser(destination.Mid(r+1));
parser.Val(port);
addr.SetPort(port);
if(addr.Input(servername) != KErrNone) // Its a real hostname, wont resolv
return 1;
iSock.Connect(addr, st);
TPckgBuf<int> one(1);
iSock.SetOpt(KSoTcpNoDelay, KSolInetTcp, one);
return 0;
}
示例9: UT_CTBCPFloorControlImpl_SetAddressLL
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());
}
示例10: TestStepResult
enum TVerdict CTestIdna04::doTestStepL()
{
INFO_PRINTF1(_L(" Testing GetByAddress(for an IDN) with IDN Enabled "));
INFO_PRINTF1(_L("*********************************************************"));
SetTestStepResult(EFail); // By default start the test case with failure.
RSocketServ pSocketServ;
User::LeaveIfError(pSocketServ.Connect());
RConnection myConnection;
myConnection.Open(pSocketServ, KAfInet);
TRequestStatus myStatus=KErrNone;
myConnection.Start(myStatus);
User::WaitForRequest(myStatus);
RHostResolver hr;
hr.Open(pSocketServ,KAfInet,KProtocolInetUdp);
TBool enableIdn = ETrue;//enabling the option of IDN support
TPckgC<TBool> pckgEnable(enableIdn);
TInt setOptErr = hr.SetOpt(KSoDnsEnableIdn , KSolInetDns , pckgEnable);
User::LeaveIfError(setOptErr);
TInetAddr inetAddr;
//inetAddr.Input(_L("83.241.177.38")); // this is the IPAddress of the domain räksmörgås.josefsson.org
// as of 06 Feb 2009. If this IP changes, this test case might fail
// but no harm on this.
//TNameEntry resultEntry;
inetAddr.Input(_L("64.233.169.103"));
TNameRecord asdf;
TPckgBuf<TNameRecord> resultEntry(asdf);
hr.GetByAddress(inetAddr,resultEntry,myStatus);
User::WaitForRequest(myStatus);
TInt err = myStatus.Int();
if(err == KErrNone)
{
INFO_PRINTF2(_L(" GetByAddress with IDN disabled returned %d"),err);
SetTestStepResult(EPass);
}
hr.Close();
myConnection.Close();
pSocketServ.Close();
return TestStepResult();
}
示例11: UT_CTBCPFloorControlImpl_ConnectionStartedLL
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);
}
示例12: sizeof
/*
* Convert text to IPv4/IPv6 address.
*/
PJ_DEF(pj_status_t) pj_inet_pton(int af, const pj_str_t *src, void *dst)
{
char tempaddr[PJ_INET6_ADDRSTRLEN];
PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6, PJ_EINVAL);
PJ_ASSERT_RETURN(src && src->slen && dst, PJ_EINVAL);
/* Initialize output with PJ_IN_ADDR_NONE for IPv4 (to be
* compatible with pj_inet_aton()
*/
if (af==PJ_AF_INET) {
((pj_in_addr*)dst)->s_addr = PJ_INADDR_NONE;
}
/* Caution:
* this function might be called with cp->slen >= 46
* (i.e. when called with hostname to check if it's an IP addr).
*/
if (src->slen >= PJ_INET6_ADDRSTRLEN) {
return PJ_ENAMETOOLONG;
}
pj_memcpy(tempaddr, src->ptr, src->slen);
tempaddr[src->slen] = '\0';
wchar_t tempaddr16[PJ_INET6_ADDRSTRLEN];
pj_ansi_to_unicode(tempaddr, pj_ansi_strlen(tempaddr),
tempaddr16, sizeof(tempaddr16));
TBuf<PJ_INET6_ADDRSTRLEN> ip_addr((const TText*)tempaddr16);
TInetAddr addr;
addr.Init(KAfInet6);
if (addr.Input(ip_addr) == KErrNone) {
if (af==PJ_AF_INET) {
/* Success (Symbian IP address is in host byte order) */
pj_uint32_t ip = pj_htonl(addr.Address());
pj_memcpy(dst, &ip, 4);
} else if (af==PJ_AF_INET6) {
const TIp6Addr & ip6 = addr.Ip6Address();
pj_memcpy(dst, ip6.u.iAddr8, 16);
} else {
pj_assert(!"Unexpected!");
return PJ_EBUG;
}
return PJ_SUCCESS;
} else {
/* Error */
return PJ_EINVAL;
}
}
示例13: InternalizeL
// -----------------------------------------------------------------------------
// CSdpConnectionField::InternalizeL
// Internalizes the object from stream
// -----------------------------------------------------------------------------
//
CSdpConnectionField* CSdpConnectionField::InternalizeL(
RReadStream& aStream )
{
TUint32 length;
CSdpConnectionField* obj = NULL;
RStringPool pool = SdpCodecStringPool::StringPoolL();
// address
length = aStream.ReadUint32L();
HBufC8* address = HBufC8::NewLC( length );
TPtr8 ptr( address->Des() );
aStream.ReadL( ptr, length );
// TTL
TInt ttl = aStream.ReadInt32L();
// Number of addresses
TInt numOfAddr = aStream.ReadInt32L();
// Network type
length = aStream.ReadUint32L();
HBufC8* netType = HBufC8::NewLC( length );
ptr.Set( netType->Des() );
aStream.ReadL( ptr, length );
// Address type
length = aStream.ReadUint32L();
HBufC8* addrType = HBufC8::NewLC( length );
ptr.Set( addrType->Des() );
aStream.ReadL( ptr, length );
TInetAddr addr;
HBufC* address16 = HBufC::NewLC( address->Length() ) ;
address16->Des().Copy( *address );
TInt err = addr.Input( *address16 );
if ( !err )
{
// Create connection field based on TInetAddr
obj = CSdpConnectionField::NewL( addr, ttl, numOfAddr );
}
else
{
// Create connection field from buffer, ttl & numOfAddr
// are in this case irrelevant
RStringF netTypeStr = pool.OpenFStringL( *netType );
CleanupClosePushL( netTypeStr );
RStringF addrTypeStr = pool.OpenFStringL( *addrType );
CleanupClosePushL( addrTypeStr );
obj = CSdpConnectionField::NewL( netTypeStr, addrTypeStr, *address );
CleanupStack::PopAndDestroy( 2 ); // netTypeStr, addrTypeStr
}
CleanupStack::PopAndDestroy( 4 ); // address, netType, addrType, address16
return obj;
}
示例14: IsValidAddress
// -----------------------------------------------------------------------------
// CSdpOriginField::IsValidAddress
// Checks if the address is valid
// -----------------------------------------------------------------------------
//
TBool CSdpOriginField::IsValidAddress(
const TDesC8& aAddress ) const
{
TInetAddr addr;
TBool valid = ETrue;
if ( aAddress.Length() > 0 && aAddress.Length() <= KMaxAddressLength )
{
TBuf<KMaxAddressLength> address16;
address16.Copy( aAddress );
TInt err = addr.Input( address16 );
if ( !err )
{
valid = ( addr.IsUnicast() || addr.IsUnspecified() );
}
else
{
RStringF addrTypeIP4 =
iPool.StringF( SdpCodecStringConstants::EAddressTypeIP4,
SdpCodecStringConstants::Table );
RStringF addrTypeIP6 =
iPool.StringF( SdpCodecStringConstants::EAddressType,
SdpCodecStringConstants::Table );
if ( iAddressType == addrTypeIP4 || iAddressType == addrTypeIP6 )
{
// FQDN address, check that it has only valid characters
// 0..9, a..z, A..Z, '.', '-'
for ( TInt i( 0 ); i < aAddress.Length() && valid; i++ )
{
if (KValidFQDNChars().Locate(aAddress[i]) == KErrNotFound)
{
valid = EFalse;
}
}
}
else
{
valid = SdpUtil::IsNonWhitespace( aAddress );
}
}
}
else
{
valid = EFalse;
}
return valid;
}
示例15:
void TFtpTest02Params::SetParams(const TDesC& aInetAddr, TUint aPort, const TDesC& aHostName,
const TDesC8& aUserName, const TDesC8& aPassword, const TDesC8& aDirectoryPath,
const TDesC8& aRemoteFileName, const TDesC& aLocalFileName)
{
iInetAddr.Input(aInetAddr);
iInetAddr.SetPort(aPort);
iPort=aPort;
iHostName=aHostName;
iUserName.Set(aUserName);
iDirectoryPath.Set(aDirectoryPath);
iPassword.Set(aPassword);
iRemoteFileName.Set(aRemoteFileName);
iLocalFileName.Set(aLocalFileName);
}