senf::INet4Network Class Reference

IPv4 network prefix. More...

#include <senf/Socket/Protocols/INet/INet4Address.hh>

Inheritance diagram for senf::INet4Network:
Inheritance graph
[legend]

List of all members.


Detailed Description

IPv4 network prefix.

This class represents an IPv4 network prefix in CIDR notation.

Definition at line 218 of file INet4Address.hh.


Public Member Functions

INet4Address const &  address () const
  Get the networks address.
unsigned  prefix_len () const
  Get the networks prefix length.
bool  boolean_test () const
  true, if INet4Network is non-empty
bool  operator== (INet4Network const &other) const
  Compare to networks for equality.
bool  match (INet4Address const &addr) const
  true, if the network includes addr
bool  match (INet4Network const &net) const
  true, if the network includes net
INet4Address  host (boost::uint32_t number)
  Return the host with the given number.
INet4Network  subnet (boost::uint32_t net, unsigned prefix_len)
  Return the given subnet of this.

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.
std::istream &  operator>> (std::istream &is, INet4Network &addr)
  Initialize INet4Address instance from a string representation.

Structors and default members

  INet4Network ()
  Construct empty (0.0.0.0/0) network.
  INet4Network (INet4Address const &address, unsigned prefix_len)
  Construct network from given address and prefix length.
  INet4Network (std::string const &s)
  Construct network from CIDR notation.

Constructor & Destructor Documentation

senf::INet4Network::
INet4Network ()

Construct empty (0.0.0.0/0) network.

Definition at line 103 of file INet4Address.cci.

senf::INet4Network::
INet4Network ( INet4Address const &  address,
unsigned  prefix_len )

Construct network from given address and prefix length.

Definition at line 107 of file INet4Address.cci.

senf::INet4Network::
INet4Network ( std::string const &  s )

Construct network from CIDR notation.

Definition at line 129 of file INet4Address.cc.


Member Function Documentation

senf::INet4Address const & senf::INet4Network::
address ()

Get the networks address.

Definition at line 111 of file INet4Address.cci.

bool senf::INet4Network::
boolean_test ()

true, if INet4Network is non-empty

Definition at line 117 of file INet4Address.cci.

senf::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.

Definition at line 141 of file INet4Address.cci.

bool senf::INet4Network::
match ( INet4Network const &  net )

true, if the network includes net

The is true, if net is sub-network (or the same as) this.

Definition at line 135 of file INet4Address.cci.

bool senf::INet4Network::
match ( INet4Address const &  addr )

true, if the network includes addr

Definition at line 129 of file INet4Address.cci.

bool senf::INet4Network::
operator== ( INet4Network const &  other )

Compare to networks for equality.

Definition at line 123 of file INet4Address.cci.

unsigned senf::INet4Network::
prefix_len ()

Get the networks prefix length.

Definition at line 84 of file INet4Address.cci.

senf::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:

INet4Network("192.168.0.0/16").subnet(111u,24u) == INet4Network("192.168.111.0/24")
INet4Network("192.168.111.0/24").subnet(1u,28u) == INet4Network("192.168.111.16/28")
Parameters:
[in]  net  network number
[in]  prefix_len  length of subnet prefix

Definition at line 146 of file INet4Address.cci.


Friends And Related Function Documentation

std::ostream &
operator<< ( std::ostream &  os,
INet4Network const &  addr )

Output INet4Network instance as it's string representation.

std::istream &
operator>> ( std::istream &  is,
INet4Network addr )

Initialize INet4Address instance from a string representation.

sets std::ios::failbit on the stream if an error occurred

See also:
INet4Address from_string()

The documentation for this class was generated from the following files: