OverSim
BrooseHandle Class Reference

#include <BrooseHandle.h>

Inheritance diagram for BrooseHandle:
NodeHandle TransportAddress

Public Member Functions

 BrooseHandle ()
 BrooseHandle (OverlayKey initKey, IPvXAddress initIP, int initPort)
 BrooseHandle (const NodeHandle &node)
 BrooseHandle (const TransportAddress &node, const OverlayKey &destKey)
bool operator== (const BrooseHandle &rhs) const
bool operator!= (const BrooseHandle &rhs) const
BrooseHandleoperator= (const BrooseHandle &rhs)
- Public Member Functions inherited from NodeHandle
 NodeHandle ()
 Constructs an unspecified NodeHandle.
virtual ~NodeHandle ()
 Standard destructor.
 NodeHandle (const NodeHandle &handle)
 Copy constructor.
 NodeHandle (const OverlayKey &key, const IPvXAddress &ip, int port)
 Complete constructor.
 NodeHandle (const TransportAddress &ta)
 Constructor to generate a NodeHandle from a TransportAddress.
 NodeHandle (const OverlayKey &key, const TransportAddress &ta)
 Constructor to generate a NodeHandle from an existing OverlayKey and TransportAddress.
bool operator== (const NodeHandle &rhs) const
 compares this NodeHandle to another given NodeHandle
bool operator!= (const NodeHandle &rhs) const
 compares this NodeHandle to another given NodeHandle
bool operator< (const NodeHandle &rhs) const
 compares this to a given NodeHandle
bool operator> (const NodeHandle &rhs) const
 compares this to a given NodeHandle
bool operator<= (const NodeHandle &rhs) const
 compares this to a given NodeHandle
bool operator>= (const NodeHandle &rhs) const
 compares this to a given NodeHandle
NodeHandleoperator= (const NodeHandle &rhs)
 assigns key, ip and port of rhs to this->key, this->ip and this->port
void setKey (const OverlayKey &key)
 saves given key to NodeHandle::key
const OverlayKeygetKey () const
 returns key of this NodeHandle
bool isUnspecified () const
 indicates if this NodeHandle is specified
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 NodeHandle
- Public Member Functions inherited from TransportAddress
 TransportAddress ()
 Constructs a unspecified TransportAddress.
virtual ~TransportAddress ()
 Standard destructor.
 TransportAddress (const TransportAddress &handle)
 Copy constructor.
 TransportAddress (const IPvXAddress &ip, int port=-1, NatType natType=UNKNOWN_NAT)
 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 setIp (const IPvXAddress &ip, int port=-1, NatType natType=UNKNOWN_NAT)
 Sets the ip address, port and NAT type.
void setAddress (const IPvXAddress &ip, int port=-1, NatType natType=UNKNOWN_NAT) __attribute((deprecated))
 Sets the ip address, port and NAT type.
void appendSourceRoute (const TransportAddress &sourceRoute)
 Appends a source route to this TransportAddress.
void clearSourceRoute ()
 Clears the source route of this TransportAddress.
void setPort (int port)
 sets this->port to the given port
const IPvXAddress & getIp () const
 returns ip address
const IPvXAddress & getAddress () const __attribute((deprecated))
 returns ip address.
int getPort () const
 returns port
NatType getNatType () const
 returns the type of NAT this node is behind
size_t getSourceRouteSize () const
 Returns the length of the source route to reach this node.
const TransportAddressVectorgetSourceRoute () const
 Returns source route used to reach this node.
size_t hash () const
 creates a hash value of ip and port

Static Public Member Functions

static const BrooseHandleunspecifiedNode ()

Public Attributes

int failedResponses
simtime_t rtt
simtime_t lastSeen

Static Private Attributes

static const BrooseHandle_unspecifiedNode = NULL

Friends

std::ostream & operator<< (std::ostream &os, const BrooseHandle &n)

Additional Inherited Members

- Public Types inherited from TransportAddress
enum  NatType {
  UNKNOWN_NAT = 0, NO_NAT = 1, FULL_CONE_NAT = 2, PORT_RESTRICTED_NAT = 3,
  SYMMETRIC_NAT = 4
}
typedef UNORDERED_SET
< TransportAddress, hashFcn
Set
 a hashed set of TransportAddresses
