NodeHandle Class Reference

#include <NodeHandle.h>

List of all members.


Detailed Description

This class implements a common node handle.


It covers the complete node information, like IP-Address, port, NodeID and some additional flags for Simulation behaviour. 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 hash_set< NodeHandle,
hashFcn
Set

Public Member Functions

 NodeHandle ()
 Constructs a unspecified NodeHandle.
 NodeHandle (const NodeHandle &handle)
 Copy constructor.
 NodeHandle (const OverlayKey &key, const IPvXAddress &ip, int port, int moduleId=-1)
 Complete constructor.
bool operator== (const NodeHandle &rhs) const
bool operator!= (const NodeHandle &rhs) const
bool operator< (const NodeHandle &rhs) const
bool operator> (const NodeHandle &rhs) const
bool operator<= (const NodeHandle &rhs) const
bool operator>= (const NodeHandle &rhs) const
NodeHandleoperator= (const NodeHandle &rhs)
void setAddress (const IPvXAddress &ip, int port=-1)
void setPort (int port)
void setModuleId (int moduleId)
void setKey (const OverlayKey &key)
const IPvXAddress & getAddress () const
int getPort () const
int getModuleId () const
const OverlayKeygetKey () const
bool isUnspecified () const
bool isMalicious () const
size_t hash () const
void netPack (cCommBuffer *b)
void netUnpack (cCommBuffer *b)

Public Attributes

IPvXAddress ip
OverlayKey key
int port
int moduleId

Static Public Attributes

static const NodeHandle UNSPECIFIED_NODE

Private Member Functions

void assertUnspecified (const NodeHandle &handle) const

Friends

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

Classes

class  hashFcn


Member Typedef Documentation

typedef hash_set<NodeHandle, hashFcn> NodeHandle::Set


Constructor & Destructor Documentation

NodeHandle::NodeHandle (  ) 

Constructs a unspecified NodeHandle.

00052 {
00053     moduleId = -1;
00054     port = -1;
00055     key = OverlayKey::UNSPECIFIED_KEY;
00056 }

NodeHandle::NodeHandle ( const NodeHandle handle  ) 

Copy constructor.

Parameters:
handle The NodeHandle to copy
00060 {
00061     moduleId = handle.moduleId;
00062     key = handle.key;
00063     port = handle.port;
00064     ip = handle.ip;
00065 }

NodeHandle::NodeHandle ( const OverlayKey key,
const IPvXAddress &  ip,
int  port,
int  moduleId = -1 
)

Complete constructor.

Parameters:
key The OverlayKey
ip The IPvXAddress
port The UDP-Port
moduleId The simulation module id
00072 {
00073     this->moduleId = moduleId;
00074     this->ip = ip;
00075     this->port = port;
00076     this->key = key;
00077 }


Member Function Documentation

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

00219 {
00220     if ( this->isUnspecified() || handle.isUnspecified() )
00221         opp_error("NodeHandle: Trying to compare unspecified nodeHandle!");
00222 }

const IPvXAddress & NodeHandle::getAddress (  )  const

00180 {
00181     return ip;
00182 }

const OverlayKey & NodeHandle::getKey (  )  const

00198 {
00199     return key;
00200 }

int NodeHandle::getModuleId (  )  const

00192 {
00193     return moduleId;
00194 }

int NodeHandle::getPort (  )  const

00186 {
00187     return port;
00188 }

size_t NodeHandle::hash (  )  const

00204 {
00205     size_t iphash;
00206     if (ip.isIPv6()) {
00207         uint32_t* addr = ip.get6().words();
00208         iphash = (size_t)(addr[0]^addr[1]^addr[2]^addr[3]);
00209     } else {
00210         iphash = (size_t)ip.get4().getInt();
00211     }
00212 
00213     return (size_t)(iphash^port^key.hash());
00214 }

bool NodeHandle::isMalicious (  )  const

00087 {
00088     BaseOverlay* overlay
00089         = dynamic_cast<BaseOverlay*>(simulation.module(moduleId));
00090     if (overlay==NULL)
00091         opp_error("NodeHandle not associated with a BaseOverlay Module");
00092     return overlay->isMalicious();
00093 }

bool NodeHandle::isUnspecified (  )  const

00081 {
00082     return (moduleId == -1);
00083 }

void NodeHandle::netPack ( cCommBuffer *  b  ) 

00266 {
00267     //cMessage::netPack(b);
00268     doPacking(b,this->ip);
00269     doPacking(b,this->key);
00270     doPacking(b,this->port);
00271     doPacking(b,this->moduleId);
00272 }

void NodeHandle::netUnpack ( cCommBuffer *  b  ) 

00275 {
00276     //cMessage::netUnpack(b);
00277     doUnpacking(b,this->ip);
00278     doUnpacking(b,this->key);
00279     doUnpacking(b,this->port);
00280     doUnpacking(b,this->moduleId);
00281 }

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

00117 {
00118     assertUnspecified( rhs );
00119     return !( this->moduleId == rhs.moduleId &&
00120               this->key == rhs.key &&
00121               this->ip == rhs.ip && this->port == rhs.port );
00122 }

bool NodeHandle::operator< ( const NodeHandle rhs  )  const

00126 {
00127     assertUnspecified(rhs);
00128     return this->key < rhs.key;
00129 }

bool NodeHandle::operator<= ( const NodeHandle rhs  )  const

00140 {
00141     assertUnspecified(rhs);
00142     return this->key <= rhs.key;
00143 }

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

00097 {
00098     this->key = rhs.key;
00099     this->ip = rhs.ip;
00100     this->port = rhs.port;
00101     this->moduleId = rhs.moduleId;
00102 
00103     return *this;
00104 }

bool NodeHandle::operator== ( const NodeHandle rhs  )  const

00108 {
00109     assertUnspecified( rhs );
00110     return ( this->moduleId == rhs.moduleId &&
00111              this->key == rhs.key &&
00112              this->ip == rhs.ip && this->port == rhs.port );
00113 }

bool NodeHandle::operator> ( const NodeHandle rhs  )  const

00133 {
00134     assertUnspecified(rhs);
00135     return this->key > rhs.key;
00136 }

bool NodeHandle::operator>= ( const NodeHandle rhs  )  const

00147 {
00148     assertUnspecified(rhs);
00149     return this->key >= rhs.key;
00150 }

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

00154 {
00155     this->ip = ip;
00156     if (port!=-1)
00157         this->port = port;
00158 }

void NodeHandle::setKey ( const OverlayKey key  ) 

00174 {
00175     this->key = key;
00176 }

void NodeHandle::setModuleId ( int  moduleId  ) 

00168 {
00169     this->moduleId = moduleId;
00170 }

void NodeHandle::setPort ( int  port  ) 

00162 {
00163     this->port = port;
00164 }


Friends And Related Function Documentation

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

00038 {
00039     if (n.isUnspecified()) {
00040         os << "<unspec>";
00041     } else {
00042         os << n.ip << ":" << n.port << " " << n.key
00043         << " " << n.moduleId;
00044     }
00045 
00046     return os;
00047 };


Member Data Documentation

IPvXAddress NodeHandle::ip

OverlayKey NodeHandle::key

int NodeHandle::moduleId

int NodeHandle::port

const NodeHandle NodeHandle::UNSPECIFIED_NODE [static]


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:37:06 2007 for ITM OverSim by  doxygen 1.4.7