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 srcPrt, L3Address destAddr, uint16 destPrt, uint32 globalVtag)
 
SCTPNatEntrygetEntry (L3Address globalAddr, uint16 globalPrt, L3Address nattedAddr, uint16 nattedPrt, uint32 localVtag)
 
SCTPNatEntrygetSpecialEntry (L3Address globalAddr, uint16 globalPrt, L3Address nattedAddr, uint16 nattedPrt)
 
SCTPNatEntrygetLocalInitEntry (L3Address globalAddr, uint16 localPrt, uint16 globalPrt)
 
SCTPNatEntrygetLocalEntry (L3Address globalAddr, uint16 localPrt, uint16 globalPrt, uint32 localVtag)
 
void removeEntry (SCTPNatEntry *entry)
 
void printNatTable ()
 

Static Public Member Functions

static uint32 getNextEntryNumber ()
 

Public Attributes

SCTPNatEntryTable natEntries
 

Static Public Attributes

static uint32 nextEntryNumber = 0
 

Member Typedef Documentation

Constructor & Destructor Documentation

inet::sctp::SCTPNatTable::SCTPNatTable ( )
39 {
40 }
inet::sctp::SCTPNatTable::~SCTPNatTable ( )
43 {
44  for (auto & elem : natEntries)
45  delete(elem);
46  natEntries.clear();
47 }
SCTPNatEntryTable natEntries
Definition: SCTPNatTable.h:74

Member Function Documentation

SCTPNatEntry * inet::sctp::SCTPNatTable::findNatEntry ( L3Address  srcAddr,
uint16  srcPrt,
L3Address  destAddr,
uint16  destPrt,
uint32  globalVtag 
)

Referenced by inet::sctp::SCTPNatHook::datagramForwardHook().

50 {
51  // linear search is OK because normally we don't have many interfaces and this func is rarely called
52  Enter_Method_Silent();
53  for (auto & elem : natEntries)
54  if ((elem)->getLocalAddress() == srcAddr && (elem)->getLocalPort() == srcPrt &&
55  (elem)->getGlobalAddress() == destAddr && (elem)->getGlobalPort() == destPrt && (elem)->getGlobalVTag() == globalVtag)
56  {
57  return elem;
58  }
59  return nullptr;
60 }
SCTPNatEntryTable natEntries
Definition: SCTPNatTable.h:74
SCTPNatEntry * inet::sctp::SCTPNatTable::getEntry ( L3Address  globalAddr,
uint16  globalPrt,
L3Address  nattedAddr,
uint16  nattedPrt,
uint32  localVtag 
)

Referenced by inet::sctp::SCTPNatHook::datagramPreRoutingHook().

63 {
64  // linear search is OK because normally we don't have many interfaces and this func is rarely called
65  Enter_Method_Silent();
66  for (auto & elem : natEntries)
67  if ((elem)->getGlobalAddress() == globalAddr && (elem)->getGlobalPort() == globalPrt &&
68  (elem)->getNattedAddress() == nattedAddr && (elem)->getNattedPort() == nattedPrt &&
69  (elem)->getLocalVTag() == localVtag)
70  // (*i)->getGlobalVTag()==localVtag)
71  {
72  return elem;
73  }
74  return nullptr;
75 }
SCTPNatEntryTable natEntries
Definition: SCTPNatTable.h:74
SCTPNatEntry * inet::sctp::SCTPNatTable::getLocalEntry ( L3Address  globalAddr,
uint16  localPrt,
uint16  globalPrt,
uint32  localVtag 
)

Referenced by inet::sctp::SCTPNatHook::datagramPreRoutingHook().

107 {
108  // linear search is OK because normally we don't have many interfaces and this func is rarely called
109  Enter_Method_Silent();
110  for (auto & elem : natEntries)
111  if ((elem)->getGlobalAddress() == globalAddr && (elem)->getGlobalPort() == localPrt &&
112  (elem)->getLocalPort() == globalPrt && (elem)->getLocalVTag() == localVtag)
113  {
114  return elem;
115  }
116  return nullptr;
117 }
SCTPNatEntryTable natEntries
Definition: SCTPNatTable.h:74
SCTPNatEntry * inet::sctp::SCTPNatTable::getLocalInitEntry ( L3Address  globalAddr,
uint16  localPrt,
uint16  globalPrt 
)

Referenced by inet::sctp::SCTPNatHook::datagramPreRoutingHook().

94 {
95  // linear search is OK because normally we don't have many interfaces and this func is rarely called
96  Enter_Method_Silent();
97  for (auto & elem : natEntries)
98  if ((elem)->getGlobalAddress() == globalAddr && (elem)->getGlobalPort() == localPrt &&
99  (elem)->getLocalPort() == globalPrt)
100  {
101  return elem;
102  }
103  return nullptr;
104 }
SCTPNatEntryTable natEntries
Definition: SCTPNatTable.h:74
static uint32 inet::sctp::SCTPNatTable::getNextEntryNumber ( )
inlinestatic
98 { return nextEntryNumber++; };
static uint32 nextEntryNumber
Definition: SCTPNatTable.h:80
SCTPNatEntry * inet::sctp::SCTPNatTable::getSpecialEntry ( L3Address  globalAddr,
uint16  globalPrt,
L3Address  nattedAddr,
uint16  nattedPrt 
)

Referenced by inet::sctp::SCTPNatHook::datagramPreRoutingHook().

78 {
79  // linear search is OK because normally we don't have many interfaces and this func is rarely called
80  Enter_Method_Silent();
81 
82  for (auto & elem : natEntries) {
83  if ((elem)->getGlobalAddress() == globalAddr && (elem)->getGlobalPort() == globalPrt &&
84  (elem)->getNattedAddress() == nattedAddr && (elem)->getNattedPort() == nattedPrt &&
85  (elem)->getGlobalVTag() == 0)
86  {
87  return elem;
88  }
89  }
90  return nullptr;
91 }
SCTPNatEntryTable natEntries
Definition: SCTPNatTable.h:74
void inet::sctp::SCTPNatTable::printNatTable ( )

Referenced by inet::sctp::SCTPNatHook::datagramForwardHook(), and inet::sctp::SCTPNatHook::datagramPreRoutingHook().

134 {
135  for (auto & elem : natEntries) {
136  EV << "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";
137  }
138 }
SCTPNatEntryTable natEntries
Definition: SCTPNatTable.h:74
void inet::sctp::SCTPNatTable::removeEntry ( SCTPNatEntry entry)
120 {
121  Enter_Method_Silent();
122  for (auto i = natEntries.begin(); i != natEntries.end(); ++i)
123  if (((*i)->getGlobalAddress() == entry->getGlobalAddress() && (*i)->getGlobalPort() == entry->getGlobalPort() &&
124  (*i)->getLocalPort() == entry->getLocalPort() && (*i)->getLocalVTag() == entry->getLocalVTag())
125  || (((*i)->getLocalAddress() == entry->getGlobalAddress() && (*i)->getLocalPort() == entry->getGlobalPort() &&
126  (*i)->getGlobalPort() == entry->getLocalPort() && (*i)->getGlobalVTag() == entry->getLocalVTag())))
127  {
128  natEntries.erase(i);
129  return;
130  }
131 }
SCTPNatEntryTable natEntries
Definition: SCTPNatTable.h:74

Member Data Documentation

uint32 inet::sctp::SCTPNatTable::nextEntryNumber = 0
static

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