本文整理汇总了C++中TInetAddr::IsUnicast方法的典型用法代码示例。如果您正苦于以下问题:C++ TInetAddr::IsUnicast方法的具体用法?C++ TInetAddr::IsUnicast怎么用?C++ TInetAddr::IsUnicast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TInetAddr
的用法示例。
在下文中一共展示了TInetAddr::IsUnicast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: IsValidAddress
// -----------------------------------------------------------------------------
// 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;
}