VR-Link API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
DtInetAddr Class Reference

Represents a IPv4 or IPv6 address. More...

+ Collaboration diagram for DtInetAddr:

Public Member Functions

 DtInetAddr (DtInetUtils::DtInetAddrFamily family=DtInetUtils::DtInetAddrFamily_IPv4)
 Default Constructor.
 DtInetAddr (const struct sockaddr_in6 &addr, DtU32 prefixLen=0)
 IPv6 Constructors.
 DtInetAddr (const struct sockaddr_storage &addr, DtU32 prefixLen=0)
 Constructor taking a sockaddr_storage, which may contain either an IPv4 or IPv6 address.
 DtInetAddr (const DtU128 &addr, DtInetUtils::DtInetAddrFamily family, DtU32 prefixLen=0)
 Constructor taking a 128-bit value, which may contain either an IPv4 or IPv6 address.
 DtInetAddr (void *boostAsioIpAddress)
 Constructor taking a boost::asio::ip::address which is abstracted to a void pointer.
virtual ~DtInetAddr ()
 Destructor.
 DtInetAddr (const DtInetAddr &orig)
 Copy constructor.
DtInetAddroperator= (const DtInetAddr &orig)
 Assignment.
virtual DtString toDtString (bool useShortForm=false) const
 Returns a DtString representation of the address in the appropriate format.
virtual
DtInetUtils::DtInetAddrFamily 
family () const
 Returns the family, IPv4 or IPv6, of the address object.
virtual void setNetmask (DtU32 mask)
 Set the IPv4 netmask.
virtual DtU32 netmask () const
 Return the IPv4 netmask derived from the address class as an unsigned 32-bit integer in host byte order.
virtual void setPrefixLen (DtU64 prefixLen)
 Set the IPv4 or IPv6 netmask based on the supplied CIDR prefix length.
virtual DtU64 prefix () const
 Return the IPv4 or IPv6 prefix length.
virtual bool isMulticast () const
 Return true if the address is a multicast address.
virtual bool isBroadcast () const
 Return true if the address is a broadcast address.
virtual bool isLoopback () const
 Return true if the address is a loopback address.
virtual bool isAnyAddr () const
 Return true if the address represents the INADDR_ANY (or IN6ADDR_ANY) address.
virtual const DtInetAddrgetBroadcastAddr ()
 Return the default broadcast address associated with the address based on its class & netmask (if IPv4) or link scope (if IPv6)
virtual const DtInetAddrgetLoopbackAddr ()
 Return the default loopback address based on the family, IPv4 or IPv6.
virtual void toAddrStorage (struct sockaddr_storage *addrStor) const
 Stores the address in a sockaddr_storage to be sent in a message.
virtual DtU128 toU128 () const
 Return the address value as a DtU128 in host byte order (IPv4 & IPv6).
virtual DtU32 toULong () const
 Return the address value as a DtU32 in host byte order (IPv4 only).
virtual void setScope (DtInetIpv6Scope scopeId)
 Sets the link scope (IPv6 only).
virtual DtInetIpv6Scope scope () const
 Returns the link scope (IPv6 only).
virtual void * boostAddress ()
 Returns the Boost address class object.
virtual const void * boostAddress () const
 DtInetAddr (const DtString &addrString, const DtString &netmaskString="")
 Constructors.
 DtInetAddr (const char *addrString, const char *netmaskString=NULL)
 Constructors.
 DtInetAddr (const struct sockaddr_in &addr, DtU32 netmask=0)
 IPv4 Constructors.
 DtInetAddr (const DtU32 addr, DtU32 netmask=0)
 IPv4 Constructors.
virtual bool isIPv4 () const
 Return true if the address matches the queried family.
virtual bool isIPv6 () const
 Return true if the address matches the queried family.
virtual int toSockaddr (struct sockaddr_in *s) const
 Copy address into sockaddr struct in network byte order.
virtual int toSockaddr (struct sockaddr_in6 *s) const
 Copy address into sockaddr struct in network byte order.

Static Public Member Functions

static const DtInetAddrinaddrAny (DtInetUtils::DtInetAddrFamily family=DtInetUtils::DtInetAddrFamily_IPv4)
static const DtInetAddrloopbackAddress (DtInetUtils::DtInetAddrFamily family=DtInetUtils::DtInetAddrFamily_IPv4)

Protected Member Functions

void init ()
void initFromStrings (const char *addrString, const char *netmaskString)

Protected Attributes

void * myAddr
 Private data, do not change.
