Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

WvIPNet Class Reference

#include <wvaddr.h>

Inheritance diagram for WvIPNet:

WvIPAddr WvIPAddr WvAddr WvAddr WvAddr WvAddr List of all members.

Public Methods

 WvIPNet (const WvIPNet &_net)
 WvIPNet (const char string[])
 WvIPNet (const WvString &string)
void string_init (const char string[])
 WvIPNet (const WvIPAddr &base, const WvIPAddr &_mask)
 WvIPNet (const WvIPAddr &base, int bits=32)
 WvIPNet ()
virtual ~WvIPNet ()
virtual unsigned WvHash () const
virtual bool comparator (const WvAddr *a2) const
WvIPAddr base () const
const WvIPAddr & netmask () const
WvIPAddr network () const
WvIPAddr broadcast () const
void include (const WvIPNet &addr)
bool includes (const WvIPNet &addr) const
int bits () const
void normalize ()
bool is_default () const
bool is_host () const
 WvIPNet (const WvIPNet &_net)
 WvIPNet (const char string[])
 WvIPNet (const WvString &string)
void string_init (const char string[])
 WvIPNet (const WvIPAddr &base, const WvIPAddr &_mask)
 WvIPNet (const WvIPAddr &base, int bits=32)
 WvIPNet ()
virtual ~WvIPNet ()
virtual unsigned WvHash () const
virtual bool comparator (const WvAddr *a2) const
WvIPAddr base () const
const WvIPAddr & netmask () const
WvIPAddr network () const
WvIPAddr broadcast () const
void include (const WvIPNet &addr)
bool includes (const WvIPNet &addr) const
int bits () const
void normalize ()
bool is_default () const
bool is_host () const

Protected Methods

virtual WvString printable () const
virtual WvString printable () const

Protected Attributes

WvIPAddr mask

Detailed Description

An IP network comprises two WvIPAddr structures: an address and a netmask. The two ANDed together comprise the "network address", which, if it is correct, can be ORed with any IP address on the network without changing the address. Together, a network address and netmask provide a good description of the IP addresses available on a network.

WvIPNet internally stores a base IP address (the inherited WvIPAddr) and the netmask (a member variable).

Note that the rawdata() function is inherited from WvIPAddr, so it does not include the netmask in the raw data.

Definition at line 272 of file include/wvaddr.h.


Constructor & Destructor Documentation

WvIPNet::WvIPNet (  const WvIPNet &    _net ) 
 

Definition at line 506 of file wvaddr.cc.

References WvAddr::addrtype, and wvipnet.

WvIPNet::WvIPNet (  const char    string[] )  [inline]
 

Definition at line 280 of file include/wvaddr.h.

References string_init().

WvIPNet::WvIPNet (  const WvString &    string )  [inline]
 

Definition at line 282 of file include/wvaddr.h.

References string_init().

WvIPNet::WvIPNet (  const WvIPAddr &    base,
const WvIPAddr &    _mask
) 
 

Definition at line 545 of file wvaddr.cc.

References WvAddr::addrtype, and wvipnet.

WvIPNet::WvIPNet (  const WvIPAddr &    base,
int    bits = 32
) 
 

construct an IPNet from a base address and a number of bits in the netmask. The default of 32 gives a one-host network, (netmask 255.255.255.255).

Definition at line 552 of file wvaddr.cc.

References WvAddr::addrtype, bits(), mask, WvIPAddr::WvIPAddr(), and wvipnet.

WvIPNet::WvIPNet (    ) 
 

construct an empty IPNet for later copying (probably by operator=)

Definition at line 500 of file wvaddr.cc.

References WvAddr::addrtype, and wvipnet.

WvIPNet::~WvIPNet (    )  [virtual]
 

Definition at line 564 of file wvaddr.cc.

WvIPNet::WvIPNet (  const WvIPNet &    _net ) 
 

WvIPNet::WvIPNet (  const char    string[] )  [inline]
 

Definition at line 280 of file ipstreams/wvaddr.h.

References string_init().

WvIPNet::WvIPNet (  const WvString &    string )  [inline]
 

Definition at line 282 of file ipstreams/wvaddr.h.

References string_init().

WvIPNet::WvIPNet (  const WvIPAddr &    base,
const WvIPAddr &    _mask
) 
 

WvIPNet::WvIPNet (  const WvIPAddr &    base,
int    bits = 32
) 
 

construct an IPNet from a base address and a number of bits in the netmask. The default of 32 gives a one-host network, (netmask 255.255.255.255).

WvIPNet::WvIPNet (    ) 
 

construct an empty IPNet for later copying (probably by operator=)

virtual WvIPNet::~WvIPNet (    )  [virtual]
 


Member Function Documentation

WvIPAddr WvIPNet::base (    )  const [inline]
 

Get the 'base IP address' component, netmask, network, and broadcast

Definition at line 310 of file ipstreams/wvaddr.h.

References WvIPAddr::binaddr, and WvIPAddr::WvIPAddr().

WvIPAddr WvIPNet::base (    )  const [inline]
 

Get the 'base IP address' component, netmask, network, and broadcast

Definition at line 310 of file include/wvaddr.h.

References WvIPAddr::binaddr, and WvIPAddr::WvIPAddr().

Referenced by includes(), WvInterfaceDict::islocal(), and WvInterface::setipaddr().

int WvIPNet::bits (    )  const
 

weird netmasks such as 255.0.255.0 (easy example) are almost never used -- they have '0' bits in the middle. However, using the include() function will result in odd netmasks like this, since it will not eliminate a '1' bit unless absolutely necessary. normalize() would convert the above netmask into 255.0.0.0, which is probably the netmask _really_ in use. bits() calculates the number of leading '1' bits in the normalized netmask, without actually doing the normalization.

