Open Lighting Architecture: ola::rpc::IPV4Address Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
ola::rpc::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.
IPV4Address & | operator= (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 IPV4Address * | FromString (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

## ◆ IPV4Address() [1/2]

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

Create a new IPv4 Address from an uint32.

Parameters

  address | the ip address, in network byte order.

## ◆ IPV4Address() [2/2]

ola::network::IPV4Address::IPV4Address | ( | const IPV4Address & | other | ) |
| inline

Copy constructor.

Parameters

  other | the IPV4Address to copy.

## Member Function Documentation

## ◆ AsInt()

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.

## ◆ Broadcast()

IPV4Address ola::network::IPV4Address::Broadcast | ( |  | ) |
| static

Returns the broadcast address INADDR_NONE (255.255.255.255).

Returns
  an IPV4Address representing the broadcast address.

## ◆ FromString() [1/2]

IPV4Address * ola::network::IPV4Address::FromString | ( | const std::string & | address | ) |
| static

Convert a string to an IPV4Address.

Parameters

  address | the 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.

## ◆ FromString() [2/2]

bool ola::network::IPV4Address::FromString | ( | const std::string & | address,
|  | IPV4Address * | target )
| static

Convert a string to an IPV4Address.

Parameters

  | address | the IP address string to convert.
  [out] | target | the converted IPV4Address.

Returns
  true if the string was a valid IPv4 address, false otherwise.

## ◆ FromStringOrDie()

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

  address | the IP address to convert.

Returns
  an IPV4Address matching the string.

## ◆ Get()

void ola::network::IPV4Address::Get | ( | uint8_t | ptr[LENGTH] | ) |
| inline

Copy the IPV4Address to a memory location.

Parameters

  ptr | the memory location to copy the address to. The location should be at least LENGTH bytes.

Note
  The address is copied in network byte order.

## ◆ IsWildcard()

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.

## ◆ Loopback()

IPV4Address ola::network::IPV4Address::Loopback | ( |  | ) |
| static

Returns the loopback address (127.0.0.1).

Returns
  an IPV4Address representing the loopback address.

## ◆ operator!=()

bool ola::network::IPV4Address::operator!= | ( | const IPV4Address & | other | ) | const
| inline

Not equals operator.

Parameters

  other | the IPV4Address to compare.

Returns
  false if both IPV4Addresses are equal.

## ◆ operator=()

IPV4Address & ola::network::IPV4Address::operator= | ( | const IPV4Address & | other | ) |
| inline

Assignment operator.

Parameters

  other | the IPV4Address to assign to this object.

## ◆ operator==()

bool ola::network::IPV4Address::operator== | ( | const IPV4Address & | other | ) | const
| inline

Equals operator.

Parameters

  other | the IPV4Address to compare.

Returns
  true if both IPV4Addresses are equal.

## ◆ ToCIDRMask()

bool ola::network::IPV4Address::ToCIDRMask | ( | IPV4Address | address,
|  | uint8_t * | mask )
| static

Convert a subnet mask to its CIDR format value.

Parameters

  address | the subnet mask as an IPV4Address object
  mask | the mask variable to populate

Returns
  true if we managed to convert the address to a CIDR value, false otherwise

## ◆ ToString()

string ola::network::IPV4Address::ToString | ( |  | ) | const

Convert the IPV4Address to a string.

Returns
  the string representation of this IPV4Address.

## ◆ WildCard()

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 Symbol Documentation

## ◆ operator<<

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

Write the string representation of this IPV4Address to an ostream.

Parameters

  out | the ostream to write to.
  address | to address to write.

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

- include/ola/network/IPV4Address.h
- common/network/IPV4Address.cpp