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

#include <SCTPSocket.h>

Classes

class  CallbackInterface
 Abstract base class for your callback objects. More...
 

Public Types

enum  State {
  NOT_BOUND, CLOSED, LISTENING, CONNECTING,
  CONNECTED, PEER_CLOSED, LOCALLY_CLOSED, SOCKERROR
}
 

Public Member Functions

 SCTPSocket (bool type=true)
 Constructor. More...
 
 SCTPSocket (cMessage *msg)
 Constructor, to be used with forked sockets (see listen()). More...
 
 ~SCTPSocket ()
 Destructor. More...
 
int getConnectionId () const
 Returns the internal connection Id. More...
 
int getState ()
 Returns the socket state, one of NOT_BOUND, CLOSED, LISTENING, CONNECTING, CONNECTED, etc. More...
 
void setState (int state)
 
Getter functions
AddressVector getLocalAddresses ()
 
int getLocalPort ()
 
AddressVector getRemoteAddresses ()
 
int getRemotePort ()
 
L3Address getRemoteAddr ()
 
Opening and closing connections, sending data
void setOutputGate (cGate *toSctp)
 Sets the gate on which to send to SCTP. More...
 
void setOutboundStreams (int streams)
 Setter and getter methods for socket and API Parameters. More...
 
void setInboundStreams (int streams)
 
void setAppLimited (bool option)
 
void setStreamReset (int option)
 
void setStreamPriority (uint32 stream, uint32 priority)
 
void setMaxInitRetrans (int option)
 
void setMaxInitRetransTimeout (int option)
 
void setRtoInitial (double option)
 
void setRtoMin (double option)
 
void setRtoMax (double option)
 
void setSackFrequency (int option)
 
void setSackPeriod (double option)
 
void setMaxBurst (int option)
 
void setFragPoint (int option)
 
void setNagle (int option)
 
void setPathMaxRetrans (int option)
 
void setEnableHeartbeats (bool option)
 
void setHbInterval (double option)
 
void setRtoInfo (double initial, double max, double min)
 
void setAssocMaxRtx (int option)
 
void setUserOptions (void *msg)
 
int getOutboundStreams ()
 
int getInboundStreams ()
 
bool getStreamReset ()
 
int getLastStream ()
 
double getRtoInitial ()
 
int getMaxInitRetransTimeout ()
 
int getMaxInitRetrans ()
 
int getMaxBurst ()
 
int getFragPoint ()
 
int getAssocMaxRtx ()
 
void getSocketOptions ()
 
void bind (int localPort)
 Bind the socket to a local port number. More...
 
void bind (L3Address localAddr, int localPort)
 Bind the socket to a local port number and IP address (useful with multi-homing). More...
 
void bindx (AddressVector localAddr, int localPort)
 
void addAddress (L3Address addr)
 
void listen (bool fork=true, bool streamReset=false, uint32 requests=0, uint32 messagesToPush=0)
 Initiates passive OPEN. More...
 
void listen (uint32 requests=0, bool fork=false, uint32 messagesToPush=0, bool options=false, int32 fd=-1)
 
void connect (L3Address remoteAddress, int32 remotePort, bool streamReset=false, int32 prMethod=0, uint32 numRequests=0)
 Active OPEN to the given remote socket. More...
 
void connect (int32 fd, L3Address remoteAddress, int32 remotePort, uint32 numRequests, bool options=false)
 
void connectx (AddressVector remoteAddresses, int32 remotePort, bool streamReset=false, int32 prMethod=0, uint32 numRequests=0)
 Active OPEN to the given remote socket. More...
 
void accept (int32 assocId, int32 fd)
 
void send (SCTPSimpleMessage *msg, int prMethod=0, double prValue=0.0, int32 streamId=0, bool last=true, bool primary=true)
 Send data message. More...
 
void sendMsg (cMessage *cmsg)
 Send data message (provided within control message). More...
 
void sendNotification (cMessage *msg)
 Send notification. More...
 
void sendRequest (cMessage *msg)
 Send request. More...
 
void close (int id=-1)
 Closes the local end of the connection. More...
 
void abort ()
 Aborts the association. More...
 
void shutdown (int id=-1)
 
void requestStatus ()
 Causes SCTP to reply with a fresh SCTPStatusInfo, attached to a dummy message as controlInfo(). More...
 

Static Public Member Functions

static int32 getNewAssocId ()
 Generates a new integer, to be used as assocId. More...
 
static const char * stateName (int state)
 Returns name of socket state code returned by state(). More...
 

Public Attributes

cGate * gateToSctp
 

Protected Member Functions

void sendToSCTP (cMessage *msg)
 

Protected Attributes

int assocId
 
int sockstate
 
bool oneToOne
 
bool appLimited
 
L3Address localAddr
 
AddressVector localAddresses
 
int localPrt
 
L3Address remoteAddr
 
AddressVector remoteAddresses
 
int remotePrt
 
int fsmStatus
 
int lastStream
 
SocketOptionssOptions
 
AppSocketOptionsappOptions
 
CallbackInterfacecb
 
void * yourPtr
 

Static Protected Attributes

static int32 nextAssocId = 0
 

Handling of messages arriving from SCTP

bool belongsToSocket (cMessage *msg)
 Returns true if the message belongs to this socket instance (message has a SCTPCommand as controlInfo(), and the assocId in it matches that of the socket.) More...
 
void setCallbackObject (CallbackInterface *cb, void *yourPtr=nullptr)
 Sets a callback object, to be used with processMessage(). More...
 
void processMessage (cMessage *msg)
 Examines the message (which should have arrived from SCTPMain), updates socket state, and if there is a callback object installed (see setCallbackObject(), class CallbackInterface), dispatches to the appropriate method of it with the same yourPtr that you gave in the setCallbackObject() call. More...
 
static bool belongsToAnySCTPSocket (cMessage *msg)
 Returns true if the message belongs to any SCTPSocket instance. More...
 

Member Enumeration Documentation

Enumerator
NOT_BOUND 
CLOSED 
LISTENING 
CONNECTING 
CONNECTED 
PEER_CLOSED 
LOCALLY_CLOSED 
SOCKERROR 
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87

Constructor & Destructor Documentation

inet::SCTPSocket::SCTPSocket ( bool  type = true)

Constructor.

The connectionId() method returns a valid Id right after constructor call.

29 {
31  localPrt = remotePrt = 0;
32  fsmStatus = -1;
33  cb = nullptr;
34  yourPtr = nullptr;
35  gateToSctp = nullptr;
36  lastStream = -1;
37  oneToOne = type;
38  sOptions = new SocketOptions();
39  appOptions = new AppSocketOptions();
43  appLimited = false;
44  if (oneToOne)
46  else
47  assocId = 0;
48  EV_INFO << "sockstate=" << stateName(sockstate) << "\n";
49 }
int lastStream
Definition: SCTPSocket.h:104
Definition: SCTPSocket.h:87
cGate * gateToSctp
Definition: SCTPSocket.h:117
void * yourPtr
Definition: SCTPSocket.h:111
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
static int32 getNewAssocId()
Generates a new integer, to be used as assocId.
Definition: SCTPSocket.h:147
int fsmStatus
Definition: SCTPSocket.h:103
int remotePrt
Definition: SCTPSocket.h:102
CallbackInterface * cb
Definition: SCTPSocket.h:110
bool oneToOne
Definition: SCTPSocket.h:93
static const char * stateName(int state)
Returns name of socket state code returned by state().
Definition: SCTPSocket.cc:99
bool streamReset
Definition: SCTPSocket.h:53
int localPrt
Definition: SCTPSocket.h:99
int outboundStreams
Definition: SCTPSocket.h:52
SocketOptions * sOptions
Definition: SCTPSocket.h:107
int assocId
Definition: SCTPSocket.h:90
int inboundStreams
Definition: SCTPSocket.h:51
int sockstate
Definition: SCTPSocket.h:92
bool appLimited
Definition: SCTPSocket.h:94
inet::SCTPSocket::SCTPSocket ( cMessage *  msg)

