TransportAddress Class Reference

#include <TransportAddress.h>

Inheritance diagram for TransportAddress:

I3IPAddress NodeHandle BootstrapNodeHandle BrooseHandle GiaNode KademliaBucketEntry

List of all members.


Detailed Description

This class implements a common transport address.


It covers the complete node information, like IP-Address, and port. The information can be sparse, so parts can be omited by setting the property to an unspecified value.

Author:
Markus Mauch

Sebastian Mies

Definition at line 44 of file TransportAddress.h.


Public Types

typedef UNORDERED_SET
< TransportAddress, hashFcn > 
Set
 a hashed set of TransportAddresses

Public Member Functions

 TransportAddress ()
 Constructs a unspecified TransportAddress.
virtual ~TransportAddress ()
 Standard destructor.
 TransportAddress (const TransportAddress &handle)
 Copy constructor.
 TransportAddress (const IPvXAddress &ip, int port=-1)
 Complete constructor.
bool operator== (const TransportAddress &rhs) const
 compares this to a given TransportAddress
bool operator!= (const TransportAddress &rhs) const
 compares this to a given TransportAddress
bool operator< (const TransportAddress &rhs) const
 compares this to a given TransportAddress
bool operator> (const TransportAddress &rhs) const
 compares this to a given TransportAddress
bool operator<= (const TransportAddress &rhs) const
 compares this to a given TransportAddress
bool operator>= (const TransportAddress &rhs) const
 compares this to a given TransportAddress
TransportAddress & operator= (const TransportAddress &rhs)
 assigns ip and port of rhs to this->ip and this->port
void setAddress (const IPvXAddress &ip, int port=-1)
 sets this->ip to ip and port to -1 if unspecified
void setPort (int port)
 sets this->port to the given port
const IPvXAddress & getAddress () const
 returns ip address
int getPort () const
 returns port
bool isUnspecified () const
 indicates if TransportAddress is specified
size_t hash () const
 creates a hash value of ip and port
virtual TransportAddress * dup () const
 returns a copy of the TransportAddress

Public Attributes

IPvXAddress ip
 the ip of this TransportAddress object
int port
 the port of this TransportAddress object

Static Public Attributes

static const TransportAddress UNSPECIFIED_NODE
 TransportAddress without specified ip and port.
static const std::vector
< TransportAddress > 
UNSPECIFIED_NODES

Private Member Functions

void assertUnspecified (const TransportAddress &handle) const
 throws an opp_error if this or handle is unspecified

Friends

std::ostream & operator<< (std::ostream &os, const TransportAddress &n)
 standard output stream for TransportAddress, gives out ip and port

Classes

class  hashFcn
 defines a hash function for TransportAddress More...

Member Typedef Documentation

a hashed set of TransportAddresses

Reimplemented in NodeHandle.

Definition at line 62 of file TransportAddress.h.


Constructor & Destructor Documentation

TransportAddress::TransportAddress (  ) 

Constructs a unspecified TransportAddress.

Definition at line 46 of file TransportAddress.cc.

Referenced by dup().

00047 {
00048     port = -1;
00049 }

virtual TransportAddress::~TransportAddress (  )  [inline, virtual]

Standard destructor.

Definition at line 79 of file TransportAddress.h.

00079 {};

TransportAddress::TransportAddress ( const TransportAddress &  handle  ) 

Copy constructor.

Parameters:
handle The TransportAddress to copy

Definition at line 52 of file TransportAddress.cc.

00053 {
00054     port = handle.port;
00055     ip = handle.ip;
00056 }

TransportAddress::TransportAddress ( const IPvXAddress &  ip,
int  port = -1 
)

Complete constructor.

Parameters:
ip The IPvXAddress
port The UDP-Port

Definition at line 60 of file TransportAddress.cc.

00061 {
00062     this->ip = ip;
00063     this->port = port;
00064 }


Member Function Documentation

bool TransportAddress::operator== ( const TransportAddress &  rhs  )  const

compares this to a given TransportAddress

Parameters:
rhs the TransportAddress this is compared to
Returns:
true if both IPvXAddress and port are equal, false otherwise

Definition at line 82 of file TransportAddress.cc.

