本文整理汇总了C++中TInetAddr::IsUnspecified方法的典型用法代码示例。如果您正苦于以下问题:C++ TInetAddr::IsUnspecified方法的具体用法?C++ TInetAddr::IsUnspecified怎么用?C++ TInetAddr::IsUnspecified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TInetAddr
的用法示例。
在下文中一共展示了TInetAddr::IsUnspecified方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsUnspecifiedL
// ---------------------------------------------------------------------------
// NSPUtil::IsUnspecifiedL
// ---------------------------------------------------------------------------
//
TBool NSPUtil::IsUnspecifiedL( const TDesC8& aAddress, TUint aPort )
{
TInetAddr addr;
TRAPD( error, addr = ConvertTDesC8ToTInetAddrL( aAddress, aPort ) );
User::LeaveIfError( KErrNoMemory == error ? KErrNoMemory : KErrNone );
return ( KErrNone == error ? addr.IsUnspecified() : EFalse );
}
示例2: UT_CICEHostResolver_LocalAddressL
void UT_CIceHostResolver::UT_CICEHostResolver_LocalAddressL()
{
UT_CICEHostResolver_FetchCandidateLL();
for ( TInt i(0); i < iLocalCandidates.Count(); ++i )
{
if ( CNATFWCandidate::EHost == iLocalCandidates[i]->Type() )
{
TInetAddr address = iResolver->LocalAddress(
iLocalCandidates[i]->StreamId(), KAfInet );
EUNIT_ASSERT( !address.IsUnspecified() );
}
else
{
TInetAddr address = iResolver->LocalAddress(
iLocalCandidates[i]->StreamId(), KAfInet );
EUNIT_ASSERT( address.IsUnspecified() );
}
}
}
示例3: 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;
}
示例4: CheckAndSetAddr
// -----------------------------------------------------------------------------
// CLocalAddrResolver::CheckAndSetAddr
// -----------------------------------------------------------------------------
//
void CLocalAddrResolver::CheckAndSetAddr( TInetAddr& aTarget,
TInetAddr& aCandidate,
TUint32 aCandidateIap,
TUint32 aSpecifiedIap )
{
if ( !aCandidate.IsUnspecified() && !aCandidate.IsLoopback() )
{
if ( aCandidate.IsV4Mapped())
{
aCandidate.ConvertToV4();
}
if ( aCandidateIap == aSpecifiedIap )
{
SetAddr( aTarget, aCandidate );
}
}
}
示例5: SetIPAddressType
// -----------------------------------------------------------------------------
// CSdpOriginField::SetIPAddressType
// -----------------------------------------------------------------------------
//
void CSdpOriginField::SetIPAddressType( const TInetAddr& aAddr )
{
iAddressType.Close();
if ( aAddr.Address() || aAddr.IsUnspecified() )
{
//IPv4, IPv4-Mapped IPv6 and 0.0.0.0
iAddressType =
iPool.StringF( SdpCodecStringConstants::EAddressTypeIP4,
SdpCodecStringConstants::Table ).Copy();
}
else
{
//IPv6
iAddressType =
iPool.StringF( SdpCodecStringConstants::EAddressType,
SdpCodecStringConstants::Table ).Copy();
}
}
示例6: Connect
int CPjSSLSocket::Connect(CPjSSLSocket_cb cb, void *key,
const TInetAddr &local_addr,
const TInetAddr &rem_addr,
const TDesC8 &servername,
const TDesC8 &ciphers)
{
pj_status_t status;
PJ_ASSERT_RETURN(state_ == SSL_STATE_NULL, PJ_EINVALIDOP);
status = pj_sock_socket(rem_addr.Family(), pj_SOCK_STREAM(), 0, &sock_);
if (status != PJ_SUCCESS)
return status;
// Apply QoS
status = pj_sock_apply_qos2(sock_, qos_type_, &qos_params_,
2, THIS_FILE, NULL);
RSocket &rSock = ((CPjSocket*)sock_)->Socket();
local_addr_ = local_addr;
if (!local_addr_.IsUnspecified()) {
TInt err = rSock.Bind(local_addr_);
if (err != KErrNone)
return PJ_RETURN_OS_ERROR(err);
}
cb_ = cb;
key_ = key;
rem_addr_ = rem_addr;
/* Note: the following members only keep the pointer, not the data */
servername_.Set(servername);
ciphers_.Set(ciphers);
rSock.Connect(rem_addr_, iStatus);
SetActive();
state_ = SSL_STATE_CONNECTING;
rSock.LocalName(local_addr_);
return PJ_EPENDING;
}
示例7: TypeMatchesWithFormat
// -----------------------------------------------------------------------------
// CSdpOriginField::TypeMatchesWithFormat
// Checks if address type is aligned with the address format
// -----------------------------------------------------------------------------
//
TBool CSdpOriginField::TypeMatchesWithFormat(
const TDesC8& aAddress,
const TDesC8& aType,
RStringPool aPool ) const
{
RStringF addrTypeIP4 =
aPool.StringF( SdpCodecStringConstants::EAddressTypeIP4,
SdpCodecStringConstants::Table );
RStringF addrTypeIP6 =
aPool.StringF( SdpCodecStringConstants::EAddressType,
SdpCodecStringConstants::Table );
TBool valid( ETrue );
// Check that address type and address matches together
TInetAddr addr;
TBuf<KMaxAddressLength> address16;
address16.Copy( aAddress );
TInt err = addr.Input( address16 );
if ( err == KErrNone && !addr.IsUnspecified())
{
TBool ip4Type = ( addrTypeIP4.DesC().CompareF( aType ) == 0 );
TBool ip6Type = ( addrTypeIP6.DesC().CompareF( aType ) == 0 );
if ( ip4Type || ip6Type )
{
if ( ( addr.Address() && !addr.IsV4Mapped() && !ip4Type ) ||
(addr.Address() && addr.IsV4Mapped() && !ip6Type) ||
( !addr.Address() && !ip6Type ) )
{
valid = EFalse;
}
}
}
return valid;
}
示例8: UpdateOriginFieldL
// ---------------------------------------------------------------------------
// NSPUtil::UpdateOriginFieldL
// ---------------------------------------------------------------------------
//
void NSPUtil::UpdateOriginFieldL(
CSdpOriginField& aField, const TDesC8& aAddress )
{
__ASSERT_ALWAYS( &aField, User::Leave( KErrArgument ) );
__ASSERT_ALWAYS( &aAddress != NULL, User::Leave( KErrArgument ) );
TBool unspecf( EFalse );
RStringF netType = aField.NetType();
RStringF addressType = aField.AddressType();
const TDesC8& address = aField.Address();
TInetAddr addr;
HBufC* addrBuf = HBufC::NewLC( KMaxLengthOfFQDN );
TPtr addrPtr( addrBuf->Des() );
addrPtr.Copy( address );
if ( !addr.Input( addrBuf->Des() ) ) // valid IP
{
unspecf = addr.IsUnspecified();
addrPtr.Copy( aAddress );
if ( !unspecf && !addr.Input( addrBuf->Des() ) )
{
CSdpConnectionField* field = CSdpConnectionField::NewL( addr );
addressType = field->AddressType();
delete field;
}
}
if ( !unspecf )
{
aField.SetAddressL( aAddress, netType, addressType );
}
CleanupStack::PopAndDestroy( addrBuf );
}
示例9: ListInterfacesL
//.........这里部分代码省略.........
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);
}
示例10: AddInfoL
// -----------------------------------------------------------------------------
// CUpnpDeviceLibraryElement::AddInfoL
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C void CUpnpDeviceLibraryElement::AddInfoL(const TUpnpAddLocalDevice* anIndex,
const TDesC8& aBuffer,
const TInetAddr& aAddr)
{
if ( !anIndex )
{
return;
}
TInt index = 0;
TPtrC8 uuid = aBuffer.Left(anIndex->iUuidLength);
index += anIndex->iUuidLength;
TPtrC8 deviceType = aBuffer.Mid(index, anIndex->iDeviceTypeLength);
index += anIndex->iDeviceTypeLength;
TPtrC8 descriptionUrl = aBuffer.Mid(index, anIndex->iDescriptionUrlLength);
index += anIndex->iDescriptionUrlLength;
TPtrC8 domain = aBuffer.Mid(index, anIndex->iDomainLength);
index += anIndex->iDomainLength;
TPtrC8 port = aBuffer.Mid(index, anIndex->iPortNumberLength);
index += anIndex->iPortNumberLength;
TPtrC8 root = aBuffer.Mid(index, anIndex->iRootDeviceLength);
index += anIndex->iRootDeviceLength;
if (uuid.Length()> 0)
{
SetUuidL(uuid);
}
if (deviceType.Length()> 0)
{
SetDeviceTypeL(deviceType);
}
if (root.Length()> 0)
{
SetRootDevice( ETrue );
}
else
{
SetRootDevice( EFalse );
}
if (descriptionUrl.Length()> 0)
{
if (aAddr.IsUnspecified())
{
SetDescriptionUrlL(descriptionUrl);
}
else
{
SetDescriptionUrlL(descriptionUrl, aAddr, port);
}
}
if (domain.Length()> 0)
{
SetDomainL(domain);
}
for (TInt i=0; i < KMaxServiceCount; i++)
{
TPtrC8 serviceType = aBuffer.Mid(index, anIndex->iServiceLength[i]);
index += anIndex->iServiceLength[i];
AddServiceTypeL(serviceType);
}
}
示例11: fromName
QHostInfo QHostInfoAgent::fromName(const QString &hostName, QSharedPointer<QNetworkSession> networkSession)
{
QHostInfo results;
// Connect to ESOCK
RSocketServ socketServ(qt_symbianGetSocketServer());
RHostResolver hostResolver;
int err;
if (networkSession)
err = QNetworkSessionPrivate::nativeOpenHostResolver(*networkSession, hostResolver, KAfInet, KProtocolInetUdp);
else
err = hostResolver.Open(socketServ, KAfInet, KProtocolInetUdp);
if (err) {
setError_helper(results, err);
return results;
}
TNameEntry nameResult;
#if defined(QHOSTINFO_DEBUG)
qDebug("QHostInfoAgent::fromName(%s) looking up...",
hostName.toLatin1().constData());
#endif
QHostAddress address;
if (address.setAddress(hostName)) {
// Reverse lookup
#if defined(QHOSTINFO_DEBUG)
qDebug("(reverse lookup)");
#endif
TInetAddr IpAdd;
IpAdd.Input(qt_QString2TPtrC(hostName));
// Synchronous request. nameResult returns Host Name.
err = hostResolver.GetByAddress(IpAdd, nameResult);
if (err) {
//for behavioural compatibility with Qt 4.7 and unix/windows
//backends: don't report error, return ip address as host name
results.setHostName(address.toString());
} else {
results.setHostName(qt_TDesC2QString(nameResult().iName));
}
results.setAddresses(QList<QHostAddress>() << address);
return results;
}
// IDN support
QByteArray aceHostname = QUrl::toAce(hostName);
results.setHostName(hostName);
if (aceHostname.isEmpty()) {
results.setError(QHostInfo::HostNotFound);
results.setErrorString(hostName.isEmpty() ?
QCoreApplication::translate("QHostInfoAgent", "No host name given") :
QCoreApplication::translate("QHostInfoAgent", "Invalid hostname"));
return results;
}
// Call RHostResolver::GetByAddress, and place all IPv4 addresses at the start and
// the IPv6 addresses at the end of the address list in results.
// Synchronous request.
err = hostResolver.GetByName(qt_QString2TPtrC(QString::fromLatin1(aceHostname)), nameResult);
if (err) {
setError_helper(results, err);
return results;
}
QList<QHostAddress> hostAddresses;
TInetAddr hostAdd = nameResult().iAddr;
if (!(nameResult().iFlags & TNameRecord::EAlias) && !(hostAdd.IsUnspecified()))
hostAddresses.append(qt_QHostAddressFromTInetAddr(hostAdd));
// Check if there's more than one IP address linkd to this name
while (hostResolver.Next(nameResult) == KErrNone) {
hostAdd = nameResult().iAddr;
// Ensure that record is valid (not an alias and with length greater than 0)
if (!(nameResult().iFlags & TNameRecord::EAlias) && !(hostAdd.IsUnspecified()))
hostAddresses.append(qt_QHostAddressFromTInetAddr(hostAdd));
}
hostResolver.Close();
results.setAddresses(hostAddresses);
return results;
}