Constructor, to be used with forked sockets (see listen()).

The assocId will be picked up from the message: it should have arrived from SCTPMain and contain SCTPCommmand control info.

52 {
53  SCTPCommand *ind = dynamic_cast<SCTPCommand *>(msg->getControlInfo());
54 
55  if (!ind)
56  throw cRuntimeError("SCTPSocket::SCTPSocket(cMessage *): no SCTPCommand control info in message (not from SCTP?)");
57 
58  assocId = ind->getAssocId();
60 
61  localPrt = remotePrt = -1;
62  sOptions = new SocketOptions();
63  appOptions = new AppSocketOptions();
66  appLimited = false;
67  cb = nullptr;
68  yourPtr = nullptr;
69  gateToSctp = nullptr;
70  lastStream = -1;
71  oneToOne = true;
72 
73  if (msg->getKind() == SCTP_I_ESTABLISHED) {
74  // management of stockstate is left to processMessage() so we always
75  // set it to CONNECTED in the ctor, whatever SCTP_I_xxx arrives.
76  // However, for convenience we extract SCTPConnectInfo already here, so that
77  // remote address/port can be read already after the ctor call.
78 
79  SCTPConnectInfo *connectInfo = check_and_cast<SCTPConnectInfo *>(msg->getControlInfo());
80  localAddr = connectInfo->getLocalAddr();
81  remoteAddr = connectInfo->getRemoteAddr();
82  localPrt = connectInfo->getLocalPort();
83  remotePrt = connectInfo->getRemotePort();
84  fsmStatus = connectInfo->getStatus();
85  appOptions->inboundStreams = connectInfo->getInboundStreams();
86  appOptions->outboundStreams = connectInfo->getOutboundStreams();
87  }
88 }
int lastStream
Definition: SCTPSocket.h:104
cGate * gateToSctp
Definition: SCTPSocket.h:117
void * yourPtr
Definition: SCTPSocket.h:111
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
int fsmStatus
Definition: SCTPSocket.h:103
int remotePrt
Definition: SCTPSocket.h:102
L3Address remoteAddr
Definition: SCTPSocket.h:100
CallbackInterface * cb
Definition: SCTPSocket.h:110
bool oneToOne
Definition: SCTPSocket.h:93
L3Address localAddr
Definition: SCTPSocket.h:96
Definition: SCTPCommand.h:65
int localPrt
Definition: SCTPSocket.h:99
int outboundStreams
Definition: SCTPSocket.h:52
SocketOptions * sOptions
Definition: SCTPSocket.h:107
int assocId
Definition: SCTPSocket.h:90
int inboundStreams
Definition: SCTPSocket.h:51
Definition: SCTPSocket.h:87
int sockstate
Definition: SCTPSocket.h:92
bool appLimited
Definition: SCTPSocket.h:94
inet::SCTPSocket::~SCTPSocket ( )

Destructor.

91 {
92  delete sOptions;
93  delete appOptions;
94  if (cb) {
96  }
97 }
void * yourPtr
Definition: SCTPSocket.h:111
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
CallbackInterface * cb
Definition: SCTPSocket.h:110
virtual void socketDeleted(int assocId, void *yourPtr)
Definition: SCTPSocket.h:78
SocketOptions * sOptions
Definition: SCTPSocket.h:107
int assocId
Definition: SCTPSocket.h:90

Member Function Documentation

void inet::SCTPSocket::abort ( )

Aborts the association.

Referenced by inet::SCTPClient::handleTimer(), and inet::NetPerfMeter::successfullyEstablishedConnection().

440 {
441  if (sockstate != NOT_BOUND && sockstate != CLOSED && sockstate != SOCKERROR) {
442  cMessage *msg = new cMessage("ABORT", SCTP_C_ABORT);
443  SCTPCommand *cmd = new SCTPCommand();
444  cmd->setAssocId(assocId);
445  msg->setControlInfo(cmd);
446  sendToSCTP(msg);
447  }
448  sockstate = CLOSED;
449 }
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPCommand.h:35
Definition: SCTPSocket.h:87
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
int assocId
Definition: SCTPSocket.h:90
int sockstate
Definition: SCTPSocket.h:92
void inet::SCTPSocket::accept ( int32  assocId,
int32  fd 
)
323 {
324  SCTPCommand *cmd = new SCTPCommand();
325  cmd->setLocalPort(localPrt);
326  cmd->setRemoteAddr(remoteAddr);
327  cmd->setRemotePort(remotePrt);
328  cmd->setAssocId(assId);
329  cmd->setFd(fd);
330  cMessage *cmsg = new cMessage("Accept", SCTP_C_ACCEPT);
331  cmsg->setControlInfo(cmd);
332  sendToSCTP(cmsg);
333 }
int remotePrt
Definition: SCTPSocket.h:102
L3Address remoteAddr
Definition: SCTPSocket.h:100
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
int localPrt
Definition: SCTPSocket.h:99
Definition: SCTPCommand.h:52
void inet::SCTPSocket::addAddress ( L3Address  addr)
160 {
161  EV_INFO << "add address " << addr << "\n";
162  localAddresses.push_back(addr);
163 }
AddressVector localAddresses
Definition: SCTPSocket.h:97
bool inet::SCTPSocket::belongsToAnySCTPSocket ( cMessage *  msg)
static

Returns true if the message belongs to any SCTPSocket instance.

(This basically checks if the message has a SCTPCommand attached to it as controlInfo().)

469 {
470  return dynamic_cast<SCTPCommand *>(msg->getControlInfo());
471 }
bool inet::SCTPSocket::belongsToSocket ( cMessage *  msg)

Returns true if the message belongs to this socket instance (message has a SCTPCommand as controlInfo(), and the assocId in it matches that of the socket.)

461 {
462  bool ret = dynamic_cast<SCTPCommand *>(msg->getControlInfo()) &&
463  ((SCTPCommand *)(msg->getControlInfo()))->getAssocId() == assocId;
464  EV_INFO << "assoc=" << ((SCTPCommand *)(msg->getControlInfo()))->getAssocId() << "\n";
465  return ret;
466 }
int assocId
Definition: SCTPSocket.h:90
void inet::SCTPSocket::bind ( int  localPort)

Bind the socket to a local port number.

Referenced by connect(), inet::NetPerfMeter::createAndBindSocket(), inet::SCTPServer::initialize(), inet::SCTPClient::initialize(), and inet::SCTPPeer::initialize().

