class IPNet

A template class for subnets. More...

Definition#include <ipnet.hh>
Template formIPNet<class A>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods

Protected Methods

Protected Members


Detailed Description

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:
abase address for the subnet.
preflenlength of subnet mask (e.g., class C nets would have preflen=24).

 IPNet (const char *from_cstring)
throw (InvalidString, InvalidNetmaskLength)

IPNet

Constructor from a string.

Parameters:
from_cstringC-style string with slash separated address and prefix length.

 IPNet (const IPNet& n)

IPNet

Copy constructor

Parameters:
nthe subnet to copy from.

IPNet&  operator= (const IPNet& n)

operator=

Assignment operator

Parameters:
nthe subnet to assign from.

Returns: the subnet after the assignment.

bool  operator== (const IPNet& other)

operator==

[const]

Equality Operator

Parameters:
otherthe 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:
otherthe 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

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.

bool  is_valid ()

is_valid

[const]

Test if the object contains a real (non-default) value.

Returns: true if the object stores a real (non-default) value.

inline bool  is_overlap (const IPNet& other)

is_overlap

[const]

Test if subnets overlap.

Parameters:
otherthe 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:
otherthe 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:
addrthe 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:
otherthe subnet to test against.

Returns: the number of bits overlapping between other and this subnet.

const int  af ()

af

[static]

Get the address family.

Returns: the address family of this address.

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, InvalidNetmaskLength)

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, InvalidNetmaskLength)

initialize_from_string

[protected]

template <class A> inline size_t  overlap (const IPNet<A>& other)

overlap

[protected const]

template<> inline  IPNet (const IPvX& ipvx, size_t preflen)
throw (InvalidNetmaskLength)

IPNet

[protected]

template <> inline void  initialize_from_string (const char *cp)
throw (InvalidString, InvalidNetmaskLength)

initialize_from_string

[protected]


Generated by: pavlin on possum.icir.org on Mon Jun 9 13:23:43 2003, using kdoc 2.0a54+XORP.