IPv4 network prefix. More...
#include <senf/Socket/Protocols/INet/INet4Address.hh>
Public Member Functions | |
INet4Address const & | address () const |
Get the networks address. More... | |
unsigned | prefix_len () const |
Get the networks prefix length. More... | |
bool | boolean_test () const |
true , if INet4Network is non-empty More... | |
bool | operator== (INet4Network const &other) const |
Compare to networks for equality. More... | |
bool | match (INet4Address const &addr) const |
true , if the network includes addr More... | |
bool | match (INet4Network const &net) const |
true , if the network includes net More... | |
INet4Address | host (boost::uint32_t number) |
Return the host with the given number. More... | |
INet4Network | subnet (boost::uint32_t net, unsigned prefix_len) |
Return the given subnet of this . More... | |
Public Member Functions inherited from senf::comparable_safe_bool< INet4Network > | |
operator bool_type () const | |
bool | operator! () const |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &os, INet4Network const &addr) |
Output INet4Network instance as it's string representation. More... | |
std::istream & | operator>> (std::istream &is, INet4Network &addr) |
Initialize INet4Address instance from a string representation. More... | |
Structors and default members | |
INet4Network () | |
Construct empty (0.0.0.0/0) network. More... | |
INet4Network (INet4Address const &address, unsigned prefix_len) | |
Construct network from given address and prefix length. More... | |
INet4Network (std::string const &s) | |
Construct network from CIDR notation. More... | |
Additional Inherited Members | |
Protected Types inherited from senf::safe_bool_base | |
typedef void(safe_bool_base::* | bool_type) () const |
Protected Member Functions inherited from senf::comparable_safe_bool< INet4Network > | |
~comparable_safe_bool () | |
Protected Member Functions inherited from senf::safe_bool_base | |
void | this_type_does_not_support_comparisons () const |
safe_bool_base () | |
safe_bool_base (const safe_bool_base &) | |
safe_bool_base & | operator= (const safe_bool_base &) |
~safe_bool_base () | |
IPv4 network prefix.
This class represents an IPv4 network prefix in CIDR notation.
Definition at line 208 of file INet4Address.hh.
senf::INet4Network::INet4Network | ( | ) |
Construct empty (0.0.0.0/0) network.
senf::INet4Network::INet4Network | ( | INet4Address const & | address, |
unsigned | prefix_len | ||
) |
Construct network from given address and prefix length.
|
explicit |
Construct network from CIDR notation.
Definition at line 116 of file INet4Address.cc.
INet4Address const& senf::INet4Network::address | ( | ) | const |
Get the networks address.
bool senf::INet4Network::boolean_test | ( | ) | const |
true
, if INet4Network is non-empty
INet4Address senf::INet4Network::host | ( | boost::uint32_t | number | ) |
Return the host with the given number.
Returns the host with the given number within the network. If the number is larger than the maximum host number in the network, it is truncated. So host(0)
is the networks own address, host(1)
customarily is the default router and host
(-1) is the broadcast address.
bool senf::INet4Network::match | ( | INet4Address const & | addr | ) | const |
true
, if the network includes addr
bool senf::INet4Network::match | ( | INet4Network const & | net | ) | const |
true
, if the network includes net
The is true, if net is sub-network (or the same as) this
.
bool senf::INet4Network::operator== | ( | INet4Network const & | other | ) | const |
Compare to networks for equality.
unsigned senf::INet4Network::prefix_len | ( | ) | const |
Get the networks prefix length.
INet4Network senf::INet4Network::subnet | ( | boost::uint32_t | net, |
unsigned | prefix_len | ||
) |
Return the given subnet of this
.
The returned INet4Network will be a subnet of this
with the given network number. The network number is comprised by the bits above prefix_len:
[in] | net | network number |
[in] | prefix_len | length of subnet prefix |
|
related |
Output INet4Network instance as it's string representation.
|
related |
Initialize INet4Address instance from a string representation.
sets std::ios::failbit on the stream if an error occurred