137 {
138  if (sockstate != NOT_BOUND)
139  throw cRuntimeError("SCTPSocket::bind(): socket already bound");
140 
141  localAddresses.push_back(L3Address()); // Unspecified address
142  localPrt = lPort;
143  sockstate = CLOSED;
145 }
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
AddressVector localAddresses
Definition: SCTPSocket.h:97
void getSocketOptions()
Definition: SCTPSocket.cc:126
int localPrt
Definition: SCTPSocket.h:99
int sockstate
Definition: SCTPSocket.h:92
void inet::SCTPSocket::bind ( L3Address  localAddr,
int  localPort 
)

Bind the socket to a local port number and IP address (useful with multi-homing).

148 {
149  EV_INFO << "bind address " << lAddr << "\n";
150  if (sockstate != NOT_BOUND)
151  throw cRuntimeError("SCTPSocket::bind(): socket already bound");
152 
153  localAddresses.push_back(lAddr);
154  localPrt = lPort;
155  sockstate = CLOSED;
157 }
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
AddressVector localAddresses
Definition: SCTPSocket.h:97
void getSocketOptions()
Definition: SCTPSocket.cc:126
int localPrt
Definition: SCTPSocket.h:99
int sockstate
Definition: SCTPSocket.h:92
void inet::SCTPSocket::bindx ( AddressVector  localAddr,
int  localPort 
)

Referenced by inet::SCTPServer::initialize(), inet::SCTPClient::initialize(), and inet::SCTPPeer::initialize().

166 {
167  L3Address lAddr;
168  for (auto & lAddresse : lAddresses) {
169  EV << "bindx: bind address " << (lAddresse) << "\n";
170  localAddresses.push_back((lAddresse));
171  }
172  localPrt = lPort;
173  sockstate = CLOSED;
175 }
Definition: SCTPSocket.h:87
AddressVector localAddresses
Definition: SCTPSocket.h:97
void getSocketOptions()
Definition: SCTPSocket.cc:126
int localPrt
Definition: SCTPSocket.h:99
int sockstate
Definition: SCTPSocket.h:92
void inet::SCTPSocket::close ( int  id = -1)

Closes the local end of the connection.

With SCTP, a CLOSE operation means "I have no more data to send", and thus results in a one-way connection until the remote SCTP closes too (or the FIN_WAIT_1 timeout expires)

Referenced by inet::SCTPClient::close(), inet::NetPerfMeter::handleTimer(), inet::SCTPPeer::socketDataArrived(), inet::SCTPPeer::socketPeerClosed(), and inet::NetPerfMeter::teardownConnection().

411 {
412  EV_INFO << "SCTPSocket::close()\n";
413 
414  cMessage *msg = new cMessage("CLOSE", SCTP_C_CLOSE);
415  SCTPCommand *cmd = new SCTPCommand();
416  if (id == -1)
417  cmd->setAssocId(assocId);
418  else
419  cmd->setFd(id);
420  msg->setControlInfo(cmd);
421  sendToSCTP(msg);
423 }
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
Definition: SCTPCommand.h:34
int assocId
Definition: SCTPSocket.h:90
Definition: SCTPSocket.h:87
int sockstate
Definition: SCTPSocket.h:92
void inet::SCTPSocket::connect ( L3Address  remoteAddress,
int32  remotePort,
bool  streamReset = false,
int32  prMethod = 0,
uint32  numRequests = 0 
)

Active OPEN to the given remote socket.

Referenced by inet::SCTPClient::connect(), inet::SCTPPeer::connect(), and connectx().

238 {
239  EV_INFO << "Socket connect. Assoc=" << assocId << ", sockstate=" << stateName(sockstate) << "\n";
240 
241  if (oneToOne && sockstate == NOT_BOUND)
242  bind(0);
243 
244  if (oneToOne && sockstate != CLOSED)
245  throw cRuntimeError("SCTPSocket::connect(): connect() or listen() already called");
246 
247  if (!oneToOne && sockstate != LISTENING)
248  throw cRuntimeError("SCTPSocket::connect(): one-to-many style socket must be listening");
249 
250  remoteAddr = remoteAddress;
251  remotePrt = remotePort;
252 
253  SCTPOpenCommand *openCmd = new SCTPOpenCommand();
254  if (oneToOne)
255  openCmd->setAssocId(assocId);
256  else
257  openCmd->setAssocId(getNewAssocId());
258  EV_INFO << "Socket connect. Assoc=" << openCmd->getAssocId() << ", sockstate=" << stateName(sockstate) << "\n";
259  openCmd->setLocalAddresses(localAddresses);
260  openCmd->setLocalPort(localPrt);
261  openCmd->setRemoteAddr(remoteAddr);
262  openCmd->setRemotePort(remotePrt);
263  openCmd->setOutboundStreams(appOptions->outboundStreams);
264  openCmd->setInboundStreams(appOptions->inboundStreams);
265  appOptions->streamReset = streamReset;
266  openCmd->setNumRequests(numRequests);
267  openCmd->setPrMethod(prMethod);
268  openCmd->setStreamReset(streamReset);
269 
270  cMessage *cmsg = new cMessage("Associate", SCTP_C_ASSOCIATE);
271  cmsg->setControlInfo(openCmd);
272  sendToSCTP(cmsg);
273 
274  if (oneToOne)
276 }
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
static int32 getNewAssocId()
Generates a new integer, to be used as assocId.
Definition: SCTPSocket.h:147
AddressVector localAddresses
Definition: SCTPSocket.h:97
int remotePrt
Definition: SCTPSocket.h:102
L3Address remoteAddr
Definition: SCTPSocket.h:100
bool oneToOne
Definition: SCTPSocket.h:93
Definition: SCTPSocket.h:87
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
void bind(int localPort)
Bind the socket to a local port number.
Definition: SCTPSocket.cc:136
static const char * stateName(int state)
Returns name of socket state code returned by state().
Definition: SCTPSocket.cc:99
Definition: SCTPCommand.h:31
bool streamReset
Definition: SCTPSocket.h:53
int localPrt
Definition: SCTPSocket.h:99
int outboundStreams
Definition: SCTPSocket.h:52
int assocId
Definition: SCTPSocket.h:90
int inboundStreams
Definition: SCTPSocket.h:51
Definition: SCTPSocket.h:87
int sockstate
Definition: SCTPSocket.h:92
void inet::SCTPSocket::connect ( int32  fd,
L3Address  remoteAddress,
int32  remotePort,
uint32  numRequests,
bool  options = false 
)
279 {
280  EV_INFO << "Socket connect. Assoc=" << assocId << ", sockstate=" << stateName(sockstate) << "\n";
281 
282  if (oneToOne && sockstate == NOT_BOUND)
283  bind(0);
284 
285  if (oneToOne && sockstate != CLOSED)
286  throw cRuntimeError("SCTPSocket::connect(): connect() or listen() already called");
287 
288  if (!oneToOne && sockstate != LISTENING)
289  throw cRuntimeError("SCTPSocket::connect(): one-to-many style socket must be listening");
290 
291  remoteAddr = remoteAddress;
292  remotePrt = remotePort;
293 
294  SCTPOpenCommand *openCmd = new SCTPOpenCommand();
295  if (oneToOne)
296  openCmd->setAssocId(assocId);
297  else
298  openCmd->setAssocId(getNewAssocId());
299  EV_INFO << "Socket connect. Assoc=" << openCmd->getAssocId() << ", sockstate=" << stateName(sockstate) << "\n";
300  openCmd->setLocalAddresses(localAddresses);
301  openCmd->setLocalPort(localPrt);
302  openCmd->setRemoteAddr(remoteAddr);
303  openCmd->setRemotePort(remotePrt);
304  openCmd->setOutboundStreams(appOptions->outboundStreams);
305  openCmd->setInboundStreams(appOptions->inboundStreams);
306  openCmd->setStreamReset(appOptions->streamReset);
307  openCmd->setNumRequests(numRequests);
308  openCmd->setFd(fd);
309  openCmd->setAppLimited(appLimited);
310 
311  cMessage *cmsg = new cMessage("Associate", SCTP_C_ASSOCIATE);
312  cmsg->setControlInfo(openCmd);
313  if (options) {
314  cmsg->setContextPointer((void*) sOptions);
315  }
316  sendToSCTP(cmsg);
317 
318  if (oneToOne)
320 }
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
static int32 getNewAssocId()
Generates a new integer, to be used as assocId.
Definition: SCTPSocket.h:147
AddressVector localAddresses
Definition: SCTPSocket.h:97
int remotePrt
Definition: SCTPSocket.h:102
L3Address remoteAddr
Definition: SCTPSocket.h:100
bool oneToOne
Definition: SCTPSocket.h:93
Definition: SCTPSocket.h:87
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
void bind(int localPort)
Bind the socket to a local port number.
Definition: SCTPSocket.cc:136
static const char * stateName(int state)
Returns name of socket state code returned by state().
Definition: SCTPSocket.cc:99
Definition: SCTPCommand.h:31
bool streamReset
Definition: SCTPSocket.h:53
int localPrt
Definition: SCTPSocket.h:99
int outboundStreams
Definition: SCTPSocket.h:52
SocketOptions * sOptions
Definition: SCTPSocket.h:107
int assocId
Definition: SCTPSocket.h:90
int inboundStreams
Definition: SCTPSocket.h:51
Definition: SCTPSocket.h:87
int sockstate
Definition: SCTPSocket.h:92
bool appLimited
Definition: SCTPSocket.h:94
void inet::SCTPSocket::connectx ( AddressVector  remoteAddresses,
int32  remotePort,
bool  streamReset = false,
int32  prMethod = 0,
uint32  numRequests = 0 
)

