Open Lighting Architecture  0.9.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
ola::network::IPV4Address Class Reference

Detailed Description

Represents a IPv4 Address.

All methods use network byte order unless otherwise mentioned.

Public Types

enum  { LENGTH = 4 }
 The length in bytes of an IPv4 address.

Public Member Functions

 IPV4Address ()
 Create a new IPv4 Address set to INADDR_ANY (0.0.0.0).
 IPV4Address (uint32_t address)
 Create a new IPv4 Address from an uint32.
 IPV4Address (const IPV4Address &other)
 Copy constructor.
IPV4Addressoperator= (const IPV4Address &other)
 Assignment operator.
bool operator== (const IPV4Address &other) const
 Equals operator.
bool operator!= (const IPV4Address &other) const
 Not equals operator.
bool operator< (const IPV4Address &other) const
 Less than operator for partial ordering.
bool operator> (const IPV4Address &other) const
 Greater than operator.
uint32_t AsInt () const
 Return the IPV4Address as an int in network-byte order.
bool IsWildcard () const
 Checks if this address is the wildcard address (0.0.0.0).
void Get (uint8_t ptr[LENGTH])
 Copy the IPV4Address to a memory location.
std::string ToString () const
 Convert the IPV4Address to a string.

Static Public Member Functions

static IPV4AddressFromString (const std::string &address)
 Convert a string to an IPV4Address.
static bool FromString (const std::string &address, IPV4Address *target)
 Convert a string to an IPV4Address.
static IPV4Address FromStringOrDie (const std::string &address)
 Convert a string to an IPV4Address or abort.
static bool ToCIDRMask (IPV4Address address, uint8_t *mask)
 Convert a subnet mask to its CIDR format value.
static IPV4Address WildCard ()
 Returns the wildcard address INADDR_ANY (0.0.0.0).
static IPV4Address Broadcast ()
 Returns the broadcast address INADDR_NONE (255.255.255.255).
static IPV4Address Loopback ()
 Returns the loopback address (127.0.0.1).

Friends

std::ostream & operator<< (std::ostream &out, const IPV4Address &address)
 Write the string representation of this IPV4Address to an ostream.

Constructor & Destructor Documentation

ola::network::IPV4Address::IPV4Address ( uint32_t  address)
inlineexplicit

Create a new IPv4 Address from an uint32.

Parameters
addressthe ip address, in network byte order.
ola::network::IPV4Address::IPV4Address ( const IPV4Address other)
inline

Copy constructor.

Parameters
otherthe IPV4Address to copy.

Member Function Documentation

uint32_t ola::network::IPV4Address::AsInt ( ) const
inline

Return the IPV4Address as an int in network-byte order.

Returns
An uint32 representing the IP address.
IPV4Address ola::network::IPV4Address::Broadcast ( )
static

Returns the broadcast address INADDR_NONE (255.255.255.255).

Returns
an IPV4Address representing the broadcast address.
IPV4Address * ola::network::IPV4Address::FromString ( const std::string &  address)
static

Convert a string to an IPV4Address.

Parameters
addressthe IP address string to convert.
Returns
a new IPV4Address or NULL if the string was invalid. The caller is responsible for deleting the IPV4Address object.
bool ola::network::IPV4Address::FromString ( const std::string &  address,
IPV4Address target 
)
static

Convert a string to an IPV4Address.

Parameters
addressthe IP address string to convert.
[out]targetthe converted IPV4Address.
Returns
true if the string was a valid IPv4 address, false otherwise.
IPV4Address ola::network::IPV4Address::FromStringOrDie ( const std::string &  address)
static

Convert a string to an IPV4Address or abort.

Note
This should only be used within tests.
Parameters
addressthe IP address to convert.
Returns
an IPV4Address matching the string.
void ola::network::IPV4Address::Get ( uint8_t  ptr[LENGTH])
inline

Copy the IPV4Address to a memory location.

Parameters
ptrthe memory location to copy the address to. The location should be at least LENGTH bytes.
Note
The address is copied in network byte order.
bool ola::network::IPV4Address::IsWildcard ( ) const

Checks if this address is the wildcard address (0.0.0.0).

Returns
true if this address is the wildcard address.
IPV4Address ola::network::IPV4Address::Loopback ( )
static

Returns the loopback address (127.0.0.1).

Returns
an IPV4Address representing the loopback address.
bool ola::network::IPV4Address::operator!= ( const IPV4Address other) const
inline

Not equals operator.

Parameters
otherthe IPV4Address to compare.
Returns
false if both IPV4Addresses are equal.
IPV4Address& ola::network::IPV4Address::operator= ( const IPV4Address other)
inline

Assignment operator.

Parameters
otherthe IPV4Address to assign to this object.
bool ola::network::IPV4Address::operator== ( const IPV4Address other) const
inline

Equals operator.

Parameters
otherthe IPV4Address to compare.
Returns
true if both IPV4Addresses are equal.
bool ola::network::IPV4Address::ToCIDRMask ( IPV4Address  address,
uint8_t *  mask 
)
static

Convert a subnet mask to its CIDR format value.

Parameters
addressthe subnet mask as an IPV4Address object
maskthe mask variable to populate
Returns
true if we managed to convert the address to a CIDR value, false otherwise
string ola::network::IPV4Address::ToString ( ) const

Convert the IPV4Address to a string.

Returns
the string representation of this IPV4Address.
IPV4Address ola::network::IPV4Address::WildCard ( )
static

Returns the wildcard address INADDR_ANY (0.0.0.0).

Returns
an IPV4Address representing the wildcard address.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const IPV4Address address 
)
friend

Write the string representation of this IPV4Address to an ostream.

Parameters
outthe ostream to write to.
addressto address to write.

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