int WvIPNet::bits (    )  const
 

weird netmasks such as 255.0.255.0 (easy example) are almost never used -- they have '0' bits in the middle. However, using the include() function will result in odd netmasks like this, since it will not eliminate a '1' bit unless absolutely necessary. normalize() would convert the above netmask into 255.0.0.0, which is probably the netmask _really_ in use. bits() calculates the number of leading '1' bits in the normalized netmask, without actually doing the normalization.

Definition at line 604 of file wvaddr.cc.

References bits(), mask, and WvIPAddr::s_addr().

Referenced by bits(), normalize(), printable(), WvInterface::setipaddr(), string_init(), and WvIPNet().

WvIPAddr WvIPNet::broadcast (    )  const [inline]
 

Definition at line 316 of file ipstreams/wvaddr.h.

WvIPAddr WvIPNet::broadcast (    )  const [inline]
 

Definition at line 316 of file include/wvaddr.h.

Referenced by WvInterfaceDict::islocal(), and WvInterface::setipaddr().

virtual bool WvIPNet::comparator (  const WvAddr *    a2 )  const [virtual]
 

Reimplemented from WvAddr.

bool WvIPNet::comparator (  const WvAddr *    a2 )  const [virtual]
 

Reimplemented from WvAddr.

Definition at line 585 of file wvaddr.cc.

References WvAddr::comparator(), and mask.

void WvIPNet::include (  const WvIPNet &    addr ) 
 

adjust the netmask so that 'addr' would be included in this network

void WvIPNet::include (  const WvIPNet &    addr ) 
 

adjust the netmask so that 'addr' would be included in this network

Definition at line 591 of file wvaddr.cc.

References mask.

bool WvIPNet::includes (  const WvIPNet &    addr )  const
 

determine whether the given address is already included in this net

bool WvIPNet::includes (  const WvIPNet &    addr )  const
 

determine whether the given address is already included in this net

Definition at line 597 of file wvaddr.cc.

References base(), mask, and network().

Referenced by WvInterfaceDict::on_local_net().

bool WvIPNet::is_default (    )  const [inline]
 

is this net the default gateway? (0.0.0.0/0)

Definition at line 345 of file ipstreams/wvaddr.h.

References WvIPAddr::binaddr.

bool WvIPNet::is_default (    )  const [inline]
 

is this net the default gateway? (0.0.0.0/0)

Definition at line 345 of file include/wvaddr.h.

References WvIPAddr::binaddr.

Referenced by WvInterface::addroute(), and WvInterface::delroute().

bool WvIPNet::is_host (    )  const [inline]
 

is it a plain host? (x.x.x.x/32)

Definition at line 351 of file ipstreams/wvaddr.h.

References WvIPAddr::binaddr.

bool WvIPNet::is_host (    )  const [inline]
 

is it a plain host? (x.x.x.x/32)

Definition at line 351 of file include/wvaddr.h.

References WvIPAddr::binaddr.

Referenced by WvInterface::addarp().

const WvIPAddr& WvIPNet::netmask (    )  const [inline]
 

Definition at line 312 of file ipstreams/wvaddr.h.

const WvIPAddr& WvIPNet::netmask (    )  const [inline]
 

Definition at line 312 of file include/wvaddr.h.

Referenced by WvInterface::addarp(), WvIPRoute::operator==(), and WvInterface::setipaddr().

WvIPAddr WvIPNet::network (    )  const [inline]
 

Definition at line 314 of file ipstreams/wvaddr.h.

WvIPAddr WvIPNet::network (    )  const [inline]
 

Definition at line 314 of file include/wvaddr.h.

Referenced by WvInterface::addarp(), includes(), WvIPRoute::operator==(), and printable().

void WvIPNet::normalize (    ) 
 

void WvIPNet::normalize (    ) 
 

Definition at line 618 of file wvaddr.cc.

References bits(), mask, and WvIPAddr::WvIPAddr().

virtual WvString WvIPNet::printable (    )  const [protected, virtual]
 

Reimplemented from WvIPAddr.

WvString WvIPNet::printable (    )  const [protected, virtual]
 

Reimplemented from WvIPAddr.

Definition at line 570 of file wvaddr.cc.

References bits(), network(), and WvIPAddr::printable().

void WvIPNet::string_init (  const char    string[] ) 
 

Reimplemented from WvIPAddr.

void WvIPNet::string_init (  const char    string[] ) 
 

Reimplemented from WvIPAddr.

Definition at line 514 of file wvaddr.cc.

References WvAddr::addrtype, bits(), mask, WvIPAddr::WvIPAddr(), and wvipnet.

Referenced by WvIPNet().

virtual unsigned WvIPNet::WvHash (    )  const [virtual]
 

Override the hash and comparison functions

Reimplemented from WvAddr.

unsigned WvIPNet::WvHash (    )  const [virtual]
 

Override the hash and comparison functions

Reimplemented from WvAddr.

Definition at line 579 of file wvaddr.cc.

References mask, and WvAddr::WvHash().


Member Data Documentation

WvIPAddr WvIPNet::mask [protected]
 

Definition at line 275 of file ipstreams/wvaddr.h.

Referenced by bits(), comparator(), include(), includes(), normalize(), string_init(), WvHash(), and WvIPNet().


The documentation for this class was generated from the following files:
Generated on Fri Apr 5 15:16:55 2002 for WvStreams by doxygen1.2.15