Active OPEN to the given remote socket.

The current implementation just calls connect() with the first address of the given list. This behaviour may be improved in the future.

Referenced by inet::NetPerfMeter::establishConnection().

336 {
337  EV_INFO << "Socket connectx. sockstate=" << stateName(sockstate) << "\n";
338  remoteAddresses = remoteAddressList;
339  connect(remoteAddressList.front(), remotePort, streamReset, prMethod, numRequests);
340 }
void connect(L3Address remoteAddress, int32 remotePort, bool streamReset=false, int32 prMethod=0, uint32 numRequests=0)
Active OPEN to the given remote socket.
Definition: SCTPSocket.cc:237
static const char * stateName(int state)
Returns name of socket state code returned by state().
Definition: SCTPSocket.cc:99
AddressVector remoteAddresses
Definition: SCTPSocket.h:101
int sockstate
Definition: SCTPSocket.h:92
int inet::SCTPSocket::getAssocMaxRtx ( )
inline
214 { return sOptions->assocMaxRtx; };
int assocMaxRtx
Definition: SCTPSocket.h:47
SocketOptions * sOptions
Definition: SCTPSocket.h:107
int inet::SCTPSocket::getConnectionId ( ) const
inline

Returns the internal connection Id.

SCTP uses the (gate index, assocId) pair to identify the connection when it receives a command from the application (or SCTPSocket).

Referenced by inet::SCTPSocketMap::addSocket(), inet::SCTPPeer::connect(), inet::SCTPSocketMap::removeSocket(), inet::SCTPClient::sendQueueRequest(), inet::SCTPPeer::sendQueueRequest(), inet::SCTPClient::sendStreamResetNotification(), and inet::SCTPClient::setPrimaryPath().

141 { return assocId; }
int assocId
Definition: SCTPSocket.h:90
int inet::SCTPSocket::getFragPoint ( )
inline
213 { return sOptions->fragPoint; };
int fragPoint
Definition: SCTPSocket.h:42
SocketOptions * sOptions
Definition: SCTPSocket.h:107
int inet::SCTPSocket::getInboundStreams ( )
inline
206 { return appOptions->inboundStreams; };
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
int inboundStreams
Definition: SCTPSocket.h:51
int inet::SCTPSocket::getLastStream ( )
inline
208 { return lastStream; };
int lastStream
Definition: SCTPSocket.h:104
AddressVector inet::SCTPSocket::getLocalAddresses ( )
inline
163 { return localAddresses; }
AddressVector localAddresses
Definition: SCTPSocket.h:97
int inet::SCTPSocket::getLocalPort ( )
inline
164 { return localPrt; }
int localPrt
Definition: SCTPSocket.h:99
int inet::SCTPSocket::getMaxBurst ( )
inline
212 { return sOptions->maxBurst; };
int maxBurst
Definition: SCTPSocket.h:41
SocketOptions * sOptions
Definition: SCTPSocket.h:107
int inet::SCTPSocket::getMaxInitRetrans ( )
inline
211 { return sOptions->maxInitRetrans; };
int maxInitRetrans
Definition: SCTPSocket.h:34
SocketOptions * sOptions
Definition: SCTPSocket.h:107
int inet::SCTPSocket::getMaxInitRetransTimeout ( )
inline
210 { return sOptions->maxInitRetransTimeout; };
int maxInitRetransTimeout
Definition: SCTPSocket.h:35
SocketOptions * sOptions
Definition: SCTPSocket.h:107
static int32 inet::SCTPSocket::getNewAssocId ( )
inlinestatic

Generates a new integer, to be used as assocId.

(assocId is part of the key which associates connections with their apps).

Referenced by inet::sctp::SCTP::addForkedAssociation(), connect(), listen(), and SCTPSocket().

147 { return ++nextAssocId; }
static int32 nextAssocId
Definition: SCTPSocket.h:91
int inet::SCTPSocket::getOutboundStreams ( )
inline
205 { return appOptions->outboundStreams; };
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
int outboundStreams
Definition: SCTPSocket.h:52
L3Address inet::SCTPSocket::getRemoteAddr ( )
inline

Referenced by inet::SCTPClient::sendStreamResetNotification().

167 { return remoteAddr; }
L3Address remoteAddr
Definition: SCTPSocket.h:100
AddressVector inet::SCTPSocket::getRemoteAddresses ( )
inline
165 { return remoteAddresses; }
AddressVector remoteAddresses
Definition: SCTPSocket.h:101
int inet::SCTPSocket::getRemotePort ( )
inline
166 { return remotePrt; }
int remotePrt
Definition: SCTPSocket.h:102
double inet::SCTPSocket::getRtoInitial ( )
inline
209 { return sOptions->rtoInitial; };
double rtoInitial
Definition: SCTPSocket.h:36
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::getSocketOptions ( )

Referenced by bind(), and bindx().

127 {
128  cPacket* cmsg = new cPacket("GetSocketOptions", SCTP_C_GETSOCKETOPTIONS);
129  SCTPSendInfo *cmd = new SCTPSendInfo("getOptions");
130  cmd->setAssocId(assocId);
131  cmd->setSid(0);
132  cmsg->setControlInfo(cmd);
133  sendToSCTP(cmsg);
134 }
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
Definition: SCTPCommand.h:51
int assocId
Definition: SCTPSocket.h:90
int inet::SCTPSocket::getState ( )
inline