DtU64 myIpv4Netmask
DtU64 myPrefixLen
DtInetAddrmyBroadcastAddr
DtInetAddrmyLoopbackAddr
bool myIsBroadcast
bool myIsMulticast
bool myIsLoopback
bool myIsAnyAddr
DtInetIpv6Scope myIpv6ScopeId

Friends

bool operator== (const DtInetAddr &addr1, const DtInetAddr &addr2)
 Comparison operator.
bool operator!= (const DtInetAddr &addr1, const DtInetAddr &addr2)
 Comparison operator.
bool operator< (const DtInetAddr &addr1, const DtInetAddr &addr2)
 Comparison operator.
bool operator> (const DtInetAddr &addr1, const DtInetAddr &addr2)
 Comparison operator.

Detailed Description

Represents a IPv4 or IPv6 address.

Constructor & Destructor Documentation

Default Constructor.

Takes an optional address family and creates an INADDR_ANY (IPv4) or IN6ADDR_ANY (IPv6) address

DtInetAddr::DtInetAddr ( const DtString addrString,
const DtString netmaskString = "" 
)

Constructors.

Takes a string representing either IPv4 or IPv6 address and a netmask string. For IPv4 addresses the netmask string can be expressed in either dotted decimal notation (eg. "/255.255.0.0") or as a CIDR prefix length (eg. "/24"). For IPv6 addresses the netmask string must be expressed as a CIDR prefix length. The '/' may be omitted.

DtInetAddr::DtInetAddr ( const char *  addrString,
const char *  netmaskString = NULL 
)

Constructors.

Takes a string representing either IPv4 or IPv6 address and a netmask string. For IPv4 addresses the netmask string can be expressed in either dotted decimal notation (eg. "/255.255.0.0") or as a CIDR prefix length (eg. "/24"). For IPv6 addresses the netmask string must be expressed as a CIDR prefix length. The '/' may be omitted.

DtInetAddr::DtInetAddr ( const struct sockaddr_in &  addr,
DtU32  netmask = 0 
)

IPv4 Constructors.

If netmask is specified is must be expressed as a 32-bit integer representing the bitmask, not as a prefix length. Use DtInetUtils::prefixLenToIpv4Netmask() to make the conversion.

DtInetAddr::DtInetAddr ( const DtU32  addr,
DtU32  netmask = 0 
)

IPv4 Constructors.

If netmask is specified is must be expressed as a 32-bit integer representing the bitmask, not as a prefix length. Use DtInetUtils::prefixLenToIpv4Netmask() to make the conversion.

DtInetAddr::DtInetAddr ( const struct sockaddr_in6 &  addr,
DtU32  prefixLen = 0 
)

IPv6 Constructors.

DtInetAddr::DtInetAddr ( const struct sockaddr_storage &  addr,
DtU32  prefixLen = 0 
)

Constructor taking a sockaddr_storage, which may contain either an IPv4 or IPv6 address.

DtInetAddr::DtInetAddr ( const DtU128 addr,
DtInetUtils::DtInetAddrFamily  family,
DtU32  prefixLen = 0 
)

Constructor taking a 128-bit value, which may contain either an IPv4 or IPv6 address.

Must specify if it is IPv4 or IPv6, cannot tell otherwise.

DtInetAddr::DtInetAddr ( void *  boostAsioIpAddress)

Constructor taking a boost::asio::ip::address which is abstracted to a void pointer.

virtual DtInetAddr::~DtInetAddr ( )
virtual

Destructor.

DtInetAddr::DtInetAddr ( const DtInetAddr orig)

Copy constructor.

Member Function Documentation

virtual void* DtInetAddr::boostAddress ( )
virtual

Returns the Boost address class object.

Note
This function should not be considered part of the public interface.
virtual const void* DtInetAddr::boostAddress ( ) const
virtual
virtual DtInetUtils::DtInetAddrFamily DtInetAddr::family ( ) const
virtual

Returns the family, IPv4 or IPv6, of the address object.

virtual const DtInetAddr* DtInetAddr::getBroadcastAddr ( )
virtual

Return the default broadcast address associated with the address based on its class & netmask (if IPv4) or link scope (if IPv6)

virtual const DtInetAddr* DtInetAddr::getLoopbackAddr ( )
virtual

Return the default loopback address based on the family, IPv4 or IPv6.

