#include <TransportAddress.h>
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.
Public Types | |
typedef hash_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 void | netPack (cCommBuffer *b) |
serializes the object into a buffer | |
virtual void | netUnpack (cCommBuffer *b) |
deserializes the object from a buffer | |
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. | |
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... |
typedef hash_set<TransportAddress, hashFcn> TransportAddress::Set |
TransportAddress::TransportAddress | ( | ) |
TransportAddress::TransportAddress | ( | const TransportAddress & | handle | ) |
TransportAddress::TransportAddress | ( | const IPvXAddress & | ip, | |
int | port = -1 | |||
) |
bool TransportAddress::operator== | ( | const TransportAddress & | rhs | ) | const |
compares this to a given TransportAddress
rhs | the TransportAddress this is compared to |
00087 { 00088 assertUnspecified(rhs); 00089 return (this->ip == rhs.ip && this->port == rhs.port); 00090 }
bool TransportAddress::operator!= | ( | const TransportAddress & | rhs | ) | const |
compares this to a given TransportAddress
rhs | the TransportAddress this is compared to |
00094 { 00095 assertUnspecified(rhs); 00096 return !(this->ip == rhs.ip && this->port == rhs.port ); 00097 }
bool TransportAddress::operator< | ( | const TransportAddress & | rhs | ) | const |
compares this to a given TransportAddress
rhs | the TransportAddress this is compared to |
00101 { 00102 assertUnspecified(rhs); 00103 return this->ip < rhs.ip; 00104 }
bool TransportAddress::operator> | ( | const TransportAddress & | rhs | ) | const |
compares this to a given TransportAddress
rhs | the TransportAddress this is compared to |
00108 { 00109 assertUnspecified(rhs); 00110 return !(this->ip < rhs.ip || this->ip == rhs.ip); 00111 }
bool TransportAddress::operator<= | ( | const TransportAddress & | rhs | ) | const |
compares this to a given TransportAddress
rhs | the TransportAddress this is compared to |
00115 { 00116 assertUnspecified(rhs); 00117 return this->ip < rhs.ip || this->ip == rhs.ip; 00118 }
bool TransportAddress::operator>= | ( | const TransportAddress & | rhs | ) | const |
compares this to a given TransportAddress
rhs | the TransportAddress this is compared to |
00122 { 00123 assertUnspecified(rhs); 00124 return !(this->ip < rhs.ip); 00125 }
TransportAddress & TransportAddress::operator= | ( | const TransportAddress & | rhs | ) |
assigns ip and port of rhs to this->ip and this->port
rhs | the TransportAddress with the defined ip and port |
void TransportAddress::setAddress | ( | const IPvXAddress & | ip, | |
int | port = -1 | |||
) |
void TransportAddress::setPort | ( | int | port | ) |
const IPvXAddress & TransportAddress::getAddress | ( | ) | const |
int TransportAddress::getPort | ( | ) | const |
bool TransportAddress::isUnspecified | ( | ) | const |
indicates if TransportAddress is specified
Reimplemented in NodeHandle.
size_t TransportAddress::hash | ( | ) | const |
creates a hash value of ip and port
00155 { 00156 size_t iphash; 00157 if (ip.isIPv6()) { 00158 uint32_t* addr = (uint32_t*) 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 }
void TransportAddress::assertUnspecified | ( | const TransportAddress & | handle | ) | const [inline, private] |
throws an opp_error if this or handle is unspecified
handle | the TransportAddress to check |
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
b | the buffer |
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] |
deserializes the object from a buffer
b | the buffer |
Reimplemented in NodeHandle.
00223 { 00224 //cMessage::netUnpack(b); 00225 doUnpacking(b,this->ip); 00226 doUnpacking(b,this->port); 00227 }
std::ostream& operator<< | ( | std::ostream & | os, | |
const TransportAddress & | n | |||
) | [friend] |
standard output stream for TransportAddress, gives out ip and port
os | the ostream | |
n | the TransportAddress |
00038 { 00039 if (n.isUnspecified()) { 00040 os << "<unspec>"; 00041 } else { 00042 os << n.ip << ":" << n.port; 00043 } 00044 00045 return os; 00046 };
IPvXAddress TransportAddress::ip |
the ip of this TransportAddress object
the port of this TransportAddress object
const TransportAddress TransportAddress::UNSPECIFIED_NODE [static] |
TransportAddress without specified ip and port.
Reimplemented in NodeHandle, BrooseHandle, and GiaNode.