Returns the socket state, one of NOT_BOUND, CLOSED, LISTENING, CONNECTING, CONNECTED, etc.

Messages received from SCTP must be routed through processMessage() in order to keep socket state up-to-date.

Referenced by inet::SCTPPeer::handleMessage(), inet::SCTPClient::socketPeerClosed(), and inet::SCTPPeer::socketPeerClosed().

154 { return sockstate; }
int sockstate
Definition: SCTPSocket.h:92
bool inet::SCTPSocket::getStreamReset ( )
inline
207 { return appOptions->streamReset; }
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
bool streamReset
Definition: SCTPSocket.h:53
void inet::SCTPSocket::listen ( bool  fork = true,
bool  streamReset = false,
uint32  requests = 0,
uint32  messagesToPush = 0 
)

Initiates passive OPEN.

If fork=true, you'll have to create a new SCTPSocket object for each incoming connection, and this socket will keep listening on the port. If fork=false, the first incoming connection will be accepted, and SCTP will refuse subsequent ones. See SCTPOpenCommand documentation (neddoc) for more info.

Referenced by inet::NetPerfMeter::createAndBindSocket(), inet::SCTPServer::initialize(), and inet::SCTPPeer::initialize().

178 {
179  if (sockstate != CLOSED)
180  throw cRuntimeError(sockstate == NOT_BOUND ?
181  "SCTPSocket::listen(): must call bind() before listen()" :
182  "SCTPSocket::listen(): connect() or listen() already called");
183 
184  SCTPOpenCommand *openCmd = new SCTPOpenCommand();
185  openCmd->setLocalAddresses(localAddresses);
186  openCmd->setLocalPort(localPrt);
187  if (oneToOne)
188  openCmd->setAssocId(assocId);
189  else
190  openCmd->setAssocId(getNewAssocId());
191  openCmd->setFork(fork);
192  openCmd->setOutboundStreams(appOptions->outboundStreams);
193  openCmd->setInboundStreams(appOptions->inboundStreams);
194  appOptions->streamReset = reset;
195  openCmd->setNumRequests(requests);
196  openCmd->setStreamReset(reset);
197  openCmd->setMessagesToPush(messagesToPush);
198 
199  EV_INFO << "Assoc " << openCmd->getAssocId() << ": PassiveOPEN to SCTP from SCTPSocket:listen()\n";
200  cMessage *cmsg = new cMessage("PassiveOPEN", SCTP_C_OPEN_PASSIVE);
201  cmsg->setControlInfo(openCmd);
202  sendToSCTP(cmsg);
204 }
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPCommand.h:32
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
static int32 getNewAssocId()
Generates a new integer, to be used as assocId.
Definition: SCTPSocket.h:147
AddressVector localAddresses
Definition: SCTPSocket.h:97
bool oneToOne
Definition: SCTPSocket.h:93
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
bool streamReset
Definition: SCTPSocket.h:53
int localPrt
Definition: SCTPSocket.h:99
int outboundStreams
Definition: SCTPSocket.h:52
int assocId
Definition: SCTPSocket.h:90
int inboundStreams
Definition: SCTPSocket.h:51
Definition: SCTPSocket.h:87
int sockstate
Definition: SCTPSocket.h:92
void inet::SCTPSocket::listen ( uint32  requests = 0,
bool  fork = false,
uint32  messagesToPush = 0,
bool  options = false,
int32  fd = -1 
)
207 {
208  if (sockstate != CLOSED)
209  throw cRuntimeError(sockstate == NOT_BOUND ?
210  "SCTPSocket::listen(): must call bind() before listen()" :
211  "SCTPSocket::listen(): connect() or listen() already called");
212 
213  SCTPOpenCommand *openCmd = new SCTPOpenCommand();
214  openCmd->setLocalAddresses(localAddresses);
215  openCmd->setLocalPort(localPrt);
216  if (oneToOne)
217  openCmd->setAssocId(assocId);
218  else
219  openCmd->setAssocId(getNewAssocId());
220  openCmd->setFork(fork);
221  openCmd->setFd(fd);
222  openCmd->setInboundStreams(appOptions->inboundStreams);
223  openCmd->setOutboundStreams(appOptions->outboundStreams);
224  openCmd->setNumRequests(requests);
225  openCmd->setMessagesToPush(messagesToPush);
226  openCmd->setStreamReset(appOptions->streamReset);
227 
228  EV_INFO << "Assoc " << openCmd->getAssocId() << ": PassiveOPEN to SCTP from SCTPSocket:listen()\n";
229  cMessage *cmsg = new cMessage("PassiveOPEN", SCTP_C_OPEN_PASSIVE);
230  cmsg->setControlInfo(openCmd);
231  if (options)
232  cmsg->setContextPointer((void*) sOptions);
233  sendToSCTP(cmsg);
235 }
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPCommand.h:32
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
static int32 getNewAssocId()
Generates a new integer, to be used as assocId.
Definition: SCTPSocket.h:147
AddressVector localAddresses
Definition: SCTPSocket.h:97
bool oneToOne
Definition: SCTPSocket.h:93
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
bool streamReset
Definition: SCTPSocket.h:53
int localPrt
Definition: SCTPSocket.h:99
int outboundStreams
Definition: SCTPSocket.h:52
SocketOptions * sOptions
Definition: SCTPSocket.h:107
int assocId
Definition: SCTPSocket.h:90
int inboundStreams
Definition: SCTPSocket.h:51
Definition: SCTPSocket.h:87
int sockstate
Definition: SCTPSocket.h:92
void inet::SCTPSocket::processMessage ( cMessage *  msg)

Examines the message (which should have arrived from SCTPMain), updates socket state, and if there is a callback object installed (see setCallbackObject(), class CallbackInterface), dispatches to the appropriate method of it with the same yourPtr that you gave in the setCallbackObject() call.

The method deletes the message, unless (1) there is a callback object installed AND (2) the message is payload (message kind SCTP_I_DATA or SCTP_I_URGENT_DATA) when the responsibility of destruction is on the socketDataArrived() callback method.

IMPORTANT: for performance reasons, this method doesn't check that the message belongs to this socket, i.e. belongsToSocket(msg) would return true!

Referenced by inet::SCTPClient::handleMessage(), and inet::SCTPPeer::handleMessage().

