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

Small utility class for managing a large number of SCTPSocket objects. More...

#include <SCTPSocketMap.h>

Public Member Functions

 SCTPSocketMap ()
 Constructor. More...
 
 ~SCTPSocketMap ()
 Destructor. More...
 
SCTPSocketfindSocketFor (cMessage *msg)
 Finds the socket (by connId) for the given message. More...
 
void addSocket (SCTPSocket *socket)
 Registers the given socket. More...
 
SCTPSocketremoveSocket (SCTPSocket *socket)
 Removes the given socket from the data structure. More...
 
unsigned int size ()
 Returns the number of sockets stored. More...
 
void deleteSockets ()
 Deletes the socket objects. More...
 

Protected Types

typedef std::map< int, SCTPSocket * > SocketMap
 

Protected Attributes

SocketMap socketMap
 

Detailed Description

Small utility class for managing a large number of SCTPSocket objects.

Member Typedef Documentation

typedef std::map<int, SCTPSocket *> inet::SCTPSocketMap::SocketMap
protected

Constructor & Destructor Documentation

inet::SCTPSocketMap::SCTPSocketMap ( )
inline

Constructor.

45 {}
inet::SCTPSocketMap::~SCTPSocketMap ( )
inline

Destructor.

Does NOT delete the SCTPSocket objects.

50 {}

Member Function Documentation

void inet::SCTPSocketMap::addSocket ( SCTPSocket socket)

Registers the given socket.

Should not be called multiple times for one socket object.

40 {
41  ASSERT(socketMap.find(socket->getConnectionId()) == socketMap.end());
42  socketMap[socket->getConnectionId()] = socket;
43 }
SocketMap socketMap
Definition: SCTPSocketMap.h:39
void inet::SCTPSocketMap::deleteSockets ( )

Deletes the socket objects.

54 {
55  for (auto & elem : socketMap)
56  delete elem.second;
57  socketMap.clear();
58 }
SocketMap socketMap
Definition: SCTPSocketMap.h:39
SCTPSocket * inet::SCTPSocketMap::findSocketFor ( cMessage *  msg)

Finds the socket (by connId) for the given message.

The message must have arrived from SCTP, and must contain a SCTPCommand control info object. The method returns nullptr if the socket was not found, and throws an error if the message doesn't contain a SCTPCommand.

26 {
27  SCTPCommand *ind = dynamic_cast<SCTPCommand *>(msg->getControlInfo());
28  if (!ind)
29  throw cRuntimeError("SCTPSocketMap: findSocketFor(): no SCTPCommand control info in message (not from SCTP?)");
30 
31  for (auto & elem : socketMap) {
32  if (elem.second->belongsToSocket(msg)) {
33  return elem.second;
34  }
35  }
36  return nullptr;
37 }
SocketMap socketMap
Definition: SCTPSocketMap.h:39
SCTPSocket * inet::SCTPSocketMap::removeSocket ( SCTPSocket socket)

Removes the given socket from the data structure.

46 {
47  auto i = socketMap.find(socket->getConnectionId());
48  if (i != socketMap.end())
49  socketMap.erase(i);
50  return socket;
51 }
SocketMap socketMap
Definition: SCTPSocketMap.h:39
unsigned int inet::SCTPSocketMap::size ( )
inline

Returns the number of sockets stored.

75 { return socketMap.size(); }
SocketMap socketMap
Definition: SCTPSocketMap.h:39

Member Data Documentation

SocketMap inet::SCTPSocketMap::socketMap
protected

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