Abstraction of an IPv4 address.
More...
#include <ip_address.h>
|
TINS_API friend std::ostream & | operator<< (std::ostream &output, const IPv4Address &addr) |
| Writes this address to a std::ostream.
|
|
Abstraction of an IPv4 address.
◆ IPv4Address() [1/3]
Tins::IPv4Address::IPv4Address |
( |
const char * | ip = 0 | ) |
|
Constructor taking a const char*.
Constructs an IPv4Address from a dotted-notation address cstring. If the pointer provided is null, then a default IPv4Address object is constructed, which corresponds to the 0.0.0.0 address.
- Parameters
-
ip | const char* containing the dotted-notation address. |
◆ IPv4Address() [2/3]
Tins::IPv4Address::IPv4Address |
( |
const std::string & | ip | ) |
|
Constructor taking a std::string.
Constructs an IPv4Address from a dotted-notation std::strings
- Parameters
-
ip | std::string containing the dotted-notation address. |
◆ IPv4Address() [3/3]
Tins::IPv4Address::IPv4Address |
( |
uint32_t | ip | ) |
|
|
explicit |
Constructor taking a IP address represented as a big endian integer.
This constructor should be used internally by PDUs that handle IP addresses. The provided integer must be be in big endian.
◆ from_prefix_length()
IPv4Address Tins::IPv4Address::from_prefix_length |
( |
uint32_t | prefix_length | ) |
|
|
static |
Constructs an IPv4 address from a prefix length.
- Parameters
-
prefix_length | The length of the prefix |
◆ is_loopback()
bool Tins::IPv4Address::is_loopback |
( |
| ) |
const |
Returns true if this is a loopback IPv4 address.
This method returns true if this address is in the address range 127.0.0.0/8, false otherwise.
◆ is_multicast()
bool Tins::IPv4Address::is_multicast |
( |
| ) |
const |
Returns true if this is a multicast IPv4 address.
This method returns true if this address is in the address range 224.0.0.0/4, false otherwise.
◆ is_private()
bool Tins::IPv4Address::is_private |
( |
| ) |
const |
Returns true if this is a private IPv4 address.
This takes into account the private network ranges defined in RFC 1918. Therefore, this method returns true if this address is in any of the following network ranges, false otherwise:
- 192.168.0.0/16
- 10.0.0.0/8
- 172.16.0.0/12
◆ operator!=()
bool Tins::IPv4Address::operator!= |
( |
const IPv4Address & | rhs | ) |
const |
|
inline |
Compare this IPv4Address for inequality.
- Parameters
-
rhs | The address to be compared. |
- Returns
- bool indicating whether this address is distinct from rhs.
◆ operator&()
Apply a mask to this address.
- Parameters
-
mask | The mask to be applied |
- Returns
- The result of applying the mask to this address
◆ operator<()
bool Tins::IPv4Address::operator< |
( |
const IPv4Address & | rhs | ) |
const |
|
inline |
Compare this IPv4Address for less-than inequality.
- Parameters
-
rhs | The address to be compared. |
- Returns
- bool indicating whether this address is less-than rhs.
◆ operator<=()
bool Tins::IPv4Address::operator<= |
( |
const IPv4Address & | rhs | ) |
const |
|
inline |
Compares this address for less-than equality.
- Parameters
-
rhs | The address to be compared to. |
- Returns
- bool indicating whether this address is equal or less-than rhs.
◆ operator==()
bool Tins::IPv4Address::operator== |
( |
const IPv4Address & | rhs | ) |
const |
|
inline |
Compare this IPv4Address for equality.
- Parameters
-
rhs | The address to be compared. |
- Returns
- bool indicating whether this address equals rhs.
◆ operator>()
bool Tins::IPv4Address::operator> |
( |
const IPv4Address & | rhs | ) |
const |
|
inline |
Compare this IPv4Address for greater-than inequality.
- Parameters
-
rhs | The address to be compared. |
- Returns
- bool indicating whether this address is greater-than rhs.
◆ operator>=()
bool Tins::IPv4Address::operator>= |
( |
const IPv4Address & | rhs | ) |
const |
|
inline |
Compares this address for greater-than equality.
- Parameters
-
rhs | The address to be compared to. |
- Returns
- bool indicating whether this address is equal or greater-than rhs.
◆ operator|()
Apply a mask to this address.
- Parameters
-
mask | The mask to be applied |
- Returns
- The result of applying the mask to this address
◆ operator~()
◆ size()
size_t Tins::IPv4Address::size |
( |
| ) |
const |
|
inline |
◆ to_string()
string Tins::IPv4Address::to_string |
( |
| ) |
const |
Retrieve the string representation of this address.
- Returns
- std::string containing the representation of this address.
◆ operator<<
TINS_API friend std::ostream & operator<< |
( |
std::ostream & | output, |
|
|
const IPv4Address & | addr ) |
|
friend |
Writes this address to a std::ostream.
This method writes addr in a dotted-string notation address to the std::ostream argument.
- Parameters
-
output | The std::ostream in which to write the address. |
addr | The IPv4Address to be written. |
- Returns
- std::stream& pointing to output.
◆ address_size
const size_t Tins::IPv4Address::address_size = sizeof(uint32_t) |
|
static |
◆ broadcast
The documentation for this class was generated from the following files:
- /builddir/build/BUILD/libtins-4.5-build/libtins-4.5/include/tins/ip_address.h
- /builddir/build/BUILD/libtins-4.5-build/libtins-4.5/src/ip_address.cpp