480 {
481  SCTPStatusInfo *status;
482  switch (msg->getKind()) {
483  case SCTP_I_DATA:
484  EV_INFO << "SCTP_I_DATA\n";
485  if (cb) {
486  cb->socketDataArrived(assocId, yourPtr, PK(msg), false);
487  msg = nullptr;
488  }
489  break;
490 
492  EV_INFO << "SCTP_I_NOTIFICATION\n";
493  if (cb) {
495  }
496  break;
497 
498  case SCTP_I_SEND_MSG:
499  if (cb) {
501  }
502  break;
503 
504  case SCTP_I_ESTABLISHED: {
505  if (oneToOne)
507  SCTPConnectInfo *connectInfo = check_and_cast<SCTPConnectInfo *>(msg->removeControlInfo());
508  localAddr = connectInfo->getLocalAddr();
509  remoteAddr = connectInfo->getRemoteAddr();
510  localPrt = connectInfo->getLocalPort();
511  remotePrt = connectInfo->getRemotePort();
512  fsmStatus = connectInfo->getStatus();
513  appOptions->inboundStreams = connectInfo->getInboundStreams();
514  appOptions->outboundStreams = connectInfo->getOutboundStreams();
515 
516  if (cb) {
517  cb->socketEstablished(assocId, yourPtr, connectInfo->getNumMsgs());
518  }
519  delete connectInfo;
520  break;
521  }
522 
523  case SCTP_I_PEER_CLOSED:
524  EV_INFO << "peer closed\n";
525  if (oneToOne)
527 
528  if (cb) {
530  }
531  break;
532 
533  case SCTP_I_ABORT:
534  case SCTP_I_CONN_LOST:
535  case SCTP_I_CLOSED:
536  EV_INFO << "SCTP_I_CLOSED called\n";
537  sockstate = CLOSED;
538  if (cb) {
540  }
541  break;
542 
545  case SCTP_I_TIMED_OUT:
547  if (cb) {
548  cb->socketFailure(assocId, yourPtr, msg->getKind());
549  }
550  break;
551 
552  case SCTP_I_STATUS:
553  status = check_and_cast<SCTPStatusInfo *>(msg->removeControlInfo());
554  if (cb) {
556  }
557  break;
558 
559  case SCTP_I_ABANDONED:
560  if (cb) {
562  }
563  break;
564 
566  EV_INFO << "SCTP_I_SHUTDOWN_RECEIVED\n";
567  if (cb) {
569  }
570  break;
571 
573  if (cb) {
575  }
576  break;
577 
579  SCTPCommand *cmd = check_and_cast<SCTPCommand *>(msg->removeControlInfo());
580  if (cb) {
581  cb->sendqueueAbatedArrived(assocId, cmd->getNumMsgs());
582  }
583  delete cmd;
584  break;
585  }
586 
591  break;
592 
593  case SCTP_I_ADDRESS_ADDED: {
594  SCTPCommand *cmd = check_and_cast<SCTPCommand *>(msg->removeControlInfo());
595  if (cb) {
596  cb->addressAddedArrived(assocId, cmd->getLocalAddr(), remoteAddr);
597  }
598  delete cmd;
599  break;
600  }
601 
602  default:
603  throw cRuntimeError("SCTPSocket::processMessage(): invalid msg kind %d, one of the SCTP_I_xxx constants expected", msg->getKind());
604  }
605 
606  if (msg != nullptr) {
607  delete msg;
608  }
609 }
virtual void addressAddedArrived(int assocId, L3Address localAddr, L3Address remoteAddr)
Definition: SCTPSocket.h:84
Definition: SCTPCommand.h:76
Definition: SCTPCommand.h:80
Definition: SCTPCommand.h:83
virtual void socketClosed(int assocId, void *yourPtr)
Definition: SCTPSocket.h:75
Definition: SCTPSocket.h:87
virtual void sendqueueAbatedArrived(int connId, unsigned long int buffer)
Definition: SCTPSocket.h:83
void * yourPtr
Definition: SCTPSocket.h:111
Definition: SCTPCommand.h:67
virtual void socketStatusArrived(int assocId, void *yourPtr, SCTPStatusInfo *status)
Definition: SCTPSocket.h:77
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
Definition: SCTPCommand.h:81
virtual void socketDataArrived(int assocId, void *yourPtr, cPacket *msg, bool urgent)=0
int fsmStatus
Definition: SCTPSocket.h:103
Definition: SCTPCommand.h:77
int remotePrt
Definition: SCTPSocket.h:102
virtual void sendqueueFullArrived(int connId)
Definition: SCTPSocket.h:82
virtual void msgAbandonedArrived(int assocId)
Definition: SCTPSocket.h:80
L3Address remoteAddr
Definition: SCTPSocket.h:100
virtual void socketDataNotificationArrived(int assocId, void *yourPtr, cPacket *msg)=0
Definition: SCTPCommand.h:79
Definition: SCTPCommand.h:68
CallbackInterface * cb
Definition: SCTPSocket.h:110
bool oneToOne
Definition: SCTPSocket.h:93
Definition: SCTPCommand.h:73
virtual void sendRequestArrived()
Definition: SCTPSocket.h:79
Definition: SCTPCommand.h:63
L3Address localAddr
Definition: SCTPSocket.h:96
virtual void socketPeerClosed(int assocId, void *yourPtr)
Definition: SCTPSocket.h:74
Definition: SCTPSocket.h:87
Definition: SCTPCommand.h:65
Definition: SCTPSocket.h:87
Definition: SCTPCommand.h:69
Definition: SCTPCommand.h:75
Definition: SCTPCommand.h:66
Definition: SCTPCommand.h:64
Definition: SCTPCommand.h:72
Definition: SCTPCommand.h:71
Definition: SCTPCommand.h:70
Definition: SCTPCommand.h:78
#define PK(msg)
Definition: INETDefs.h:92
int localPrt
Definition: SCTPSocket.h:99
Definition: SCTPCommand.h:74
virtual void shutdownReceivedArrived(int connId)
Definition: SCTPSocket.h:81
int outboundStreams
Definition: SCTPSocket.h:52
virtual void socketFailure(int assocId, void *yourPtr, int code)
Definition: SCTPSocket.h:76
int assocId
Definition: SCTPSocket.h:90
int inboundStreams
Definition: SCTPSocket.h:51
Definition: SCTPSocket.h:87
int sockstate
Definition: SCTPSocket.h:92
virtual void socketEstablished(int assocId, void *yourPtr, unsigned long int buffer)
Definition: SCTPSocket.h:73
Definition: SCTPCommand.h:82
void inet::SCTPSocket::requestStatus ( )

Causes SCTP to reply with a fresh SCTPStatusInfo, attached to a dummy message as controlInfo().

The reply message can be recognized by its message kind SCTP_I_STATUS, or (if a callback object is used) the socketStatusArrived() method of the callback object will be called.

452 {
453  cMessage *msg = new cMessage("STATUS", SCTP_C_STATUS);
454  SCTPCommand *cmd = new SCTPCommand();
455  cmd->setAssocId(assocId);
456  msg->setControlInfo(cmd);
457  sendToSCTP(msg);
458 }
Definition: SCTPCommand.h:36
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
int assocId
Definition: SCTPSocket.h:90
void inet::SCTPSocket::send ( SCTPSimpleMessage msg,
int  prMethod = 0,
double  prValue = 0.0,
int32  streamId = 0,
bool  last = true,
bool  primary = true 
)

Send data message.

Referenced by sendToSCTP().

343 {
345  throw cRuntimeError("SCTPSocket::send(): not connected or connecting");
346  }
347  else if (!oneToOne && sockstate != LISTENING) {
348  throw cRuntimeError("SCTPSocket::send(): one-to-many style socket must be listening");
349  }
350 
351  SCTPSendInfo *sendCommand = new SCTPSendInfo();
352  sendCommand->setAssocId(assocId);
353  sendCommand->setSid(streamId);
354  sendCommand->setPrValue(prValue);
355  sendCommand->setPrMethod(prMethod);
356  sendCommand->setLast(last);
357  sendCommand->setPrimary(primary);
358  sendCommand->setSendUnordered( (msg->getKind() == SCTP_C_SEND_UNORDERED) ?
360 
361  cPacket* cmsg = new cPacket("SCTP_C_SEND");
362  cmsg->setKind(SCTP_C_SEND);
363  cmsg->encapsulate(msg);
364  cmsg->setControlInfo(sendCommand);
365 
366  sendToSCTP(cmsg);
367 }
Definition: SCTPCommand.h:33
bool oneToOne
Definition: SCTPSocket.h:93
Definition: SCTPSocket.h:87
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
Definition: SCTPSocket.h:87
Definition: SCTPCommand.h:87
Definition: SCTPCommand.h:88
int assocId
Definition: SCTPSocket.h:90
Definition: SCTPCommand.h:39
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
int sockstate
Definition: SCTPSocket.h:92
void inet::SCTPSocket::sendMsg ( cMessage *  cmsg)