00083 {
00084     assertUnspecified(rhs);
00085     return (this->ip == rhs.ip && this->port == rhs.port);
00086 }

bool TransportAddress::operator!= ( const TransportAddress &  rhs  )  const

compares this to a given TransportAddress

Parameters:
rhs the TransportAddress this is compared to
Returns:
true if both IPvXAddress and port are not equal, false otherwise

Definition at line 89 of file TransportAddress.cc.

00090 {
00091     assertUnspecified(rhs);
00092     return !(this->ip == rhs.ip && this->port == rhs.port );
00093 }

bool TransportAddress::operator< ( const TransportAddress &  rhs  )  const

compares this to a given TransportAddress

Parameters:
rhs the TransportAddress this is compared to
Returns:
true if this->ip is smaller than rhs->ip, false otherwise

Definition at line 96 of file TransportAddress.cc.

00097 {
00098     assertUnspecified(rhs);
00099     return this->ip < rhs.ip;
00100 }

bool TransportAddress::operator> ( const TransportAddress &  rhs  )  const

compares this to a given TransportAddress

Parameters:
rhs the TransportAddress this is compared to
Returns:
true if this->ip is greater than rhs->ip, false otherwise

Definition at line 103 of file TransportAddress.cc.

00104 {
00105     assertUnspecified(rhs);
00106     return !(this->ip < rhs.ip || this->ip == rhs.ip);
00107 }

bool TransportAddress::operator<= ( const TransportAddress &  rhs  )  const

compares this to a given TransportAddress

Parameters:
rhs the TransportAddress this is compared to
Returns:
true if this->ip is smaller than or equal to rhs->ip, false otherwise

Definition at line 110 of file TransportAddress.cc.

00111 {
00112     assertUnspecified(rhs);
00113     return this->ip < rhs.ip || this->ip == rhs.ip;
00114 }

bool TransportAddress::operator>= ( const TransportAddress &  rhs  )  const

compares this to a given TransportAddress

Parameters:
rhs the TransportAddress this is compared to
Returns:
true if this->ip is greater than or equal to rhs->ip, false otherwise

Definition at line 117 of file TransportAddress.cc.

00118 {
00119     assertUnspecified(rhs);
00120     return !(this->ip < rhs.ip);
00121 }

TransportAddress & TransportAddress::operator= ( const TransportAddress &  rhs  ) 

assigns ip and port of rhs to this->ip and this->port

Parameters:
rhs the TransportAddress with the defined ip and port
Returns:
this TransportAddress object

Definition at line 73 of file TransportAddress.cc.

00074 {
00075     this->ip = rhs.ip;
00076     this->port = rhs.port;
00077 
00078     return *this;
00079 }

void TransportAddress::setAddress ( const IPvXAddress &  ip,
int  port = -1 
)

sets this->ip to ip and port to -1 if unspecified

Parameters:
ip the new IPvXAddress
port the new port

Definition at line 124 of file TransportAddress.cc.

Referenced by doUnpacking().

00125 {
00126     this->ip = ip;
00127     if (port!=-1)
00128         this->port = port;
00129 }

void TransportAddress::setPort ( int  port  ) 

sets this->port to the given port

Parameters:
port the new port

Definition at line 132 of file TransportAddress.cc.

00133 {
00134     this->port = port;
00135 }

const IPvXAddress & TransportAddress::getAddress (  )  const

returns ip address

Returns:
this->ip

Definition at line 138 of file TransportAddress.cc.

Referenced by RealWorldTestApp::deliver(), doPacking(), and GlobalNodeList::getBootstrapNode().

00139 {
00140     return ip;
00141 }

int TransportAddress::getPort (  )  const

returns port

Returns:
this->port

Definition at line 144 of file TransportAddress.cc.

Referenced by doPacking().

00145 {
00146     return port;
00147 }

bool TransportAddress::isUnspecified (  )  const

size_t TransportAddress::hash (  )  const

creates a hash value of ip and port

Returns:
the hash value

Definition at line 150 of file TransportAddress.cc.

Referenced by TransportAddress::hashFcn::operator()().

