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


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
TransportAddressoperator= (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 void netPack (cCommBuffer *b)
 serializes the object into a buffer
virtual void netUnpack (cCommBuffer *b)
 deserializes the object from a buffer
virtual TransportAddressdup () 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.


Constructor & Destructor Documentation

TransportAddress::TransportAddress (  ) 

Constructs a unspecified TransportAddress.

Referenced by dup().

00047 {
00048     port = -1;
00049 }

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

Standard destructor.

00079 {};

TransportAddress::TransportAddress ( const TransportAddress handle  ) 

Copy constructor.

Parameters:
handle The TransportAddress to copy
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
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
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
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
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
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
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
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
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
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
00133 {
00134     this->port = port;
00135 }

const IPvXAddress & TransportAddress::getAddress (  )  const

returns ip address

Returns:
this->ip

Referenced by RealWorldTestApp::deliver(), and BootstrapOracle::getBootstrapNode().

00139 {
00140     return ip;
00141 }

int TransportAddress::getPort (  )  const

returns port

Returns:
this->port
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

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

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 }

void TransportAddress::netPack ( cCommBuffer *  b  )  [virtual]

serializes the object into a buffer

Parameters:
b the buffer

Reimplemented in NodeHandle.

Referenced by doPacking().

00216 {
00217     //cMessage::netPack(b);
00218     doPacking(b,this->ip);
00219     doPacking(b,this->port);
00220 }

void TransportAddress::netUnpack ( cCommBuffer *  b  )  [virtual]

deserializes the object from a buffer

Parameters:
b the buffer

Reimplemented in NodeHandle.

Referenced by doUnpacking().

00223 {
00224     //cMessage::netUnpack(b);
00225     doUnpacking(b,this->ip);
00226     doUnpacking(b,this->port);
00227 }

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

returns a copy of the TransportAddress

Returns:
a copy of the TransportAddress

Reimplemented in NodeHandle.

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
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

Referenced by BootstrapOracle::addPeer(), Broose::binaryOutput(), BaseOverlay::bindToPort(), BaseApp::bindToPort(), I3BaseApp::bootstrapI3(), BootstrapNodeHandle::BootstrapNodeHandle(), BrooseHandle::BrooseHandle(), BaseApp::callRoute(), BaseOverlay::callUpdate(), Vast::changeState(), Gia::changeState(), Chord::changeState(), Broose::changeState(), Pastry::checkProxCache(), Chord::closestPreceedingNode(), I3SubIdentifier::compareTo(), KBRTestApp::deliver(), Scribe::deliverALMDataToGroup(), Broose::displayBucketState(), PastryRoutingTable::failedNode(), PastryNeighborhoodSet::failedNode(), PastryLeafSet::failedNode(), BaseOverlay::findNodeRpc(), KBRTestApp::forward(), getAddress(), BrooseBucket::getClosestNode(), BrooseBucket::getFailedResponses(), BrooseBucket::getLastSeen(), BootstrapOracle::getPeerInfo(), BrooseBucket::getRTT(), Vast::handleAppMessage(), BaseOverlay::handleBaseOverlayMessage(), BaseApp::handleCommonAPIMessage(), Koorde::handleDeBruijnTimerExpired(), Scribe::handleJoinMessage(), Scribe::handleJoinResponse(), KBRTestApp::handleLookupResponse(), BootstrapList::handleLookupResponse(), GIASearchApp::handleLowerMessage(), XmlRpcInterface::handleMessage(), BaseOverlay::handleMessage(), BaseApp::handleMessage(), Scribe::handlePublishCall(), Scribe::handlePublishResponse(), SimpleGameClient::handleRealworldPacket(), Koorde::handleRpcNotifyResponse(), Chord::handleRpcNotifyResponse(), Scribe::handleRpcResponse(), PubSubMMOG::handleRpcResponse(), Koorde::handleRpcResponse(), KBRTestApp::handleRpcResponse(), Chord::handleRpcResponse(), Broose::handleRpcResponse(), BootstrapList::handleRpcResponse(), PubSubMMOG::handleRpcTimeout(), PubSubLobby::handleRpcTimeout(), Koorde::handleRpcTimeout(), Chord::handleRpcTimeout(), Broose::handleRpcTimeout(), Pastry::handleStateMessage(), SimpleGameClient::handleTimerEvent(), Scribe::handleTimerEvent(), GIASearchApp::handleTimerEvent(), BaseOverlay::handleTransportAddressChangedNotification(), Vast::handleUDPMessage(), Pastry::handleUDPMessage(), Scribe::handleUpperMessage(), hash(), I3IPAddress::I3IPAddress(), BrooseBucket::increaseFailedResponses(), BaseOverlay::initialize(), BaseApp::initialize(), I3::insertTrigger(), BaseRpc::internalHandleRpcMessage(), isUnspecified(), NodeHandle::isUnspecified(), BaseOverlay::join(), I3IPAddress::length(), IterativeLookup::lookup(), SendToKeyListener::lookupFinished(), netPack(), NodeHandle::netPack(), netUnpack(), NodeHandle::netUnpack(), 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(), Chord::pingResponse(), BootstrapList::pingResponse(), BasePastry::pingResponse(), Chord::pingTimeout(), BootstrapList::pingTimeout(), BasePastry::pingTimeout(), I3IdentifierStack::push(), Vast::receiveChangeNotification(), I3BaseApp::refreshTriggers(), BootstrapOracle::registerPeer(), BrooseBucket::remove(), BootstrapOracle::removePeer(), BrooseBucket::resetFailedResponses(), Gia::route(), BaseOverlay::route(), Vast::sendDiscardNode(), Vast::sendMessage(), BaseOverlay::sendMessageToUDP(), BaseApp::sendMessageToUDP(), I3::sendPacket(), I3::sendQueryReply(), BasePastry::sendStateTables(), Vast::sendToApp(), BaseOverlay::sendToKey(), BrooseBucket::setLastSeen(), BrooseBucket::setRTT(), Scribe::subscribeToGroup(), TransportAddress(), SimpleGameClient::updateNeighbors(), Koorde::updateTooltip(), and Broose::updateTooltip().


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

Generated on Fri Sep 19 13:05:08 2008 for ITM OverSim by  doxygen 1.5.5