OverSim
I3IPAddress Struct Reference

A simple wrapper around an IPvXAddress and a port. More...

#include <I3IPAddress.h>

Inheritance diagram for I3IPAddress:
TransportAddress

Public Member Functions

 I3IPAddress ()
 Constructor.
 I3IPAddress (IPvXAddress add, int port)
 Constructor.
bool operator< (const I3IPAddress &a) const
 "Less than" operator
bool operator== (const I3IPAddress &a) const
 "Equals" operator (takes port in account)
bool operator> (const I3IPAddress &a) const
 "Greater than" operator (takes port in account)
int length () const
- 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
TransportAddress & operator= (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 TransportAddressVector & getSourceRoute () const
 Returns source route used to reach this node.
bool isUnspecified () const
 indicates if TransportAddress is specified
size_t hash () const
 creates a hash value of ip and port
virtual TransportAddress * dup () const
 returns a copy of the TransportAddress

Friends

std::ostream & operator<< (std::ostream &os, const I3IPAddress &ip)
 String stream output operation.

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 TransportAddress
static const TransportAddress UNSPECIFIED_NODE
 TransportAddress without specified ip and port.
static const TransportAddressVector UNSPECIFIED_NODES
- Protected Attributes inherited from TransportAddress
IPvXAddress ip
 the ip of this TransportAddress object
int port
 the port of this TransportAddress object

Detailed Description

A simple wrapper around an IPvXAddress and a port.

Definition at line 32 of file I3IPAddress.h.

Constructor & Destructor Documentation

I3IPAddress::I3IPAddress ( )

Constructor.

Definition at line 26 of file I3IPAddress.cc.

{
port = 0;
}
I3IPAddress::I3IPAddress ( IPvXAddress  add,
int  port 
)

Constructor.

Definition at line 31 of file I3IPAddress.cc.

{
ip = add;
port = p;
}

Member Function Documentation

int I3IPAddress::length ( ) const

Definition at line 52 of file I3IPAddress.cc.

Referenced by I3SubIdentifier::length().

{
//return sizeof(address) + sizeof(port);
return (ip.isIPv6() ? 128 : 32) + 16; // 16 = port length
}
bool I3IPAddress::operator< ( const I3IPAddress &  a) const

"Less than" operator

Parameters
aAddress to be compared

Definition at line 37 of file I3IPAddress.cc.

{
return ip < a.ip || (ip == a.ip && port < a.port);
}
bool I3IPAddress::operator== ( const I3IPAddress &  a) const

"Equals" operator (takes port in account)

Parameters
aAddress to be compared

Definition at line 42 of file I3IPAddress.cc.

{
return ip == a.ip && port == a.port;
}
bool I3IPAddress::operator> ( const I3IPAddress &  a) const

"Greater than" operator (takes port in account)

Parameters
aAddress to be compared

Definition at line 47 of file I3IPAddress.cc.

{
return a < *this;
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const I3IPAddress &  ip 
)
friend

String stream output operation.

Parameters
osString stream
ipAddress to be output
Returns
os parameter

Definition at line 57 of file I3IPAddress.cc.

{
os << ip.ip << ':' << ip.port;
return os;
}

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