static const DtInetAddr& DtInetAddr::inaddrAny ( DtInetUtils::DtInetAddrFamily  family = DtInetUtils::DtInetAddrFamily_IPv4)
static
void DtInetAddr::init ( )
protected
void DtInetAddr::initFromStrings ( const char *  addrString,
const char *  netmaskString 
)
protected
virtual bool DtInetAddr::isAnyAddr ( ) const
virtual

Return true if the address represents the INADDR_ANY (or IN6ADDR_ANY) address.

virtual bool DtInetAddr::isBroadcast ( ) const
virtual

Return true if the address is a broadcast address.

virtual bool DtInetAddr::isIPv4 ( ) const
virtual

Return true if the address matches the queried family.

virtual bool DtInetAddr::isIPv6 ( ) const
virtual

Return true if the address matches the queried family.

virtual bool DtInetAddr::isLoopback ( ) const
virtual

Return true if the address is a loopback address.

virtual bool DtInetAddr::isMulticast ( ) const
virtual

Return true if the address is a multicast address.

static const DtInetAddr& DtInetAddr::loopbackAddress ( DtInetUtils::DtInetAddrFamily  family = DtInetUtils::DtInetAddrFamily_IPv4)
static
virtual DtU32 DtInetAddr::netmask ( ) const
virtual

Return the IPv4 netmask derived from the address class as an unsigned 32-bit integer in host byte order.

Returns 0 if called on an IPv6 address object.

DtInetAddr& DtInetAddr::operator= ( const DtInetAddr orig)

Assignment.

virtual DtU64 DtInetAddr::prefix ( ) const
virtual

Return the IPv4 or IPv6 prefix length.

virtual DtInetIpv6Scope DtInetAddr::scope ( ) const
virtual

Returns the link scope (IPv6 only).

Returns 0 if called on an IPv4 address.

virtual void DtInetAddr::setNetmask ( DtU32  mask)
virtual

Set the IPv4 netmask.

Argument must be an unsigned 32-bit integer in host byte order.

virtual void DtInetAddr::setPrefixLen ( DtU64  prefixLen)
virtual

Set the IPv4 or IPv6 netmask based on the supplied CIDR prefix length.

virtual void DtInetAddr::setScope ( DtInetIpv6Scope  scopeId)
virtual

Sets the link scope (IPv6 only).

virtual void DtInetAddr::toAddrStorage ( struct sockaddr_storage *  addrStor) const
virtual

Stores the address in a sockaddr_storage to be sent in a message.

virtual DtString DtInetAddr::toDtString ( bool  useShortForm = false) const
virtual

Returns a DtString representation of the address in the appropriate format.

If useShortForm is set to true it will omit the zone index from the IPv6 address string.

virtual int DtInetAddr::toSockaddr ( struct sockaddr_in *  s) const
virtual

Copy address into sockaddr struct in network byte order.

Returns 0 on success, -1 on error.

virtual int DtInetAddr::toSockaddr ( struct sockaddr_in6 *  s) const
virtual

Copy address into sockaddr struct in network byte order.

Returns 0 on success, -1 on error.

virtual DtU128 DtInetAddr::toU128 ( ) const
virtual

Return the address value as a DtU128 in host byte order (IPv4 & IPv6).

virtual DtU32 DtInetAddr::toULong ( ) const
virtual

Return the address value as a DtU32 in host byte order (IPv4 only).

Returns 0 if the address is not an IPv4 address

Friends And Related Function Documentation

bool operator!= ( const DtInetAddr addr1,
const DtInetAddr addr2 
)
friend

Comparison operator.

bool operator< ( const DtInetAddr addr1,
const DtInetAddr addr2 
)
friend

Comparison operator.

bool operator== ( const DtInetAddr addr1,
const DtInetAddr addr2 
)
friend

Comparison operator.

bool operator> ( const DtInetAddr addr1,
const DtInetAddr addr2 
)
friend

Comparison operator.

Member Data Documentation

void* DtInetAddr::myAddr
protected

Private data, do not change.

DtInetAddr* DtInetAddr::myBroadcastAddr
protected
DtU64 DtInetAddr::myIpv4Netmask
protected
DtInetIpv6Scope DtInetAddr::myIpv6ScopeId
protected
bool DtInetAddr::myIsAnyAddr
protected
bool DtInetAddr::myIsBroadcast
protected
bool DtInetAddr::myIsLoopback
protected
bool DtInetAddr::myIsMulticast
protected
DtInetAddr* DtInetAddr::myLoopbackAddr
protected
DtU64 DtInetAddr::myPrefixLen
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Tue Mar 1 02:56:17 EST 2016 from SVN revision 162687
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)