INET Framework for OMNeT++/OMNEST
inet::sctp::SctpNatTable Class Reference

#include <SctpNatTable.h>

Inheritance diagram for inet::sctp::SctpNatTable:

Public Types

typedef std::vector< SctpNatEntry * > SctpNatEntryTable
 

Public Member Functions

 SctpNatTable ()
 
 ~SctpNatTable ()
 
SctpNatEntryfindNatEntry (L3Address srcAddr, uint16_t srcPrt, L3Address destAddr, uint16_t destPrt, uint32_t globalVtag)
 
SctpNatEntrygetEntry (L3Address globalAddr, uint16_t globalPrt, L3Address nattedAddr, uint16_t nattedPrt, uint32_t localVtag)
 
SctpNatEntrygetSpecialEntry (L3Address globalAddr, uint16_t globalPrt, L3Address nattedAddr, uint16_t nattedPrt)
 
SctpNatEntrygetLocalInitEntry (L3Address globalAddr, uint16_t localPrt, uint16_t globalPrt)
 
SctpNatEntrygetLocalEntry (L3Address globalAddr, uint16_t localPrt, uint16_t globalPrt, uint32_t localVtag)
 
void removeEntry (SctpNatEntry *entry)
 
void printNatTable ()
 

Static Public Member Functions

static uint32_t getNextEntryNumber ()
 

Public Attributes

SctpNatEntryTable natEntries
 

Static Public Attributes

static uint32_t nextEntryNumber = 0
 

Member Typedef Documentation

◆ SctpNatEntryTable

Constructor & Destructor Documentation

◆ SctpNatTable()

inet::sctp::SctpNatTable::SctpNatTable ( )
28 {
29 }

◆ ~SctpNatTable()

inet::sctp::SctpNatTable::~SctpNatTable ( )
32 {
33  for (auto& elem : natEntries)
34  delete elem;
35  natEntries.clear();
36 }

Member Function Documentation

◆ findNatEntry()

SctpNatEntry * inet::sctp::SctpNatTable::findNatEntry ( L3Address  srcAddr,
uint16_t  srcPrt,
L3Address  destAddr,
uint16_t  destPrt,
uint32_t  globalVtag 
)
39 {
40  // linear search is OK because normally we don't have many interfaces and this func is rarely called
41  Enter_Method("findNatEntry");
42  for (auto& elem : natEntries)
43  if ((elem)->getLocalAddress() == srcAddr && (elem)->getLocalPort() == srcPrt &&
44  (elem)->getGlobalAddress() == destAddr && (elem)->getGlobalPort() == destPrt && (elem)->getGlobalVTag() == globalVtag)
45  {
46  return elem;
47  }
48  return nullptr;
49 }

◆ getEntry()

SctpNatEntry * inet::sctp::SctpNatTable::getEntry ( L3Address  globalAddr,
uint16_t  globalPrt,
L3Address  nattedAddr,
uint16_t  nattedPrt,
uint32_t  localVtag 
)
52 {
53  // linear search is OK because normally we don't have many interfaces and this func is rarely called
54  Enter_Method("getEntry");
55  for (auto& elem : natEntries)
56  if ((elem)->getGlobalAddress() == globalAddr && (elem)->getGlobalPort() == globalPrt &&
57  (elem)->getNattedAddress() == nattedAddr && (elem)->getNattedPort() == nattedPrt &&
58  (elem)->getLocalVTag() == localVtag)
59 // (*i)->getGlobalVTag()==localVtag)
60  {
61  return elem;
62  }
63  return nullptr;
64 }

◆ getLocalEntry()

SctpNatEntry * inet::sctp::SctpNatTable::getLocalEntry ( L3Address  globalAddr,
uint16_t  localPrt,
uint16_t  globalPrt,
uint32_t  localVtag 
)
96 {
97  // linear search is OK because normally we don't have many interfaces and this func is rarely called
98  Enter_Method("getLocalEntry");
99  for (auto& elem : natEntries)
100  if ((elem)->getGlobalAddress() == globalAddr && (elem)->getGlobalPort() == localPrt &&
101  (elem)->getLocalPort() == globalPrt && (elem)->getLocalVTag() == localVtag)
102  {
103  return elem;
104  }
105  return nullptr;
106 }

