nidas v1.2.3
|
Support for IP version 4 host address. More...
#include <Inet4Address.h>
Public Member Functions | |
Inet4Address () | |
Default constructor. | |
Inet4Address (const struct in_addr *) | |
Construct an address from a pointer to the C in_addr structure. | |
Inet4Address (unsigned int addr) | |
Construct an address. | |
std::string | getHostAddress () const |
Return string containing address in dot notation: w.x.y.z. | |
std::string | getHostName () const throw () |
Return a hostname for this address. | |
const struct in_addr * | getInAddrPtr () const |
Return const pointer to struct in_addr. | |
const struct in_addr | getInAddr () const |
Get the structure containing the 4 byte internet version 4 address. | |
bool | operator< (const Inet4Address &x) const |
Comparator operator for addresses. | |
bool | operator== (const Inet4Address &x) const |
Equality operator for addresses. | |
bool | operator!= (const Inet4Address &x) const |
Inequality operator for addresses. | |
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. | |
int | bitsMatch (const Inet4Address &x) const throw () |
How many leading bits match in the two addresses? | |
Static Public Member Functions | |
static std::list< Inet4Address > | getAllByName (const std::string &hostname) |
Static method returning a list of addresses for a name. | |
static Inet4Address | getByName (const std::string &hostname) |
Return an address of a name, the first one found by getAllByName. | |
static std::string | getHostName (const Inet4Address &addr) |
Do reverse lookup of a name, given an address. | |
Protected Attributes | |
struct in_addr | _inaddr |
The IP address, in network byte order. | |
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.
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.
int Inet4Address::bitsMatch | ( | const Inet4Address & | x | ) | const | |
throw | ( | ) |
How many leading bits match in the two addresses?
|
static |
Static method returning a list of addresses for a name.
This is the name-to-address lookup method.
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". |
UnknownHostException; |
Referenced by getByName().
|
static |
Return an address of a name, the first one found by getAllByName.
UnknownHostException; |
References getAllByName().
Referenced by nidas::util::SocketImpl::connect(), PConfig::loadRemoteXML(), and main().
string Inet4Address::getHostAddress | ( | ) | const |
Return string containing address in dot notation: w.x.y.z.
References _inaddr.
Referenced by nidas::core::Project::findDSM(), getHostName(), nidas::util::SocketImpl::getInterface(), nidas::util::Inet4NetworkInterface::getInterface(), and nidas::util::Inet4SocketAddress::toAddressString().
string Inet4Address::getHostName | ( | ) | const | |||
throw | ( | ) |
Return a hostname for this address.
Calls static getHostName() method.
References getHostName().
Referenced by getHostName().
|
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 _inaddr, ELOG, err, nidas::util::Exception::errnoToString(), getHostAddress(), getInAddr(), and WLOG.
Referenced by nidas::util::Inet4SocketAddress::toString().
|
inline |
Get the structure containing the 4 byte internet version 4 address.
To get the actual 4 byte integer value:
Referenced by getHostName().
|
inline |
Return const pointer to struct in_addr.
References _inaddr.
Referenced by nidas::util::Inet4SocketAddress::Inet4SocketAddress().
|
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::util::McSocketListener::run().
|
inline |
Inequality operator for addresses.
References _inaddr.
|
inline |
Comparator operator for addresses.
References _inaddr.
|
inline |
Equality operator for addresses.
References _inaddr.
|
protected |
The IP address, in network byte order.
Referenced by getHostAddress(), getHostName(), getInAddrPtr(), Inet4Address(), isMultiCastAddress(), operator!=(), operator<(), and operator==().