TInetAddr Class Reference

class TInetAddr : public TSockAddr

This class specialises the generic socket server address class TSockAddr for the TCP/IP protocol family. It represents an IP address and stores either an IPv4 or an IPv6 address in its buffer after the generic data defined by TSockAddr. The protocol family field provided by the TSockAddr base class can be set to KAfInet, KAfInet6 or KAFUnspec.

The address family defines the format of the stored address:

  • KAfInet is for plain 32 bits IPv4 address presented as SInetAddr structure.

  • KAfInet6 is for both IPv4 and IPv6 addresses (IPv4 addresses are in IPv4 mapped format). The content is presented as SInet6Addr structure, which includes the scope id and flow label, in addition to the 128 address bits.

  • KAFUnspec does not contain any addresses and works in most contexts as unspecified address, This is better than placing explicit IPv4 "0.0.0.0" or IPv6 "::", which in certain situations may limit the connections to either IPv4 or IPv6, but not both.

The flow label and scope id fields exist only in KAfInet6 format. However, the access functions TInetAddr::FlowLabel and TInetAddr::Scope will also work for other address formats by always returning 0.

Any function which sets or changes the address bits, will always reset the scope id and flow label to 0 (the TInetAddr::Init is always called internally). These are reasonable defaults, and normal application user does not normally need to worry about flow label or scope id.

When address is returned from the stack, it will often be in KAfInet6 format, and may contain non-zero values for flow label and scope id fields. When copying addresses, the full TInetAddr (or at least SInet6Addr) should be copied to preserve these fields.

7.0 The IPv4 only portion is backward compatible with older versions. In 7.0s some functions have additional features.

