nidas
v1.2-1520
|
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< Inet4Address > | getAllByName (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... | |
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". |
Referenced by nidas::core::Project::findDSM(), nidas::core::Site::findDSM(), nidas::core::Project::findServer(), and nidas::core::Project::findServers().
|
static |
Return an address of a name, the first one found by getAllByName.
Referenced by nidas::util::SocketImpl::connect(), nidas::core::DSMEngine::DSMEngine(), nidas::core::MultipleUDPSockets::fromDOMElement(), nidas::core::DSMServer::fromDOMElement(), nidas::core::McSocketUDP::fromDOMElement(), nidas::core::McSocket::fromDOMElement(), nidas::core::DatagramSocket::fromDOMElement(), nidas::core::DSMConfig::fromDOMElement(), nidas::core::Socket::fromDOMElement(), nidas::core::Socket::getRemoteSocketAddress(), nidas::core::DatagramSocket::getSocketAddress(), PConfig::loadRemoteXML(), RemoteSerial::main(), nidas::core::SocketIODevice::open(), nidas::core::ServerSocketIODevice::open(), nidas::core::NidasApp::parseInputs(), SyncDumper::parseRunstring(), SensorExtract::parseRunstring(), nidas::core::DSMEngine::parseRunstring(), and nidas::core::StatusListener::run().
string Inet4Address::getHostAddress | ( | ) | const |
Return string containing address in dot notation: w.x.y.z.
References _inaddr.
Referenced by nidas::core::MultipleUDPSockets::addClient(), nidas::dynld::XMLConfigService::connected(), nidas::core::Project::findDSM(), nidas::util::SocketImpl::getInterface(), nidas::util::listMulticastInterfaces(), nidas::util::SocketImpl::receive(), nidas::core::DSMServerStat::run(), nidas::core::Socket::Socket(), and nidas::util::Inet4SocketAddress::toAddressString().
|
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.
|
inline |
|
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::core::MultipleUDPSockets::addClient(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::addDestination(), nidas::core::UDPSocketIODevice::open(), nidas::util::McSocketListener::run(), and nidas::util::McSocketMulticaster< SocketTT >::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(), getInAddr(), getInAddrPtr(), Inet4Address(), isMultiCastAddress(), operator!=(), operator<(), and operator==().