INET Framework for OMNeT++/OMNEST
inet::ClnsAddress Class Reference

#include <ClnsAddress.h>

Public Types

enum  AddressCategory { UNSPECIFIED }
 

Public Member Functions

 ClnsAddress ()
 
 ClnsAddress (std::string net)
 
 ClnsAddress (uint64_t areaID, uint64_t systemID, uint8_t nsel=0)
 
void set (uint64_t areaID, uint64_t systemID, uint8_t nsel=0)
 
virtual ~ClnsAddress ()
 
bool isUnspecified () const
 
std::string str (bool printUnspec=true) const
 Returns the string representation of the address (e.g. More...
 
bool equals (const ClnsAddress &toCmp) const
 Returns true if the two addresses are equal. More...
 
uint64_t getAreaId () const
 
uint64_t getSystemId () const
 
uint8_t getNsel () const
 
void setNsel (uint8_t nsel)
 
bool operator== (const ClnsAddress &addr1) const
 Returns equals(addr). More...
 
bool operator!= (const ClnsAddress &addr1) const
 Returns !equals(addr). More...
 
bool operator< (const ClnsAddress &addr1) const
 Compares two CLNS addresses. More...
 
bool operator<= (const ClnsAddress &addr1) const
 
bool operator> (const ClnsAddress &addr1) const
 
bool operator>= (const ClnsAddress &addr1) const
 

Static Public Attributes

static const ClnsAddress UNSPECIFIED_ADDRESS
 

Private Attributes

uint64_t systemID
 
uint64_t areaID
 
uint8_t nsel
 

Member Enumeration Documentation

◆ AddressCategory

Enumerator
UNSPECIFIED 
34  {
35  UNSPECIFIED // 00.0000.0000.0000.0000.00
36  };

Constructor & Destructor Documentation

◆ ClnsAddress() [1/3]

inet::ClnsAddress::ClnsAddress ( )
25 {
26  areaID = 0;
27  systemID = 0;
28  nsel = 0;
29 }

◆ ClnsAddress() [2/3]

inet::ClnsAddress::ClnsAddress ( std::string  net)
46 {
47  areaID = 0;
48  systemID = 0;
49  nsel = 0;
50 
51  unsigned int dots = 0;
52  size_t found;
53 
54  // net address (in this module - not according to standard O:-) MUST have the following format:
55  // 49.0001.1921.6800.1001.00
56  // IDI: 49 (private addressing)
57  // AREA: 0001
58  // systemID: 1921.6800.1001 from IP 192.168.1.1
59  // NSEL: 00
60 
61  found = net.find_first_of(".");
62  if (found != 2 || net.length() != 25) {
63  return;
64  }
65 
66  while (found != std::string::npos) {
67  switch (found) {
68  case 2:
69  dots++;
70 // area[0] = (unsigned char) (atoi(net.substr(0, 2).c_str()));
71  areaID += (uint64_t)(strtoul(net.substr(0, 2).c_str(), nullptr, 16)) << 16;
72  break;
73  case 7:
74  areaID += (uint64_t)(strtoul(net.substr(3, 4).c_str(), nullptr, 16));
75  dots++;
76  break;
77  case 12:
78  dots++;
79  systemID += (uint64_t)(strtoul(net.substr(8, 4).c_str(), nullptr, 16)) << 32;
80  break;
81  case 17:
82  dots++;
83  systemID += (uint64_t)(strtoul(net.substr(13, 4).c_str(), nullptr, 16)) << 16;
84  break;
85  case 22:
86  dots++;
87  systemID += (uint64_t)(strtoul(net.substr(18, 4).c_str(), nullptr, 16));
88  break;
89  default:
90  return;
91  break;
92  }
93 
94  found = net.find_first_of(".", found + 1);
95  }
96 
97  if (dots != 5) {
98  return;
99  }
100 
101  nsel = strtoul(net.substr(23, 2).c_str(), nullptr, 16);
102 
103  // 49.0001.1921.6801.2003.00
104 // this->nickname = this->sysId[ISIS_SYSTEM_ID - 1] + this->sysId[ISIS_SYSTEM_ID - 2] * 0xFF;
105 }

◆ ClnsAddress() [3/3]

inet::ClnsAddress::ClnsAddress ( uint64_t  areaID,
uint64_t  systemID,
uint8_t  nsel = 0 
)
31  :
33  areaID(areaID),
34  nsel(nsel)
35 {
36 }

◆ ~ClnsAddress()

inet::ClnsAddress::~ClnsAddress ( )
virtual
108 {
109  // TODO Auto-generated destructor stub
110 }

Member Function Documentation

◆ equals()

bool inet::ClnsAddress::equals ( const ClnsAddress toCmp) const
inline

Returns true if the two addresses are equal.

57 { return systemID == toCmp.systemID && areaID == toCmp.areaID; }

Referenced by operator!=(), and operator==().

◆ getAreaId()

uint64_t inet::ClnsAddress::getAreaId ( ) const
134 {
135  return areaID;
136 }

Referenced by operator<(), operator<=(), operator>(), operator>=(), and inet::L3Address::set().

◆ getNsel()

uint8_t inet::ClnsAddress::getNsel ( ) const
139 {
140  return nsel;
141 }

Referenced by inet::L3Address::set().

◆ getSystemId()

uint64_t inet::ClnsAddress::getSystemId ( ) const
149 {
150  return systemID;
151 }

Referenced by operator<(), operator<=(), operator>(), operator>=(), and inet::L3Address::set().

◆ isUnspecified()

bool inet::ClnsAddress::isUnspecified ( ) const
113 {
114  return systemID == 0 && areaID == 0;
115 }

Referenced by str().

◆ operator!=()

bool inet::ClnsAddress::operator!= ( const ClnsAddress addr1) const
inline

Returns !equals(addr).

72 { return !equals(addr1); }

◆ operator<()

bool inet::ClnsAddress::operator< ( const ClnsAddress addr1) const
inline

Compares two CLNS addresses.

77 { if (areaID == addr1.getAreaId()) { return systemID < addr1.getSystemId(); } else { return areaID < addr1.getAreaId(); } }

◆ operator<=()

bool inet::ClnsAddress::operator<= ( const ClnsAddress addr1) const
inline
78 { if (areaID == addr1.getAreaId()) { return systemID <= addr1.getSystemId(); } else { return areaID < addr1.getAreaId(); } }

◆ operator==()

bool inet::ClnsAddress::operator== ( const ClnsAddress addr1) const
inline

Returns equals(addr).

67 { return equals(addr1); }

◆ operator>()

bool inet::ClnsAddress::operator> ( const ClnsAddress addr1) const
inline
79 { if (areaID == addr1.getAreaId()) { return systemID > addr1.getSystemId(); } else { return areaID > addr1.getAreaId(); } }

◆ operator>=()

bool inet::ClnsAddress::operator>= ( const ClnsAddress addr1) const
inline
80 { if (areaID == addr1.getAreaId()) { return systemID >= addr1.getSystemId(); } else { return areaID > addr1.getAreaId(); } }

◆ set()

void inet::ClnsAddress::set ( uint64_t  areaID,
uint64_t  systemID,
uint8_t  nsel = 0 
)
39 {
40  this->areaID = areaID;
41  this->systemID = systemID;
42  this->nsel = nsel;
43 }

◆ setNsel()

void inet::ClnsAddress::setNsel ( uint8_t  nsel)
144 {
145  this->nsel = nsel;
146 }

◆ str()

std::string inet::ClnsAddress::str ( bool  printUnspec = true) const

Returns the string representation of the address (e.g.

"49.0001.1921.6800.1001.00")

Parameters
printUnspecshow 00.0000.0000.0000.0000.00 as "<unspec>" if true
118 {
119  if (printUnspec && isUnspecified())
120  return std::string("<unspec>");
121 
122  std::ostringstream buf;
123  buf << std::hex << std::setfill('0')
124  << std::setw(2) << ((areaID >> 16) & (0xFF)) << "."
125  << std::setw(4) << (areaID & 0xFFFF) << "."
126  << std::setw(4) << ((systemID >> 32) & 0xFFFF) << "."
127  << std::setw(4) << ((systemID >> 16) & 0xFFFF) << "."
128  << std::setw(4) << (systemID & 0xFFFF) << "."
129  << std::setw(2) << (nsel & 0xFF);
130  return buf.str();
131 }

Referenced by inet::operator<<(), and inet::L3Address::str().

Member Data Documentation

◆ areaID

uint64_t inet::ClnsAddress::areaID
private

◆ nsel

uint8_t inet::ClnsAddress::nsel
private

Referenced by ClnsAddress(), getNsel(), set(), setNsel(), and str().

◆ systemID

uint64_t inet::ClnsAddress::systemID
private

◆ UNSPECIFIED_ADDRESS


The documentation for this class was generated from the following files:
inet::ClnsAddress::nsel
uint8_t nsel
Definition: ClnsAddress.h:31
inet::utils::hex
std::string hex(uint16_t l)
Definition: INETUtils.cc:28
inet::ClnsAddress::systemID
uint64_t systemID
Definition: ClnsAddress.h:29
inet::ClnsAddress::isUnspecified
bool isUnspecified() const
Definition: ClnsAddress.cc:112
inet::ClnsAddress::areaID
uint64_t areaID
Definition: ClnsAddress.h:30
inet::ClnsAddress::equals
bool equals(const ClnsAddress &toCmp) const
Returns true if the two addresses are equal.
Definition: ClnsAddress.h:57
inet::ClnsAddress::UNSPECIFIED
@ UNSPECIFIED
Definition: ClnsAddress.h:35