Public Member Functions
TInetAddr()
TInetAddr(const TSockAddr &)
TInetAddr(TUint)
TInetAddr(const TIp6Addr &, TUint)
TInetAddr(TUint32, TUint)
IMPORT_C TUint32Address()
TInetAddr &Cast(const TSockAddr &)
TInetAddr &Cast(const TSockAddr *)
IMPORT_C TBoolCmpAddr(const TInetAddr &)
IMPORT_C voidConvertToV4()
IMPORT_C voidConvertToV4Compat()
IMPORT_C voidConvertToV4Mapped()
IMPORT_C TIntFlowLabel()
IMPORT_C voidInit(TUint)
IMPORT_C TIntInput(const TDesC &)
IMPORT_C const TIp6Addr &Ip6Address()
TBool IsBroadcast()
TBool IsClassA()
TBool IsClassB()
TBool IsClassC()
IMPORT_C TBoolIsLinkLocal()
IMPORT_C TBoolIsLoopback()
IMPORT_C TBoolIsMulticast()
IMPORT_C TBoolIsSiteLocal()
IMPORT_C TBoolIsUnicast()
IMPORT_C TBoolIsUnspecified()
IMPORT_C TBoolIsV4Compat()
IMPORT_C TBoolIsV4Mapped()
TBool IsWildAddr()
TBool IsWildPort()
IMPORT_C TBoolMatch(const TInetAddr &)
IMPORT_C TBoolMatch(const TInetAddr &, const TInetAddr &)
IMPORT_C TBoolMatch(const TInetAddr &, TInt)
IMPORT_C voidNet(const TInetAddr &)
IMPORT_C voidNetBroadcast(const TInetAddr &)
IMPORT_C voidNetMask(const TInetAddr &)
IMPORT_C voidOutput(TDes &)
IMPORT_C voidOutputWithScope(TDes &)
IMPORT_C voidPrefix(const TInetAddr &, TInt)
IMPORT_C voidPrefixMask(TInt)
IMPORT_C TUint32Scope()
IMPORT_C voidSetAddress(TUint32)
IMPORT_C voidSetAddress(const TIp6Addr &)
IMPORT_C voidSetFlowLabel(TInt)
IMPORT_C voidSetScope(TUint32)
IMPORT_C voidSetV4CompatAddress(TUint32)
IMPORT_C voidSetV4MappedAddress(TUint32)
IMPORT_C voidSubNet(const TInetAddr &, const TInetAddr &)
IMPORT_C voidSubNetBroadcast(const TInetAddr &, const TInetAddr &)
Protected Member Functions
SInetAddr *Addr4Ptr()
TInt AddrLen()
SInet6Addr *AddrPtr()
Private Member Functions
TInt Ipv4Input(const TDesC &)
TInt Ipv6Input(const TDesC &)
Inherited Functions
TBuf8< KMaxSockAddrSize >::TBuf8()
TBuf8< KMaxSockAddrSize >::TBuf8(TInt)
TBuf8< KMaxSockAddrSize >::TBuf8(const TDesC8 &)
TBuf8< KMaxSockAddrSize >::TBuf8(const TUint8 *)
TBuf8< KMaxSockAddrSize >::operator=(const TBuf8< S > &)
TBuf8< KMaxSockAddrSize >::operator=(const TDesC8 &)
TBuf8< KMaxSockAddrSize >::operator=(const TUint8 *)
TBufBase8::TBufBase8(TInt)
TBufBase8::TBufBase8(TInt,TInt)
TBufBase8::TBufBase8(const TDesC8 &,TInt)
TBufBase8::TBufBase8(const TUint8 *,TInt)
TDes8::Append(TChar)
TDes8::Append(const TDesC16 &)
TDes8::Append(const TDesC8 &)
TDes8::Append(const TUint8 *,TInt)
TDes8::AppendFill(TChar,TInt)
TDes8::AppendFormat(TRefByValue< const TDesC8 >,...)
TDes8::AppendFormat(TRefByValue< const TDesC8 >,TDes8Overflow *,...)
TDes8::AppendFormatList(const TDesC8 &,VA_LIST,TDes8Overflow *)
TDes8::AppendJustify(const TDesC8 &,TInt,TAlign,TChar)
TDes8::AppendJustify(const TDesC8 &,TInt,TInt,TAlign,TChar)
TDes8::AppendJustify(const TUint8 *,TInt,TAlign,TChar)
TDes8::AppendJustify(const TUint8 *,TInt,TInt,TAlign,TChar)
TDes8::AppendNum(TInt64)
TDes8::AppendNum(TReal,const TRealFormat &)
TDes8::AppendNum(TUint64,TRadix)
TDes8::AppendNumFixedWidth(TUint,TRadix,TInt)
TDes8::AppendNumFixedWidthUC(TUint,TRadix,TInt)
TDes8::AppendNumUC(TUint64,TRadix)
TDes8::Capitalize()
TDes8::Collapse()
TDes8::Collate()
TDes8::Copy(const TDesC16 &)
TDes8::Copy(const TDesC8 &)
TDes8::Copy(const TUint8 *)
TDes8::Copy(const TUint8 *,TInt)
TDes8::CopyC(const TDesC8 &)
TDes8::CopyCP(const TDesC8 &)
TDes8::CopyF(const TDesC8 &)
TDes8::CopyLC(const TDesC8 &)
TDes8::CopyUC(const TDesC8 &)
TDes8::Delete(TInt,TInt)
TDes8::DoAppendNum(TUint64,TRadix,TUint,TInt)
TDes8::DoPadAppendNum(TInt,TInt,const TUint8 *)
TDes8::Expand()
TDes8::Fill(TChar)
TDes8::Fill(TChar,TInt)
TDes8::FillZ()
TDes8::FillZ(TInt)
TDes8::Fold()
TDes8::Format(TRefByValue< const TDesC8 >,...)
TDes8::FormatList(const TDesC8 &,VA_LIST)
TDes8::Insert(TInt,const TDesC8 &)
TDes8::Justify(const TDesC8 &,TInt,TAlign,TChar)
TDes8::LeftTPtr(TInt)const
TDes8::LowerCase()
TDes8::MaxLength()const
TDes8::MaxSize()const
TDes8::MidTPtr(TInt)const
TDes8::MidTPtr(TInt,TInt)const
TDes8::Num(TInt64)
TDes8::Num(TReal,const TRealFormat &)
TDes8::Num(TUint64,TRadix)
TDes8::NumFixedWidth(TUint,TRadix,TInt)
TDes8::NumFixedWidthUC(TUint,TRadix,TInt)
TDes8::NumUC(TUint64,TRadix)
TDes8::PtrZ()
TDes8::Repeat(const TDesC8 &)
TDes8::Repeat(const TUint8 *,TInt)
TDes8::Replace(TInt,TInt,const TDesC8 &)
TDes8::RightTPtr(TInt)const
TDes8::SetLength(TInt)
TDes8::SetMax()
TDes8::Swap(TDes8 &)
TDes8::TDes8()
TDes8::TDes8(TInt,TInt,TInt)
TDes8::Trim()
TDes8::TrimAll()
TDes8::TrimLeft()
TDes8::TrimRight()
TDes8::UpperCase()
TDes8::WPtr()const
TDes8::Zero()
TDes8::ZeroTerminate()
TDes8::operator+=(const TDesC8 &)
TDes8::operator=(const TDes8 &)
TDes8::operator[](TInt)
TDes8::operator[](TInt)const
TDesC8::Alloc()const
TDesC8::AllocL()const
TDesC8::AllocLC()const
TDesC8::AtC(TInt)const
TDesC8::Compare(const TDesC8 &)const
TDesC8::CompareC(const TDesC8 &)const
TDesC8::CompareF(const TDesC8 &)const
TDesC8::DoSetLength(TInt)
TDesC8::Find(const TDesC8 &)const
TDesC8::Find(const TUint8 *,TInt)const
TDesC8::FindC(const TDesC8 &)const
TDesC8::FindC(const TUint8 *,TInt)const
TDesC8::FindF(const TDesC8 &)const
TDesC8::FindF(const TUint8 *,TInt)const
TDesC8::Left(TInt)const
TDesC8::Length()const
TDesC8::Locate(TChar)const
TDesC8::LocateF(TChar)const
TDesC8::LocateReverse(TChar)const
TDesC8::LocateReverseF(TChar)const
TDesC8::Match(const TDesC8 &)const
TDesC8::MatchC(const TDesC8 &)const
TDesC8::MatchF(const TDesC8 &)const
TDesC8::Mid(TInt)const
TDesC8::Mid(TInt,TInt)const
TDesC8::Ptr()const
TDesC8::Right(TInt)const
TDesC8::Size()const
TDesC8::TDesC8()
TDesC8::TDesC8(TInt,TInt)
TDesC8::Type()const
TDesC8::operator!=(const TDesC8 &)const
TDesC8::operator<(const TDesC8 &)const
TDesC8::operator<=(const TDesC8 &)const
TDesC8::operator==(const TDesC8 &)const
TDesC8::operator>(const TDesC8 &)const
TDesC8::operator>=(const TDesC8 &)const
TSockAddr::CmpPort(const TSockAddr &)const
TSockAddr::Family()const
TSockAddr::GetUserLen()
TSockAddr::Port()const
TSockAddr::SetFamily(TUint)
TSockAddr::SetPort(TUint)
TSockAddr::SetUserLen(TInt)
TSockAddr::TSockAddr()
TSockAddr::TSockAddr(TUint)
TSockAddr::UserPtr()const
Inherited Attributes
TBuf8< KMaxSockAddrSize >::iBuf
TDes8::__DECLARE_TEST
TDes8::iMaxLength

Constructor & Destructor Documentation

TInetAddr()

IMPORT_CTInetAddr()

TInetAddr(const TSockAddr &)

IMPORT_CTInetAddr(const TSockAddr &aAddr)

Parameters

const TSockAddr & aAddr

TInetAddr(TUint)

IMPORT_CTInetAddr(TUintaPort)

Parameters

TUint aPort

TInetAddr(const TIp6Addr &, TUint)

IMPORT_CTInetAddr(const TIp6Addr &aAddr,
TUintaPort
)

Parameters

const TIp6Addr & aAddr
TUint aPort

TInetAddr(TUint32, TUint)

IMPORT_CTInetAddr(TUint32aAddr,
TUintaPort
)

Parameters

TUint32 aAddr
TUint aPort

Member Functions Documentation

Addr4Ptr()

SInetAddr *Addr4Ptr()const [protected, inline]

Returns a pointer to KAfInet content format

AddrLen()

TInt AddrLen()[protected, static, inline]

Returns the size of the KAfInet6 content format.

AddrPtr()

SInet6Addr *AddrPtr()const [protected, inline]

Returns a pointer to KAfInet6 content format.

Address()

IMPORT_C TUint32Address()const

Cast(const TSockAddr &)

TInetAddr &Cast(const TSockAddr &aAddr)[static, inline]