- Static Public Attributes inherited from NodeHandle
static const NodeHandle UNSPECIFIED_NODE
 the unspecified NodeHandle
- Protected Attributes inherited from NodeHandle
OverlayKey key
 the OverlayKey of this NodeHandle

Detailed Description

Definition at line 29 of file BrooseHandle.h.

Constructor & Destructor Documentation

BrooseHandle::BrooseHandle ( )

Definition at line 42 of file BrooseHandle.cc.

Referenced by unspecifiedNode().

{
//
// Default-constructor.
//
port = -1;
rtt = -1;
lastSeen = -1;
}
BrooseHandle::BrooseHandle ( OverlayKey  initKey,
IPvXAddress  initIP,
int  initPort 
)

Definition at line 54 of file BrooseHandle.cc.

{
//
// Constructor. Initializes the node handle with the passed arguments.
//
ip = initIP;
port = initPort;
key = initKey;
rtt = -1;
lastSeen = -1;
}
BrooseHandle::BrooseHandle ( const NodeHandle node)

Definition at line 67 of file BrooseHandle.cc.

{
//
// Constructor. Initializes the node handle with the passed arguments.
//
ip = node.getIp();
port = node.getPort();
key = node.getKey();
rtt = -1;
lastSeen = -1;
}
BrooseHandle::BrooseHandle ( const TransportAddress node,
const OverlayKey destKey 
)

Definition at line 81 of file BrooseHandle.cc.

{
//
// Constructor. Initializes the node handle with the passed arguments.
//
ip = node.getIp();
port = node.getPort();
key = destKey;
rtt = -1;
lastSeen = -1;
}

Member Function Documentation

bool BrooseHandle::operator!= ( const BrooseHandle rhs) const

Definition at line 119 of file BrooseHandle.cc.

{
if (this->isUnspecified() || rhs.isUnspecified())
opp_error("BrooseHandle: Trying to compare unspecified nodeHandle!");
if (this->key == rhs.getKey() &&
this->ip == rhs.getIp() && this->port == rhs.getPort())
return false;
return true;
}
BrooseHandle & BrooseHandle::operator= ( const BrooseHandle rhs)

Definition at line 93 of file BrooseHandle.cc.

{
this->key = rhs.getKey();
this->ip = rhs.getIp();
this->port = rhs.getPort();
this->rtt = rhs.rtt;
this->lastSeen = rhs.lastSeen;
return *this;
}
bool BrooseHandle::operator== ( const BrooseHandle rhs) const

Definition at line 105 of file BrooseHandle.cc.

{
if (this->isUnspecified() || rhs.isUnspecified())
opp_error("BrooseHandle: Trying to compare unspecified nodeHandle!");
if (this->key != rhs.getKey() )
return false;
if (this->ip != rhs.getIp() )
return false;
if (this->port != rhs.getPort() )
return false;
return true;
}
static const BrooseHandle& BrooseHandle::unspecifiedNode ( )
inlinestatic

Definition at line 45 of file BrooseHandle.h.

Referenced by BrooseBucket::get().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const BrooseHandle n 
)
friend

Definition at line 30 of file BrooseHandle.cc.

{
if (n.isUnspecified()) {
os << "<unspec>";
} else {
os << n.getIp() << ":" << n.getPort() << " " << n.getKey() << " last-seen: " << n.lastSeen
<< " failedResponses: " << n.failedResponses << " rtt: " << n.rtt;
}
return os;
};

Member Data Documentation

const BrooseHandle * BrooseHandle::_unspecifiedNode = NULL
staticprivate

Definition at line 43 of file BrooseHandle.h.

Referenced by unspecifiedNode().

int BrooseHandle::failedResponses

Definition at line 32 of file BrooseHandle.h.

Referenced by BrooseHandle(), operator<<(), and operator=().

simtime_t BrooseHandle::lastSeen

Definition at line 34 of file BrooseHandle.h.

Referenced by BrooseHandle(), operator<<(), operator=(), and BrooseBucket::output().

simtime_t BrooseHandle::rtt

Definition at line 33 of file BrooseHandle.h.

Referenced by BrooseHandle(), operator<<(), operator=(), and BrooseBucket::output().


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