TransportAddress Class Reference

#include <TransportAddress.h>

Inheritance diagram for TransportAddress:

NodeHandle BrooseHandle 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 hash_set< TransportAddress,
hashFcn
Set

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
bool operator!= (const TransportAddress &rhs) const
bool operator< (const TransportAddress &rhs) const
bool operator> (const TransportAddress &rhs) const
bool operator<= (const TransportAddress &rhs) const
bool operator>= (const TransportAddress &rhs) const
TransportAddressoperator= (const TransportAddress &rhs)
void setAddress (const IPvXAddress &ip, int port=-1)
void setPort (int port)
const IPvXAddress & getAddress () const
int getPort () const
bool isUnspecified () const
size_t hash () const
virtual void netPack (cCommBuffer *b)
virtual void netUnpack (cCommBuffer *b)

Public Attributes

IPvXAddress ip
int port

Static Public Attributes

static const TransportAddress UNSPECIFIED_NODE

Private Member Functions

void assertUnspecified (const TransportAddress &handle) const

Friends

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

Classes

class  hashFcn


Member Typedef Documentation

typedef hash_set<TransportAddress, hashFcn> TransportAddress::Set

Reimplemented in NodeHandle.


Constructor & Destructor Documentation

TransportAddress::TransportAddress (  ) 

Constructs a unspecified TransportAddress.

00051 {
00052     port = -1;
00053 }

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

Standard destructor.

00082 {};

TransportAddress::TransportAddress ( const TransportAddress handle  ) 

Copy constructor.

Parameters:
handle The TransportAddress to copy
00057 {
00058     port = handle.port;
00059     ip = handle.ip;
00060 }

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

Complete constructor.

Parameters:
ip The IPvXAddress
port The UDP-Port
00065 {
00066     this->ip = ip;
00067     this->port = port;
00068 }


Member Function Documentation

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

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

const IPvXAddress & TransportAddress::getAddress (  )  const

00143 {
00144     return ip;
00145 }

int TransportAddress::getPort (  )  const

00149 {
00150     return port;
00151 }

size_t TransportAddress::hash (  )  const

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

bool TransportAddress::isUnspecified (  )  const

Reimplemented in NodeHandle.

00072 {
00073     return (ip.isUnspecified() || (port == -1));
00074 }

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

Reimplemented in NodeHandle.

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

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

Reimplemented in NodeHandle.

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

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

00094 {
00095     assertUnspecified(rhs);
00096     return !(this->ip == rhs.ip && this->port == rhs.port );
00097 }

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

00101 {
00102     assertUnspecified(rhs);
00103     return this->ip < rhs.ip;
00104 }

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

00115 {
00116     assertUnspecified(rhs);
00117     return this->ip < rhs.ip || this->ip == rhs.ip;
00118 }

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

00078 {
00079     this->ip = rhs.ip;
00080     this->port = rhs.port;
00081 
00082     return *this;
00083 }

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

00087 {
00088     assertUnspecified(rhs);
00089     return (this->ip == rhs.ip && this->port == rhs.port);
00090 }

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

00108 {
00109     assertUnspecified(rhs);
00110     return !(this->ip < rhs.ip || this->ip == rhs.ip);
00111 }

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

00122 {
00123     assertUnspecified(rhs);
00124     return !(this->ip < rhs.ip);
00125 }

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

00129 {
00130     this->ip = ip;
00131     if (port!=-1)
00132         this->port = port;
00133 }

void TransportAddress::setPort ( int  port  ) 

00137 {
00138     this->port = port;
00139 }


Friends And Related Function Documentation

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

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


Member Data Documentation

IPvXAddress TransportAddress::ip

int TransportAddress::port

const TransportAddress TransportAddress::UNSPECIFIED_NODE [static]

Reimplemented in NodeHandle, and BrooseHandle.


The documentation for this class was generated from the following files:
Generated on Fri May 11 14:52:41 2007 for ITM OverSim by  doxygen 1.4.7