◆ getLocalInitEntry()

SctpNatEntry * inet::sctp::SctpNatTable::getLocalInitEntry ( L3Address  globalAddr,
uint16_t  localPrt,
uint16_t  globalPrt 
)
83 {
84  // linear search is OK because normally we don't have many interfaces and this func is rarely called
85  Enter_Method("getLocalInitEntry");
86  for (auto& elem : natEntries)
87  if ((elem)->getGlobalAddress() == globalAddr && (elem)->getGlobalPort() == localPrt &&
88  (elem)->getLocalPort() == globalPrt)
89  {
90  return elem;
91  }
92  return nullptr;
93 }

◆ getNextEntryNumber()

static uint32_t inet::sctp::SctpNatTable::getNextEntryNumber ( )
inlinestatic
85 { return nextEntryNumber++; };

◆ getSpecialEntry()

SctpNatEntry * inet::sctp::SctpNatTable::getSpecialEntry ( L3Address  globalAddr,
uint16_t  globalPrt,
L3Address  nattedAddr,
uint16_t  nattedPrt 
)
67 {
68  // linear search is OK because normally we don't have many interfaces and this func is rarely called
69  Enter_Method("getSpecialEntry");
70 
71  for (auto& elem : natEntries) {
72  if ((elem)->getGlobalAddress() == globalAddr && (elem)->getGlobalPort() == globalPrt &&
73  (elem)->getNattedAddress() == nattedAddr && (elem)->getNattedPort() == nattedPrt &&
74  (elem)->getGlobalVTag() == 0)
75  {
76  return elem;
77  }
78  }
79  return nullptr;
80 }

◆ printNatTable()

void inet::sctp::SctpNatTable::printNatTable ( )
123 {
124  for (auto& elem : natEntries) {
125  EV_INFO << "localAddr:" << (elem)->getLocalAddress() << " globalAddr:" << (elem)->getGlobalAddress() << " localPort:" << (elem)->getLocalPort() << " globalPort:" << (elem)->getGlobalPort() << " nattedAddr:" << (elem)->getNattedAddress() << " nattedPort:" << (elem)->getNattedPort() << " localVtag:" << (elem)->getLocalVTag() << " globalVtag:" << (elem)->getGlobalVTag() << "\n";
126  }
127 }

◆ removeEntry()

void inet::sctp::SctpNatTable::removeEntry ( SctpNatEntry entry)
109 {
110  Enter_Method("removeEntry");
111  for (auto i = natEntries.begin(); i != natEntries.end(); ++i)
112  if (((*i)->getGlobalAddress() == entry->getGlobalAddress() && (*i)->getGlobalPort() == entry->getGlobalPort() &&
113  (*i)->getLocalPort() == entry->getLocalPort() && (*i)->getLocalVTag() == entry->getLocalVTag())
114  || (((*i)->getLocalAddress() == entry->getGlobalAddress() && (*i)->getLocalPort() == entry->getGlobalPort() &&
115  (*i)->getGlobalPort() == entry->getLocalPort() && (*i)->getGlobalVTag() == entry->getLocalVTag())))
116  {
117  natEntries.erase(i);
118  return;
119  }
120 }

Member Data Documentation

◆ natEntries

◆ nextEntryNumber

uint32_t inet::sctp::SctpNatTable::nextEntryNumber = 0
static

The documentation for this class was generated from the following files:
inet::sctp::SctpNatTable::natEntries
SctpNatEntryTable natEntries
Definition: SctpNatTable.h:61
inet::sctp::SctpNatTable::nextEntryNumber
static uint32_t nextEntryNumber
Definition: SctpNatTable.h:67
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71