Brief description of class still missing. More...
#include <Address.h>
Public Member Functions | |
| Address () | |
| Address (in_addr_t a) | |
| Address (int index, const Address &subnet) | |
| Address (const Address &o) | |
| void | fromString (const char *a) |
| int | index () const |
| bool | isValid () const |
| bool | operator!= (const Address &o) const |
| Address | operator& (const Address &o) const |
| bool | operator< (const Address &o) const |
| Address | operator= (const Address &o) |
| bool | operator== (const Address &o) const |
| bool | operator> (const Address &o) const |
| Address | subnet () const |
| std::string | toString () const |
| in_addr_t | value () const |
Static Public Member Functions | |
| static void | identifyMe (const char *interface) |
| static const Address & | mask () |
| static int | maskSize () |
| static const Address & | me () |
| static void | setMaskSize (int m) |
Brief description of class still missing.
Full description of class still missing
| GpCoreTools::Address::Address | ( | ) | [inline] |
{_value=0;}
| GpCoreTools::Address::Address | ( | in_addr_t | a | ) | [inline] |
{_value=a;}
| GpCoreTools::Address::Address | ( | int | index, |
| const Address & | subnet | ||
| ) |
| GpCoreTools::Address::Address | ( | const Address & | o | ) | [inline] |
{_value=o._value;}
| void GpCoreTools::Address::fromString | ( | const char * | a | ) | [inline] |
Referenced by TimeRequest::exec(), identifyMe(), and main().
{_value=inet_addr(a);}
| void GpCoreTools::Address::identifyMe | ( | const char * | interface | ) | [static] |
References fromString(), isValid(), toString(), and GpCoreTools::Log::write().
{
_me._value=0;
struct ifaddrs *ifaddr, *ifa;
char host[NI_MAXHOST];
if(getifaddrs(&ifaddr)==-1) {
Log::write(2, "error getifaddrs: %s\n", strerror(errno));
} else {
// Walk through linked list, maintaining head pointer so we can free list later
for(ifa=ifaddr; ifa!=NULL; ifa=ifa->ifa_next) {
if(ifa->ifa_addr && ifa->ifa_addr->sa_family==AF_INET && strcmp(ifa->ifa_name, interface)==0) {
if(getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST)!=0) {
Log::write(2, "error getnameinfo: %s\n", strerror(errno));
break;
}
_me.fromString(host);
break;
}
}
freeifaddrs(ifaddr);
}
if(_me.isValid()) {
Log::write(0, "running on host %s\n", _me.toString().data());
}
}
| int GpCoreTools::Address::index | ( | ) | const |
Referenced by PeerTracker::addFromMasterRoute(), PeerTracker::event(), PeerTracker::removeFromMasterRoute(), PeerTracker::setLink(), PeerTracker::start(), and PeerTracker::stop().
{
return _value >> _maskSize;
}
| bool GpCoreTools::Address::isValid | ( | ) | const [inline] |
Referenced by PeerTracker::addFromMasterRoute(), identifyMe(), PeerTracker::removeFromMasterRoute(), PeerTracker::setAsMaster(), PeerTracker::setMasterAddress(), and Route::toString().
{return _value!=0;}
| static const Address& GpCoreTools::Address::mask | ( | ) | [inline, static] |
{return _mask;}
| static int GpCoreTools::Address::maskSize | ( | ) | [inline, static] |
{return _maskSize;}
| static const Address& GpCoreTools::Address::me | ( | ) | [inline, static] |
Referenced by GpCoreTools::UdpServerStream::send().
{return _me;}
| bool GpCoreTools::Address::operator!= | ( | const Address & | o | ) | const [inline] |
{return _value!=o._value;}
Referenced by subnet().
{return _value & o._value;}
| bool GpCoreTools::Address::operator< | ( | const Address & | o | ) | const [inline] |
{return _value<o._value;}
{_value=o._value; return *this;}
| bool GpCoreTools::Address::operator== | ( | const Address & | o | ) | const [inline] |
{return _value==o._value;}
| bool GpCoreTools::Address::operator> | ( | const Address & | o | ) | const [inline] |
{return _value>o._value;}
| void GpCoreTools::Address::setMaskSize | ( | int | m | ) | [static] |
{
_mask=(0xFFFFFFFF) >> (32-m);
_maskSize=m;
}
| Address GpCoreTools::Address::subnet | ( | ) | const [inline] |
References operator&().
Referenced by GpCoreTools::UdpServerStream::send().
{return operator&(_mask);}
| std::string GpCoreTools::Address::toString | ( | ) | const [inline] |
Referenced by PeerTracker::addFromMasterRoute(), LinkBuffer::bytesAvailable(), GpCoreTools::TcpClientStream::connect(), PeerTracker::event(), GpCoreTools::TcpClientStream::event(), identifyMe(), PeerTracker::removeFromMasterRoute(), PeerTracker::setMasterAddress(), LinkBuffer::startTest(), PeerTracker::stop(), LinkInfo::toLog(), RoutingTask::toLog(), Route::toString(), and LinkBuffer::~LinkBuffer().
{
in_addr a;
a.s_addr=_value;
return inet_ntoa(a);
}
| in_addr_t GpCoreTools::Address::value | ( | ) | const [inline] |
Referenced by GpCoreTools::TcpClientStream::connect(), and GpCoreTools::UdpServerStream::send().
{return _value;}