libDwm-0.6.0
Dwm::Ipv4Address Class Reference

This class encapsulates an IPv4 address. More...

#include <DwmIpv4Address.hh>

Inheritance diagram for Dwm::Ipv4Address:
Collaboration diagram for Dwm::Ipv4Address:

Public Member Functions

 Ipv4Address ()
 Constructor.
 
 Ipv4Address (ipv4addr_t addr)
 Construct from an ipv4addr_t (32-bit value in network byte order).
 
 Ipv4Address (const std::string &dottedAddr)
 Construct from a dotted-decimal string.
 
ipv4addr_t Raw () const
 Returns an ipv4addr_t representation (32-bit value in network byte order). More...
 
 operator std::string () const
 Returns a dotted-decimal string representation.
 
bool IsV6 () const
 
bool operator< (const Ipv4Address &addr) const
 less-than operator.
 
bool operator> (const Ipv4Address &addr) const
 Greater-than operator.
 
bool operator>= (const Ipv4Address &addr) const
 Greater than or equal-to operator.
 
bool operator<= (const Ipv4Address &addr) const
 Less-than or equal-to operator.
 
bool operator== (const Ipv4Address &addr) const
 Equal-to operator.
 
bool operator!= (const Ipv4Address &addr) const
 Not-equal-to operator.
 
Ipv4Addressoperator&= (const Ipv4Address &mask)
 Mask operator.
 
Ipv4Address operator++ (int)
 Post-increment operator.
 
Ipv4Addressoperator++ ()
 Pre-increment operator.
 
Ipv4Address operator-- (int)
 Post-decrement operator.
 
Ipv4Addressoperator-- ()
 Pre-decrement operator.
 
Ipv4Addressoperator-= (uint32_t i)
 -= operator. More...
 
Ipv4Addressoperator+= (uint32_t i)
 += operator. More...
 
bool BitIsSet (int8_t bit) const
 
int GetBit (int bit) const
 
uint32_t StreamedLength () const
 Returns the number of bytes that would be written if we called one of the Write() members. More...
 
std::istream & Read (std::istream &is)
 Reads from an istream. Returns the istream.
 
std::ostream & Write (std::ostream &os) const
 Writes to an ostream. Returns the ostream.
 
ssize_t Read (int fd)
 Reads from a file descriptor. More...
 
ssize_t Write (int fd) const
 Writes to a file descriptor. More...
 
size_t Read (FILE *f)
 Reads from a FILE pointer. Returns 1 on success, 0 on failure.
 
size_t Write (FILE *f) const
 Writes to a FILE pointer. Returns 1 on success, 0 on failure.
 
int Read (gzFile gzf)
 Reads from a gzFile. More...
 
int Write (gzFile gzf) const
 Writes to a gzFile. More...
 
int BZRead (BZFILE *bzf)
 Reads from a BZFILE pointer. More...
 
int BZWrite (BZFILE *bzf) const
 Writes to a BZFILE pointer. More...
 
uint32_t IpSum () const
 Returns the partial sum of the IP address, as would be used when calculating the IP header checksum or UDP checksum (as part of the 'pseudo-header' used for UDP checksums). More...
 
- Public Member Functions inherited from Dwm::Readable
virtual ~Readable ()
 destructor
 
- Public Member Functions inherited from Dwm::Writable
virtual ~Writable ()
 Destructor.
 
- Public Member Functions inherited from Dwm::GZReadable
virtual ~GZReadable ()
 destructor
 
- Public Member Functions inherited from Dwm::GZWritable
virtual ~GZWritable ()
 destructor
 

Static Public Member Functions

static uint8_t MaxKeyBits ()
 

Protected Attributes

uint32_t _addr
 

Friends

std::ostream & operator<< (std::ostream &os, const Ipv4Address &addr)
 Prints an Ipv4Address to an ostream in human-readable form.
 
Ipv4Address operator& (const Ipv4Address &addr, const Ipv4Address &mask)
 

Detailed Description

This class encapsulates an IPv4 address.

Member Function Documentation

◆ BZRead()

int Dwm::Ipv4Address::BZRead ( BZFILE *  bzf)
virtual

Reads from a BZFILE pointer.

Returns the number of bytes read (4 on success).

Implements Dwm::BZ2Readable.

◆ BZWrite()

int Dwm::Ipv4Address::BZWrite ( BZFILE *  bzf) const
virtual

Writes to a BZFILE pointer.

Returns the number of bytes written (4 on success).

Implements Dwm::BZ2Writable.

◆ IpSum()

uint32_t Dwm::Ipv4Address::IpSum ( ) const

Returns the partial sum of the IP address, as would be used when calculating the IP header checksum or UDP checksum (as part of the 'pseudo-header' used for UDP checksums).

◆ operator+=()

Ipv4Address& Dwm::Ipv4Address::operator+= ( uint32_t  i)
inline

+= operator.

Protects against roll-over (will not increment past 255.255.255.255). Note that the right hand side must be in host byte order.

Here is the call graph for this function:

◆ operator-=()

Ipv4Address& Dwm::Ipv4Address::operator-= ( uint32_t  i)
inline

-= operator.

Protects against roll-under (will not decrement past 0.0.0.0). Note that the right hand side must be in host byte order.

◆ Raw()

ipv4addr_t Dwm::Ipv4Address::Raw ( ) const
inline

Returns an ipv4addr_t representation (32-bit value in network byte order).

◆ Read() [1/2]

ssize_t Dwm::Ipv4Address::Read ( int  fd)
virtual

Reads from a file descriptor.

Returns the number of bytes read (4 on success).

Implements Dwm::Readable.

◆ Read() [2/2]

int Dwm::Ipv4Address::Read ( gzFile  gzf)
virtual

Reads from a gzFile.

Returns the number of bytes read (4 on success).

Implements Dwm::GZReadable.

◆ StreamedLength()

uint32_t Dwm::Ipv4Address::StreamedLength ( ) const
virtual

Returns the number of bytes that would be written if we called one of the Write() members.

Implements Dwm::Writable.

◆ Write() [1/2]

ssize_t Dwm::Ipv4Address::Write ( int  fd) const
virtual

Writes to a file descriptor.

Returns the number of bytes written (4 on success).

Implements Dwm::Writable.

◆ Write() [2/2]

int Dwm::Ipv4Address::Write ( gzFile  gzf) const
virtual

Writes to a gzFile.

Returns the number of bytes written (4 on success).

Implements Dwm::GZWritable.


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