TInetAddr Class Reference

#include <in_sock.h>

Link against: insock.lib

class TInetAddr : public TSockAddr

Inherits from

  • TInetAddr
    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()
    Inherited Attributes
    TBuf8< KMaxSockAddrSize >::iBuf
    TDes8::__DECLARE_TEST
    TDes8::iMaxLength
    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

    Detailed Description

    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.

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

    Constructor & Destructor Documentation

    TInetAddr ( )

    IMPORT_CTInetAddr()

    Constructs a basic TInetAddr object.

    The port is initialised to 0, and the IP address is unspecified. The resulting address family is KAFUnspec.

    TInetAddr ( const TSockAddr & )

    IMPORT_CTInetAddr(const TSockAddr &aAddr)

    Constructs a TInetAddr from a TSockAddr.

    The port and IP address values are copied from aAddr. The resulting address family is same as that of aAddr.

    The function does a raw copy operation of the TSockAddr. No checks are made at this point.

    ParameterDescription
    aAddrTSockAddr to be used as initial content.

    TInetAddr ( TUint )

    IMPORT_CTInetAddr(TUintaPort)

    Constructs a TInetAddr and initialises the port to the specified value, and the IP address is unspecified.

    The resulting address family is KAFUnspec.

    ParameterDescription
    aPortValue to which to set the port.

    TInetAddr ( const TIp6Addr &, TUint )

    IMPORT_CTInetAddr(const TIp6Addr &aAddr,
    TUintaPort
    )

    Constructs a TInetAddr and initialises the port to the specified value, and the IPv6 address to aAddr.

    The resulting address family is KAfInet6.

    Since
    7.0
    ParameterDescription
    aAddrValue to which to set the IPv6 address.
    aPortValue to which to set the port.

    TInetAddr ( TUint32, TUint )

    IMPORT_CTInetAddr(TUint32aAddr,
    TUintaPort
    )

    Constructs a TInetAddr and initialise the specified port value to aPort and the IP address to aAddr.

    The resulting address family is KAfInet

    ParameterDescription
    aAddrValue to which to set the IP address.
    aPortValue to which to set the port.

    Member Function 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

    Gets the IPv4 address value.

    If the stored address is not an IPv4 address, the returned value is ZERO.

    This works also for IPv4 addresses which are stored in IPv4-mapped or IPv4-compatible format. (since 7.0).

    Returns: The IP address value.

    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.

    ParameterDescription
    aAddrTSockAddr to cast

    Returns: Casted reference to a TInetAddr.

    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.

    ParameterDescription
    aAddrTSockAddr to cast

    Returns: Casted pointer to a TInetAddr.

    CmpAddr ( const TInetAddr & )

    IMPORT_C TBoolCmpAddr(const TInetAddr &aAddr)const

    Compares IP address and port values with those in another TInetAddr.

    ParameterDescription
    aAddrTInetAddr with which to compare

    Returns: ETrue if IP address and port values are the same; EFalse, otherwise.

    ConvertToV4 ( )

    IMPORT_C voidConvertToV4()

    Converts an IPv4-mapped or IPv4-comptatible address to IPv4.

    The function assumes that the previous content is IPv4 address and accesses this using TInetAddr::Address() function. If the previous content was not IPv4 address (in any format), function acts as if the old content was 0.0.0.0.

    The address family is set to KAfInet.
    Since
    7.0

    ConvertToV4Compat ( )

    IMPORT_C voidConvertToV4Compat()

    Converts an IPv4 address to an IPv4-compatible IPv6 address.

    The function assumes that the previous content is IPv4 address and accesses this using TInetAddr::Address() function. If the previous content was not IPv4 address (in any format), function acts as if the old content was 0.0.0.0.

    The IPv4-compatible format is x.x.x.x.

    The resulting address family is KAfInet6. The scope id and flow label are zeroed.

    DeprecatedThis address format is deprecated and should not be used.
    Since
    7.0

    ConvertToV4Mapped ( )

    IMPORT_C voidConvertToV4Mapped()

    Converts an IPv4 address to an IPv4-mapped IPv6 address.

    The function assumes that the previous content is IPv4 address and accesses this using TInetAddr::Address() function. If the previous content was not IPv4 address (in any format), function acts as if the old content was "0.0.0.0".

    The IPv4-mapped format is ffff:x.x.x.x. Internally, all IPv4 addresses are stored in this format.

    The resulting address family is KAfInet6. The scope id and flow label are zeroed.
    Since
    7.0

    FlowLabel ( )

    IMPORT_C TIntFlowLabel()const

    Gets the Flow Label.

    Only for KAfInet6, return zero for KAfInet.

    Since
    7.0

    Returns: The flow label

    Init ( TUint )

    IMPORT_C voidInit(TUintaFamily)

    Initialises the object properly according to the address family passed in.

    Post-condition
    In all above cases, IsUnspecified() returns ETrue after this function.
    Since
    7.0
    ParameterDescription
    aFamilyThe address family. Valid values are KAfInet, plain IPv4 address format KAfInet6, combined IPv4 and IPv6 format, including fields for the scope id and flow label. anything else, initialized to KAFUnspec, with empty content.

    Input ( const TDesC & )

    IMPORT_C TIntInput(const TDesC &aBuf)

    Sets the IP address from a string containing a representation of an IP address, such as might be entered in a dialog.

    The string must contain an ASCII representation of the address. The format may be one of the following examples:
    • Four 8-bit decimal numbers separated by '.' (eg. 192.168.40.4)

    • Two 8-bit decimal numbers and a 16 bit decimal (eg. 192.168.10244)

    • One 8-bit decimal number and a 24-bit decimal (eg. 192.11020292)

    • One 32 decimal number (eg. 3232245764)

    • Eight 16-bit hex numbers separated by ':' (eg.2001:618:400:6a:0:0:0:abc)

    Use at most one '::' to denote consecutive zeroes (eg. 2001:618:400:6aabc), IPv4-compatible address (eg. ::192.168.40.4), and IPv4-mapped address (eg. ffff:192.168.40.4)

    Any of the address notations above can be followed by "%scope-id" and the scope id of the TInetAddress is also set accordingly. If a dotted IPv4 address is associated with scope id, the address is stored as IPv4-mapped. If scope is not specified, the value defaults to zero. The flow label is set to zero.

    The hexadecimal numbers may be either upper or lower case.

    Since
    7.0 (IPv6 support)
    ParameterDescription
    aBufDescriptor containing a string representation of an IP address

    Returns: KErrNone, if address syntax was correct and input succeeded; otherwise, one of the system-wide error codes.

    Ip6Address ( )

    IMPORT_C const TIp6Addr &Ip6Address()const

    Gets the IPv6 address

    Only for KAfInet6, undefined for KAfInet.

    This function returns a reference to a location where IPv6 address would be stored. No check on family is made, and using this function for any other address family except KAfInet6 does not cause an error, but returned reference does not point to valid IPv6 address (unless content is converted to KAfInet6).

    Since
    7.0

    Returns: The IPv6 address

    IsBroadcast ( )

    TBool IsBroadcast()const [inline]

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

    Returns: 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.

    DeprecatedWorks 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.

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

    IsClassB ( )

    TBool IsClassB()const [inline]

    Tests if the IP address is Class B.

    DeprecatedWorks 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.

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

    IsClassC ( )

    TBool IsClassC()const [inline]

    Tests if the IP address is Class C.

    DeprecatedWorks 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.

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

    IsLinkLocal ( )

    IMPORT_C TBoolIsLinkLocal()const

    Tests if IP address is link-local address

    For IPv4 this returns true, if the address belongs to the link-local net (169.254.x.x).

    For IPv6 this returns true, if the address is IPv6 link-local address (fe80:..).

    Note:

    Does not return true for multicast addresses which are in the link-local scope.

    Since
    7.0

    Returns: ETrue, if this address is a link-local address; EFalse, otherwise

    IsLoopback ( )

    IMPORT_C TBoolIsLoopback()const

    Tests if the IP address is a loopback address.

    For IPv4 addresses this returns true, if address belongs to the loopback net (127.x.x.x). IPv4 address can be in KAfInet or in IPv4-mapped/compatible formats.

    For IPv6 address this returns true for IPv6 loopback address (= ::1).

    Since
    7.0

    Returns: ETrue, if the address is loopback; EFalse, otherwise

    IsMulticast ( )

    IMPORT_C TBoolIsMulticast()const

    Tests if the IP address is a multicast address.

    For IPv4 addresses this returns true, if address is Class D (multicast). IPv4 address can be in KAfInet or KAfInet6 (IPv4-mapped or IPv4-compatible) formats.

    For IPv6 addresses this returns true, if address is IPv6 multicast address (start with 0xff byte).

    Since
    7.0

    Returns: ETrue if the IP address value is multicast; EFalse, otherwise

    IsSiteLocal ( )

    IMPORT_C TBoolIsSiteLocal()const

    Tests if IP address is site-local address.

    Always false for IPv4 addressess.

    For IPv6 this returns true, if the address is IPv6 site-local address (fec0:...)

    Note:

    Does not return true for multicast addresses which are in the site-local scope.

    Since
    7.0

    Returns: ETrue, if this is a site-local address; EFalse, otherwise

    IsUnicast ( )

    IMPORT_C TBoolIsUnicast()const

    Tests if address is unicast address.

    This is just a "shorthand" notation for a test that none of the following is true

    For exact semantics of IsUnicast, see the descriptions of the above functions.

    Caution: the test is based purely on the address, and it should be kept in mind that this test has no way of detecting IPv4 net broadcast addresses (because the netmask is not known).

    Since
    7.0

    Returns: ETrue if the address is unicast: EFalse, otherwise

    IsUnspecified ( )

    IMPORT_C TBoolIsUnspecified()const

    Tests if the IP address is unspecified.

    The address is unspecified if the
    • family is KAFUnspec

    • family is KAfInet6 and address is ::

    • family is KAfInet6 and address is IPv4-mapped 0.0.0.0

    • family is KAfInet and address is 0.0.0.0

    Since
    7.0

    Returns: ETrue if the IP address is unspecified; EFalse, otherwise

    IsV4Compat ( )

    IMPORT_C TBoolIsV4Compat()const

    Tests if this address is an IPv4-compatible address.

    This is always false, if address is in KAfInet format.

    DeprecatedIPv4-compatible addresses should not be used.
    Since
    7.0

    Returns: ETrue, if this is a IPv4 compatible address; EFalse, otherwise.

    IsV4Mapped ( )

    IMPORT_C TBoolIsV4Mapped()const

    Tests if this address is an IPv4-mapped address.

    This is always false, if address is in KAfInet format.

    Since
    7.0

    Returns: ETrue, if this address is an IPv4-mapped address; EFalse, otherwise.

    IsWildAddr ( )

    TBool IsWildAddr()const [inline]

    Tests if the IP address is unspecified.

    This is same as IsUnspecified()

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

    IsWildPort ( )

    TBool IsWildPort()const [inline]

    Tests if the port is zero.

    Returns: ETrue if the port is zero; otherwise, EFalse.

    Match ( const TInetAddr & )

    IMPORT_C TBoolMatch(const TInetAddr &aHost)const

    Tests the IP address value with that in another TInetAddr.

    Note:

    The function matches IPv4 addresses even if they are stored in different formats (KAfInet or KAfInet6 using IPv4-mapped format) (since Symbian OS 7.0s).

    ParameterDescription
    aHostTInetAddr with which to compare

    Returns: ETrue if IP address value is the same as this, EFalse, otherwise.

    Match ( const TInetAddr &, const TInetAddr & )

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

    Tests if another TInetAddr is in the same subnet.

    The function applies the subnet mask passed through aMask to the IP address and to the IP address in aNet. If the resulting values are the same, this indicates that the addresses are part of the same subnet, and ETrue is returned.

    Note:

    The function matches IPv4 addresses even if they are stored in different formats (KAfInet or KAfInet6 using IPv4-mapped format). (since Symbian OS 7.0s).

    ParameterDescription
    aNetTInetAddr with which to compare.
    aMaskTInetAddr object with the IP address set to the relevant subnet mask.

    Returns: ETrue if both IP address values are the members of the same subnet; EFalse, otherwise.

    Match ( const TInetAddr &, TInt )

    IMPORT_C TBoolMatch(const TInetAddr &aNet,
    TIntaPrefixLen
    )const

    Tests if the specified number of left-most bits on addresses are same.

    Return ETrue if leftmost aPrefixLen bits on addresses are same (both families must be the same).

    Since
    7.0
    ParameterDescription
    aNetTInetAddr with which to compare.
    aPrefixLenNumber of left-most bits to compare.

    Returns: ETrue, if the bits match; EFalse, otherwise.

    Net ( const TInetAddr & )

    IMPORT_C voidNet(const TInetAddr &aAddr)

    Obtains a network mask corresponding to the class of the IP address, using the NetMask() function, and then applies this mask to the current IP address (deprecated).

    The resulting address family is KAfInet

    DeprecatedWorks only for IPv4. Prefix() should be used instead.

    ParameterDescription
    aAddrTInetAddr from which to obtain IP address for creating the network mask.

    NetBroadcast ( const TInetAddr & )

    IMPORT_C voidNetBroadcast(const TInetAddr &aAddr)

    Sets the IP address to be suitable for a network-directed broadcast address (deprecated).

    The function obtains a network mask corresponding to the class of the IP address in aAddr, using the NetMask() function. It then applies this mask to the current IP address to separate the network number part of the address. The mask is then used again to set all host number bits to 1 (which signifies, broadcast to all hosts on the network).

    The resulting address family is KAfInet

    DeprecatedWorks only for IPv4. This function 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.

    ParameterDescription
    aAddrTInetAddr from which to obtain IP address for creating the network mask.

    NetMask ( const TInetAddr & )

    IMPORT_C voidNetMask(const TInetAddr &aAddr)

    Sets the IP address to a mask suitable for extracting the network number part of the IP address (deprecated).

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

    The function tests whether the IP address in aAddr is a Class A, B, C, or other address. It then sets the IP address to suitable mask values as follows:

    • Class A addresses: mask 255.0.0.0

    • Class B addresses: mask 255.255.0.0

    • Class C addresses: mask 255.255.255.0

    • other addresses: mask 255.255.255.255

    The resulting address family is KAfInet.

    DeprecatedWorks only for IPv4. The length of the network prefix needs to be aqcuired by other means. When prefix length is known, PrefixMask() function can be used.

    ParameterDescription
    aAddrTInetAddr from which to obtain IP address

    Output ( TDes & )

    IMPORT_C voidOutput(TDes &aBuf)const

    Writes the IP address into a string.

    For an IPv4 address, the format is d.d.d.d, where "d" is an 8-bit decimal number. (An example IPv4 address: 127.0.0.1).

    For an IPv6 address, the format is h:h:h:h:h:h:h:h, where "h" is a 16-bit hexadecimal number. (An example IPv6 address: 2001:618:40C:20:2C0:4FFF:FE24:AA79).

    If address family is not KAfInet or KAfInet6, then empty string is returned (aBuf.Length() == 0).

    If the family is KAfInet6, the output buffer must be at least 39 characters. If less, the buffer is filled with '*' characters.

    Since
    7.0 (IPv6 support)

    Return Values

    aBuf contains a string representation of the IP address.

    OutputWithScope ( TDes & )

    IMPORT_C voidOutputWithScope(TDes &aBuf)const

    Writes the IP address into a string and appends the scope id.

    The IP address is formatted with as with the standard Output.

    If the scope id has non-zero value and if there is room in the output buffer, the scope id is appended to the address using the "%scope-id"-notation.

    Since
    after 7.0s

    Return Values

    aBuf contains a string representation of the address.

    Prefix ( const TInetAddr &, TInt )

    IMPORT_C voidPrefix(const TInetAddr &aAddr,
    TIntaPrefixLen
    )

    Creates an IPv6 address with the specified number of left-most bits copied from another address, and remaining bits set to 0.

    The function does not check the family of the aAddr, and for anything else but KAfInet6 the resulting prefix value is undefined.

    The resulting address family is KAfInet6. The scope id and flow label are zeroed.

    Since
    7.0
    ParameterDescription
    aAddrThe address to copy the prefix from.
    aPrefixLenNumber of left-most bits to set to copy from aAddr.

    PrefixMask ( TInt )

    IMPORT_C voidPrefixMask(TIntaPrefixLen)

    Creates an IPv6 address with the specified number of left-most bits set to 1, and the rest set to 0.

    The previous content does not matter, and is overwritten.

    Since
    7.0
    ParameterDescription
    aPrefixLenNumber of left-most bits to set to 1.

    Scope ( )

    IMPORT_C TUint32Scope()const

    Gets the scope id value

    Only for KAfInet6, return zero for KAfInet.

    When an IPv4 address is stored in IPv4-mapped format (KAfInet6), then non-zero scopes are also possible for IPv4 (and needed for proper handling of overlapping private address ranges or for IPv4 link local addresses).

    Since
    7.0

    Returns: The scope id of the address.

    SetAddress ( TUint32 )

    IMPORT_C voidSetAddress(TUint32aAddr)

    Sets the IPv4 address value.

    Note:

    An IP address in dotted-decimal form can be converted into a TUint32 by the INET_ADDR macro.

    The resulting address family is KAfInet.

    ParameterDescription
    aAddrValue to which to set the IPv4 address.

    SetAddress ( const TIp6Addr & )

    IMPORT_C voidSetAddress(const TIp6Addr &aAddr)

    Sets the IPv6 address value.

    The resulting address family is KAfInet6. The scope id and flow label are zeroed.

    Since
    7.0
    ParameterDescription
    aAddrValue to which to set the IPv6 address.

    SetFlowLabel ( TInt )

    IMPORT_C voidSetFlowLabel(TIntaLabel)

    Sets the Flow Label.

    Only for KAfInet6, undefined (ignored) for KAfInet.

    Since
    7.0
    ParameterDescription
    aLabelThe flow label (only low 20 bits used)

    SetScope ( TUint32 )

    IMPORT_C voidSetScope(TUint32aScope)

    Sets the scope id value

    Only for KAfInet6, undefined (ignored) for KAfInet.

    When an IPv4 address is stored in IPv4-mapped format (KAfInet6), then non-zero scopes are also possible for IPv4 (and needed for proper handling of overlapping private address ranges or for IPv4 link local addresses).

    Since
    7.0
    ParameterDescription
    aScopeThe scope id of the address.

    SetV4CompatAddress ( TUint32 )

    IMPORT_C voidSetV4CompatAddress(TUint32aAddr)

    Creates an IPv4-compatible IPv6 address.

    The IPv4-compatible format is x.x.x.x.

    The resulting address family is KAfInet6. The scope id and flow label are zeroed.

    DeprecatedThis address format is deprecated and should not be used.
    Since
    7.0
    ParameterDescription
    aAddrIPv4 address from which the IPv6 address is generated.

    SetV4MappedAddress ( TUint32 )

    IMPORT_C voidSetV4MappedAddress(TUint32aAddr)

    Creates an IPv4-mapped IPv6 address.

    The IPv4-mapped format is ffff:x.x.x.x. Internally, all IPv4 addresses are stored in this format.

    The resulting address family is KAfInet6. The scope id and flow label are zeroed.

    Since
    7.0
    ParameterDescription
    aAddrIPv4 address from which the IPv6 address is generated.

    SubNet ( const TInetAddr &, const TInetAddr & )

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

    Sets the IP address to the network number and subnet parts of the IP address (that is, the original IP address with the host number part cleared).

    This is obtained by applying the mask value in aMask to the IP address in aAddr. The result is undefined if address and mask have different address family.

    ParameterDescription
    aAddrTInetAddr from which to obtain IP address
    aMaskTInetAddr object with the IP address set to the relevant subnet mask.

    SubNetBroadcast ( const TInetAddr &, const TInetAddr & )

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

    Sets the IP address to be suitable for a subnet-directed broadcast address.

    To achieve this, the subnet mask value in aMask is applied to the IP address in aAddr. The mask is then used again to set all host number bits to 1 (which signifies, broadcast to all hosts on the subnet).

    Only for IPv4. The function does not have a sensible interpretation in IPv6. An application that uses this needs to code separate branches for IPv4 and IPv6 cases.

    DeprecatedWorks only for IPv4. IPv6 has all-nodes link local multicast address (ff02::1) for this purpose.

    ParameterDescription
    aAddrTInetAddr from which to obtain IP address
    aMaskTInetAddr object with the IP address set to the relevant subnet mask.