00151 {
00152     size_t iphash;
00153     if (ip.isIPv6()) {
00154         uint32_t* addr = (uint32_t*) ip.get6().words();
00155         iphash = (size_t)(addr[0]^addr[1]^addr[2]^addr[3]);
00156     } else {
00157         iphash = (size_t)ip.get4().getInt();
00158     }
00159 
00160     return (size_t)(iphash^port);
00161 }

void TransportAddress::assertUnspecified ( const TransportAddress &  handle  )  const [inline, private]

throws an opp_error if this or handle is unspecified

Parameters:
handle the TransportAddress to check

Definition at line 169 of file TransportAddress.cc.

Referenced by operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

00170 {
00171     if ( this->isUnspecified() || handle.isUnspecified() )
00172         opp_error("TransportAddress: Trying to compare unspecified TransportAddress!");
00173 }

TransportAddress * TransportAddress::dup (  )  const [virtual]

returns a copy of the TransportAddress

Returns:
a copy of the TransportAddress

Reimplemented in NodeHandle.

Definition at line 163 of file TransportAddress.cc.

Referenced by BaseRpc::sendRpcCall().

00164 {
00165     return new TransportAddress(*this);
00166 }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const TransportAddress &  n 
) [friend]

standard output stream for TransportAddress, gives out ip and port

Parameters:
os the ostream
n the TransportAddress
Returns:
the output stream

Definition at line 33 of file TransportAddress.cc.

00034 {
00035     if (n.isUnspecified()) {
00036         os << "<unspec>";
00037     } else {
00038         os << n.ip << ":" << n.port;
00039     }
00040 
00041     return os;
00042 };


Member Data Documentation

IPvXAddress TransportAddress::ip

the ip of this TransportAddress object

Definition at line 66 of file TransportAddress.h.

