Open Search
    NetworkIpAddrInterface Class Reference

    #include <network_ip_addr.h>

    Inheritance diagram for NetworkIpAddrInterface:

    Detailed Description

    This class represents an Internet Protocol (IP) address. It is version agnostic and supports both IPv4 and IPv6.

    @MAXON_ANNOTATION{refclass=false}

    Public Member Functions

    MAXON_METHOD NetworkSockAddrIn GetNetworkSockAddrIn () const
     
    MAXON_METHOD void SetNetworkSockaddrIn (const NetworkSockAddrIn &sa, PROTOCOL protocol)
     
    MAXON_METHOD void Reset ()
     
    MAXON_METHOD void Flush ()
     
    MAXON_METHOD void SetIPv4 (UInt32 ip, Bool isHostByteOrder)
     
    MAXON_METHOD void SetIPv4 (UChar a, UChar b, UChar c, UChar d)
     
    MAXON_METHOD void SetIPv6 (UInt16 x1, UInt16 x2, UInt16 x3, UInt16 x4, UInt16 x5, UInt16 x6, UInt16 x7, UInt16 x8)
     
    MAXON_METHOD void SetIPv4 (const in_addr &in)
     
    MAXON_METHOD void SetIPv6 (const in6_addr &in)
     
    MAXON_METHOD Result< void > SetIPv4 (const sockaddr_in *in)
     
    MAXON_METHOD Result< void > SetIPv6 (const sockaddr_in6 *in)
     
    MAXON_METHOD void SetIPv4 (WILDCARD_IPV4_ADDRESS_TYPE)
     
    MAXON_METHOD void SetIPv6 (WILDCARD_IPV6_ADDRESS_TYPE)
     
    MAXON_METHOD Result< void > GetIPv4 (UChar &a, UChar &b, UChar &c, UChar &d) const
     
    MAXON_METHOD Result< void > GetIPv6 (UInt16 &x1, UInt16 &x2, UInt16 &x3, UInt16 &x4, UInt16 &x5, UInt16 &x6, UInt16 &x7, UInt16 &x8) const
     
    MAXON_METHOD Result< void > GetIPv4 (sockaddr_in *sockaddr) const
     
    MAXON_METHOD Result< void > GetIPv6 (sockaddr_in6 *sockaddr) const
     
    MAXON_METHOD PROTOCOL GetProtocol () const
     
    MAXON_METHOD int GetNativeProtocol () const
     
    MAXON_METHOD void SetProtocol (PROTOCOL protocol)
     
    MAXON_METHOD Bool IsPrivateAddress () const
     
    MAXON_METHOD Bool IsMulticastAddress () const
     
    MAXON_METHOD Bool IsWildcardAddress () const
     
    MAXON_METHOD Bool IsUnspecified () const
     
    MAXON_METHOD Bool IsEmpty () const
     
    MAXON_FUNCTION Bool IsPopulated () const
     
    MAXON_METHOD Bool IsValid () const
     
    MAXON_METHOD String GetString (Int32 port=0) const
     
    String ToString (const FormatStatement *formatStatement=nullptr) const
     
    MAXON_METHOD Bool IsEqual (const NetworkIpAddrInterface *adr) const
     
    MAXON_METHOD Bool IsInSameNetwork (const NetworkIpAddr &otherAddress, const NetworkIpAddr &subnetMask) const
     
    MAXON_METHOD HashInt GetHashCode () const
     

    Private Member Functions

     MAXON_INTERFACE_NONVIRTUAL (NetworkIpAddrInterface, MAXON_REFERENCE_COPY_ON_WRITE, "net.maxon.interface.networkipaddr")
     

    Member Function Documentation

    ◆ MAXON_INTERFACE_NONVIRTUAL()

    MAXON_INTERFACE_NONVIRTUAL ( NetworkIpAddrInterface  ,
    MAXON_REFERENCE_COPY_ON_WRITE  ,
    "net.maxon.interface.networkipaddr"   
    )
    private

    ◆ GetNetworkSockAddrIn()

    MAXON_METHOD NetworkSockAddrIn GetNetworkSockAddrIn ( ) const

    Returns the internal POD representation of this address.

    ◆ SetNetworkSockaddrIn()

    MAXON_METHOD void SetNetworkSockaddrIn ( const NetworkSockAddrIn sa,
    PROTOCOL  protocol 
    )

    Sets the raw NetworkSockAddrIn into this class.

    Parameters
    [in]saReference to the NetworkSockAddrIn value.
    [in]protocolType of the IP address given in the variable "in".

    ◆ Reset()

    MAXON_METHOD void Reset ( )

    Resets the content of this value. The protocol is set to PROTOCOL::UNSPEC.

    ◆ Flush()

    MAXON_METHOD void Flush ( )

    DEPRECATED. Exists for backward compatibility. Use Reset() instead.

    ◆ SetIPv4() [1/5]

    MAXON_METHOD void SetIPv4 ( UInt32  ip,
    Bool  isHostByteOrder 
    )

    Sets an IPV4 address.

    Parameters
    [in]ipIP address to be set.
    [in]isHostByteOrderTrue if the address is delivered in the host specific byte order.

    ◆ SetIPv4() [2/5]

    MAXON_METHOD void SetIPv4 ( UChar  a,
    UChar  b,
    UChar  c,
    UChar  d 
    )

    Sets an IPV4 address.

    Parameters
    [in]aIP address of the format "a.b.c.d" to be set.
    [in]bIP address of the format "a.b.c.d" to be set.
    [in]cIP address of the format "a.b.c.d" to be set.
    [in]dIP address of the format "a.b.c.d" to be set.

    ◆ SetIPv6() [1/4]

    MAXON_METHOD void SetIPv6 ( UInt16  x1,
    UInt16  x2,
    UInt16  x3,
    UInt16  x4,
    UInt16  x5,
    UInt16  x6,
    UInt16  x7,
    UInt16  x8 
    )

    Sets an IPV6 address.

    Parameters
    [in]x1IP address of the format "x1:x2:x3:x4:x5:x6:x7:x8" to be set.
    [in]x2IP address of the format "x1:x2:x3:x4:x5:x6:x7:x8" to be set.
    [in]x3IP address of the format "x1:x2:x3:x4:x5:x6:x7:x8" to be set.
    [in]x4IP address of the format "x1:x2:x3:x4:x5:x6:x7:x8" to be set.
    [in]x5IP address of the format "x1:x2:x3:x4:x5:x6:x7:x8" to be set.
    [in]x6IP address of the format "x1:x2:x3:x4:x5:x6:x7:x8" to be set.
    [in]x7IP address of the format "x1:x2:x3:x4:x5:x6:x7:x8" to be set.
    [in]x8IP address of the format "x1:x2:x3:x4:x5:x6:x7:x8" to be set.

    ◆ SetIPv4() [3/5]

    MAXON_METHOD void SetIPv4 ( const in_addr &  in)

    Sets an ip v4 address from the native in_addr structure.

    Parameters
    [in]inReference to the ip v4 structure.

    ◆ SetIPv6() [2/4]

    MAXON_METHOD void SetIPv6 ( const in6_addr &  in)

    Sets an ip v6 address from the native in_addr6 structure.

    Parameters
    [in]inReference to the ip v6 structure.

    ◆ SetIPv4() [4/5]

    MAXON_METHOD Result<void> SetIPv4 ( const sockaddr_in *  in)

    Sets an ip v4 address from the native sockaddr_in structure.

    Parameters
    [in]inPointer to sockaddr_in structure.

    ◆ SetIPv6() [3/4]

    MAXON_METHOD Result<void> SetIPv6 ( const sockaddr_in6 *  in)

    Sets an ip v4 address from the native sockaddr_in6 structure.

    Parameters
    [in]inPointer to sockaddr_in6 structure.

    ◆ SetIPv4() [5/5]

    Sets an IP v4 address from the native in_addr structure.

    ◆ SetIPv6() [4/4]

    Sets an IP v6 address from the native in_addr structure.

    ◆ GetIPv4() [1/2]

    MAXON_METHOD Result<void> GetIPv4 ( UChar a,
    UChar b,
    UChar c,
    UChar d 
    ) const

    Returns the IP v4 address.

    Parameters
    [out]aReturns the 'a' component of the address in the format "a.b.c.d".
    [out]bReturns the 'b' component of the address in the format "a.b.c.d".
    [out]cReturns the 'c' component of the address in the format "a.b.c.d".
    [out]dReturns the 'd' component of the address in the format "a.b.c.d".
    Returns
    Returns OK on success or an error if the protocol doesn't match.

    ◆ GetIPv6() [1/2]

    MAXON_METHOD Result<void> GetIPv6 ( UInt16 x1,
    UInt16 x2,
    UInt16 x3,
    UInt16 x4,
    UInt16 x5,
    UInt16 x6,
    UInt16 x7,
    UInt16 x8 
    ) const

    Returns the IP v6 address.

    Parameters
    [out]x1Returns the 'x1' component of the address in the format "x1:x2:x3:x4:x5:x6:x7:x8".
    [out]x2Returns the 'x2' component of the address in the format "x1:x2:x3:x4:x5:x6:x7:x8".
    [out]x3Returns the 'x3' component of the address in the format "x1:x2:x3:x4:x5:x6:x7:x8".
    [out]x4Returns the 'x4' component of the address in the format "x1:x2:x3:x4:x5:x6:x7:x8".
    [out]x5Returns the 'x5' component of the address in the format "x1:x2:x3:x4:x5:x6:x7:x8".
    [out]x6Returns the 'x6' component of the address in the format "x1:x2:x3:x4:x5:x6:x7:x8".
    [out]x7Returns the 'x7' component of the address in the format "x1:x2:x3:x4:x5:x6:x7:x8".
    [out]x8Returns the 'x8' component of the address in the format "x1:x2:x3:x4:x5:x6:x7:x8".
    Returns
    Returns OK on success or an error if the protocol doesn't match.

    ◆ GetIPv4() [2/2]

    MAXON_METHOD Result<void> GetIPv4 ( sockaddr_in *  sockaddr) const

    Returns the IP v4 address as sockaddr_in structure.

    Parameters
    [out]sockaddrPointer to sockaddr_in structure.
    Returns
    Returns OK on success or an error if the protocol doesn't match.

    ◆ GetIPv6() [2/2]

    MAXON_METHOD Result<void> GetIPv6 ( sockaddr_in6 *  sockaddr) const

    Returns the IP v6 address as sockaddr_in6 structure.

    Parameters
    [out]sockaddrPointer to sockaddr_in structure.
    Returns
    Returns OK on success or an error if the protocol doesn't match.

    ◆ GetProtocol()

    MAXON_METHOD PROTOCOL GetProtocol ( ) const

    Returns the type of the IP address used in this object.

    ◆ GetNativeProtocol()

    MAXON_METHOD int GetNativeProtocol ( ) const

    Returns the type of the IP address used in this object.

    ◆ SetProtocol()

    MAXON_METHOD void SetProtocol ( PROTOCOL  protocol)

    ◆ IsPrivateAddress()

    MAXON_METHOD Bool IsPrivateAddress ( ) const

    Returns whether the IP address is a private address. The following ranges are defined as private (RFC 1918, Chapter 3): IPv4: 10/8, 172.16/12, 192.168/16 (IPv4) IPv6: fc00::/7 For an invalid address, the result is always false.

    ◆ IsMulticastAddress()

    MAXON_METHOD Bool IsMulticastAddress ( ) const

    Returns whether the IP address is a multicast address. The following ranges are reserved for multicast: IPv4: 224.0.0.0/4 IPv6: ff00::/8 For an invalid address, the result is always false.

    ◆ IsWildcardAddress()

    MAXON_METHOD Bool IsWildcardAddress ( ) const

    Returns whether the IP address is a wildcard address. This refers to the following addresses: IPv4: 0.0.0.0 (INADDR_ANY) IPv6: ::0 (in6addr_any) For an invalid address, the result is always false.

    ◆ IsUnspecified()

    MAXON_METHOD Bool IsUnspecified ( ) const

    Returns whether the value of the IP address is unspecified. This is true iff GetProtocol() == PROTOCOL::UNSPEC.

    ◆ IsEmpty()

    MAXON_METHOD Bool IsEmpty ( ) const

    DEPRECATED. Exists for backward compatibility. Use IsUnspecified() and IsWildcardAddress() instead.

    ◆ IsPopulated()

    MAXON_FUNCTION Bool IsPopulated ( ) const

    DEPRECATED. Exists for backward compatibility. Use IsUnspecified() and IsWildcardAddress() instead.

    ◆ IsValid()

    MAXON_METHOD Bool IsValid ( ) const

    DEPRECATED. Exists for backward compatibility. Use IsUnspecified() and IsWildcardAddress() instead.

    ◆ GetString()

    MAXON_METHOD String GetString ( Int32  port = 0) const

    ◆ ToString()

    String ToString ( const FormatStatement formatStatement = nullptr) const

    Returns a readable string of the content.

    Parameters
    [in]formatStatementNullptr or additional formatting instruction. Currently no additional formatting instructions are supported.
    Returns
    The converted result.

    ◆ IsEqual()

    MAXON_METHOD Bool IsEqual ( const NetworkIpAddrInterface adr) const

    Compares the object against another given object.

    Parameters
    [in]adrIP address to compare.
    Returns
    True if both ip addresses are identical.

    ◆ IsInSameNetwork()

    MAXON_METHOD Bool IsInSameNetwork ( const NetworkIpAddr otherAddress,
    const NetworkIpAddr subnetMask 
    ) const

    Returns if this address is in the same network as other address based on the given subnet mask.

    ◆ GetHashCode()

    MAXON_METHOD HashInt GetHashCode ( ) const

    Returns the hash value of this object. This value can be used for all HashSet<>/HashMap<> classes.