nidas  v1.2-1520
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
nidas::util::Inet4Address Class Reference

Support for IP version 4 host address. More...

#include <Inet4Address.h>

Public Member Functions

 Inet4Address ()
 Default constructor. More...
 
 Inet4Address (const struct in_addr *)
 Construct an address from a pointer to the C in_addr structure. More...
 
 Inet4Address (unsigned int addr)
 Construct an address. More...
 
std::string getHostAddress () const
 Return string containing address in dot notation: w.x.y.z. More...
 
std::string getHostName () const throw ()
 Return a hostname for this address. More...
 
struct in_addr * getInAddrPtr () const
 Return const pointer to struct in_addr. More...
 
struct in_addr getInAddr () const
 Get the structure containing the 4 byte internet version 4 address. More...
 
bool operator< (const Inet4Address &x) const
 Comparator operator for addresses. More...
 
bool operator== (const Inet4Address &x) const
 Equality operator for addresses. More...
 
bool operator!= (const Inet4Address &x) const
 Inequality operator for addresses. More...
 
bool isMultiCastAddress () const
 Is this address a multicast address? Multicast addresses are in the range 224.0.0.1 to 239.255.255.255, their first four bits are 1110=0xe. More...
 
int bitsMatch (const Inet4Address &x) const throw ()
 How many leading bits match in the two addresses? More...
 

Static Public Member Functions

static std::list< Inet4AddressgetAllByName (const std::string &hostname) throw (UnknownHostException)
 Static method returning a list of addresses for a name. More...
 
static Inet4Address getByName (const std::string &hostname) throw (UnknownHostException)
 Return an address of a name, the first one found by getAllByName. More...
 
static std::string getHostName (const Inet4Address &addr) throw ()
 Do reverse lookup of a name, given an address. More...
 

Protected Attributes

struct in_addr _inaddr
 The IP address, in network byte order. More...
 

Detailed Description

Support for IP version 4 host address.

This class provides by-name and by-address name service lookup, and caches the names and addresses in static maps.

Constructor & Destructor Documentation

Inet4Address::Inet4Address ( )

Default constructor.

Creates address: 0.0.0.0, aka: INADDR_ANY.

Inet4Address::Inet4Address ( const struct in_addr *  a)

Construct an address from a pointer to the C in_addr structure.

Inet4Address::Inet4Address ( unsigned int  addr)

Construct an address.

References _inaddr.

Member Function Documentation

int Inet4Address::bitsMatch ( const Inet4Address x) const
throw (
)

How many leading bits match in the two addresses?

list< Inet4Address > Inet4Address::getAllByName ( const std::string &  hostname)
throw (UnknownHostException
)
static

Static method returning a list of addresses for a name.

This is the name-to-address lookup method.

Parameters
hostname,:either a local hostname, like "linus", or a fully qualified name, "linus.atd.ucar.edu", or an address in dot notation: "128.117.80.208".

Referenced by nidas::core::Project::findDSM(), nidas::core::Site::findDSM(), nidas::core::Project::findServer(), and nidas::core::Project::findServers().

Inet4Address Inet4Address::getByName ( const std::string &  hostname)
throw (UnknownHostException
)
static
string Inet4Address::getHostAddress ( ) const
string Inet4Address::getHostName ( const Inet4Address addr)
throw (
)
static

Do reverse lookup of a name, given an address.

This is the address-to-name lookup method. If a host name is not found for the address, returns a string in dot notation: "x.x.x.x" using getHostAddress().

References ELOG, err, nidas::util::Exception::errnoToString(), and WLOG.

Referenced by nidas::util::Inet4SocketAddress::toString().

string Inet4Address::getHostName ( ) const
throw (
)

Return a hostname for this address.

Calls static getHostName() method.

struct in_addr nidas::util::Inet4Address::getInAddr ( ) const
inline

Get the structure containing the 4 byte internet version 4 address.

To get the actual 4 byte integer value:

uint32_t addr = getInAddr().s_addr;

References _inaddr.

struct in_addr* nidas::util::Inet4Address::getInAddrPtr ( ) const
inline

Return const pointer to struct in_addr.

References _inaddr.

Referenced by nidas::util::Inet4SocketAddress::Inet4SocketAddress().

bool nidas::util::Inet4Address::isMultiCastAddress ( ) const
inline

Is this address a multicast address? Multicast addresses are in the range 224.0.0.1 to 239.255.255.255, their first four bits are 1110=0xe.

References _inaddr.

Referenced by nidas::core::MultipleUDPSockets::addClient(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::addDestination(), nidas::core::UDPSocketIODevice::open(), nidas::util::McSocketListener::run(), and nidas::util::McSocketMulticaster< SocketTT >::run().

bool nidas::util::Inet4Address::operator!= ( const Inet4Address x) const
inline

Inequality operator for addresses.

References _inaddr.

bool nidas::util::Inet4Address::operator< ( const Inet4Address x) const
inline

Comparator operator for addresses.

References _inaddr.

bool nidas::util::Inet4Address::operator== ( const Inet4Address x) const
inline

Equality operator for addresses.

References _inaddr.

Member Data Documentation

struct in_addr nidas::util::Inet4Address::_inaddr
protected

The IP address, in network byte order.

Referenced by getHostAddress(), getInAddr(), getInAddrPtr(), Inet4Address(), isMultiCastAddress(), operator!=(), operator<(), and operator==().


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