Referenced by GlobalNodeList::addPeer(), QuonPR::addSite(), QuonP::addSite(), BasePastry::baseInit(), BaseOverlay::bindToPort(), BaseApp::bindToPort(), I3BaseApp::bootstrapI3(), BootstrapNodeHandle::BootstrapNodeHandle(), BrooseHandle::BrooseHandle(), BaseApp::callRoute(), BaseOverlay::callUpdate(), Vast::changeState(), QuonPR::changeState(), QuonP::changeState(), Gia::changeState(), oversim::Chord::changeState(), Broose::changeState(), Pastry::checkProxCache(), oversim::Chord::closestPreceedingNode(), I3SubIdentifier::compareTo(), QuonPR::deleteSite(), QuonP::deleteSite(), KBRTestApp::deliver(), Scribe::deliverALMDataToGroup(), Broose::displayBucketState(), BasePastry::doRoutingTableMaintenance(), Pastry::doSecondStage(), PastryRoutingTable::failedNode(), PastryNeighborhoodSet::failedNode(), PastryLeafSet::failedNode(), BaseOverlay::findNodeRpc(), KBRTestApp::forward(), getAddress(), BrooseBucket::getClosestNode(), BrooseBucket::getFailedResponses(), BrooseBucket::getLastSeen(), NeighborCache::getNodeContexts(), NeighborCache::getNodeCoordError(), NeighborCache::getNodeCoords(), GlobalNodeList::getPeerInfo(), Gia::getRoute(), BrooseBucket::getRTT(), PubSubMMOG::handleAdoptChildCall(), PubSubMMOG::handleAdoptChildResponse(), Vast::handleAppMessage(), QuonPR::handleAppMessage(), QuonP::handleAppMessage(), BaseOverlay::handleBaseOverlayMessage(), BaseApp::handleCommonAPIMessage(), oversim::Koorde::handleDeBruijnTimerExpired(), Pastry::handleFailedNode(), PubSubMMOG::handleHelpResponse(), PubSubMMOG::handleIntermediateResponse(), Scribe::handleJoinMessage(), Scribe::handleJoinResponse(), KBRTestApp::handleLookupResponse(), BootstrapList::handleLookupResponse(), GIASearchApp::handleLowerMessage(), XmlRpcInterface::handleMessage(), BaseOverlay::handleMessage(), BaseApp::handleMessage(), PubSubMMOG::handleMoveMessage(), Vast::handleNodeLeaveNotification(), QuonPR::handleNodeLeaveNotification(), PubSubMMOG::handlePingCall(), Scribe::handlePublishCall(), Scribe::handlePublishResponse(), SimpleGameClient::handleRealworldPacket(), BasePastry::handleRequestMessage(), oversim::Koorde::handleRpc(), oversim::Chord::handleRpc(), oversim::Koorde::handleRpcNotifyResponse(), oversim::Chord::handleRpcNotifyResponse(), Scribe::handleRpcResponse(), PubSubMMOG::handleRpcResponse(), oversim::Koorde::handleRpcResponse(), KBRTestApp::handleRpcResponse(), oversim::Chord::handleRpcResponse(), Broose::handleRpcResponse(), BootstrapList::handleRpcResponse(), PubSubMMOG::handleRpcTimeout(), PubSubLobby::handleRpcTimeout(), oversim::Koorde::handleRpcTimeout(), Kademlia::handleRpcTimeout(), oversim::Chord::handleRpcTimeout(), Broose::handleRpcTimeout(), Pastry::handleStateMessage(), Bamboo::handleStateMessage(), SimpleGameClient::handleTimerEvent(), Scribe::handleTimerEvent(), Pastry::handleTimerEvent(), GIASearchApp::handleTimerEvent(), Bamboo::handleTimerEvent(), BaseOverlay::handleTransportAddressChangedNotification(), Vast::handleUDPMessage(), QuonPR::handleUDPMessage(), QuonP::handleUDPMessage(), Pastry::handleUDPMessage(), Bamboo::handleUDPMessage(), Scribe::handleUpperMessage(), hash(), I3IPAddress::I3IPAddress(), BrooseBucket::increaseFailedResponses(), BaseOverlay::initialize(), BaseApp::initialize(), SimpleGameClient::initializeApp(), BootstrapList::initializeApp(), NeighborCache::insertNodeContext(), I3::insertTrigger(), BaseRpc::internalHandleRpcMessage(), isUnspecified(), NodeHandle::isUnspecified(), BaseOverlay::join(), I3IPAddress::length(), IterativeLookup::lookup(), SendToKeyListener::lookupFinished(), Pastry::mergeState(), NodeHandle::netPack(), NodeHandle::netUnpack(), BasePastry::newLeafs(), NodeHandle::NodeHandle(), BrooseBucket::nodeInBucket(), operator!=(), NodeHandle::operator!=(), BrooseHandle::operator!=(), operator<(), I3IPAddress::operator<(), operator<<(), operator<=(), operator=(), NodeHandle::operator=(), GiaNode::operator=(), BrooseHandle::operator=(), operator==(), NodeHandle::operator==(), I3IPAddress::operator==(), BrooseHandle::operator==(), operator>(), operator>=(), BrooseBucket::output(), oversim::Chord::pingResponse(), BootstrapList::pingResponse(), BasePastry::pingResponse(), oversim::Chord::pingTimeout(), BootstrapList::pingTimeout(), BasePastry::pingTimeout(), QuonPR::purgeSites(), QuonP::purgeSites(), I3IdentifierStack::push(), I3BaseApp::refreshTriggers(), GlobalNodeList::registerPeer(), BrooseBucket::remove(), GlobalNodeList::removePeer(), BrooseBucket::resetFailedResponses(), BaseOverlay::route(), Vast::sendDiscardNode(), Vast::sendMessage(), QuonPR::sendMessage(), QuonP::sendMessage(), BaseOverlay::sendMessageToUDP(), BaseApp::sendMessageToUDP(), I3::sendPacket(), I3::sendQueryReply(), BasePastry::sendStateTables(), Vast::sendToApp(), QuonPR::sendToApp(), QuonP::sendToApp(), BaseOverlay::sendToKey(), BrooseBucket::setLastSeen(), NeighborCache::setNodeTimeout(), BrooseBucket::setRTT(), PubSubMMOG::startTimer(), Scribe::subscribeToGroup(), TransportAddress(), NeighborCache::updateEntry(), SimpleGameClient::updateNeighbors(), NeighborCache::updateNode(), QuonPR::updateThisSite(), QuonP::updateThisSite(), oversim::Koorde::updateTooltip(), and Broose::updateTooltip().

Definition at line 99 of file TransportAddress.h.


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

Generated on Wed Mar 25 16:32:54 2009 for OverSim by  doxygen 1.5.5