Send data message (provided within control message).

Referenced by inet::SCTPPeer::sendRequest(), inet::SCTPClient::sendRequest(), inet::SCTPClient::socketDataArrived(), and inet::SCTPPeer::socketDataArrived().

370 {
371  SCTPSendInfo *sendCommand;
372 
373  if (cmsg->getControlInfo()) {
374  sendCommand = check_and_cast<SCTPSendInfo *>(cmsg->removeControlInfo());
375  if (sendCommand->getSid() == -1) {
377  sendCommand->setSid(lastStream);
378  }
379  if (sendCommand->getAssocId() == -1)
380  sendCommand->setAssocId(assocId);
381  cmsg->setControlInfo(sendCommand);
382  } else {
383  sendCommand = new SCTPSendInfo();
384  sendCommand->setAssocId(assocId);
386  sendCommand->setSid(lastStream);
387  cmsg->setControlInfo(sendCommand);
388  }
389  cmsg->setKind(SCTP_C_SEND);
390  sendToSCTP(cmsg);
391 }
int lastStream
Definition: SCTPSocket.h:104
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
Definition: SCTPCommand.h:33
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
int outboundStreams
Definition: SCTPSocket.h:52
int assocId
Definition: SCTPSocket.h:90
void inet::SCTPSocket::sendNotification ( cMessage *  msg)

Send notification.

Referenced by inet::SCTPClient::sendStreamResetNotification(), inet::SCTPClient::setPrimaryPath(), inet::SCTPClient::shutdownReceivedArrived(), inet::SCTPPeer::shutdownReceivedArrived(), inet::SCTPClient::socketDataNotificationArrived(), and inet::SCTPPeer::socketDataNotificationArrived().

394 {
396  throw cRuntimeError("SCTPSocket::sendNotification(%s): not connected or connecting", msg->getName());
397  }
398  else if (!oneToOne && sockstate != LISTENING) {
399  throw cRuntimeError("SCTPSocket::sendNotification(%s): one-to-many style socket must be listening", msg->getName());
400  }
401 
402  sendToSCTP(msg);
403 }
bool oneToOne
Definition: SCTPSocket.h:93
Definition: SCTPSocket.h:87
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
int sockstate
Definition: SCTPSocket.h:92
void inet::SCTPSocket::sendRequest ( cMessage *  msg)

Send request.

Referenced by inet::SCTPClient::sendQueueRequest(), inet::SCTPPeer::sendQueueRequest(), and inet::NetPerfMeter::sendSCTPQueueRequest().

406 {
407  sendToSCTP(msg);
408 }
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
void inet::SCTPSocket::sendToSCTP ( cMessage *  msg)
protected

Referenced by abort(), accept(), close(), connect(), getSocketOptions(), listen(), requestStatus(), send(), sendMsg(), sendNotification(), sendRequest(), setRtoInfo(), setStreamPriority(), and shutdown().

119 {
120  if (!gateToSctp)
121  throw cRuntimeError("SCTPSocket::sendToSCTP(): setOutputGate() must be invoked before socket can be used");
122 
123  check_and_cast<cSimpleModule *>(gateToSctp->getOwnerModule())->send(msg, gateToSctp);
124 }
void send(SCTPSimpleMessage *msg, int prMethod=0, double prValue=0.0, int32 streamId=0, bool last=true, bool primary=true)
Send data message.
Definition: SCTPSocket.cc:342
cGate * gateToSctp
Definition: SCTPSocket.h:117
void inet::SCTPSocket::setAppLimited ( bool  option)
inline
184 { appLimited = option; };
bool appLimited
Definition: SCTPSocket.h:94
void inet::SCTPSocket::setAssocMaxRtx ( int  option)
inline
201 { sOptions->assocMaxRtx = option; };
int assocMaxRtx
Definition: SCTPSocket.h:47
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setCallbackObject ( CallbackInterface cb,
void *  yourPtr = nullptr 
)

Sets a callback object, to be used with processMessage().

