mavtables
0.2.1
MAVLink router and firewall.
|
#include <IPAddress.hpp>
Public Member Functions | |
IPAddress (const IPAddress &other)=default | |
IPAddress (IPAddress &&other)=default | |
IPAddress (const IPAddress &other, unsigned int port) | |
IPAddress (unsigned long address, unsigned int port=0) | |
IPAddress (std::string address) | |
unsigned long | address () const |
unsigned int | port () const |
IPAddress & | operator= (const IPAddress &other)=default |
IPAddress & | operator= (IPAddress &&other)=default |
Friends | |
std::ostream & | operator<< (std::ostream &os, const IPAddress &ipaddress) |
Related Functions | |
(Note that these are not member functions.) | |
bool | operator== (const IPAddress &lhs, const IPAddress &rhs) |
bool | operator!= (const IPAddress &lhs, const IPAddress &rhs) |
bool | operator< (const IPAddress &lhs, const IPAddress &rhs) |
bool | operator> (const IPAddress &lhs, const IPAddress &rhs) |
bool | operator<= (const IPAddress &lhs, const IPAddress &rhs) |
bool | operator>= (const IPAddress &lhs, const IPAddress &rhs) |
IPAddress | dnslookup (const std::string &url) |
An IP address with optional port number.
Definition at line 31 of file IPAddress.hpp.
|
default |
Copy constructor.
other | IP address to copy from. |
|
default |
Move constructor.
other | IP address to move from. |
IPAddress::IPAddress | ( | const IPAddress & | other, |
unsigned int | port | ||
) |
Construct IP address from another IP address, changing the port number.
Copy constructor that also changes the port.
other | IP address to copy from. |
port | Port number (0 - 65535). A port number of 0 has the special meaning of no specific port. |
std::out_of_range | if the port number is outside of the allowed 16 bit range. |
Definition at line 88 of file IPAddress.cpp.
References port().
IPAddress::IPAddress | ( | unsigned long | address, |
unsigned int | port = 0 |
||
) |
Construct IP address from address and port number.
address | 32-bit IP address in system byte order (0x00000000 - 0xFFFFFFFF). |
port | Port number (0 - 65535). A port number of 0 has the special meaning of no specific port. |
std::out_of_range | if either the IP address or the port number is outside of the respectively allowed 32 or 16 bit ranges. |
Definition at line 103 of file IPAddress.cpp.
References address(), and port().
IPAddress::IPAddress | ( | std::string | address | ) |
Construct IP address from a string.
Parse a string of the form "<IP Address>" or "<IP Address>:<Port Number>".
Some examples are:
If no port is given the 0 port is used which represents no specific port.
address | String representing the IP address and optionally the port number. |
std::invalid_argument | if the string does not represent a valid IP address. |
std::out_of_range | if an address octet or the port number is out of range. |
Definition at line 127 of file IPAddress.cpp.
References address(), and port().
unsigned long IPAddress::address | ( | ) | const |
Return the IP address.
Definition at line 205 of file IPAddress.cpp.
Assignment operator.
other | IP address to copy from. |
Assignment operator (by move semantics).
other | IP address to move from. |
unsigned int IPAddress::port | ( | ) | const |
Return the port.
Definition at line 215 of file IPAddress.cpp.
|
related |
Lookup an IP address based on a hostname.
url | The URL to get an IP address for. |
DNSLookupError | if the address cannot be found. |
Definition at line 371 of file IPAddress.cpp.
Inequality comparison.
lhs | The left hand side IP address. |
rhs | The right hand side IP address. |
true | if lhs and rhs do not have the same address and port. |
false | if lhs and rhs have the same address and port. |
Definition at line 247 of file IPAddress.cpp.
References address(), and port().
Less than comparison.
lhs | The left hand side IP address. |
rhs | The right hand side IP address. |
true | if lhs is less than rhs . |
false | if lhs is not less than rhs . |
Definition at line 263 of file IPAddress.cpp.
References address(), and port().
|
friend |
Print the IP address to the given output stream.
The format is "<IP Address>" or "<IP Address>:<Port Number>" if the port number is nonzero an "<IP Address>" if the port is 0.
Some examples are:
127.0.0.1
127.0.0.1:14555
183.125.120.42:443
os | The output stream to print to. |
ipaddress | The IP address to print. |
Definition at line 340 of file IPAddress.cpp.
Less than or equal comparison.
lhs | The left hand side IP address. |
rhs | The right hand side IP address. |
true | if lhs is less than or eqaul to rhs . |
false | if lhs is greater than rhs . |
Definition at line 297 of file IPAddress.cpp.
Equality comparison.
lhs | The left hand side IP address. |
rhs | The right hand side IP address. |
true | if lhs and rhs have the same address and port. |
false | if lhs and rhs do not have the same address and port. |
Definition at line 231 of file IPAddress.cpp.
References address(), and port().
Greater than comparison.
lhs | The left hand side IP address. |
rhs | The right hand side IP address. |
true | if lhs is greater than rhs . |
false | if lhs is not greater than rhs . |
Definition at line 280 of file IPAddress.cpp.
References address(), and port().
Greater than comparison.
lhs | The left hand side IP address. |
rhs | The right hand side IP address. |
true | if lhs is greater than or equal to rhs . |
false | if lhs is less than rhs . |
Definition at line 313 of file IPAddress.cpp.