Casts a TSockAddr to a TInetAddr reference.

The cast is only safe if the object being referenced is actually aTInetAddr.

Casted reference to a TInetAddr.

Parameters

const TSockAddr & aAddrTSockAddr to cast

Cast(const TSockAddr *)

TInetAddr &Cast(const TSockAddr *aAddr)[static, inline]

Casts a TSockAddr to a TInetAddr reference.

The cast is only safe if the object being referenced is actually aTInetAddr.

Casted pointer to a TInetAddr.

Parameters

const TSockAddr * aAddrTSockAddr to cast

CmpAddr(const TInetAddr &)

IMPORT_C TBoolCmpAddr(const TInetAddr &aAddr)const

Parameters

const TInetAddr & aAddr

ConvertToV4()

IMPORT_C voidConvertToV4()

ConvertToV4Compat()

IMPORT_C voidConvertToV4Compat()

ConvertToV4Mapped()

IMPORT_C voidConvertToV4Mapped()

FlowLabel()

IMPORT_C TIntFlowLabel()const

Init(TUint)

IMPORT_C voidInit(TUintaFamily)

Parameters

TUint aFamily

Input(const TDesC &)

IMPORT_C TIntInput(const TDesC &aBuf)

Parameters

const TDesC & aBuf

Ip6Address()

IMPORT_C const TIp6Addr &Ip6Address()const

Ipv4Input(const TDesC &)

TInt Ipv4Input(const TDesC &aDes)[private]

Parameters

const TDesC & aDes

Ipv6Input(const TDesC &)

TInt Ipv6Input(const TDesC &aDes)[private]

Parameters

const TDesC & aDes

IsBroadcast()

TBool IsBroadcast()const [inline]

Tests if the IP address is a limited broadcast address (255.255.255.255).

ETrue if the IPv4 address value is a limited broadcast address; otherwise, EFalse

IsClassA()

TBool IsClassA()const [inline]

Tests if the IP address is Class A.

ETrue if the IPv4 address value is Class A; otherwise, EFalse

Works only for IPv4. It assumes the old IPv4 address classes (A, B, C). Applications using this function may not work properly in the current internet environment.

IsClassB()

TBool IsClassB()const [inline]

Tests if the IP address is Class B.

ETrue if the IPv4 address value is Class B; otherwise. EFalse

Works only for IPv4. It assumes the old IPv4 address classes (A, B, C). Applications using this function may not work properly in the current internet environment.

IsClassC()

TBool IsClassC()const [inline]

Tests if the IP address is Class C.

ETrue if the IPv4 address value is Class C; otherwise, EFalse

Works only for IPv4. It assumes the old IPv4 address classes (A, B, C). Applications using this function may not work properly in the current internet environment.

IsLinkLocal()

IMPORT_C TBoolIsLinkLocal()const

IsLoopback()

IMPORT_C TBoolIsLoopback()const