This callback object may be your simple module itself (if it multiply inherits from CallbackInterface too, that is you declared it as

class MyAppModule : public cSimpleModule, public SCTPSocket::CallbackInterface

and redefined the necessary virtual functions; or you may use dedicated class (and objects) for this purpose.

SCTPSocket doesn't delete the callback object in the destructor or on any other occasion.

YourPtr is an optional pointer. It may contain any value you wish – SCTPSocket will not look at it or do anything with it except passing it back to you in the CallbackInterface calls. You may find it useful if you maintain additional per-connection information: in that case you don't have to look it up by assocId in the callbacks, you can have it passed to you as yourPtr.

Referenced by inet::SCTPClient::initialize(), and inet::SCTPPeer::initialize().

474 {
475  cb = callback;
476  yourPtr = yourPointer;
477 }
void * yourPtr
Definition: SCTPSocket.h:111
CallbackInterface * cb
Definition: SCTPSocket.h:110
void inet::SCTPSocket::setEnableHeartbeats ( bool  option)
inline
198 { sOptions->enableHeartbeats = option; printf("enableHeartbeats set to %d\n", sOptions->enableHeartbeats);};
bool enableHeartbeats
Definition: SCTPSocket.h:44
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setFragPoint ( int  option)
inline
195 { sOptions->fragPoint = option; };
int fragPoint
Definition: SCTPSocket.h:42
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setHbInterval ( double  option)
inline
199 { sOptions->hbInterval = option; };
double hbInterval
Definition: SCTPSocket.h:46
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setInboundStreams ( int  streams)
inline

Referenced by inet::SCTPClient::connect(), inet::NetPerfMeter::createAndBindSocket(), inet::SCTPServer::initialize(), and inet::SCTPPeer::initialize().

183 { appOptions->inboundStreams = streams; };
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
int inboundStreams
Definition: SCTPSocket.h:51
void inet::SCTPSocket::setMaxBurst ( int  option)
inline
194 { sOptions->maxBurst = option; };
int maxBurst
Definition: SCTPSocket.h:41
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setMaxInitRetrans ( int  option)
inline
187 { sOptions->maxInitRetrans = option; };
int maxInitRetrans
Definition: SCTPSocket.h:34
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setMaxInitRetransTimeout ( int  option)
inline
188 { sOptions->maxInitRetransTimeout = option; };
int maxInitRetransTimeout
Definition: SCTPSocket.h:35
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setNagle ( int  option)
inline
196 { sOptions->nagle = option; };
int nagle
Definition: SCTPSocket.h:43
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setOutboundStreams ( int  streams)
inline

Setter and getter methods for socket and API Parameters.

Referenced by inet::SCTPClient::connect(), inet::SCTPPeer::connect(), inet::NetPerfMeter::createAndBindSocket(), inet::SCTPServer::initialize(), and inet::SCTPPeer::initialize().

182 { appOptions->outboundStreams = streams; };
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
int outboundStreams
Definition: SCTPSocket.h:52
void inet::SCTPSocket::setOutputGate ( cGate *  toSctp)
inline

Sets the gate on which to send to SCTP.

Must be invoked before socket can be used. Example: socket.setOutputGate(gate("sctpOut"));

Referenced by inet::NetPerfMeter::createAndBindSocket(), inet::SCTPServer::initialize(), inet::SCTPClient::initialize(), inet::SCTPPeer::initialize(), and inet::NetPerfMeter::successfullyEstablishedConnection().

177 { gateToSctp = toSctp; };
cGate * gateToSctp
Definition: SCTPSocket.h:117
void inet::SCTPSocket::setPathMaxRetrans ( int  option)
inline
197 { sOptions->pathMaxRetrans = option; };
int pathMaxRetrans
Definition: SCTPSocket.h:45
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setRtoInfo ( double  initial,
double  max,
double  min 
)
623 {
624  sOptions->rtoInitial = initial;
625  sOptions->rtoMax = max;
626  sOptions->rtoMin = min;
627  if (sockstate == CONNECTED) {
628  cMessage *msg = new cMessage("RtoInfo", SCTP_C_SET_RTO_INFO);
629  SCTPRtoInfo *cmd = new SCTPRtoInfo();
630  cmd->setAssocId(assocId);
631  cmd->setRtoInitial(initial);
632  cmd->setRtoMin(min);
633  cmd->setRtoMax(max);
634  msg->setControlInfo(cmd);
635  sendToSCTP(msg);
636  }
637 }
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
Definition: SCTPCommand.h:53
double rtoMin
Definition: SCTPSocket.h:37
double rtoInitial
Definition: SCTPSocket.h:36
SocketOptions * sOptions
Definition: SCTPSocket.h:107
int assocId
Definition: SCTPSocket.h:90
double rtoMax
Definition: SCTPSocket.h:38
Definition: SCTPSocket.h:87
int sockstate
Definition: SCTPSocket.h:92
void inet::SCTPSocket::setRtoInitial ( double  option)
inline
189 { sOptions->rtoInitial = option; };
double rtoInitial
Definition: SCTPSocket.h:36
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setRtoMax ( double  option)
inline
191 { sOptions->rtoMax = option; };
SocketOptions * sOptions
Definition: SCTPSocket.h:107
double rtoMax
Definition: SCTPSocket.h:38
void inet::SCTPSocket::setRtoMin ( double  option)
inline
190 { sOptions->rtoMin = option; };
double rtoMin
Definition: SCTPSocket.h:37
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setSackFrequency ( int  option)
inline
192 { sOptions->sackFrequency = option; };
int sackFrequency
Definition: SCTPSocket.h:39
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setSackPeriod ( double  option)
inline
193 { sOptions->sackPeriod = option; };
double sackPeriod
Definition: SCTPSocket.h:40
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::setState ( int  state)
inline
366 { sockstate = state; };
int sockstate
Definition: SCTPSocket.h:92
void inet::SCTPSocket::setStreamPriority ( uint32  stream,
uint32  priority 
)

Referenced by inet::SCTPPeer::connect(), and inet::SCTPServer::initialize().

612 {
613  cMessage *msg = new cMessage("SET_STREAM_PRIO", SCTP_C_SET_STREAM_PRIO);
614  SCTPSendInfo *cmd = new SCTPSendInfo();
615  cmd->setAssocId(assocId);
616  cmd->setSid(stream);
617  cmd->setPpid(priority);
618  msg->setControlInfo(cmd);
619  sendToSCTP(msg);
620 }
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
Definition: SCTPCommand.h:50
int assocId
Definition: SCTPSocket.h:90
void inet::SCTPSocket::setStreamReset ( int  option)
inline
185 { appOptions->streamReset = option; };
AppSocketOptions * appOptions
Definition: SCTPSocket.h:108
bool streamReset
Definition: SCTPSocket.h:53
void inet::SCTPSocket::setUserOptions ( void *  msg)
inline
203 { delete sOptions; sOptions = (SocketOptions*) msg; };
SocketOptions * sOptions
Definition: SCTPSocket.h:107
void inet::SCTPSocket::shutdown ( int  id = -1)

Referenced by inet::SCTPClient::handleTimer(), inet::SCTPClient::sendqueueAbatedArrived(), inet::SCTPClient::sendRequestArrived(), inet::SCTPPeer::sendRequestArrived(), inet::SCTPClient::socketEstablished(), and inet::SCTPPeer::socketEstablished().

426 {
427  EV << "SCTPSocket::shutdown()\n";
428 
429  cMessage *msg = new cMessage("SHUTDOWN", SCTP_C_SHUTDOWN);
430  SCTPCommand *cmd = new SCTPCommand();
431  if (id == -1)
432  cmd->setAssocId(assocId);
433  else
434  cmd->setFd(id);
435  msg->setControlInfo(cmd);
436  sendToSCTP(msg);
437 }
Definition: SCTPCommand.h:43
void sendToSCTP(cMessage *msg)
Definition: SCTPSocket.cc:118
int assocId
Definition: SCTPSocket.h:90
const char * inet::SCTPSocket::stateName ( int  state)
static

Returns name of socket state code returned by state().

Referenced by connect(), connectx(), and SCTPSocket().

100 {
101 #define CASE(x) case x: \
102  s = #x; break
103  const char *s = "unknown";
104  switch (state) {
105  CASE(NOT_BOUND);
106  CASE(CLOSED);
107  CASE(LISTENING);
108  CASE(CONNECTING);
109  CASE(CONNECTED);
110  CASE(PEER_CLOSED);
112  CASE(SOCKERROR);
113  }
114  return s;
115 #undef CASE
116 }
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87
#define CASE(x)
value< double, units::s > s
Definition: Units.h:1049
Definition: SCTPSocket.h:87
Definition: SCTPSocket.h:87

Member Data Documentation

bool inet::SCTPSocket::appLimited
protected

Referenced by connect(), and SCTPSocket().

AppSocketOptions* inet::SCTPSocket::appOptions
protected
CallbackInterface* inet::SCTPSocket::cb
protected
int inet::SCTPSocket::fsmStatus
protected

Referenced by processMessage(), and SCTPSocket().

cGate* inet::SCTPSocket::gateToSctp

Referenced by SCTPSocket(), and sendToSCTP().

int inet::SCTPSocket::lastStream
protected

Referenced by SCTPSocket(), and sendMsg().

L3Address inet::SCTPSocket::localAddr
protected

Referenced by processMessage(), and SCTPSocket().

AddressVector inet::SCTPSocket::localAddresses
protected

Referenced by addAddress(), bind(), bindx(), connect(), and listen().

int inet::SCTPSocket::localPrt
protected
int32 inet::SCTPSocket::nextAssocId = 0
staticprotected
bool inet::SCTPSocket::oneToOne
protected
L3Address inet::SCTPSocket::remoteAddr
protected
AddressVector inet::SCTPSocket::remoteAddresses
protected

Referenced by connectx().

int inet::SCTPSocket::remotePrt
protected
int inet::SCTPSocket::sockstate
protected
SocketOptions* inet::SCTPSocket::sOptions
protected
void* inet::SCTPSocket::yourPtr
protected

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