|
Click
|
An IPv4 address. More...
Public Types | |
| typedef uninitialized_type | uninitialized_t |
| typedef IPAddress | parameter_type |
Public Member Functions | |
| IPAddress () | |
| Construct an IPAddress equal to 0.0.0.0. | |
| IPAddress (unsigned x) | |
| Construct an IPAddress from an integer in network byte order. | |
| IPAddress (int x) | |
| IPAddress (unsigned long x) | |
| IPAddress (long x) | |
| IPAddress (struct in_addr x) | |
| Construct an IPAddress from a struct in_addr. | |
| IPAddress (const unsigned char *data) | |
| Construct an IPAddress from data. | |
| IPAddress (const String &x) | |
| Constructs an IPAddress from a human-readable dotted-quad representation. | |
| IPAddress (const uninitialized_type &unused) | |
| Construct an uninitialized IPAddress. | |
| bool | empty () const |
| Test if the address is 0.0.0.0. | |
| uint32_t | addr () const |
| Return the address as a uint32_t in network byte order. | |
| operator uint32_t () const | |
| Return the address as a uint32_t in network byte order. | |
| bool | is_multicast () const |
| Return true iff the address is a multicast address. | |
| bool | is_link_local () const |
| struct in_addr | in_addr () const |
| Return a struct in_addr corresponding to the address. | |
| operator struct in_addr () const | |
| Return a struct in_addr corresponding to the address. | |
| unsigned char * | data () |
| Return a pointer to the address data. | |
| const unsigned char * | data () const |
| Return a pointer to the address data. | |
| uint32_t | hashcode () const |
| Hash function. | |
| int | mask_to_prefix_len () const |
| Returns the prefix length equivalent to this prefix mask, or -1 if this is not a prefix mask. | |
| bool | matches_prefix (IPAddress addr, IPAddress mask) const |
| Return true iff this address matches the address prefix addr/mask. | |
| bool | mask_as_specific (IPAddress mask) const |
| Return true iff this address, considered as a prefix mask, is at least as specific as mask. | |
| bool | mask_more_specific (IPAddress mask) const |
| Return true iff this prefix mask is more specific than mask. | |
| IPAddress & | operator&= (IPAddress) |
| Assign this address to its bitwise-and with a. | |
| IPAddress & | operator|= (IPAddress) |
| Assign this address to its bitwise-or with a. | |
| IPAddress & | operator^= (IPAddress) |
| Assign this address to its bitwise-xor with a. | |
| String | unparse () const |
| Unparses this address into a dotted-quad format String. | |
| String | unparse_mask () const |
| Unparses this address into IP address mask format: either a prefix length or unparse(). | |
| String | unparse_with_mask (IPAddress) const |
| Unparses an address prefix, specified by address and mask, into "address/mask" format. | |
| String | s () const |
| Unparse this address into a dotted-quad format String. | |
| operator String () const | |
| Unparse this address into a dotted-quad format String. | |
Static Public Member Functions | |
| static IPAddress | make_prefix (int prefix_len) |
| Return an IPAddress equal to the prefix mask of length prefix. | |
| static IPAddress | make_broadcast () |
| Return the broadcast IP address, 255.255.255.255. | |
| static IPAddress | make_random () |
| Return the broadcast IP address, 255.255.255.255. | |
Related Symbols | |
(Note that these are not member symbols.) | |
| bool | operator== (IPAddress a, IPAddress b) |
| Compare two IPAddress objects for equality. | |
| bool | operator== (IPAddress a, uint32_t b) |
| Compare an IPAddress with a network-byte-order address value for equality. | |
| bool | operator!= (IPAddress a, IPAddress b) |
| Compare two IPAddress objects for inequality. | |
| bool | operator!= (IPAddress a, uint32_t b) |
| Compare an IPAddress with a network-byte-order address value for inequality. | |
| IPAddress | operator& (IPAddress a, IPAddress b) |
| Calculate the IPAddress representing the bitwise-and of a and b. | |
| IPAddress | operator| (IPAddress a, IPAddress b) |
| Calculate the IPAddress representing the bitwise-or of a and b. | |
| IPAddress | operator^ (IPAddress a, IPAddress b) |
| Calculate the IPAddress representing the bitwise-xor of a and b. | |
| IPAddress | operator~ (IPAddress a) |
| Calculate the IPAddress representing the bitwise complement of a. | |
An IPv4 address.
The IPAddress type represents an IPv4 address. It supports bitwise operations like & and | and provides methods for unparsing IP addresses into ASCII dotted-quad form.
|
inline |
Construct an IPAddress equal to 0.0.0.0.
|
inline |
Construct an IPAddress from an integer in network byte order.
|
inlineexplicit |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineexplicit |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineexplicit |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineexplicit |
Construct an IPAddress from data.
| data | the address data, in network byte order |
Bytes data[0]...data[3] are used to construct the address.
|
explicit |
|
inline |
Construct an uninitialized IPAddress.
|
static |
Return an IPAddress equal to the prefix mask of length prefix.
| prefix_len | prefix length; 0 <= prefix_len <= 32 |
For example, make_prefix(0) is 0.0.0.0, make_prefix(8) is 255.0.0.0, and make_prefix(32) is 255.255.255.255. Causes an assertion failure if prefix_len is out of range.
|
inlinestatic |
Return the broadcast IP address, 255.255.255.255.
|
inlinestatic |
Return the broadcast IP address, 255.255.255.255.
|
inline |
Test if the address is 0.0.0.0.
|
inline |
Return the address as a uint32_t in network byte order.
|
inline |
Return the address as a uint32_t in network byte order.
Also suitable for use as an operator bool, returning true iff the address is not 0.0.0.0.
|
inline |
Return true iff the address is a multicast address.
These are the class D addresses, 224.0.0.0-239.255.255.255.
|
inline |
Return a struct in_addr corresponding to the address.
|
inline |
Return a struct in_addr corresponding to the address.
|
inline |
|
inline |
|
inline |
Hash function.
Equal IPAddress objects always have equal hashcode() values.
| int IPAddress::mask_to_prefix_len | ( | ) | const |
Returns the prefix length equivalent to this prefix mask, or -1 if this is not a prefix mask.
Maintains the invariant that make_prefix(prefix_len).mask_to_prefix_len() == prefix_len.
Return true iff this address matches the address prefix addr/mask.
| addr | prefix address |
| mask | prefix mask |
Equivalent to (addr & mask) == (*this & mask). The prefix address addr may be nonzero outside the mask.
|
inline |
Return true iff this address, considered as a prefix mask, is at least as specific as mask.
| mask | prefix mask |
Longer prefix masks are more specific than shorter ones. For example, make_prefix(20).mask_as_specific(make_prefix(18)) is true, but make_prefix(10).mask_as_specific(make_prefix(14)) is false.
Equivalent to (*this & mask) == mask.
|
inline |
Return true iff this prefix mask is more specific than mask.
| mask | prefix mask |
Both this address and mask must be prefix masks – i.e., mask_to_prefix_len() returns 0-32. Returns true iff this address contains a longer prefix than mask. For example, make_prefix(20).mask_more_specific(make_prefix(18)) is true, but make_prefix(20).mask_more_specific(make_prefix(20)) is false.
Assign this address to its bitwise-and with a.
Assign this address to its bitwise-or with a.
Assign this address to its bitwise-xor with a.
| String IPAddress::unparse | ( | ) | const |
| String IPAddress::unparse_mask | ( | ) | const |
Unparses this address into IP address mask format: either a prefix length or unparse().
If mask_to_prefix_len() >= 0, then returns that value as a base-10 String; otherwise, returns unparse(). Example results include "8" (for 255.0.0.0) and "18.26.4.9".
Unparses an address prefix, specified by address and mask, into "address/mask" format.
| mask | the address mask |
Equivalent to unparse() + "/" + mask.unparse_mask().
|
inline |
Unparse this address into a dotted-quad format String.
|
inline |
Unparse this address into a dotted-quad format String.
|
related |
Compare an IPAddress with a network-byte-order address value for equality.
| a | an address |
| b | an address value in network byte order |
|
related |
Compare an IPAddress with a network-byte-order address value for inequality.
| a | an address |
| b | an address value in network byte order |
Calculate the IPAddress representing the bitwise-and of a and b.
Calculate the IPAddress representing the bitwise-or of a and b.
Calculate the IPAddress representing the bitwise-xor of a and b.
Calculate the IPAddress representing the bitwise complement of a.