IsMulticast()

IMPORT_C TBoolIsMulticast()const

IsSiteLocal()

IMPORT_C TBoolIsSiteLocal()const

IsUnicast()

IMPORT_C TBoolIsUnicast()const

IsUnspecified()

IMPORT_C TBoolIsUnspecified()const

IsV4Compat()

IMPORT_C TBoolIsV4Compat()const

IsV4Mapped()

IMPORT_C TBoolIsV4Mapped()const

IsWildAddr()

TBool IsWildAddr()const [inline]

Tests if the IP address is unspecified.

This is same as IsUnspecified()

ETrue if the IP address value is unspecified; otherwise, EFalse.

IsWildPort()

TBool IsWildPort()const [inline]

Tests if the port is zero.

ETrue if the port is zero; otherwise, EFalse.

Match(const TInetAddr &)

IMPORT_C TBoolMatch(const TInetAddr &aHost)const

Parameters

const TInetAddr & aHost

Match(const TInetAddr &, const TInetAddr &)

IMPORT_C TBoolMatch(const TInetAddr &aNet,
const TInetAddr &aMask
)const

Parameters

const TInetAddr & aNet
const TInetAddr & aMask

Match(const TInetAddr &, TInt)

IMPORT_C TBoolMatch(const TInetAddr &aNet,
TIntaPrefixLen
)const

Parameters

const TInetAddr & aNet
TInt aPrefixLen

Net(const TInetAddr &)

IMPORT_C voidNet(const TInetAddr &aAddr)

Parameters

const TInetAddr & aAddr

NetBroadcast(const TInetAddr &)

IMPORT_C voidNetBroadcast(const TInetAddr &aAddr)

Parameters

const TInetAddr & aAddr

NetMask(const TInetAddr &)

IMPORT_C voidNetMask(const TInetAddr &aAddr)

Parameters

const TInetAddr & aAddr

Output(TDes &)

IMPORT_C voidOutput(TDes &aBuf)const

Parameters

TDes & aBuf

OutputWithScope(TDes &)

IMPORT_C voidOutputWithScope(TDes &aBuf)const

Parameters

TDes & aBuf

Prefix(const TInetAddr &, TInt)

IMPORT_C voidPrefix(const TInetAddr &aAddr,
TIntaPrefixLen
)

Parameters

const TInetAddr & aAddr
TInt aPrefixLen

PrefixMask(TInt)

IMPORT_C voidPrefixMask(TIntaPrefixLen)

Parameters

TInt aPrefixLen

Scope()

IMPORT_C TUint32Scope()const

SetAddress(TUint32)

IMPORT_C voidSetAddress(TUint32aAddr)

Parameters

TUint32 aAddr

SetAddress(const TIp6Addr &)

IMPORT_C voidSetAddress(const TIp6Addr &aAddr)

Parameters

const TIp6Addr & aAddr

SetFlowLabel(TInt)

IMPORT_C voidSetFlowLabel(TIntaLabel)

Parameters

TInt aLabel

SetScope(TUint32)

IMPORT_C voidSetScope(TUint32aScope)

Parameters

TUint32 aScope

SetV4CompatAddress(TUint32)

IMPORT_C voidSetV4CompatAddress(TUint32aAddr)

Parameters

TUint32 aAddr

SetV4MappedAddress(TUint32)

IMPORT_C voidSetV4MappedAddress(TUint32aAddr)

Parameters

TUint32 aAddr

SubNet(const TInetAddr &, const TInetAddr &)

IMPORT_C voidSubNet(const TInetAddr &aAddr,
const TInetAddr &aMask
)

Parameters

const TInetAddr & aAddr
const TInetAddr & aMask

SubNetBroadcast(const TInetAddr &, const TInetAddr &)

IMPORT_C voidSubNetBroadcast(const TInetAddr &aAddr,
const TInetAddr &aMask
)

Parameters

const TInetAddr & aAddr
const TInetAddr & aMask