#include <wvaddr.h>
Inherits WvIPAddr.
Collaboration diagram for WvIPNet:
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 306 of file wvaddr.h.
Public Member Functions | |
WvIPNet (const WvIPNet &_net) | |
WvIPNet (const char string[]) | |
WvIPNet (WvStringParm string) | |
void | string_init (const char string[]) |
WvIPNet (const WvIPAddr &base, const WvIPAddr &_mask) | |
virtual bool | comparator (const WvAddr *a2, bool first_pass=true) const |
virtual const char * | type () const |
WvIPNet (const WvIPAddr &base, int bits=32) | |
construct an IPNet from a base address and a number of bits in the netmask. | |
WvIPNet () | |
construct an empty IPNet for later copying (probably by operator=) | |
virtual | ~WvIPNet () |
virtual unsigned | WvHash () const |
Override the hash and comparison functions. | |
WvIPAddr | base () const |
Get the 'base IP address' component, netmask, network, and broadcast. | |
WvIPAddr | netmask () const |
WvIPAddr | network () const |
WvIPAddr | broadcast () const |
void | include (const WvIPNet &addr) |
adjust the netmask so that 'addr' would be included in this network | |
bool | includes (const WvIPNet &addr) const |
determine whether the given address is already included in this net | |
int | bits () const |
weird netmasks such as 255.0.255.0 (easy example) are almost never used -- they have '0' bits in the middle. | |
void | normalize () |
bool | is_default () const |
is this net the default gateway? (0.0.0.0/0) | |
bool | is_host () const |
is it a plain host? (x.x.x.x/32) | |
WvIPAddr | operator & (const WvIPAddr &a2) const |
WvIPAddr | operator| (const WvIPAddr &a2) const |
WvIPAddr | operator^ (const WvIPAddr &a2) const |
WvIPAddr | operator~ () const |
WvIPAddr | operator+ (int n) const |
WvIPAddr | operator- (int n) const |
__u32 | addr () const |
bool | is_zero () const |
virtual WvEncap | encap () const |
virtual struct sockaddr * | sockaddr () const |
virtual size_t | sockaddr_len () const |
virtual const unsigned char * | rawdata () const |
virtual size_t | rawdata_len () const |
operator WvString () const | |
virtual bool | isbroadcast () const |
bool | operator== (const WvAddr &a2) const |
bool | operator!= (const WvAddr &a2) const |
Static Public Member Functions | |
WvAddr * | gen (struct sockaddr *addr) |
Public Attributes | |
unsigned char | binaddr [4] |
Protected Member Functions | |
virtual WvString | printable () const |
Protected Attributes | |
WvIPAddr | mask |
|
|
|
|
|
Definition at line 316 of file wvaddr.h. References WvStringParm. |
|
|
|
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). |
|
construct an empty IPNet for later copying (probably by operator=)
|
|
|
|
Definition at line 277 of file wvaddr.h. References __u32. Referenced by bits(), WvIPAddr::operator+(), WvIPAddr::operator-(), and WvIPAddr::sockaddr(). |
|
Get the 'base IP address' component, netmask, network, and broadcast.
Definition at line 341 of file wvaddr.h. Referenced by includes(), WvInterfaceDict::islocal(), and WvInterface::setipaddr(). |
|
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 618 of file wvaddr.cc. References __u32, WvIPAddr::addr(), bits(), and mask. Referenced by bits(), normalize(), printable(), WvInterface::setipaddr(), and string_init(). |
|
Definition at line 347 of file wvaddr.h. Referenced by WvInterfaceDict::islocal(), and WvInterface::setipaddr(). |
|
Reimplemented from WvIPAddr. Definition at line 593 of file wvaddr.cc. References WvAddr::comparator(), comparator(), mask, WvAddr::type(), and WVIPNET. Referenced by comparator(). |
|
Implements WvAddr. |
|
Definition at line 89 of file wvaddr.cc. References WvEncap::cap, WvAddr::encap(), and WvAddr::gen(). Referenced by WvAddr::gen(). |
|
adjust the netmask so that 'addr' would be included in this network
Definition at line 605 of file wvaddr.cc. References include(), and mask. Referenced by include(). |
|
determine whether the given address is already included in this net
Definition at line 611 of file wvaddr.cc. References base(), includes(), netmask(), and network(). Referenced by includes(), and WvInterfaceDict::on_local_net(). |
|
is this net the default gateway? (0.0.0.0/0)
Definition at line 370 of file wvaddr.h. References WvIPAddr::binaddr. Referenced by WvInterface::delroute(), and realtable(). |
|
is it a plain host? (x.x.x.x/32)
Definition at line 374 of file wvaddr.h. References WvIPAddr::binaddr. Referenced by WvInterface::addarp(). |
|
|
|
Reimplemented in WvEtherAddr. |
|
Definition at line 343 of file wvaddr.h. Referenced by WvInterface::addarp(), includes(), WvIPRoute::operator==(), and WvInterface::setipaddr(). |
|
Definition at line 345 of file wvaddr.h. Referenced by WvInterface::addarp(), includes(), WvIPRoute::operator==(), and printable(). |
|
|
|
Definition at line 421 of file wvaddr.cc. References WvIPAddr::binaddr. |
|
Definition at line 123 of file wvaddr.h. References WvAddr::printable(). |
|
|
|
Definition at line 467 of file wvaddr.cc. References __u32, and WvIPAddr::addr(). |
|
Definition at line 474 of file wvaddr.cc. References __u32, and WvIPAddr::addr(). |
|
|
|
Definition at line 443 of file wvaddr.cc. References WvIPAddr::binaddr. |
|
Definition at line 432 of file wvaddr.cc. References WvIPAddr::binaddr. |
|
Definition at line 454 of file wvaddr.cc. References WvIPAddr::binaddr. |
|
Reimplemented from WvIPAddr. Definition at line 578 of file wvaddr.cc. References bits(), network(), and WvIPAddr::printable(). |
|
Reimplemented from WvAddr. Definition at line 487 of file wvaddr.cc. References WvIPAddr::binaddr. Referenced by WvIPAddr::comparator(). |
|
Reimplemented from WvAddr. Definition at line 493 of file wvaddr.cc. Referenced by WvIPAddr::comparator(). |
|
Implements WvAddr. Reimplemented in WvIPPortAddr. Definition at line 502 of file wvaddr.cc. References WvIPAddr::addr(), and sockaddr_bin. Referenced by WvInterface::addarp(), WvInterface::setipaddr(), WvIPPortAddr::sockaddr(), WvIPRawStream::uwrite(), and WvIPRawStream::WvIPRawStream(). |
|
Implements WvAddr. Definition at line 514 of file wvaddr.cc. Referenced by WvInterface::addarp(), WvTCPConn::do_connect(), WvInterface::setipaddr(), WvUDPStream::uwrite(), WvIPRawStream::uwrite(), WvIPRawStream::WvIPRawStream(), WvTCPListener::WvTCPListener(), and WvUDPStream::WvUDPStream(). |
|
Reimplemented from WvIPAddr. Definition at line 528 of file wvaddr.cc. References __u32, bits(), mask, and string_init(). Referenced by string_init(). |
|
Reimplemented from WvIPAddr. Definition at line 322 of file wvaddr.h. References WVIPNET. |
|
Override the hash and comparison functions.
Reimplemented from WvAddr. Definition at line 587 of file wvaddr.cc. References mask, and WvAddr::WvHash(). |
|
Definition at line 248 of file wvaddr.h. Referenced by WvIPAddr::comparator(), is_default(), is_host(), WvIPAddr::operator &(), WvIPAddr::operator^(), WvIPAddr::operator|(), WvIPAddr::operator~(), WvIPAddr::printable(), WvIPAddr::rawdata(), WvIPAddr::string_init(), and WvIPAddr::WvIPAddr(). |
|
Definition at line 309 of file wvaddr.h. Referenced by bits(), comparator(), include(), normalize(), string_init(), WvHash(), and WvIPNet(). |