Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

IpAddress Class Reference

Represents ONLY an IP address. More...

#include <IpAddress.h>

Inheritance diagram for IpAddress::

BasicObject List of all members.

Public Methods

 IpAddress ()
 IpAddress (unsigned long)
 IpAddress (const char *)
 IpAddress (std::string)
 IpAddress (struct in_addr)
 IpAddress (const IpAddress &)
virtual ~IpAddress ()
unsigned long getUnsignedLongForm ()
string getHostname ()
IpVersion getVersion ()
bool isLanIp ()
 Returns true if this IP address is for a local area network. More...

bool isLoopback ()
 Returns true if this is the loopback address (127.0.0.1). More...

bool isZero ()
 Return true if the IP address is zero. More...

bool isInAddrAny ()
 Returns true if the IP address is equal to INADDR_ANY. More...

void setIpAddress (unsigned long ipAddr)
void setIpAddress (const char *)
 Set the IP address given a pointer to a C string. More...

void setIpAddress (std::string)
void setIpAddress (struct in_addr)
void setIpAddress (const IpAddress &)
void setVersion (IpVersion)
bool equals (IpAddress)
bool equals (unsigned long)
bool equals (const char *)
 Returns true if the IP address given is equal to the one stored internally. More...

bool equals (std::string)
bool equals (struct in_addr)
bool read (std::istream &)
 Return true on success, false on error or EOF. More...

virtual void toStream (std::ostream &)
 Print the dotted decimal form of the IP address to the output stream. More...

const char * toCStr ()

Private Attributes

IpVersion m_version
unsigned long m_ipAddr
char m_cstr [MAX_IP_ADDR_STR]
string m_hostname

Detailed Description

Represents ONLY an IP address.

(Not IP address and port - for that see the "SocketAddress" class.) Allows you to convert from all different types into an IP address.

Definition at line 11 of file IpAddress.h.


Constructor & Destructor Documentation

IpAddress::IpAddress
 

Definition at line 10 of file IpAddress.cpp.

IpAddress::IpAddress unsigned long value
 

Definition at line 16 of file IpAddress.cpp.

IpAddress::IpAddress const char * value
 

Definition at line 22 of file IpAddress.cpp.

IpAddress::IpAddress std::string
 

Definition at line 28 of file IpAddress.cpp.

IpAddress::IpAddress struct in_addr value
 

Definition at line 34 of file IpAddress.cpp.

IpAddress::IpAddress const IpAddress & value
 

Definition at line 40 of file IpAddress.cpp.

IpAddress::~IpAddress [virtual]
 

Definition at line 45 of file IpAddress.cpp.


Member Function Documentation

bool IpAddress::equals struct in_addr value
 

Definition at line 185 of file IpAddress.cpp.

bool IpAddress::equals std::string
 

Definition at line 178 of file IpAddress.cpp.

bool IpAddress::equals const char * value
 

Returns true if the IP address given is equal to the one stored internally.

This function will automatically figure out if the string is a dotted decimal or a hostname. If it is a hostname, it will look it up and compare the IP addresses. Note: this means servers with multiple IP addresses could be a problem.

Definition at line 171 of file IpAddress.cpp.

bool IpAddress::equals unsigned long value
 

Definition at line 158 of file IpAddress.cpp.

bool IpAddress::equals IpAddress value
 

Definition at line 152 of file IpAddress.cpp.

Referenced by Node::equals(), and TcpConnection::isConnectedTo().

string IpAddress::getHostname
 

Definition at line 57 of file IpAddress.cpp.

unsigned long IpAddress::getUnsignedLongForm
 

Definition at line 51 of file IpAddress.cpp.

Referenced by ImHerePacket::getRawData(), ConnectionPacket::getRawData(), SocketAddress::setIpAddress(), and SocketAddress::setPort().

IpAddress::IpVersion IpAddress::getVersion
 

Definition at line 140 of file IpAddress.cpp.

Referenced by ImHerePacket::getRawData(), and ConnectionPacket::getRawData().

bool IpAddress::isInAddrAny
 

Returns true if the IP address is equal to INADDR_ANY.

Definition at line 270 of file IpAddress.cpp.

bool IpAddress::isLanIp
 

Returns true if this IP address is for a local area network.

This is true if the address is one of the following: (from RFC1918)

  1. 192.168.*.*
  2. 172.16.*.*
  3. 10.*.*.*

Definition at line 204 of file IpAddress.cpp.

Referenced by WebServer::handleConnection(), and Interface::toStream().

bool IpAddress::isLoopback
 

Returns true if this is the loopback address (127.0.0.1).

Definition at line 243 of file IpAddress.cpp.

Referenced by WebServer::handleConnection().

bool IpAddress::isZero
 

Return true if the IP address is zero.

Definition at line 261 of file IpAddress.cpp.

Referenced by SocketAddress::isZero().

bool IpAddress::read std::istream & in
 

Return true on success, false on error or EOF.

Definition at line 279 of file IpAddress.cpp.

void IpAddress::setIpAddress const IpAddress & value
 

Definition at line 130 of file IpAddress.cpp.

void IpAddress::setIpAddress struct in_addr value
 

Definition at line 116 of file IpAddress.cpp.

void IpAddress::setIpAddress std::string
 

Definition at line 110 of file IpAddress.cpp.

void IpAddress::setIpAddress const char * value
 

Set the IP address given a pointer to a C string.

The C string may be either a dotted decimal or a hostname, this function will figure it out for you. If the name is unable to be resolved, the IP address will be zero.

Definition at line 82 of file IpAddress.cpp.

void IpAddress::setIpAddress unsigned long value
 

Definition at line 67 of file IpAddress.cpp.

Referenced by ConnectionPacket::ConnectionPacket(), ImHerePacket::ImHerePacket(), IpAddress(), read(), setIpAddress(), and SocketAddress::setSocketAddress().

void IpAddress::setVersion IpVersion version
 

Definition at line 146 of file IpAddress.cpp.

Referenced by ConnectionPacket::ConnectionPacket(), ImHerePacket::ImHerePacket(), and IpAddress().

const char * IpAddress::toCStr
 

Definition at line 304 of file IpAddress.cpp.

Referenced by LinkLayerInterface::accept(), getHostname(), setIpAddress(), SocketAddress::toCStr(), and toStream().

void IpAddress::toStream std::ostream & out [virtual]
 

Print the dotted decimal form of the IP address to the output stream.

Reimplemented from BasicObject.

Definition at line 291 of file IpAddress.cpp.


Member Data Documentation

char IpAddress::m_cstr[MAX_IP_ADDR_STR] [private]
 

Definition at line 56 of file IpAddress.h.

string IpAddress::m_hostname [private]
 

Definition at line 57 of file IpAddress.h.

unsigned long IpAddress::m_ipAddr [private]
 

Definition at line 55 of file IpAddress.h.

IpVersion IpAddress::m_version [private]
 

Definition at line 54 of file IpAddress.h.


The documentation for this class was generated from the following files:
Generated at Thu Jul 11 13:31:57 2002 for Peekabooty by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001