|
|
A "subnet" is specified by a base "address" and a "prefix length".
IPNet ()
| IPNet |
Default constructor taking no parameters.
Default value has INADDR_ANY/0.
IPNet (const _A& a, size_t preflen)
throw (InvalidNetmaskLength) | IPNet |
Constructor from a given base address and a prefix length.
Parameters:
a | base address for the subnet. |
preflen | length of subnet mask (e.g., class C nets would have preflen=24). |
IPNet (const char *from_cstring)
throw (InvalidString) | IPNet |
Constructor from a string.
Parameters:
from_cstring | C-style string with slash separated address and prefix length. |
IPNet (const IPNet& n)
| IPNet |
Copy constructor
Parameters:
n | the subnet to copy from. |
IPNet& operator= (const IPNet& n)
| operator= |
Assignment operator
Parameters:
n | the subnet to assign from. |
Returns: the subnet after the assignment.
bool operator== (const IPNet& other)
| operator== |
[const]
Equality Operator
Parameters:
other | the right-hand operand to compare against. |
Returns: true if the left-hand operand is numerically same as the right-hand operand.
inline bool operator< (const IPNet& other)
| operator< |
[const]
Less-Than Operator
Less-than comparison for subnets (see body for description).
Parameters:
other | the right-hand side of the comparison. |
Returns: true if the left-hand side is "smaller" than the right-hand side according to the chosen order.
IPNet& operator-- ()
| operator-- |
Decrement Operator
The numerical value of the prefix address is decrement by one. Example: decrementing 128.2.0.0/16 results in 128.1.0.0/16.
Returns: a reference to this subnet after the decrement
IPNet& operator++ ()
| operator++ |
Increment Operator
The numerical value of the prefix address is incremented by one. Example: incrementing 128.2.0.0/16 results in 128.3.0.0/16.
Returns: a reference to this subnet after the increment
operator bool ()
| bool |
[const]
Bool Operator
Returns: true if the object stores a real (non-default) value.
inline string str ()
| str |
[const]
Convert this address from binary form to presentation format.
Returns: C++ string with the human-readable ASCII representation of the address.
inline bool is_overlap (const IPNet& other)
| is_overlap |
[const]
Test if subnets overlap.
Parameters:
other | the subnet to compare against. |
Returns: true if there is some overlap between the two subnets.
inline bool contains (const IPNet& other)
| contains |
[const]
Test if a subnet contains (or is equal to) another subnet.
in LaTeX, x.contains(y) would be $x \superseteq y$
Parameters:
other | the subnet to test against. |
Returns: true if this subnet contains or is equal to other.
inline bool contains (const _A& addr)
| contains |
[const]
Test if an address is within a subnet.
Parameters:
addr | the address to test against. |
Returns: true if addr is within this subnet.
inline size_t overlap (const IPNet& other)
| overlap |
[const]
Determine the number of the most significant bits overlapping with another subnet.
Parameters:
other | the subnet to test against. |
Returns: the number of bits overlapping between other and this subnet.
inline const _A& masked_addr ()
| masked_addr |
[const]
Get the base address.
Returns: the base address for this subnet.
inline size_t prefix_len ()
| prefix_len |
[const]
Get the prefix length.
Returns: the prefix length for this subnet.
inline _A netmask ()
| netmask |
[const]
Get the network mask.
Returns: the netmask associated with this subnet.
const IPNet<_A> ip_multicast_base_prefix ()
| ip_multicast_base_prefix |
[static]
Return the subnet containing all multicast addresses.
Note that this is a static function and can be used without a particular object. Example: IPv4Net my_prefix = IPv4Net::ip_multicast_base_prefix(); OK IPv4Net my_prefix = ipv4net.ip_multicast_base_prefix(); OK
Returns: the subnet containing multicast addresses.
bool is_multicast ()
| is_multicast |
[const]
Test if this subnet is within the multicast address range.
Returns: true if this subnet is within the multicast address range.
inline _A top_addr ()
| top_addr |
[const]
Get the highest address within this subnet.
Returns: the highest address within this subnet.
IPNet<_A> common_subnet (const IPNet<_A> x, const IPNet<_A> y)
| common_subnet |
[static]
Get the smallest subnet containing both subnets.
Returns: the smallest subnet containing both subnets passed as arguments.
inline void initialize_from_string (const char *s)
throw (InvalidString) | initialize_from_string |
[protected]
_A _masked_addr | _masked_addr |
[protected]
size_t _prefix_len | _prefix_len |
[protected]
template <class _A> bool
is_overlap (const IPNet<_A>& other)
| is_overlap |
[protected const]
template <class _A> bool
contains (const IPNet<_A>& other)
| contains |
[protected const]
template <class _A> void
initialize_from_string (const char *cp)
throw (InvalidString) | initialize_from_string |
[protected]
template <class _A>
inline size_t
overlap (const IPNet<_A>& other)
| overlap |
[protected const]
template<>
IPNet (const IPvX& ipvx, size_t preflen)
throw (InvalidNetmaskLength) | IPNet |
[protected]
template <> void
initialize_from_string (const char *cp)
throw (InvalidString) | initialize_from_string |
[protected]
Generated by: pavlin on possum.icir.org on Wed Dec 11 16:50:31 2002, using kdoc 2.0a54+XORP. |