INET Framework for OMNeT++/OMNEST
PacketDrill Class Reference

#include <PacketDrill.h>

Public Member Functions

 PacketDrill (PacketDrillApp *mod)
 
 ~PacketDrill ()
 
int evaluateExpressionList (cQueue *in_list, cQueue *out_list, char **error)
 
int evaluate (PacketDrillExpression *in, PacketDrillExpression *out, char **error)
 
int evaluate_binary_expression (PacketDrillExpression *in, PacketDrillExpression *out, char **error)
 
int evaluate_pollfd_expression (PacketDrillExpression *in, PacketDrillExpression *out, char **error)
 
int evaluate_msghdr_expression (PacketDrillExpression *in, PacketDrillExpression *out, char **error)
 
int evaluate_iovec_expression (PacketDrillExpression *in, PacketDrillExpression *out, char **error)
 
int evaluateListExpression (PacketDrillExpression *in, PacketDrillExpression *out, char **error)
 

Static Public Member Functions

static cPacket * buildUDPPacket (int address_family, enum direction_t direction, uint16 udp_payload_bytes, char **error)
 
static cPacket * buildTCPPacket (int address_family, enum direction_t direction, const char *flags, uint32 startSequence, uint16 tcpPayloadBytes, uint32 ackSequence, int32 window, cQueue *tcpOptions, char **error)
 
static cPacket * buildSCTPPacket (int address_family, enum direction_t direction, cQueue *chunks)
 
static PacketDrillSctpChunkbuildDataChunk (int64 flgs, int64 len, int64 tsn, int64 sid, int64 ssn, int64 ppid)
 
static PacketDrillSctpChunkbuildInitChunk (int64 flgs, int64 tag, int64 a_rwnd, int64 os, int64 is, int64 tsn, cQueue *parameters)
 
static PacketDrillSctpChunkbuildInitAckChunk (int64 flgs, int64 tag, int64 a_rwnd, int64 os, int64 is, int64 tsn, cQueue *parameters)
 
static PacketDrillSctpChunkbuildSackChunk (int64 flgs, int64 cum_tsn, int64 a_rwnd, cQueue *gaps, cQueue *dups)
 
static PacketDrillSctpChunkbuildCookieEchoChunk (int64 flgs, int64 len, PacketDrillBytes *cookie)
 
static PacketDrillSctpChunkbuildCookieAckChunk (int64 flgs)
 
static PacketDrillSctpChunkbuildShutdownChunk (int64 flgs, int64 cum_tsn)
 
static PacketDrillSctpChunkbuildShutdownAckChunk (int64 flgs)
 
static PacketDrillSctpChunkbuildShutdownCompleteChunk (int64 flgs)
 
static PacketDrillSctpChunkbuildAbortChunk (int64 flgs)
 
static PacketDrillSctpChunkbuildHeartbeatChunk (int64 flgs, PacketDrillSctpParameter *info)
 
static PacketDrillSctpChunkbuildHeartbeatAckChunk (int64 flgs, PacketDrillSctpParameter *info)
 
static PacketDrillSctpChunkbuildReconfigChunk (int64 flgs, cQueue *parameters)
 
static PacketDrillSctpChunkbuildErrorChunk (int64 flgs, cQueue *causes)
 
static IPv4DatagrammakeIPPacket (int protocol, enum direction_t direction, L3Address localAddr, L3Address remoteAddr)
 

Static Protected Attributes

static PacketDrillApppdapp = nullptr
 

Constructor & Destructor Documentation

PacketDrill::PacketDrill ( PacketDrillApp mod)
40 {
41  pdapp = mod;
42 }
double mod(double dividend, double divisor)
Returns the rest of a whole-numbered division.
Definition: INETMath.h:108
static PacketDrillApp * pdapp
Definition: PacketDrill.h:41
PacketDrill::~PacketDrill ( )
45 {
46 
47 }

Member Function Documentation

PacketDrillSctpChunk * PacketDrill::buildAbortChunk ( int64  flgs)
static

Referenced by yyparse().

848 {
849  SCTPAbortChunk *abortChunk = new SCTPAbortChunk("Abort");
850  abortChunk->setChunkType(ABORT);
851 
852  if (flgs != -1) {
853  abortChunk->setT_Bit(flgs);
854  } else {
855  flgs |= FLAG_CHUNK_FLAGS_NOCHECK;
856  }
857  abortChunk->setByteLength(SCTP_ABORT_CHUNK_LENGTH);
858  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(ABORT, (SCTPChunk *)abortChunk);
859  return sctpchunk;
860 }
#define FLAG_CHUNK_FLAGS_NOCHECK
Definition: PacketDrillUtils.h:97
Definition: PacketDrillUtils.h:717
virtual void setT_Bit(bool T_Bit)
virtual void setChunkType(uint8_t chunkType)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:202 by nedtool.
Definition: SCTPMessage_m.h:920
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
Definition: SCTPAssociation.h:117
#define SCTP_ABORT_CHUNK_LENGTH
Definition: SCTPAssociation.h:218
PacketDrillSctpChunk * PacketDrill::buildCookieAckChunk ( int64  flgs)
static

Referenced by yyparse().

795 {
796  SCTPCookieAckChunk *cookieAckChunk = new SCTPCookieAckChunk("Cookie_Ack");
797  cookieAckChunk->setChunkType(COOKIE_ACK);
798  cookieAckChunk->setByteLength(SCTP_COOKIE_ACK_LENGTH);
799  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(COOKIE_ACK, (SCTPChunk *)cookieAckChunk);
800  return sctpchunk;
801 }
#define SCTP_COOKIE_ACK_LENGTH
Definition: SCTPAssociation.h:219
Definition: PacketDrillUtils.h:717
Definition: SCTPAssociation.h:122
virtual void setChunkType(uint8_t chunkType)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
PacketDrillSctpChunk * PacketDrill::buildCookieEchoChunk ( int64  flgs,
int64  len,
PacketDrillBytes cookie 
)
static

Referenced by yyparse().

773 {
774  SCTPCookieEchoChunk *cookieechochunk = new SCTPCookieEchoChunk();
775  cookieechochunk->setChunkType(COOKIE_ECHO);
776  cookieechochunk->setName("COOKIE_ECHO");
777  uint32 flags = 0;
778 
779  if (cookie) {
780  printf("cookie present\n");
781  }
782  else
783  {
784  flags |= FLAG_CHUNK_VALUE_NOCHECK;
785  cookieechochunk->setCookieArraySize(0);
786  }
787  cookieechochunk->setUnrecognizedParametersArraySize(0);
788  cookieechochunk->setByteLength(SCTP_COOKIE_ACK_LENGTH);
789  cookieechochunk->setFlags(flags);
790  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(COOKIE_ECHO, (SCTPChunk *)cookieechochunk);
791  return sctpchunk;
792 }
#define SCTP_COOKIE_ACK_LENGTH
Definition: SCTPAssociation.h:219
virtual void setFlags(uint32_t flags)
Definition: SCTPAssociation.h:121
Definition: PacketDrillUtils.h:717
#define FLAG_CHUNK_VALUE_NOCHECK
Definition: PacketDrillUtils.h:99
virtual void setChunkType(uint8_t chunkType)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
uint32_t uint32
Definition: Compat.h:30
PacketDrillSctpChunk * PacketDrill::buildDataChunk ( int64  flgs,
int64  len,
int64  tsn,
int64  sid,
int64  ssn,
int64  ppid 
)
static

Referenced by yyparse().

454 {
455  uint32 flags = 0;
456  SCTPDataChunk *datachunk = new SCTPDataChunk();
457  datachunk->setChunkType(DATA);
458  datachunk->setName("PacketDrillDATA");
459 
460  if (flgs != -1) {
461  if (flgs & SCTP_DATA_CHUNK_B_BIT) {
462  datachunk->setBBit(1);
463  }
464  if (flgs & SCTP_DATA_CHUNK_E_BIT) {
465  datachunk->setEBit(1);
466  }
467  if (flgs & SCTP_DATA_CHUNK_U_BIT) {
468  datachunk->setUBit(1);
469  }
470  } else {
471  flags |= FLAG_CHUNK_FLAGS_NOCHECK;
472  }
473 
474  if (tsn == -1) {
475  datachunk->setTsn(0);
477  } else {
478  datachunk->setTsn((uint32) tsn);
479  }
480 
481  if (sid == -1) {
482  datachunk->setSid(0);
484  } else {
485  datachunk->setSid((uint16) sid);
486  }
487 
488  if (ssn == -1) {
489  datachunk->setSsn(0);
491  } else {
492  datachunk->setSsn((uint16) ssn);
493  }
494 
495  if (ppid == -1) {
496  datachunk->setPpid(0);
498  } else {
499  datachunk->setPpid((uint32) ppid);
500  }
501 // ToDo: Padding
502  if (len != -1) {
503  datachunk->setByteLength(SCTP_DATA_CHUNK_LENGTH);
504  SCTPSimpleMessage* msg = new SCTPSimpleMessage("payload");
505  uint32 sendBytes = len - SCTP_DATA_CHUNK_LENGTH;
506  msg->setDataArraySize(sendBytes);
507  for (uint32 i = 0; i < sendBytes; i++)
508  msg->setData(i, 'a');
509  msg->setDataLen(sendBytes);
510  msg->setEncaps(false);
511  msg->setByteLength(sendBytes);
512  datachunk->encapsulate(msg);
513  } else {
514  flags |= FLAG_CHUNK_LENGTH_NOCHECK;
515  flags |= FLAG_CHUNK_VALUE_NOCHECK;
516  datachunk->setByteLength(SCTP_DATA_CHUNK_LENGTH);
517  }
518  datachunk->setFlags(flags);
519  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(DATA, (SCTPChunk *)datachunk);
520  return sctpchunk;
521 }
#define SCTP_DATA_CHUNK_B_BIT
Definition: PacketDrillUtils.h:88
#define FLAG_CHUNK_FLAGS_NOCHECK
Definition: PacketDrillUtils.h:97
virtual void setFlags(uint32_t flags)
Definition: SCTPAssociation.h:111
#define FLAG_DATA_CHUNK_SSN_NOCHECK
Definition: PacketDrillUtils.h:120
Definition: PacketDrillUtils.h:717
virtual void setUBit(bool uBit)
uint16_t len
Definition: TCP_NSC.cc:85
#define SCTP_DATA_CHUNK_LENGTH
Definition: SCTPAssociation.h:214
#define FLAG_CHUNK_VALUE_NOCHECK
Definition: PacketDrillUtils.h:99
#define FLAG_DATA_CHUNK_SID_NOCHECK
Definition: PacketDrillUtils.h:119
#define FLAG_CHUNK_LENGTH_NOCHECK
Definition: PacketDrillUtils.h:98
virtual void setChunkType(uint8_t chunkType)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:151 by nedtool.
Definition: SCTPMessage_m.h:687
Class generated from inet/transportlayer/contract/sctp/SCTPCommand.msg:222 by nedtool.
Definition: SCTPCommand_m.h:780
virtual void setSid(uint16_t sid)
#define SCTP_DATA_CHUNK_E_BIT
Definition: PacketDrillUtils.h:89
virtual void setPpid(uint32_t ppid)
virtual void setEncaps(bool encaps)
#define SCTP_DATA_CHUNK_U_BIT
Definition: PacketDrillUtils.h:87
virtual void setEBit(bool eBit)
virtual void setBBit(bool bBit)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
uint32_t uint32
Definition: Compat.h:30
#define FLAG_DATA_CHUNK_PPID_NOCHECK
Definition: PacketDrillUtils.h:121
virtual void setData(unsigned int k, char data)
uint16_t uint16
Definition: Compat.h:32
#define FLAG_DATA_CHUNK_TSN_NOCHECK
Definition: PacketDrillUtils.h:118
virtual void setTsn(uint32_t tsn)
virtual void setDataArraySize(unsigned int size)
virtual void setSsn(uint16_t ssn)
virtual void setDataLen(uint32_t dataLen)
PacketDrillSctpChunk * PacketDrill::buildErrorChunk ( int64  flgs,
cQueue *  causes 
)
static

Referenced by yyparse().

863 {
864  PacketDrillStruct *errorcause;
865  SCTPErrorChunk *errorChunk = new SCTPErrorChunk("Error");
866  errorChunk->setChunkType(ERRORTYPE);
867  errorChunk->setByteLength(SCTP_ERROR_CHUNK_LENGTH);
868  for (cQueue::Iterator iter(*causes); !iter.end(); iter++) {
869  errorcause = (PacketDrillStruct*) (*iter);
872  cause->setByteLength(8);
873  cause->setValue(errorcause->getValue2());
874  errorChunk->addParameters(cause);
875  causes->remove((*iter));
876  }
877  delete causes;
878  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(ERRORTYPE, (SCTPChunk *)errorChunk);
879  return sctpchunk;
880 }
Definition: SCTPAssociation.h:189
Definition: PacketDrillUtils.h:717
#define SCTP_ERROR_CHUNK_LENGTH
Definition: SCTPAssociation.h:223
Definition: PacketDrillUtils.h:627
virtual void setChunkType(uint8_t chunkType)
virtual void setValue(uint16_t value)
Definition: SCTPMessage.h:83
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:362 by nedtool.
Definition: SCTPMessage_m.h:2120
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
virtual void setParameterType(uint16_t parameterType)
virtual void addParameters(cPacket *msg)
Adds a message object to the SCTP packet.
Definition: SCTPMessage.cc:188
Definition: SCTPAssociation.h:120
int64 getValue2() const
Definition: PacketDrillUtils.h:636
PacketDrillSctpChunk * PacketDrill::buildHeartbeatAckChunk ( int64  flgs,
PacketDrillSctpParameter info 
)
static

Referenced by yyparse().

920 {
921  SCTPHeartbeatAckChunk *heartbeatAckChunk = new SCTPHeartbeatAckChunk();
922  heartbeatAckChunk->setChunkType(HEARTBEAT_ACK);
923  assert(info == NULL ||
925  if (info && info->getLength() > 0)
926  {
927  printf("not implemented yet\n");
928  } else {
929  heartbeatAckChunk->setRemoteAddr(pdapp->getRemoteAddress());
930  heartbeatAckChunk->setTimeField(pdapp->getPeerHeartbeatTime());
931  heartbeatAckChunk->setByteLength(SCTP_HEARTBEAT_CHUNK_LENGTH + 12);
932  }
933  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(HEARTBEAT_ACK, (SCTPChunk *)heartbeatAckChunk);
934  return sctpchunk;
935 }
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:215 by nedtool.
Definition: SCTPMessage_m.h:1010
#define SCTP_HEARTBEAT_CHUNK_LENGTH
Definition: SCTPAssociation.h:217
simtime_t getPeerHeartbeatTime()
Definition: PacketDrillApp.h:65
static PacketDrillApp * pdapp
Definition: PacketDrill.h:41
Definition: PacketDrillUtils.h:717
Definition: SCTPAssociation.h:116
virtual void setChunkType(uint8_t chunkType)
const L3Address getRemoteAddress()
Definition: PacketDrillApp.h:60
virtual void setTimeField(::omnetpp::simtime_t timeField)
#define MAX_SCTP_CHUNK_BYTES
Definition: PacketDrillUtils.h:94
virtual void setRemoteAddr(const L3Address &remoteAddr)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
int16 getLength() const
Definition: PacketDrillUtils.h:751
PacketDrillSctpChunk * PacketDrill::buildHeartbeatChunk ( int64  flgs,
PacketDrillSctpParameter info 
)
static

Referenced by yyparse().

883 {
884  SCTPHeartbeatChunk *heartbeatChunk = new SCTPHeartbeatChunk();
885  heartbeatChunk->setChunkType(HEARTBEAT);
886  assert(info == NULL ||
888  if (info && info->getLength() > 0)
889  {
890  uint32 flgs = info->getFlags();
891  uint16 length = 0;
892  if (flgs & FLAG_CHUNK_VALUE_NOCHECK) {
893  if (flgs & FLAG_CHUNK_LENGTH_NOCHECK) {
894  length = 12;
895  } else {
896  length = info->getLength();
897  }
898  if (length >= 12) {
899  heartbeatChunk->setInfoArraySize(length - 4);
900  heartbeatChunk->setRemoteAddr(pdapp->getRemoteAddress());
901  heartbeatChunk->setTimeField(simTime());
902  for (int i = 0; i < length - 12; i++) {
903  heartbeatChunk->setInfo(i, 'x');
904  }
905  heartbeatChunk->setByteLength(SCTP_HEARTBEAT_CHUNK_LENGTH + length);
906  }
907  } else {
908  printf("Take Info Parameter not yet implemented\n");
909  }
910  } else {
911  heartbeatChunk->setRemoteAddr(pdapp->getRemoteAddress());
912  heartbeatChunk->setTimeField(simTime());
913  heartbeatChunk->setByteLength(SCTP_HEARTBEAT_CHUNK_LENGTH + 12);
914  }
915  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(HEARTBEAT, (SCTPChunk *)heartbeatChunk);
916  return sctpchunk;
917 }
#define SCTP_HEARTBEAT_CHUNK_LENGTH
Definition: SCTPAssociation.h:217
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:208 by nedtool.
Definition: SCTPMessage_m.h:960
virtual void setTimeField(::omnetpp::simtime_t timeField)
static PacketDrillApp * pdapp
Definition: PacketDrill.h:41
Definition: PacketDrillUtils.h:717
#define FLAG_CHUNK_VALUE_NOCHECK
Definition: PacketDrillUtils.h:99
uint32 getFlags() const
Definition: PacketDrillUtils.h:749
Definition: SCTPAssociation.h:115
#define FLAG_CHUNK_LENGTH_NOCHECK
Definition: PacketDrillUtils.h:98
virtual void setChunkType(uint8_t chunkType)
const L3Address getRemoteAddress()
Definition: PacketDrillApp.h:60
#define MAX_SCTP_CHUNK_BYTES
Definition: PacketDrillUtils.h:94
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
virtual void setInfo(unsigned int k, char info)
uint32_t uint32
Definition: Compat.h:30
virtual void setRemoteAddr(const L3Address &remoteAddr)
int16 getLength() const
Definition: PacketDrillUtils.h:751
uint16_t uint16
Definition: Compat.h:32
virtual void setInfoArraySize(unsigned int size)
PacketDrillSctpChunk * PacketDrill::buildInitAckChunk ( int64  flgs,
int64  tag,
int64  a_rwnd,
int64  os,
int64  is,
int64  tsn,
cQueue *  parameters 
)
static

Referenced by yyparse().

610 {
611  uint32 flags = 0;
612  uint16 length = 0;
613  SCTPInitAckChunk *initackchunk = new SCTPInitAckChunk();
614  initackchunk->setChunkType(INIT_ACK);
615  initackchunk->setName("INIT_ACK");
616 
617  if (tag == -1) {
618  initackchunk->setInitTag(0);
620  } else {
621  initackchunk->setInitTag((uint32) tag);
622  }
623 
624  if (a_rwnd == -1) {
625  initackchunk->setA_rwnd(0);
627  } else {
628  initackchunk->setA_rwnd((uint32) a_rwnd);
629  }
630 
631  if (is == -1) {
632  initackchunk->setNoInStreams(0);
634  } else {
635  initackchunk->setNoInStreams((uint16) is);
636  }
637 
638  if (os == -1) {
639  initackchunk->setNoOutStreams(0);
641  } else {
642  initackchunk->setNoOutStreams((uint16) os);
643  }
644 
645  if (tsn == -1) {
646  initackchunk->setInitTSN(0);
648  } else {
649  initackchunk->setInitTSN((uint32) tsn);
650  }
651  if (parameters != nullptr) {
652  PacketDrillSctpParameter *parameter;
653  uint16 parLen = 0;
654  for (cQueue::Iterator iter(*parameters); !iter.end(); iter++) {
655  parameter = (PacketDrillSctpParameter*) (*iter);
656  switch (parameter->getType()) {
657  case SUPPORTED_EXTENSIONS: {
658  ByteArray *ba = (ByteArray *)(parameter->getByteList());
659  parLen = ba->getDataArraySize();
660  initackchunk->setSepChunksArraySize(parLen);
661  for (int i = 0; i < parLen; i++) {
662  initackchunk->setSepChunks(i, (0x00ff & ba->getData(i)));
663  }
664  if (parLen > 0) {
666  }
667  break;
668  }
671  cQueue *list = parameter->getList();
672  if (list != nullptr) {
673  for (cQueue::Iterator iter(*list); !iter.end(); iter++)
674  list->remove((*iter));
675  delete list;
676  }
677  break;
678  }
679  default: printf("Parameter type not implemented\n");
680  }
681  }
682  } else {
684  }
685 
686  initackchunk->setAddressesArraySize(0);
687  initackchunk->setUnrecognizedParametersArraySize(0);
688 
689  initackchunk->setCookieArraySize(32);
690  for (int i = 0; i < 32; i++) {
691  initackchunk->setCookie(i, 'A');
692  }
693 
694  initackchunk->setFlags(flags);
695  initackchunk->setByteLength(SCTP_INIT_CHUNK_LENGTH + 36 + length);
696  delete parameters;
697  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(INIT_ACK, (SCTPChunk *)initackchunk);
698  return sctpchunk;
699 }
virtual void setFlags(uint32_t flags)
#define FLAG_INIT_ACK_CHUNK_TSN_NOCHECK
Definition: PacketDrillUtils.h:113
#define FLAG_INIT_ACK_CHUNK_A_RWND_NOCHECK
Definition: PacketDrillUtils.h:110
Definition: PacketDrillUtils.h:717
virtual void setNoInStreams(uint16_t noInStreams)
virtual void setInitTag(uint32_t initTag)
Definition: SCTPAssociation.h:170
virtual void setChunkType(uint8_t chunkType)
virtual void setSepChunks(unsigned int k, uint16_t sepChunks)
virtual unsigned int getDataArraySize() const
virtual void setInitTSN(uint32_t initTSN)
virtual void setCookieArraySize(unsigned int size)
Class that carries raw bytes.
Definition: ByteArray.h:27
virtual void setAddressesArraySize(unsigned int size)
#define ADD_PADDING(x)
Definition: SCTPAssociation.h:261
#define FLAG_INIT_CHUNK_OPT_SUPPORTED_ADDRESS_TYPES_PARAM_NOCHECK
Definition: PacketDrillUtils.h:107
#define SCTP_INIT_CHUNK_LENGTH
Definition: SCTPAssociation.h:213
#define SCTP_SUPPORTED_EXTENSIONS_PARAMETER_LENGTH
Definition: SCTPAssociation.h:230
#define FLAG_INIT_ACK_CHUNK_OPT_PARAM_NOCHECK
Definition: PacketDrillUtils.h:114
#define FLAG_INIT_ACK_CHUNK_IS_NOCHECK
Definition: PacketDrillUtils.h:112
virtual void setSepChunksArraySize(unsigned int size)
Definition: PacketDrillUtils.h:731
#define FLAG_INIT_ACK_CHUNK_TAG_NOCHECK
Definition: PacketDrillUtils.h:109
virtual void setUnrecognizedParametersArraySize(unsigned int size)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
uint32_t uint32
Definition: Compat.h:30
Definition: SCTPAssociation.h:181
cQueue * getList()
Definition: PacketDrillUtils.h:748
ByteArray * getByteList()
Definition: PacketDrillUtils.h:753
uint16_t uint16
Definition: Compat.h:32
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:82 by nedtool.
Definition: SCTPMessage_m.h:317
virtual void setCookie(unsigned int k, char cookie)
virtual void setA_rwnd(uint32_t a_rwnd)
Definition: SCTPAssociation.h:113
virtual char getData(unsigned int k) const
uint16 getType() const
Definition: PacketDrillUtils.h:752
virtual void setNoOutStreams(uint16_t noOutStreams)
#define FLAG_INIT_ACK_CHUNK_OS_NOCHECK
Definition: PacketDrillUtils.h:111
PacketDrillSctpChunk * PacketDrill::buildInitChunk ( int64  flgs,
int64  tag,
int64  a_rwnd,
int64  os,
int64  is,
int64  tsn,
cQueue *  parameters 
)
static

Referenced by yyparse().

524 {
525  uint32 flags = 0;
526  uint16 length = 0;
527  SCTPInitChunk *initchunk = new SCTPInitChunk();
528  initchunk->setChunkType(INIT);
529  initchunk->setName("INIT");
530 
531  if (tag == -1) {
532  initchunk->setInitTag(0);
534  } else {
535  initchunk->setInitTag((uint32) tag);
536  }
537 
538  if (a_rwnd == -1) {
539  initchunk->setA_rwnd(0);
541  } else {
542  initchunk->setA_rwnd((uint32) a_rwnd);
543  }
544 
545  if (is == -1) {
546  initchunk->setNoInStreams(0);
548  } else {
549  initchunk->setNoInStreams((uint16) is);
550  }
551 
552  if (os == -1) {
553  initchunk->setNoOutStreams(0);
555  } else {
556  initchunk->setNoOutStreams((uint16) os);
557  }
558 
559  if (tsn == -1) {
560  initchunk->setInitTSN(0);
562  } else {
563  initchunk->setInitTSN((uint32) tsn);
564  }
565 
566  if (parameters != nullptr) {
567  PacketDrillSctpParameter *parameter;
568  uint16 parLen = 0;
569  for (cQueue::Iterator iter(*parameters); !iter.end(); iter++) {
570  parameter = (PacketDrillSctpParameter*) (*iter);
571  switch (parameter->getType()) {
572  case SUPPORTED_EXTENSIONS: {
573  ByteArray *ba = (ByteArray *)(parameter->getByteList());
574  parLen = ba->getDataArraySize();
575  initchunk->setSepChunksArraySize(parLen);
576  for (int i = 0; i < parLen; i++) {
577  initchunk->setSepChunks(i, ba->getData(i));
578  }
579  if (parLen > 0) {
581  }
582  break;
583  }
586  cQueue *list = parameter->getList();
587  if (list != nullptr) {
588  for (cQueue::Iterator iter(*list); !iter.end(); iter++)
589  list->remove((*iter));
590  delete list;
591  }
592  break;
593  }
594  default: printf("Parameter type not implemented\n");
595  }
596  }
597  } else {
599  }
600  initchunk->setAddressesArraySize(0);
602  initchunk->setFlags(flags);
603  initchunk->setByteLength(SCTP_INIT_CHUNK_LENGTH + length);
604  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(INIT, (SCTPChunk *)initchunk);
605  delete parameters;
606  return sctpchunk;
607 }
#define FLAG_INIT_CHUNK_OPT_PARAM_NOCHECK
Definition: PacketDrillUtils.h:106
virtual void setFlags(uint32_t flags)
Definition: PacketDrillUtils.h:717
Definition: SCTPAssociation.h:170
virtual void setChunkType(uint8_t chunkType)
virtual void setAddressesArraySize(unsigned int size)
virtual unsigned int getDataArraySize() const
Class that carries raw bytes.
Definition: ByteArray.h:27
#define ADD_PADDING(x)
Definition: SCTPAssociation.h:261
#define FLAG_INIT_CHUNK_OPT_SUPPORTED_ADDRESS_TYPES_PARAM_NOCHECK
Definition: PacketDrillUtils.h:107
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:58 by nedtool.
Definition: SCTPMessage_m.h:197
#define SCTP_INIT_CHUNK_LENGTH
Definition: SCTPAssociation.h:213
#define SCTP_SUPPORTED_EXTENSIONS_PARAMETER_LENGTH
Definition: SCTPAssociation.h:230
virtual void setSepChunks(unsigned int k, uint16_t sepChunks)
Definition: SCTPAssociation.h:112
Definition: PacketDrillUtils.h:731
#define FLAG_INIT_CHUNK_TAG_NOCHECK
Definition: PacketDrillUtils.h:101
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
virtual void setA_rwnd(uint32_t a_rwnd)
virtual void setNoInStreams(uint16_t noInStreams)
#define FLAG_INIT_CHUNK_IS_NOCHECK
Definition: PacketDrillUtils.h:104
virtual void setNoOutStreams(uint16_t noOutStreams)
uint32_t uint32
Definition: Compat.h:30
Definition: SCTPAssociation.h:181
virtual void setUnrecognizedParametersArraySize(unsigned int size)
cQueue * getList()
Definition: PacketDrillUtils.h:748
#define FLAG_INIT_CHUNK_OS_NOCHECK
Definition: PacketDrillUtils.h:103
#define FLAG_INIT_CHUNK_TSN_NOCHECK
Definition: PacketDrillUtils.h:105
ByteArray * getByteList()
Definition: PacketDrillUtils.h:753
virtual void setInitTSN(uint32_t initTSN)
virtual void setSepChunksArraySize(unsigned int size)
uint16_t uint16
Definition: Compat.h:32
#define FLAG_INIT_CHUNK_A_RWND_NOCHECK
Definition: PacketDrillUtils.h:102
virtual void setInitTag(uint32_t initTag)
virtual char getData(unsigned int k) const
uint16 getType() const
Definition: PacketDrillUtils.h:752
PacketDrillSctpChunk * PacketDrill::buildReconfigChunk ( int64  flgs,
cQueue *  parameters 
)
static

Referenced by yyparse().

938 {
939  uint32 flags = 0;
940  uint16 len = 0;
941  SCTPStreamResetChunk *resetChunk = new SCTPStreamResetChunk("RE_CONFIG");
942  resetChunk->setChunkType(RE_CONFIG);
943  resetChunk->setByteLength(SCTP_STREAM_RESET_CHUNK_LENGTH);
944  if (parameters != nullptr) {
945  PacketDrillSctpParameter *parameter;
946  for (cQueue::Iterator iter(*parameters); !iter.end(); iter++) {
947  parameter = (PacketDrillSctpParameter*) (*iter);
948  switch (parameter->getType()) {
950  SCTPOutgoingSSNResetRequestParameter *outResetParam =
951  new SCTPOutgoingSSNResetRequestParameter("Outgoing_Request_Param");
953  PacketDrillStruct *content = (PacketDrillStruct *)parameter->getContent();
954  if (content->getValue1() == -1) {
955  outResetParam->setSrReqSn(0);
957  } else {
958  outResetParam->setSrReqSn(content->getValue1());
959  }
960  if (content->getValue2() == -1) {
961  outResetParam->setSrResSn(0);
963  } else {
964  outResetParam->setSrResSn(content->getValue2());
965  }
966  if (content->getValue3() == -1) {
967  outResetParam->setLastTsn(0);
969  } else {
970  outResetParam->setLastTsn(content->getValue3());
971  }
972  if (content->getStreams() != nullptr) {
973  outResetParam->setStreamNumbersArraySize(content->getStreams()->getLength());
974  unsigned int i = 0;
975  for (cQueue::Iterator it(*content->getStreams()); !it.end(); it++) {
976  if (((PacketDrillExpression *)(*it))->getNum() != -1)
977  outResetParam->setStreamNumbers(i++, ((PacketDrillExpression *)(*it))->getNum());
978  else
979  outResetParam->setStreamNumbersArraySize(outResetParam->getStreamNumbersArraySize() - 1);
980  }
981  len = outResetParam->getStreamNumbersArraySize();
982  for (cQueue::Iterator iter(*content->getStreams()); !iter.end(); iter++)
983  content->getStreams()->remove((*iter));
984  delete content->getStreams();
985  }
986  outResetParam->setByteLength(SCTP_OUTGOING_RESET_REQUEST_PARAMETER_LENGTH + len * 2);
987  resetChunk->addParameter(outResetParam);
988  break;
989  }
992  new SCTPIncomingSSNResetRequestParameter("Incoming_Request_Param");
993  PacketDrillStruct *content = (PacketDrillStruct *)parameter->getContent();
995  inResetParam->setSrReqSn(content->getValue1());
996  if (content->getStreams() != nullptr) {
997  inResetParam->setStreamNumbersArraySize(content->getStreams()->getLength());
998  unsigned int i = 0;
999  for (cQueue::Iterator it(*content->getStreams()); !it.end(); it++) {
1000  if (((PacketDrillExpression *)(*it))->getNum() != -1)
1001  inResetParam->setStreamNumbers(i++, ((PacketDrillExpression *)(*it))->getNum());
1002  else
1003  inResetParam->setStreamNumbersArraySize(inResetParam->getStreamNumbersArraySize() - 1);
1004  }
1005  for (cQueue::Iterator iter(*content->getStreams()); !iter.end(); iter++)
1006  content->getStreams()->remove((*iter));
1007  delete content->getStreams();
1008  }
1009  inResetParam->setByteLength(SCTP_INCOMING_RESET_REQUEST_PARAMETER_LENGTH + inResetParam->getStreamNumbersArraySize() * 2);
1010  resetChunk->addParameter(inResetParam);
1011  break;
1012  }
1014  SCTPSSNTSNResetRequestParameter *resetParam =
1015  new SCTPSSNTSNResetRequestParameter("SSN_TSN_Request_Param");
1016  PacketDrillStruct *content = (PacketDrillStruct *)parameter->getContent();
1018  resetParam->setSrReqSn(content->getValue1());
1019  resetParam->setByteLength(SCTP_SSN_TSN_RESET_REQUEST_PARAMETER_LENGTH);
1020  resetChunk->addParameter(resetParam);
1021  break;
1022  }
1024  SCTPStreamResetResponseParameter *responseParam =
1025  new SCTPStreamResetResponseParameter("Response_Param");
1026  PacketDrillStruct *content = (PacketDrillStruct *)parameter->getContent();
1028  responseParam->setSrResSn(content->getValue1());
1029  if (content->getValue2() == -1) {
1030  responseParam->setResult(0);
1032  } else {
1033  responseParam->setResult(content->getValue2());
1034  }
1036  if (content->getValue3() != -2) {
1037  if (content->getValue3() == -1) {
1038  responseParam->setSendersNextTsn(0);
1040  } else {
1041  responseParam->setSendersNextTsn(content->getValue3());
1042  }
1043  if (content->getValue4() == -1) {
1044  responseParam->setReceiversNextTsn(0);
1046  } else {
1047  responseParam->setReceiversNextTsn(content->getValue4());
1048  }
1049  len += 8;
1050  }
1051  responseParam->setByteLength(len);
1052  resetChunk->addParameter(responseParam);
1053  break;
1054  }
1056  SCTPAddStreamsRequestParameter *addInParam =
1057  new SCTPAddStreamsRequestParameter("ADD_INCOMING_STREAMS_REQUEST_PARAMETER");
1058  PacketDrillStruct *content = (PacketDrillStruct *)parameter->getContent();
1060  addInParam->setSrReqSn(content->getValue1());
1061  addInParam->setNumberOfStreams(content->getValue2());
1062  addInParam->setReserved(0);
1063  addInParam->setByteLength(SCTP_ADD_STREAMS_REQUEST_PARAMETER_LENGTH);
1064  resetChunk->addParameter(addInParam);
1065  break;
1066  }
1068  SCTPAddStreamsRequestParameter *addOutParam =
1069  new SCTPAddStreamsRequestParameter("ADD_OUTGOING_STREAMS_REQUEST_PARAMETER");
1070  PacketDrillStruct *content = (PacketDrillStruct *)parameter->getContent();
1072  addOutParam->setSrReqSn(content->getValue1());
1073  addOutParam->setNumberOfStreams(content->getValue2());
1074  addOutParam->setReserved(0);
1075  addOutParam->setByteLength(SCTP_ADD_STREAMS_REQUEST_PARAMETER_LENGTH);
1076  resetChunk->addParameter(addOutParam);
1077  break;
1078  }
1079  default: printf("Parameter type not implemented\n");
1080  }
1081  }
1082  for (cQueue::Iterator iter(*parameters); !iter.end(); iter++)
1083  parameters->remove((PacketDrillEvent *) (*iter));
1084  delete parameters;
1085  }
1086  resetChunk->setFlags(flags);
1087  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(RE_CONFIG, (SCTPChunk *)resetChunk);
1088  return sctpchunk;
1089 }
virtual void setSrReqSn(uint32_t srReqSn)
Definition: PacketDrillUtils.h:529
int64 getValue1() const
Definition: PacketDrillUtils.h:634
virtual void setFlags(uint32_t flags)
#define SCTP_ADD_STREAMS_REQUEST_PARAMETER_LENGTH
Definition: SCTPAssociation.h:229
#define SCTP_SSN_TSN_RESET_REQUEST_PARAMETER_LENGTH
Definition: SCTPAssociation.h:227
#define SCTP_INCOMING_RESET_REQUEST_PARAMETER_LENGTH
Definition: SCTPAssociation.h:226
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:286 by nedtool.
Definition: SCTPMessage_m.h:1567
virtual void addParameter(cPacket *msg)
Adds a message object to the SCTP packet.
Definition: SCTPMessage.cc:264
Definition: PacketDrillUtils.h:717
uint16_t len
Definition: TCP_NSC.cc:85
#define SCTP_STREAM_RESET_CHUNK_LENGTH
Definition: SCTPAssociation.h:224
#define FLAG_RECONFIG_LAST_TSN_NOCHECK
Definition: PacketDrillUtils.h:134
virtual void setResult(uint32_t result)
Definition: PacketDrillUtils.h:627
#define FLAG_RECONFIG_RESP_SN_NOCHECK
Definition: PacketDrillUtils.h:133
virtual void setChunkType(uint8_t chunkType)
virtual void setStreamNumbersArraySize(unsigned int size)
void * getContent()
Definition: PacketDrillUtils.h:755
Definition: SCTPAssociation.h:159
virtual void setSrResSn(uint32_t srResSn)
virtual void setSendersNextTsn(uint32_t sendersNextTsn)
virtual void setSrReqSn(uint32_t srReqSn)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:281 by nedtool.
Definition: SCTPMessage_m.h:1526
virtual void setReceiversNextTsn(uint32_t receiversNextTsn)
Definition: PacketDrillUtils.h:482
#define SCTP_STREAM_RESET_RESPONSE_PARAMETER_LENGTH
Definition: SCTPAssociation.h:228
cQueue * getStreams()
Definition: PacketDrillUtils.h:640
virtual void setLastTsn(uint32_t lastTsn)
virtual void setStreamNumbers(unsigned int k, uint16_t streamNumbers)
Definition: SCTPAssociation.h:156
Definition: SCTPAssociation.h:128
Definition: PacketDrillUtils.h:731
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
#define FLAG_RECONFIG_RESULT_NOCHECK
Definition: PacketDrillUtils.h:129
#define SCTP_OUTGOING_RESET_REQUEST_PARAMETER_LENGTH
Definition: SCTPAssociation.h:225
virtual void setParameterType(uint16_t parameterType)
virtual void setNumberOfStreams(uint16_t numberOfStreams)
Definition: SCTPAssociation.h:157
virtual void setReserved(uint16_t reserved)
virtual unsigned int getStreamNumbersArraySize() const
uint32_t uint32
Definition: Compat.h:30
#define FLAG_RECONFIG_RECEIVER_NEXT_TSN_NOCHECK
Definition: PacketDrillUtils.h:131
Definition: SCTPAssociation.h:158
int32 getValue3() const
Definition: PacketDrillUtils.h:638
Definition: SCTPMessage.h:120
int32 getValue4() const
Definition: PacketDrillUtils.h:639
uint16_t uint16
Definition: Compat.h:32
virtual void setStreamNumbers(unsigned int k, uint16_t streamNumbers)
virtual void setSrResSn(uint32_t srResSn)
#define FLAG_RECONFIG_REQ_SN_NOCHECK
Definition: PacketDrillUtils.h:132
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:294 by nedtool.
Definition: SCTPMessage_m.h:1616
virtual void setStreamNumbersArraySize(unsigned int size)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:266 by nedtool.
Definition: SCTPMessage_m.h:1407
uint16 getType() const
Definition: PacketDrillUtils.h:752
#define FLAG_RECONFIG_SENDER_NEXT_TSN_NOCHECK
Definition: PacketDrillUtils.h:130
virtual void setSrReqSn(uint32_t srReqSn)
virtual unsigned int getStreamNumbersArraySize() const
int64 getValue2() const
Definition: PacketDrillUtils.h:636
PacketDrillSctpChunk * PacketDrill::buildSackChunk ( int64  flgs,
int64  cum_tsn,
int64  a_rwnd,
cQueue *  gaps,
cQueue *  dups 
)
static

Referenced by yyparse().

702 {
703  SCTPSackChunk* sackchunk = new SCTPSackChunk();
704  sackchunk->setChunkType(SACK);
705  sackchunk->setName("SACK");
706  uint32 flags = 0;
707 
708  if (cum_tsn == -1) {
709  sackchunk->setCumTsnAck(0);
711  } else {
712  sackchunk->setCumTsnAck((uint32) cum_tsn);
713  }
714 
715  if (a_rwnd == -1) {
716  sackchunk->setA_rwnd(0);
718  } else {
719  sackchunk->setA_rwnd((uint32) a_rwnd);
720  }
721 
722  if (gaps == NULL) {
723  sackchunk->setNumGaps(0);
724  flags |= FLAG_CHUNK_LENGTH_NOCHECK;
726  } else if (gaps->getLength() != 0) {
727  gaps->setName("gapList");
728  int num = 0;
729  PacketDrillStruct* gap;
730  sackchunk->setNumGaps(gaps->getLength());
731  sackchunk->setGapStartArraySize(gaps->getLength());
732  sackchunk->setGapStopArraySize(gaps->getLength());
733  for (cQueue::Iterator iter(*gaps); !iter.end(); iter++) {
734  gap = (PacketDrillStruct*)(*iter);
735  sackchunk->setGapStart(num, gap->getValue1());
736  sackchunk->setGapStop(num, gap->getValue2());
737  num++;
738  }
739  delete gaps;
740  } else {
741  sackchunk->setNumGaps(0);
742  delete gaps;
743  }
744 
745  if (dups == NULL) {
746  sackchunk->setNumDupTsns(0);
747  flags |= FLAG_CHUNK_LENGTH_NOCHECK;
749  } else if (dups->getLength() != 0) {
750  int num = 0;
751  PacketDrillStruct* tsn;
752  sackchunk->setNumDupTsns(dups->getLength());
753  sackchunk->setDupTsnsArraySize(dups->getLength());
754 
755  for (cQueue::Iterator iter(*dups); !iter.end(); iter++) {
756  tsn = (PacketDrillStruct*)(*iter);
757  sackchunk->setDupTsns(num, tsn->getValue1());
758  num++;
759  }
760  delete dups;
761  } else {
762  sackchunk->setNumDupTsns(0);
763  delete dups;
764  }
765  sackchunk->setByteLength(SCTP_SACK_CHUNK_LENGTH + (sackchunk->getNumGaps() + sackchunk->getNumDupTsns()) * 4);
766  sackchunk->setFlags(flags);
767  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(SACK, (SCTPChunk *)sackchunk);
768  return sctpchunk;
769 
770 }
virtual void setNumGaps(uint16_t numGaps)
int64 getValue1() const
Definition: PacketDrillUtils.h:634
virtual void setFlags(uint32_t flags)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:177 by nedtool.
Definition: SCTPMessage_m.h:824
Definition: PacketDrillUtils.h:717
virtual void setGapStartArraySize(unsigned int size)
virtual void setGapStop(unsigned int k, uint32_t gapStop)
Definition: PacketDrillUtils.h:627
#define FLAG_CHUNK_LENGTH_NOCHECK
Definition: PacketDrillUtils.h:98
virtual void setChunkType(uint8_t chunkType)
virtual uint16_t getNumGaps() const
virtual void setDupTsnsArraySize(unsigned int size)
#define FLAG_SACK_CHUNK_A_RWND_NOCHECK
Definition: PacketDrillUtils.h:125
#define SCTP_SACK_CHUNK_LENGTH
Definition: SCTPAssociation.h:215
#define FLAG_SACK_CHUNK_DUP_TSNS_NOCHECK
Definition: PacketDrillUtils.h:127
virtual uint16_t getNumDupTsns() const
#define FLAG_SACK_CHUNK_CUM_TSN_NOCHECK
Definition: PacketDrillUtils.h:124
virtual void setNumDupTsns(uint16_t numDupTsns)
virtual void setA_rwnd(uint32_t a_rwnd)
virtual void setDupTsns(unsigned int k, uint32_t dupTsns)
virtual void setCumTsnAck(uint32_t cumTsnAck)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
uint32_t uint32
Definition: Compat.h:30
Definition: SCTPAssociation.h:114
virtual void setGapStart(unsigned int k, uint32_t gapStart)
virtual void setGapStopArraySize(unsigned int size)
#define FLAG_SACK_CHUNK_GAP_BLOCKS_NOCHECK
Definition: PacketDrillUtils.h:126
int64 getValue2() const
Definition: PacketDrillUtils.h:636
cPacket * PacketDrill::buildSCTPPacket ( int  address_family,
enum direction_t  direction,
cQueue *  chunks 
)
static

Referenced by yyparse().

248 {
250  SCTPMessage *sctpmsg = new SCTPMessage();
251  sctpmsg->setByteLength(SCTP_COMMON_HEADER);
252  if (direction == DIRECTION_INBOUND) {
253  sctpmsg->setSrcPort(app->getRemotePort());
254  sctpmsg->setDestPort(app->getLocalPort());
255  sctpmsg->setTag(app->getPeerVTag());
256  sctpmsg->setName("SCTPInbound");
257  for (cQueue::Iterator iter(*chunks); !iter.end(); iter++) {
259  SCTPChunk *sctpchunk = (SCTPChunk *)chunk->getChunk();
260  switch (chunk->getType()) {
262  if (sctpchunk->getFlags() & FLAG_CHUNK_FLAGS_NOCHECK) {
263  printf("chunk flags must be specified for inbound packets\n");
264  return nullptr;
265  }
266  if (sctpchunk->getFlags() & FLAG_CHUNK_LENGTH_NOCHECK) {
267  printf("chunk length must be specified for inbound packets\n");
268  return nullptr;
269  }
270  if (sctpchunk->getFlags() & FLAG_DATA_CHUNK_TSN_NOCHECK) {
271  printf("TSN must be specified for inbound packets\n");
272  return nullptr;
273  }
274  if (sctpchunk->getFlags() & FLAG_DATA_CHUNK_SID_NOCHECK) {
275  printf("SID must be specified for inbound packets\n");
276  return nullptr;
277  }
278  if (sctpchunk->getFlags() & FLAG_DATA_CHUNK_SSN_NOCHECK) {
279  printf("SSN must be specified for inbound packets\n");
280  return nullptr;
281  }
282  if (sctpchunk->getFlags() & FLAG_DATA_CHUNK_PPID_NOCHECK) {
283  printf("PPID must be specified for inbound packets\n");
284  return nullptr;
285  }
286  break;
287  case INIT:
288  if (sctpchunk->getFlags() & FLAG_INIT_CHUNK_TAG_NOCHECK) {
289  printf("TAG must be specified for inbound packets\n");
290  return nullptr;
291  }
292  if (sctpchunk->getFlags() & FLAG_INIT_CHUNK_A_RWND_NOCHECK) {
293  printf("A_RWND must be specified for inbound packets\n");
294  return nullptr;
295  }
296  if (sctpchunk->getFlags() & FLAG_INIT_CHUNK_OS_NOCHECK) {
297  printf("OS must be specified for inbound packets\n");
298  return nullptr;
299  }
300  if (sctpchunk->getFlags() & FLAG_INIT_CHUNK_IS_NOCHECK) {
301  printf("IS must be specified for inbound packets\n");
302  return nullptr;
303  }
304  if (sctpchunk->getFlags() & FLAG_INIT_CHUNK_OPT_PARAM_NOCHECK) {
305  printf("list of optional parameters must be specified for inbound packets\n");
306  return nullptr;
307  }
308  break;
309  case INIT_ACK:
310  if (sctpchunk->getFlags() & FLAG_INIT_ACK_CHUNK_TAG_NOCHECK) {
311  printf("TAG must be specified for inbound packets\n");
312  return nullptr;
313  }
314  if (sctpchunk->getFlags() & FLAG_INIT_ACK_CHUNK_A_RWND_NOCHECK) {
315  printf("A_RWND must be specified for inbound packets\n");
316  return nullptr;
317  }
318  if (sctpchunk->getFlags() & FLAG_INIT_ACK_CHUNK_OS_NOCHECK) {
319  printf("OS must be specified for inbound packets\n");
320  return nullptr;
321  }
322  if (sctpchunk->getFlags() & FLAG_INIT_ACK_CHUNK_IS_NOCHECK) {
323  printf("IS must be specified for inbound packets\n");
324  return nullptr;
325  }
326  if (sctpchunk->getFlags() & FLAG_INIT_ACK_CHUNK_OPT_PARAM_NOCHECK) {
327  printf("list of optional parameters must be specified for inbound packets\n");
328  return nullptr;
329  }
330  break;
332  if (sctpchunk->getFlags() & FLAG_SACK_CHUNK_CUM_TSN_NOCHECK) {
333  printf("CUM_TSN must be specified for inbound packets\n");
334  return nullptr;
335  }
336  if (sctpchunk->getFlags() & FLAG_SACK_CHUNK_A_RWND_NOCHECK) {
337  printf("A_RWND must be specified for inbound packets\n");
338  return nullptr;
339  }
340  if (sctpchunk->getFlags() & FLAG_SACK_CHUNK_GAP_BLOCKS_NOCHECK) {
341  printf("GAP_BLOCKS must be specified for inbound packets\n");
342  return nullptr;
343  }
344  if (sctpchunk->getFlags() & FLAG_SACK_CHUNK_DUP_TSNS_NOCHECK) {
345  printf("DUP_TSNS must be specified for inbound packets\n");
346  return nullptr;
347  }
348  break;
350  if (sctpchunk->getFlags() & FLAG_CHUNK_LENGTH_NOCHECK) {
351  printf("error causes must be specified for inbound packets\n");
352  return nullptr;
353  }
354  break;
356  if (sctpchunk->getFlags() & FLAG_SHUTDOWN_CHUNK_CUM_TSN_NOCHECK) {
357  printf("TSN must be specified for inbound packets\n");
358  return nullptr;
359  }
360  break;
361  default:
362  if (sctpchunk->getFlags() & FLAG_CHUNK_TYPE_NOCHECK) {
363  printf("chunk type must be specified for inbound packets\n");
364  return nullptr;
365  }
366  if (sctpchunk->getFlags() & FLAG_CHUNK_FLAGS_NOCHECK) {
367  printf("chunk flags must be specified for inbound packets\n");
368  return nullptr;
369  }
370  if (sctpchunk->getFlags() & FLAG_CHUNK_LENGTH_NOCHECK) {
371  printf("chunk length must be specified for inbound packets\n");
372  return nullptr;
373  }
374  break;
375  }
376  }
377  } else if (direction == DIRECTION_OUTBOUND) {
378  sctpmsg->setSrcPort(app->getLocalPort());
379  sctpmsg->setDestPort(app->getRemotePort());
380  sctpmsg->setTag(app->getLocalVTag());
381  sctpmsg->setName("SCTPOutbound");
382  for (cQueue::Iterator iter(*chunks); !iter.end(); iter++) {
383  PacketDrillSctpChunk *chunk = (PacketDrillSctpChunk *) (*iter);
384  SCTPChunk *sctpchunk = (SCTPChunk *)chunk->getChunk();
385  switch (sctpchunk->getChunkType()) {
387  SCTPStreamResetChunk* reconfig = check_and_cast<SCTPStreamResetChunk*>(sctpchunk);
388  for (unsigned int i = 0; i < reconfig->getParametersArraySize(); i++) {
389  SCTPParameter *parameter = check_and_cast<SCTPParameter *>(reconfig->getParameters(i));
390  switch (parameter->getParameterType()) {
392  printf("OUTGOING_RESET_REQUEST_PARAMETER\n");
393  SCTPOutgoingSSNResetRequestParameter *outResetParam = check_and_cast<SCTPOutgoingSSNResetRequestParameter *>(parameter);
394  if (!(pdapp->findSeqNumMap(outResetParam->getSrReqSn()))) {
395  pdapp->setSeqNumMap(outResetParam->getSrReqSn(), 0);
396  }
397  break;
398  }
400  printf("INCOMING_RESET_REQUEST_PARAMETER\n");
401  SCTPIncomingSSNResetRequestParameter *inResetParam = check_and_cast<SCTPIncomingSSNResetRequestParameter *>(parameter);
402  if (!(pdapp->findSeqNumMap(inResetParam->getSrReqSn()))) {
403  pdapp->setSeqNumMap(inResetParam->getSrReqSn(), 0);
404  }
405  break;
406  }
408  printf("SSN_TSN_RESET_REQUEST_PARAMETER\n");
409  SCTPSSNTSNResetRequestParameter *ssntsnResetParam = check_and_cast<SCTPSSNTSNResetRequestParameter *>(parameter);
410  if (!(pdapp->findSeqNumMap(ssntsnResetParam->getSrReqSn()))) {
411  pdapp->setSeqNumMap(ssntsnResetParam->getSrReqSn(), 0);
412  }
413  break;
414  }
416  printf("ADD_OUTGOING_STREAMS_REQUEST_PARAMETER\n");
417  SCTPAddStreamsRequestParameter *addOutResetParam = check_and_cast<SCTPAddStreamsRequestParameter *>(parameter);
418  if (!(pdapp->findSeqNumMap(addOutResetParam->getSrReqSn()))) {
419  pdapp->setSeqNumMap(addOutResetParam->getSrReqSn(), 0);
420  }
421  break;
422  }
424  printf("ADD_INCOMING_STREAMS_REQUEST_PARAMETER\n");
425  SCTPAddStreamsRequestParameter *addInResetParam = check_and_cast<SCTPAddStreamsRequestParameter *>(parameter);
426  if (!(pdapp->findSeqNumMap(addInResetParam->getSrReqSn()))) {
427  pdapp->setSeqNumMap(addInResetParam->getSrReqSn(), 0);
428  }
429  break;
430  }
431  }
432  }
433  break;
434  }
435  }
436  }
437  sctpmsg->setChecksumOk(true);
438 
439  for (cQueue::Iterator iter(*chunks); !iter.end(); iter++) {
440  PacketDrillSctpChunk *chunk = (PacketDrillSctpChunk *)(*iter);
441  sctpmsg->addChunk(chunk->getChunk());
442  }
443 
444  IPv4Datagram *ipDatagram = PacketDrill::makeIPPacket(IP_PROT_SCTP, direction, app->getLocalAddress(),
445  app->getRemoteAddress());
446  ipDatagram->encapsulate(sctpmsg);
447  cPacket* pkt = ipDatagram->dup();
448  delete ipDatagram;
449  delete chunks;
450  return pkt;
451 }
static IPv4Datagram * makeIPPacket(int protocol, enum direction_t direction, L3Address localAddr, L3Address remoteAddr)
Definition: PacketDrill.cc:49
#define FLAG_CHUNK_FLAGS_NOCHECK
Definition: PacketDrillUtils.h:97
#define FLAG_INIT_CHUNK_OPT_PARAM_NOCHECK
Definition: PacketDrillUtils.h:106
SCTPChunk * getChunk()
Definition: PacketDrillUtils.h:728
virtual uint16_t getParameterType() const
Definition: sctphdr.h:121
virtual void addChunk(cPacket *msg)
Adds a message object to the SCTP packet.
Definition: SCTPMessage.cc:93
Implements the packetdrill application simple module.
Definition: PacketDrillApp.h:43
#define FLAG_INIT_ACK_CHUNK_A_RWND_NOCHECK
Definition: PacketDrillUtils.h:110
static PacketDrillApp * pdapp
Definition: PacketDrill.h:41
#define SCTP_ABORT_CHUNK_TYPE
Definition: PacketDrillUtils.h:76
#define FLAG_DATA_CHUNK_SSN_NOCHECK
Definition: PacketDrillUtils.h:120
Definition: PacketDrillUtils.h:717
#define FLAG_CHUNK_TYPE_NOCHECK
Definition: PacketDrillUtils.h:96
#define FLAG_DATA_CHUNK_SID_NOCHECK
Definition: PacketDrillUtils.h:119
virtual uint32_t getSrReqSn() const
#define FLAG_CHUNK_LENGTH_NOCHECK
Definition: PacketDrillUtils.h:98
virtual void setTag(uint32_t tag)
Definition: PacketDrillUtils.h:186
#define SCTP_SACK_CHUNK_TYPE
Definition: PacketDrillUtils.h:73
#define SCTP_RECONFIG_CHUNK_TYPE
Definition: PacketDrillUtils.h:84
virtual IPv4Datagram * dup() const override
Definition: IPv4Datagram.h:42
const L3Address getRemoteAddress()
Definition: PacketDrillApp.h:60
#define FLAG_SACK_CHUNK_A_RWND_NOCHECK
Definition: PacketDrillUtils.h:125
#define FLAG_SACK_CHUNK_DUP_TSNS_NOCHECK
Definition: PacketDrillUtils.h:127
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:281 by nedtool.
Definition: SCTPMessage_m.h:1526
#define SCTP_COMMON_HEADER
Definition: SCTPAssociation.h:212
#define FLAG_SACK_CHUNK_CUM_TSN_NOCHECK
Definition: PacketDrillUtils.h:124
Represents an IPv4 datagram.
Definition: IPv4Datagram.h:31
Definition: SCTPAssociation.h:156
#define FLAG_INIT_ACK_CHUNK_OPT_PARAM_NOCHECK
Definition: PacketDrillUtils.h:114
virtual uint32 getParametersArraySize() const override
Definition: SCTPMessage.cc:249
#define FLAG_INIT_ACK_CHUNK_IS_NOCHECK
Definition: PacketDrillUtils.h:112
const L3Address getLocalAddress()
Definition: PacketDrillApp.h:59
Definition: SCTPAssociation.h:112
virtual cPacketPtr & getParameters(uint32 k) override
Returns the kth parameter in this SCTP Reset Chunk.
Definition: SCTPMessage.cc:254
virtual void setDestPort(uint16_t destPort)
#define FLAG_INIT_ACK_CHUNK_TAG_NOCHECK
Definition: PacketDrillUtils.h:109
#define FLAG_INIT_CHUNK_TAG_NOCHECK
Definition: PacketDrillUtils.h:101
bool findSeqNumMap(uint32 num)
Definition: PacketDrillApp.cc:603
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
#define FLAG_INIT_CHUNK_IS_NOCHECK
Definition: PacketDrillUtils.h:104
Definition: PacketDrillUtils.h:185
const int getRemotePort()
Definition: PacketDrillApp.h:53
Definition: SCTPAssociation.h:157
uint32 getPeerVTag()
Definition: PacketDrillApp.h:61
#define FLAG_DATA_CHUNK_PPID_NOCHECK
Definition: PacketDrillUtils.h:121
uint32 getLocalVTag()
Definition: PacketDrillApp.h:62
Definition: SCTPAssociation.h:158
uint8 getType()
Definition: PacketDrillUtils.h:727
#define FLAG_INIT_CHUNK_OS_NOCHECK
Definition: PacketDrillUtils.h:103
Definition: SCTPMessage.h:120
virtual uint32_t getFlags() const
#define FLAG_INIT_CHUNK_A_RWND_NOCHECK
Definition: PacketDrillUtils.h:102
Represents a SCTP Message.
Definition: SCTPMessage.h:35
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:244 by nedtool.
Definition: SCTPMessage_m.h:1240
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:294 by nedtool.
Definition: SCTPMessage_m.h:1616
#define FLAG_DATA_CHUNK_TSN_NOCHECK
Definition: PacketDrillUtils.h:118
#define SCTP_SHUTDOWN_CHUNK_TYPE
Definition: PacketDrillUtils.h:77
Definition: SCTPAssociation.h:113
virtual void setChecksumOk(bool checksumOk)
void setSeqNumMap(uint32 ownNum, uint32 liveNum)
Definition: PacketDrillApp.h:66
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:266 by nedtool.
Definition: SCTPMessage_m.h:1407
virtual uint8_t getChunkType() const
const int getLocalPort()
Definition: PacketDrillApp.h:52
Definition: IPProtocolId_m.h:91
virtual void setSrcPort(uint16_t srcPort)
#define FLAG_SHUTDOWN_CHUNK_CUM_TSN_NOCHECK
Definition: PacketDrillUtils.h:116
#define SCTP_DATA_CHUNK_TYPE
Definition: PacketDrillUtils.h:70
#define FLAG_SACK_CHUNK_GAP_BLOCKS_NOCHECK
Definition: PacketDrillUtils.h:126
#define FLAG_INIT_ACK_CHUNK_OS_NOCHECK
Definition: PacketDrillUtils.h:111
PacketDrillSctpChunk * PacketDrill::buildShutdownAckChunk ( int64  flgs)
static

Referenced by yyparse().

823 {
824  SCTPShutdownAckChunk *shutdownAckChunk = new SCTPShutdownAckChunk("Shutdown_Ack");
825  shutdownAckChunk->setChunkType(SHUTDOWN_ACK);
826  shutdownAckChunk->setByteLength(SCTP_COOKIE_ACK_LENGTH);
827  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(SHUTDOWN_ACK, (SCTPChunk *)shutdownAckChunk);
828  return sctpchunk;
829 }
#define SCTP_COOKIE_ACK_LENGTH
Definition: SCTPAssociation.h:219
Definition: SCTPAssociation.h:119
Definition: PacketDrillUtils.h:717
virtual void setChunkType(uint8_t chunkType)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:227 by nedtool.
Definition: SCTPMessage_m.h:1095
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
PacketDrillSctpChunk * PacketDrill::buildShutdownChunk ( int64  flgs,
int64  cum_tsn 
)
static

Referenced by yyparse().

804 {
805  SCTPShutdownChunk *shutdownchunk = new SCTPShutdownChunk();
806  shutdownchunk->setChunkType(SHUTDOWN);
807  shutdownchunk->setName("SHUTDOWN");
808  uint32 flags = 0;
809 
810  if (cum_tsn == -1) {
812  shutdownchunk->setCumTsnAck(0);
813  } else {
814  shutdownchunk->setCumTsnAck((uint32) cum_tsn);
815  }
816  shutdownchunk->setFlags(flags);
817  shutdownchunk->setByteLength(SCTP_SHUTDOWN_CHUNK_LENGTH);
818  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(SHUTDOWN, (SCTPChunk *)shutdownchunk);
819  return sctpchunk;
820 }
virtual void setFlags(uint32_t flags)
Definition: SCTPAssociation.h:118
Definition: PacketDrillUtils.h:717
#define SCTP_SHUTDOWN_CHUNK_LENGTH
Definition: SCTPAssociation.h:221
virtual void setCumTsnAck(uint32_t cumTsnAck)
virtual void setChunkType(uint8_t chunkType)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:222 by nedtool.
Definition: SCTPMessage_m.h:1058
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
uint32_t uint32
Definition: Compat.h:30
#define FLAG_SHUTDOWN_CHUNK_CUM_TSN_NOCHECK
Definition: PacketDrillUtils.h:116
PacketDrillSctpChunk * PacketDrill::buildShutdownCompleteChunk ( int64  flgs)
static

Referenced by yyparse().

832 {
833  SCTPShutdownCompleteChunk *shutdowncompletechunk = new SCTPShutdownCompleteChunk();
834  shutdowncompletechunk->setChunkType(SHUTDOWN_COMPLETE);
835  shutdowncompletechunk->setName("SHUTDOWN_COMPLETE");
836 
837  if (flgs != -1) {
838  shutdowncompletechunk->setTBit(flgs);
839  } else {
840  flgs |= FLAG_CHUNK_FLAGS_NOCHECK;
841  }
842  shutdowncompletechunk->setByteLength(SCTP_SHUTDOWN_ACK_LENGTH);
843  PacketDrillSctpChunk *sctpchunk = new PacketDrillSctpChunk(SHUTDOWN_COMPLETE, (SCTPChunk *)shutdowncompletechunk);
844  return sctpchunk;
845 }
#define FLAG_CHUNK_FLAGS_NOCHECK
Definition: PacketDrillUtils.h:97
virtual void setTBit(bool TBit)
Definition: PacketDrillUtils.h:717
virtual void setChunkType(uint8_t chunkType)
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:50 by nedtool.
Definition: SCTPMessage_m.h:137
Class generated from inet/transportlayer/sctp/SCTPMessage.msg:231 by nedtool.
Definition: SCTPMessage_m.h:1130
#define SCTP_SHUTDOWN_ACK_LENGTH
Definition: SCTPAssociation.h:222
Definition: SCTPAssociation.h:123
cPacket * PacketDrill::buildTCPPacket ( int  address_family,
enum direction_t  direction,
const char *  flags,
uint32  startSequence,
uint16  tcpPayloadBytes,
uint32  ackSequence,
int32  window,
cQueue *  tcpOptions,
char **  error 
)
static

Referenced by yyparse().

178 {
180  TCPSegment *tcpseg = new TCPSegment("TCPInject");
181 
182  // fill TCP header structure
183  if (direction == DIRECTION_INBOUND) {
184  tcpseg->setSrcPort(app->getRemotePort());
185  tcpseg->setDestPort(app->getLocalPort());
186  tcpseg->setName("TCPInbound");
187  } else if (direction == DIRECTION_OUTBOUND) {
188  tcpseg->setSrcPort(app->getLocalPort());
189  tcpseg->setDestPort(app->getRemotePort());
190  tcpseg->setName("TCPOutbound");
191  }
192  tcpseg->setSequenceNo(startSequence);
193  tcpseg->setAckNo(ackSequence);
194 
196 
197  // set flags
198  tcpseg->setFinBit(strchr(flags, 'F'));
199  tcpseg->setSynBit(strchr(flags, 'S'));
200  tcpseg->setRstBit(strchr(flags, 'R'));
201  tcpseg->setPshBit(strchr(flags, 'P'));
202  tcpseg->setAckBit(strchr(flags, '.'));
203  tcpseg->setUrgBit(0);
204  if (tcpseg->getSynBit() && !tcpseg->getAckBit())
205  tcpseg->setName("Inject SYN");
206  else if (tcpseg->getSynBit() && tcpseg->getAckBit())
207  tcpseg->setName("Inject SYN ACK");
208  else if (!tcpseg->getSynBit() && tcpseg->getAckBit() && !tcpseg->getPshBit())
209  tcpseg->setName("Inject ACK");
210  else if (tcpseg->getPshBit())
211  tcpseg->setName("Inject PUSH");
212  else if (tcpseg->getFinBit())
213  tcpseg->setName("Inject FIN");
214 
215  tcpseg->setWindow(window);
216  tcpseg->setUrgentPointer(0);
217  // Checksum (header checksum): modelled by cMessage::hasBitError()
218 
219  uint16 tcpOptionsLength = 0;
220 
221  if (tcpOptions && tcpOptions->getLength() > 0) { // options present?
222  TCPOption *option;
223  uint16 optionsCounter = 0;
224 
225  for (cQueue::Iterator iter(*tcpOptions); !iter.end(); iter++) {
227  option = setOptionValues(opt);
228  tcpOptionsLength += opt->getLength();
229  // write option to tcp header
230  tcpseg->addHeaderOption(option);
231  optionsCounter++;
232  } // for
233  } // if options present
234  tcpseg->setHeaderLength(tcpseg->getHeaderLength() + tcpOptionsLength);
235  tcpseg->setByteLength(tcpseg->getHeaderLength() + tcpPayloadBytes);
236  tcpseg->setPayloadLength(tcpPayloadBytes);
237 
238  IPv4Datagram *ipDatagram = PacketDrill::makeIPPacket(IP_PROT_TCP, direction, app->getLocalAddress(),
239  app->getRemoteAddress());
240  ipDatagram->encapsulate(tcpseg);
241  cPacket* pkt = ipDatagram->dup();
242  delete tcpOptions;
243  delete ipDatagram;
244  return pkt;
245 }
static IPv4Datagram * makeIPPacket(int protocol, enum direction_t direction, L3Address localAddr, L3Address remoteAddr)
Definition: PacketDrill.cc:49
virtual void setRstBit(bool rstBit)
Implements the packetdrill application simple module.
Definition: PacketDrillApp.h:43
static PacketDrillApp * pdapp
Definition: PacketDrill.h:41
virtual void setAckNo(unsigned int ackNo)
virtual bool getPshBit() const
Definition: PacketDrillUtils.h:186
virtual IPv4Datagram * dup() const override
Definition: IPv4Datagram.h:42
const L3Address getRemoteAddress()
Definition: PacketDrillApp.h:60
virtual void setWindow(unsigned short window)
virtual void setUrgentPointer(unsigned short urgentPointer)
virtual bool getAckBit() const
Represents an IPv4 datagram.
Definition: IPv4Datagram.h:31
virtual void setPshBit(bool pshBit)
virtual bool getSynBit() const
virtual void setFinBit(bool finBit)
const L3Address getLocalAddress()
Definition: PacketDrillApp.h:59
virtual void setHeaderLength(unsigned short headerLength)
virtual void setSequenceNo(unsigned int sequenceNo)
TCPOption * setOptionValues(PacketDrillTcpOption *opt)
Definition: PacketDrill.cc:106
#define TCP_HEADER_OCTETS
Definition: TCPSegment_m.h:50
virtual void setSynBit(bool synBit)
virtual unsigned short getHeaderLength() const
Definition: PacketDrillUtils.h:185
const int getRemotePort()
Definition: PacketDrillApp.h:53
virtual void setUrgBit(bool urgBit)
virtual void setDestPort(unsigned short destPort)
Definition: IPProtocolId_m.h:80
virtual void setPayloadLength(unsigned long payloadLength)
Represents a TCP segment.
Definition: TCPSegment.h:60
uint16_t uint16
Definition: Compat.h:32
virtual bool getFinBit() const
virtual void setSrcPort(unsigned short srcPort)
Class generated from inet/transportlayer/tcp_common/TCPSegment.msg:129 by nedtool.
Definition: TCPSegment_m.h:234
virtual void setAckBit(bool ackBit)
uint16 getLength()
Definition: PacketDrillUtils.h:701
const int getLocalPort()
Definition: PacketDrillApp.h:52
Definition: PacketDrillUtils.h:681
virtual void addHeaderOption(TCPOption *headerOption)
Adds a TCP option to the TCP segment.
Definition: TCPSegment.cc:235
cPacket * PacketDrill::buildUDPPacket ( int  address_family,
enum direction_t  direction,
uint16  udp_payload_bytes,
char **  error 
)
static

Referenced by yyparse().

80 {
82  UDPPacket *udpPacket = new UDPPacket("UDPInject");
83  udpPacket->setByteLength(8);
84  cPacket *payload = new cPacket("payload");
85  payload->setByteLength(udp_payload_bytes);
86  udpPacket->encapsulate(payload);
87  IPv4Datagram *ipDatagram = PacketDrill::makeIPPacket(IP_PROT_UDP, direction, app->getLocalAddress(), app->getRemoteAddress());
88  if (direction == DIRECTION_INBOUND) {
89  udpPacket->setSourcePort(app->getRemotePort());
90  udpPacket->setDestinationPort(app->getLocalPort());
91  udpPacket->setName("UDPInbound");
92  } else if (direction == DIRECTION_OUTBOUND) {
93  udpPacket->setSourcePort(app->getLocalPort());
94  udpPacket->setDestinationPort(app->getRemotePort());
95  udpPacket->setName("UDPOutbound");
96  } else
97  throw cRuntimeError("Unknown direction");
98 
99  ipDatagram->encapsulate(udpPacket);
100  cPacket* pkt = ipDatagram->dup();
101  delete ipDatagram;
102  return pkt;
103 }
static IPv4Datagram * makeIPPacket(int protocol, enum direction_t direction, L3Address localAddr, L3Address remoteAddr)
Definition: PacketDrill.cc:49
virtual void setSourcePort(unsigned int port) override
Definition: UDPPacket.h:45
Implements the packetdrill application simple module.
Definition: PacketDrillApp.h:43
static PacketDrillApp * pdapp
Definition: PacketDrill.h:41
Definition: PacketDrillUtils.h:186
virtual IPv4Datagram * dup() const override
Definition: IPv4Datagram.h:42
const L3Address getRemoteAddress()
Definition: PacketDrillApp.h:60
virtual void setDestinationPort(unsigned int port) override
Definition: UDPPacket.h:47
Definition: UDPPacket.h:26
Represents an IPv4 datagram.
Definition: IPv4Datagram.h:31
const L3Address getLocalAddress()
Definition: PacketDrillApp.h:59
Definition: PacketDrillUtils.h:185
const int getRemotePort()
Definition: PacketDrillApp.h:53
Definition: IPProtocolId_m.h:83
const int getLocalPort()
Definition: PacketDrillApp.h:52
int PacketDrill::evaluate ( PacketDrillExpression in,
PacketDrillExpression out,
char **  error 
)
1092 {
1093  int result = STATUS_OK;
1094  int64 number;
1095  out->setType(in->getType());
1096 
1097  if ((in->getType() <= EXPR_NONE) || (in->getType() >= NUM_EXPR_TYPES)) {
1098  EV_ERROR << "bad expression type: " << in->getType() << endl;
1099  return STATUS_ERR;
1100  }
1101  switch (in->getType()) {
1102  case EXPR_ELLIPSIS:
1103  break;
1104 
1105  case EXPR_INTEGER:
1106  out->setNum(in->getNum());
1107  break;
1108 
1109  case EXPR_WORD:
1110  out->setType(EXPR_INTEGER);
1111  if (in->symbolToInt(in->getString(), &number, error))
1112  return STATUS_ERR;
1113  out->setNum(number);
1114  break;
1115 
1116  case EXPR_SCTP_INITMSG: {
1117  assert(in->getType() == EXPR_SCTP_INITMSG);
1118  assert(out->getType() == EXPR_SCTP_INITMSG);
1119  struct sctp_initmsg_expr *expr = (struct sctp_initmsg_expr *)malloc(sizeof(struct sctp_initmsg_expr));
1121  if (evaluate(in->getInitmsg()->sinit_num_ostreams, expr->sinit_num_ostreams, error)) {
1122  delete (expr->sinit_num_ostreams);
1123  free (expr);
1124  return STATUS_ERR;
1125  }
1127  if (evaluate(in->getInitmsg()->sinit_max_instreams, expr->sinit_max_instreams, error)) {
1128  delete (expr->sinit_num_ostreams);
1129  delete (expr->sinit_max_instreams);
1130  free (expr);
1131  return STATUS_ERR;
1132  }
1134  if (evaluate(in->getInitmsg()->sinit_max_attempts, expr->sinit_max_attempts, error)) {
1135  delete (expr->sinit_num_ostreams);
1136  delete (expr->sinit_max_instreams);
1137  delete (expr->sinit_max_attempts);
1138  free (expr);
1139  return STATUS_ERR;
1140  }
1142  if (evaluate(in->getInitmsg()->sinit_max_init_timeo, expr->sinit_max_init_timeo, error)) {
1143  delete (expr->sinit_num_ostreams);
1144  delete (expr->sinit_max_instreams);
1145  delete (expr->sinit_max_attempts);
1146  delete (expr->sinit_max_init_timeo);
1147  free (expr);
1148  return STATUS_ERR;
1149  }
1150  out->setInitmsg(expr);
1151  break;
1152  }
1153 
1154  case EXPR_SCTP_ASSOCPARAMS: {
1155  assert(in->getType() == EXPR_SCTP_ASSOCPARAMS);
1156  assert(out->getType() == EXPR_SCTP_ASSOCPARAMS);
1157  struct sctp_assocparams_expr *ap = (struct sctp_assocparams_expr *)malloc(sizeof(struct sctp_assocparams_expr));
1159  if (evaluate(in->getAssocParams()->sasoc_assoc_id, ap->sasoc_assoc_id, error)) {
1160  delete (ap->sasoc_assoc_id);
1161  free (ap);
1162  return STATUS_ERR;
1163  }
1165  if (evaluate(in->getAssocParams()->sasoc_asocmaxrxt, ap->sasoc_asocmaxrxt, error)) {
1166  delete (ap->sasoc_assoc_id);
1167  delete (ap->sasoc_asocmaxrxt);
1168  free (ap);
1169  return STATUS_ERR;
1170  }
1173  delete (ap->sasoc_assoc_id);
1174  delete (ap->sasoc_asocmaxrxt);
1175  delete (ap->sasoc_number_peer_destinations);
1176  free (ap);
1177  return STATUS_ERR;
1178  }
1180  if (evaluate(in->getAssocParams()->sasoc_peer_rwnd, ap->sasoc_peer_rwnd, error)) {
1181  delete (ap->sasoc_assoc_id);
1182  delete (ap->sasoc_asocmaxrxt);
1183  delete (ap->sasoc_number_peer_destinations);
1184  delete (ap->sasoc_peer_rwnd);
1185  free (ap);
1186  return STATUS_ERR;
1187  }
1189  if (evaluate(in->getAssocParams()->sasoc_local_rwnd, ap->sasoc_local_rwnd, error)) {
1190  delete (ap->sasoc_assoc_id);
1191  delete (ap->sasoc_asocmaxrxt);
1192  delete (ap->sasoc_number_peer_destinations);
1193  delete (ap->sasoc_peer_rwnd);
1194  delete (ap->sasoc_local_rwnd);
1195  free (ap);
1196  return STATUS_ERR;
1197  }
1199  if (evaluate(in->getAssocParams()->sasoc_cookie_life, ap->sasoc_cookie_life, error)) {
1200  delete (ap->sasoc_assoc_id);
1201  delete (ap->sasoc_asocmaxrxt);
1202  delete (ap->sasoc_number_peer_destinations);
1203  delete (ap->sasoc_peer_rwnd);
1204  delete (ap->sasoc_local_rwnd);
1205  delete (ap->sasoc_cookie_life);
1206  free (ap);
1207  return STATUS_ERR;
1208  }
1209  out->setAssocParams(ap);
1210  break;
1211  }
1212 
1213  case EXPR_SCTP_RTOINFO: {
1214  assert(in->getType() == EXPR_SCTP_RTOINFO);
1215  assert(out->getType() == EXPR_SCTP_RTOINFO);
1216  struct sctp_rtoinfo_expr *info = (struct sctp_rtoinfo_expr *)malloc(sizeof(struct sctp_rtoinfo_expr));
1218  if (evaluate(in->getRtoinfo()->srto_assoc_id, info->srto_assoc_id, error)) {
1219  delete (info->srto_assoc_id);
1220  free (info);
1221  return STATUS_ERR;
1222  }
1224  if (evaluate(in->getRtoinfo()->srto_initial, info->srto_initial, error)) {
1225  delete (info->srto_assoc_id);
1226  delete (info->srto_initial);
1227  free (info);
1228  return STATUS_ERR;
1229  }
1230  info->srto_max = new PacketDrillExpression(in->getRtoinfo()->srto_max->getType());
1231  if (evaluate(in->getRtoinfo()->srto_max, info->srto_max, error)) {
1232  delete (info->srto_assoc_id);
1233  delete (info->srto_initial);
1234  delete (info->srto_max);
1235  free (info);
1236  return STATUS_ERR;
1237  }
1238  info->srto_min = new PacketDrillExpression(in->getRtoinfo()->srto_min->getType());
1239  if (evaluate(in->getRtoinfo()->srto_min, info->srto_min, error)) {
1240  delete (info->srto_assoc_id);
1241  delete (info->srto_initial);
1242  delete (info->srto_max);
1243  delete (info->srto_min);
1244  free (info);
1245  return STATUS_ERR;
1246  }
1247  out->setRtoinfo(info);
1248  break;
1249  }
1250 
1251  case EXPR_SCTP_SACKINFO: {
1252  assert(in->getType() == EXPR_SCTP_SACKINFO);
1253  assert(out->getType() == EXPR_SCTP_SACKINFO);
1254  struct sctp_sack_info_expr *si = (struct sctp_sack_info_expr *)malloc(sizeof(struct sctp_sack_info_expr));
1256  if (evaluate(in->getSackinfo()->sack_assoc_id, si->sack_assoc_id, error)) {
1257  delete (si->sack_assoc_id);
1258  free (si);
1259  return STATUS_ERR;
1260  }
1262  if (evaluate(in->getSackinfo()->sack_delay, si->sack_delay, error)) {
1263  delete (si->sack_assoc_id);
1264  delete (si->sack_delay);
1265  free (si);
1266  return STATUS_ERR;
1267  }
1269  if (evaluate(in->getSackinfo()->sack_freq, si->sack_freq, error)) {
1270  delete (si->sack_assoc_id);
1271  delete (si->sack_delay);
1272  delete (si->sack_freq);
1273  free (si);
1274  return STATUS_ERR;
1275  }
1276  out->setSackinfo(si);
1277  break;
1278  }
1279 
1280  case EXPR_SCTP_STATUS: {
1281  assert(in->getType() == EXPR_SCTP_STATUS);
1282  assert(out->getType() == EXPR_SCTP_STATUS);
1283  struct sctp_status_expr *st = (struct sctp_status_expr *)malloc(sizeof(struct sctp_status_expr));
1285  if (evaluate(in->getStatus()->sstat_assoc_id, st->sstat_assoc_id, error)) {
1286  delete (st->sstat_assoc_id);
1287  free (st);
1288  return STATUS_ERR;
1289  }
1291  if (evaluate(in->getStatus()->sstat_state, st->sstat_state, error)) {
1292  delete (st->sstat_assoc_id);
1293  delete (st->sstat_state);
1294  free (st);
1295  return STATUS_ERR;
1296  }
1298  if (evaluate(in->getStatus()->sstat_rwnd, st->sstat_rwnd, error)) {
1299  delete (st->sstat_assoc_id);
1300  delete (st->sstat_state);
1301  delete (st->sstat_rwnd);
1302  free (st);
1303  return STATUS_ERR;
1304  }
1306  if (evaluate(in->getStatus()->sstat_unackdata, st->sstat_unackdata, error)) {
1307  delete (st->sstat_assoc_id);
1308  delete (st->sstat_state);
1309  delete (st->sstat_rwnd);
1310  delete (st->sstat_unackdata);
1311  free (st);
1312  return STATUS_ERR;
1313  }
1315  if (evaluate(in->getStatus()->sstat_penddata, st->sstat_penddata, error)) {
1316  delete (st->sstat_assoc_id);
1317  delete (st->sstat_state);
1318  delete (st->sstat_rwnd);
1319  delete (st->sstat_unackdata);
1320  delete (st->sstat_penddata);
1321  free (st);
1322  return STATUS_ERR;
1323  }
1325  if (evaluate(in->getStatus()->sstat_instrms, st->sstat_instrms, error)) {
1326  delete (st->sstat_assoc_id);
1327  delete (st->sstat_state);
1328  delete (st->sstat_rwnd);
1329  delete (st->sstat_unackdata);
1330  delete (st->sstat_penddata);
1331  delete (st->sstat_instrms);
1332  free (st);
1333  return STATUS_ERR;
1334  }
1336  if (evaluate(in->getStatus()->sstat_outstrms, st->sstat_outstrms, error)) {
1337  delete (st->sstat_assoc_id);
1338  delete (st->sstat_state);
1339  delete (st->sstat_rwnd);
1340  delete (st->sstat_unackdata);
1341  delete (st->sstat_penddata);
1342  delete (st->sstat_instrms);
1343  delete (st->sstat_outstrms);
1344  free (st);
1345  return STATUS_ERR;
1346  }
1349  delete (st->sstat_assoc_id);
1350  delete (st->sstat_state);
1351  delete (st->sstat_rwnd);
1352  delete (st->sstat_unackdata);
1353  delete (st->sstat_penddata);
1354  delete (st->sstat_instrms);
1355  delete (st->sstat_outstrms);
1356  delete (st->sstat_fragmentation_point);
1357  free (st);
1358  return STATUS_ERR;
1359  }
1361  if (evaluate(in->getStatus()->sstat_primary, st->sstat_primary, error)) {
1362  delete (st->sstat_assoc_id);
1363  delete (st->sstat_state);
1364  delete (st->sstat_rwnd);
1365  delete (st->sstat_unackdata);
1366  delete (st->sstat_penddata);
1367  delete (st->sstat_instrms);
1368  delete (st->sstat_outstrms);
1369  delete (st->sstat_fragmentation_point);
1370  delete (st->sstat_primary);
1371  free (st);
1372  return STATUS_ERR;
1373  }
1374  out->setStatus(st);
1375  break;
1376  }
1377 
1378  case EXPR_SCTP_ASSOCVAL: {
1379  assert(in->getType() == EXPR_SCTP_ASSOCVAL);
1380  assert(out->getType() == EXPR_SCTP_ASSOCVAL);
1381  struct sctp_assoc_value_expr *ass = (struct sctp_assoc_value_expr *)malloc(sizeof(struct sctp_assoc_value_expr));
1383  if (evaluate(in->getAssocval()->assoc_id, ass->assoc_id, error)) {
1384  delete (ass->assoc_id);
1385  free (ass);
1386  return STATUS_ERR;
1387  }
1389  if (evaluate(in->getAssocval()->assoc_value, ass->assoc_value, error)) {
1390  delete (ass->assoc_id);
1391  delete (ass->assoc_value);
1392  free (ass);
1393  return STATUS_ERR;
1394  }
1395  out->setAssocval(ass);
1396  break;
1397  }
1398 
1399  case EXPR_SCTP_SNDRCVINFO: {
1400  assert(in->getType() == EXPR_SCTP_SNDRCVINFO);
1401  assert(out->getType() == EXPR_SCTP_SNDRCVINFO);
1402  struct sctp_sndrcvinfo_expr *sri = (struct sctp_sndrcvinfo_expr *)malloc(sizeof(struct sctp_sndrcvinfo_expr));
1404  if (evaluate(in->getSndRcvInfo()->sinfo_stream, sri->sinfo_stream, error)) {
1405  delete (sri->sinfo_stream);
1406  free (sri);
1407  return STATUS_ERR;
1408  }
1410  if (evaluate(in->getSndRcvInfo()->sinfo_ssn, sri->sinfo_ssn, error)) {
1411  delete (sri->sinfo_stream);
1412  delete (sri->sinfo_ssn);
1413  free (sri);
1414  return STATUS_ERR;
1415  }
1417  if (evaluate(in->getSndRcvInfo()->sinfo_flags, sri->sinfo_flags, error)) {
1418  delete (sri->sinfo_stream);
1419  delete (sri->sinfo_ssn);
1420  delete (sri->sinfo_flags);
1421  free (sri);
1422  return STATUS_ERR;
1423  }
1425  if (evaluate(in->getSndRcvInfo()->sinfo_ppid, sri->sinfo_ppid, error)) {
1426  delete (sri->sinfo_stream);
1427  delete (sri->sinfo_ssn);
1428  delete (sri->sinfo_flags);
1429  delete (sri->sinfo_ppid);
1430  free (sri);
1431  return STATUS_ERR;
1432  }
1434  if (evaluate(in->getSndRcvInfo()->sinfo_context, sri->sinfo_context, error)) {
1435  delete (sri->sinfo_stream);
1436  delete (sri->sinfo_ssn);
1437  delete (sri->sinfo_flags);
1438  delete (sri->sinfo_ppid);
1439  delete (sri->sinfo_context);
1440  free (sri);
1441  return STATUS_ERR;
1442  }
1444  if (evaluate(in->getSndRcvInfo()->sinfo_timetolive, sri->sinfo_timetolive, error)) {
1445  delete (sri->sinfo_stream);
1446  delete (sri->sinfo_ssn);
1447  delete (sri->sinfo_flags);
1448  delete (sri->sinfo_ppid);
1449  delete (sri->sinfo_context);
1450  delete (sri->sinfo_timetolive);
1451  free (sri);
1452  return STATUS_ERR;
1453  }
1455  if (evaluate(in->getSndRcvInfo()->sinfo_tsn, sri->sinfo_tsn, error)) {
1456  delete (sri->sinfo_stream);
1457  delete (sri->sinfo_ssn);
1458  delete (sri->sinfo_flags);
1459  delete (sri->sinfo_ppid);
1460  delete (sri->sinfo_context);
1461  delete (sri->sinfo_timetolive);
1462  delete (sri->sinfo_tsn);
1463  free (sri);
1464  return STATUS_ERR;
1465  }
1467  if (evaluate(in->getSndRcvInfo()->sinfo_cumtsn, sri->sinfo_cumtsn, error)) {
1468  delete (sri->sinfo_stream);
1469  delete (sri->sinfo_ssn);
1470  delete (sri->sinfo_flags);
1471  delete (sri->sinfo_ppid);
1472  delete (sri->sinfo_context);
1473  delete (sri->sinfo_timetolive);
1474  delete (sri->sinfo_tsn);
1475  delete (sri->sinfo_cumtsn);
1476  free (sri);
1477  return STATUS_ERR;
1478  }
1480  if (evaluate(in->getSndRcvInfo()->sinfo_assoc_id, sri->sinfo_assoc_id, error)) {
1481  delete (sri->sinfo_stream);
1482  delete (sri->sinfo_ssn);
1483  delete (sri->sinfo_flags);
1484  delete (sri->sinfo_ppid);
1485  delete (sri->sinfo_context);
1486  delete (sri->sinfo_timetolive);
1487  delete (sri->sinfo_tsn);
1488  delete (sri->sinfo_cumtsn);
1489  delete (sri->sinfo_assoc_id);
1490  free (sri);
1491  return STATUS_ERR;
1492  }
1493  out->setSndRcvInfo(sri);
1494  break;
1495  }
1496 
1497  case EXPR_SCTP_RESET_STREAMS: {
1498  assert(in->getType() == EXPR_SCTP_RESET_STREAMS);
1499  assert(out->getType() == EXPR_SCTP_RESET_STREAMS);
1500  printf("evaluate EXPR_SCTP_RESET_STREAMS\n");
1501  struct sctp_reset_streams_expr *rs = (struct sctp_reset_streams_expr *) malloc(sizeof(struct sctp_reset_streams_expr));
1503  if (evaluate(in->getResetStreams()->srs_assoc_id, rs->srs_assoc_id, error)) {
1504  delete (rs->srs_assoc_id);
1505  free (rs);
1506  return STATUS_ERR;
1507  }
1509  if (evaluate(in->getResetStreams()->srs_flags, rs->srs_flags, error)) {
1510  delete (rs->srs_assoc_id);
1511  delete (rs->srs_flags);
1512  free (rs);
1513  return STATUS_ERR;
1514  }
1517  delete (rs->srs_assoc_id);
1518  delete (rs->srs_flags);
1519  delete (rs->srs_number_streams);
1520  free (rs);
1521  return STATUS_ERR;
1522  }
1523  printf("srs_number_streams = %" PRId64 "\n", rs->srs_number_streams->getNum());
1524  if (rs->srs_number_streams->getNum() > 0) {
1526  if (evaluate(in->getResetStreams()->srs_stream_list, rs->srs_stream_list, error)) {
1527  printf("Fehler in evaluate\n");
1528  delete (rs->srs_assoc_id);
1529  delete (rs->srs_flags);
1530  delete (rs->srs_number_streams);
1531  delete (rs->srs_stream_list);
1532  free (rs);
1533  return STATUS_ERR;
1534  }
1535  delete in->getResetStreams()->srs_stream_list->getList();
1536  } else {
1537  rs->srs_stream_list = nullptr;
1538  }
1539  out->setResetStreams(rs);
1540  break;
1541  }
1542 
1543  case EXPR_SCTP_ADD_STREAMS: {
1544  assert(in->getType() == EXPR_SCTP_ADD_STREAMS);
1545  assert(out->getType() == EXPR_SCTP_ADD_STREAMS);
1546  printf("evaluate EXPR_SCTP_ADD_STREAMS\n");
1547  struct sctp_add_streams_expr *as = (struct sctp_add_streams_expr *) malloc(sizeof(struct sctp_add_streams_expr));
1549  if (evaluate(in->getAddStreams()->sas_assoc_id, as->sas_assoc_id, error)) {
1550  printf("add streams assoc id=%" PRId64 "\n", as->sas_assoc_id->getNum());
1551  delete (as->sas_assoc_id);
1552  free (as);
1553  return STATUS_ERR;
1554  }
1556  if (evaluate(in->getAddStreams()->sas_instrms, as->sas_instrms, error)) {
1557  delete (as->sas_assoc_id);
1558  delete (as->sas_instrms);
1559  free (as);
1560  return STATUS_ERR;
1561  }
1563  if (evaluate(in->getAddStreams()->sas_outstrms, as->sas_outstrms, error)) {
1564  delete (as->sas_assoc_id);
1565  delete (as->sas_instrms);
1566  delete (as->sas_outstrms);
1567  free (as);
1568  return STATUS_ERR;
1569  }
1570  out->setAddStreams(as);
1571  break;
1572  }
1573 
1575  assert(in->getType() == EXPR_SCTP_PEER_ADDR_PARAMS);
1576  assert(out->getType() == EXPR_SCTP_PEER_ADDR_PARAMS);
1577  struct sctp_paddrparams_expr *spp = (struct sctp_paddrparams_expr *) malloc(sizeof(struct sctp_paddrparams_expr));
1579  if (evaluate(in->getPaddrParams()->spp_assoc_id, spp->spp_assoc_id, error)) {
1580  delete (spp->spp_assoc_id);
1581  free (spp);
1582  return STATUS_ERR;
1583  }
1585  if (evaluate(in->getPaddrParams()->spp_address, spp->spp_address, error)) {
1586  delete (spp->spp_assoc_id);
1587  delete (spp->spp_address);
1588  free (spp);
1589  return STATUS_ERR;
1590  }
1592  if (evaluate(in->getPaddrParams()->spp_hbinterval, spp->spp_hbinterval, error)) {
1593  delete (spp->spp_assoc_id);
1594  delete (spp->spp_address);
1595  delete (spp->spp_hbinterval);
1596  free (spp);
1597  return STATUS_ERR;
1598  }
1600  if (evaluate(in->getPaddrParams()->spp_pathmaxrxt, spp->spp_pathmaxrxt, error)) {
1601  delete (spp->spp_assoc_id);
1602  delete (spp->spp_address);
1603  delete (spp->spp_hbinterval);
1604  delete (spp->spp_pathmaxrxt);
1605  free (spp);
1606  return STATUS_ERR;
1607  }
1609  if (evaluate(in->getPaddrParams()->spp_pathmtu, spp->spp_pathmtu, error)) {
1610  delete (spp->spp_assoc_id);
1611  delete (spp->spp_address);
1612  delete (spp->spp_hbinterval);
1613  delete (spp->spp_pathmaxrxt);
1614  delete (spp->spp_pathmtu);
1615  free (spp);
1616  return STATUS_ERR;
1617  }
1619  if (evaluate(in->getPaddrParams()->spp_flags, spp->spp_flags, error)) {
1620  delete (spp->spp_assoc_id);
1621  delete (spp->spp_address);
1622  delete (spp->spp_hbinterval);
1623  delete (spp->spp_pathmaxrxt);
1624  delete (spp->spp_pathmtu);
1625  delete (spp->spp_flags);
1626  free (spp);
1627  return STATUS_ERR;
1628  }
1630  if (evaluate(in->getPaddrParams()->spp_ipv6_flowlabel, spp->spp_ipv6_flowlabel, error)) {
1631  delete (spp->spp_assoc_id);
1632  delete (spp->spp_address);
1633  delete (spp->spp_hbinterval);
1634  delete (spp->spp_pathmaxrxt);
1635  delete (spp->spp_pathmtu);
1636  delete (spp->spp_flags);
1637  delete (spp->spp_ipv6_flowlabel);
1638  free (spp);
1639  return STATUS_ERR;
1640  }
1642  if (evaluate(in->getPaddrParams()->spp_dscp, spp->spp_dscp, error)) {
1643  delete (spp->spp_assoc_id);
1644  delete (spp->spp_address);
1645  delete (spp->spp_hbinterval);
1646  delete (spp->spp_pathmaxrxt);
1647  delete (spp->spp_pathmtu);
1648  delete (spp->spp_flags);
1649  delete (spp->spp_ipv6_flowlabel);
1650  delete (spp->spp_dscp);
1651  free (spp);
1652  return STATUS_ERR;
1653  }
1654  out->setPaddrParams(spp);
1655  break;
1656  }
1657 
1658  case EXPR_STRING:
1659  if (out->unescapeCstringExpression(in->getString(), error))
1660  return STATUS_ERR;
1661  break;
1662 
1663  case EXPR_BINARY:
1664  if (evaluate_binary_expression(in, out, error)) {
1665  printf("Fehler in EXPR_BINARY\n");
1666  }
1667  break;
1668 
1669  case EXPR_LIST:
1670  if (evaluateListExpression(in, out, error)) {
1671  printf("Fehler in EXPR_LIST\n");
1672  }
1673  break;
1674 
1676  printf("name=%s\n", out->getName());
1677  break;
1678  case EXPR_NONE:
1679  break;
1680 
1681  default:
1682  EV_INFO << "type " << in->getType() << " not implemented\n";
1683  }
1684  return result;
1685 }
PacketDrillExpression * spp_assoc_id
Definition: PacketDrillUtils.h:390
PacketDrillExpression * spp_pathmaxrxt
Definition: PacketDrillUtils.h:393
Definition: PacketDrillUtils.h:529
int unescapeCstringExpression(const char *input_string, char **error)
Definition: PacketDrillUtils.cc:141
PacketDrillExpression * sasoc_assoc_id
Definition: PacketDrillUtils.h:373
struct sctp_add_streams_expr * getAddStreams()
Definition: PacketDrillUtils.h:589
void setSndRcvInfo(struct sctp_sndrcvinfo_expr *exp)
Definition: PacketDrillUtils.h:581
Definition: PacketDrillUtils.h:413
Definition: PacketDrillUtils.h:288
Definition: PacketDrillUtils.h:258
Definition: PacketDrillUtils.h:357
PacketDrillExpression * sinfo_assoc_id
Definition: PacketDrillUtils.h:410
PacketDrillExpression * sack_freq
Definition: PacketDrillUtils.h:385
Definition: PacketDrillUtils.h:246
Definition: PacketDrillUtils.h:349
Definition: PacketDrillUtils.h:247
void setInitmsg(struct sctp_initmsg_expr *exp)
Definition: PacketDrillUtils.h:571
cQueue * getList()
Definition: PacketDrillUtils.h:565
int evaluate_binary_expression(PacketDrillExpression *in, PacketDrillExpression *out, char **error)
Definition: PacketDrill.cc:1705
PacketDrillExpression * srs_number_streams
Definition: PacketDrillUtils.h:416
struct sctp_rtoinfo_expr * getRtoinfo()
Definition: PacketDrillUtils.h:570
Definition: PacketDrillUtils.h:249
int evaluate(PacketDrillExpression *in, PacketDrillExpression *out, char **error)
Definition: PacketDrill.cc:1091
PacketDrillExpression * sinfo_tsn
Definition: PacketDrillUtils.h:408
PacketDrillExpression * sstat_penddata
Definition: PacketDrillUtils.h:426
PacketDrillExpression * sstat_state
Definition: PacketDrillUtils.h:423
void setSackinfo(struct sctp_sack_info_expr *exp)
Definition: PacketDrillUtils.h:577
struct sctp_assocparams_expr * getAssocParams()
Definition: PacketDrillUtils.h:574
int evaluateListExpression(PacketDrillExpression *in, PacketDrillExpression *out, char **error)
Definition: PacketDrill.cc:1737
Definition: PacketDrillUtils.h:263
PacketDrillExpression * assoc_id
Definition: PacketDrillUtils.h:367
PacketDrillExpression * sinfo_context
Definition: PacketDrillUtils.h:406
struct sctp_initmsg_expr * getInitmsg()
Definition: PacketDrillUtils.h:572
Definition: PacketDrillUtils.h:260
PacketDrillExpression * srs_flags
Definition: PacketDrillUtils.h:415
Definition: PacketDrillUtils.h:257
Definition: PacketDrillUtils.h:259
PacketDrillExpression * srs_stream_list
Definition: PacketDrillUtils.h:417
int64 getNum() const
Definition: PacketDrillUtils.h:560
Definition: PacketDrillUtils.h:366
void * malloc(YYSIZE_T)
void setStatus(struct sctp_status_expr *exp)
Definition: PacketDrillUtils.h:586
PacketDrillExpression * sas_assoc_id
Definition: PacketDrillUtils.h:435
Definition: PacketDrillUtils.h:262
PacketDrillExpression * sinfo_ppid
Definition: PacketDrillUtils.h:405
PacketDrillExpression * sas_outstrms
Definition: PacketDrillUtils.h:437
void setAssocParams(struct sctp_assocparams_expr *exp)
Definition: PacketDrillUtils.h:573
PacketDrillExpression * spp_hbinterval
Definition: PacketDrillUtils.h:392
struct sctp_reset_streams_expr * getResetStreams()
Definition: PacketDrillUtils.h:584
Definition: PacketDrillUtils.h:264
PacketDrillExpression * sinfo_timetolive
Definition: PacketDrillUtils.h:407
PacketDrillExpression * spp_flags
Definition: PacketDrillUtils.h:395
struct sctp_paddrparams_expr * getPaddrParams()
Definition: PacketDrillUtils.h:580
void setPaddrParams(struct sctp_paddrparams_expr *exp)
Definition: PacketDrillUtils.h:579
Definition: PacketDrillUtils.h:245
PacketDrillExpression * sinit_max_instreams
Definition: PacketDrillUtils.h:359
PacketDrillExpression * spp_ipv6_flowlabel
Definition: PacketDrillUtils.h:396
Definition: PacketDrillUtils.h:372
PacketDrillExpression * sstat_fragmentation_point
Definition: PacketDrillUtils.h:429
Definition: PacketDrillUtils.h:401
Definition: PacketDrillUtils.h:434
PacketDrillExpression * sstat_unackdata
Definition: PacketDrillUtils.h:425
int symbolToInt(const char *input_symbol, int64 *output_integer, char **error)
Definition: PacketDrillUtils.cc:247
PacketDrillExpression * sasoc_local_rwnd
Definition: PacketDrillUtils.h:377
struct sctp_status_expr * getStatus()
Definition: PacketDrillUtils.h:587
PacketDrillExpression * sstat_rwnd
Definition: PacketDrillUtils.h:424
PacketDrillExpression * sasoc_number_peer_destinations
Definition: PacketDrillUtils.h:375
PacketDrillExpression * srto_assoc_id
Definition: PacketDrillUtils.h:350
PacketDrillExpression * sinfo_flags
Definition: PacketDrillUtils.h:404
Definition: PacketDrillUtils.h:389
PacketDrillExpression * sasoc_cookie_life
Definition: PacketDrillUtils.h:378
PacketDrillExpression * srto_max
Definition: PacketDrillUtils.h:352
PacketDrillExpression * sinit_max_init_timeo
Definition: PacketDrillUtils.h:361
PacketDrillExpression * sasoc_asocmaxrxt
Definition: PacketDrillUtils.h:374
Definition: PacketDrillUtils.h:261
PacketDrillExpression * sinfo_stream
Definition: PacketDrillUtils.h:402
PacketDrillExpression * sinfo_ssn
Definition: PacketDrillUtils.h:403
struct sctp_sndrcvinfo_expr * getSndRcvInfo()
Definition: PacketDrillUtils.h:582
PacketDrillExpression * sstat_assoc_id
Definition: PacketDrillUtils.h:422
struct sctp_sack_info_expr * getSackinfo()
Definition: PacketDrillUtils.h:578
PacketDrillExpression * sstat_outstrms
Definition: PacketDrillUtils.h:428
PacketDrillExpression * spp_dscp
Definition: PacketDrillUtils.h:397
Definition: PacketDrillUtils.h:287
PacketDrillExpression * sack_delay
Definition: PacketDrillUtils.h:384
Definition: PacketDrillUtils.h:253
PacketDrillExpression * srto_min
Definition: PacketDrillUtils.h:353
void setAssocval(struct sctp_assoc_value_expr *exp)
Definition: PacketDrillUtils.h:575
void setNum(int64 n)
Definition: PacketDrillUtils.h:559
void free(void *)
Definition: PacketDrillUtils.h:382
Definition: PacketDrillUtils.h:251
PacketDrillExpression * sinit_max_attempts
Definition: PacketDrillUtils.h:360
PacketDrillExpression * sinit_num_ostreams
Definition: PacketDrillUtils.h:358
PacketDrillExpression * sstat_primary
Definition: PacketDrillUtils.h:430
void setType(enum expression_t t)
Definition: PacketDrillUtils.h:557
Definition: PacketDrillUtils.h:255
PacketDrillExpression * sstat_instrms
Definition: PacketDrillUtils.h:427
const char * getString() const
Definition: PacketDrillUtils.h:562
PacketDrillExpression * srs_assoc_id
Definition: PacketDrillUtils.h:414
enum expression_t getType() const
Definition: PacketDrillUtils.h:558
void setResetStreams(struct sctp_reset_streams_expr *exp)
Definition: PacketDrillUtils.h:583
PacketDrillExpression * sack_assoc_id
Definition: PacketDrillUtils.h:383
PacketDrillExpression * sas_instrms
Definition: PacketDrillUtils.h:436
void setRtoinfo(struct sctp_rtoinfo_expr *exp)
Definition: PacketDrillUtils.h:569
void setAddStreams(struct sctp_add_streams_expr *exp)
Definition: PacketDrillUtils.h:588
PacketDrillExpression * spp_address
Definition: PacketDrillUtils.h:391
Definition: PacketDrillUtils.h:266
struct sctp_assoc_value_expr * getAssocval()
Definition: PacketDrillUtils.h:576
PacketDrillExpression * sasoc_peer_rwnd
Definition: PacketDrillUtils.h:376
int64_t int64
Definition: Compat.h:29
Definition: PacketDrillUtils.h:254
PacketDrillExpression * sinfo_cumtsn
Definition: PacketDrillUtils.h:409
Definition: PacketDrillUtils.h:421
PacketDrillExpression * srto_initial
Definition: PacketDrillUtils.h:351
PacketDrillExpression * assoc_value
Definition: PacketDrillUtils.h:368
Definition: PacketDrillUtils.h:250
PacketDrillExpression * spp_pathmtu
Definition: PacketDrillUtils.h:394
Definition: PacketDrillUtils.h:256
int PacketDrill::evaluate_binary_expression ( PacketDrillExpression in,
PacketDrillExpression out,
char **  error 
)
1706 {
1707  int result = STATUS_ERR;
1708  assert(in->getType() == EXPR_BINARY);
1709  assert(in->getBinary());
1710  out->setType(EXPR_INTEGER);
1711 
1714  if ((evaluate(in->getBinary()->lhs, lhs, error)) ||
1715  (evaluate(in->getBinary()->rhs, rhs, error))) {
1716  delete(rhs);
1717  delete(lhs);
1718  return result;
1719  }
1720  if (strcmp("|", in->getBinary()->op) == 0) {
1721  if (lhs->getType() != EXPR_INTEGER) {
1722  EV_ERROR << "left hand side of | not an integer\n";
1723  } else if (rhs->getType() != EXPR_INTEGER) {
1724  EV_ERROR << "right hand side of | not an integer\n";
1725  } else {
1726  out->setNum(lhs->getNum() | rhs->getNum());
1727  result = STATUS_OK;
1728  }
1729  } else {
1730  EV_ERROR << "bad binary operator '" << in->getBinary()->op << "'\n";
1731  }
1732  delete(rhs);
1733  delete(lhs);
1734  return result;
1735 }
Definition: PacketDrillUtils.h:529
Definition: PacketDrillUtils.h:288
Definition: PacketDrillUtils.h:247
char * op
Definition: PacketDrillUtils.h:344
int evaluate(PacketDrillExpression *in, PacketDrillExpression *out, char **error)
Definition: PacketDrill.cc:1091
int64 getNum() const
Definition: PacketDrillUtils.h:560
struct binary_expression * getBinary()
Definition: PacketDrillUtils.h:567
Definition: PacketDrillUtils.h:287
Definition: PacketDrillUtils.h:253
PacketDrillExpression * lhs
Definition: PacketDrillUtils.h:345
void setNum(int64 n)
Definition: PacketDrillUtils.h:559
void setType(enum expression_t t)
Definition: PacketDrillUtils.h:557
enum expression_t getType() const
Definition: PacketDrillUtils.h:558
PacketDrillExpression * rhs
Definition: PacketDrillUtils.h:346
int PacketDrill::evaluate_iovec_expression ( PacketDrillExpression in,
PacketDrillExpression out,
char **  error 
)
int PacketDrill::evaluate_msghdr_expression ( PacketDrillExpression in,
PacketDrillExpression out,
char **  error 
)
int PacketDrill::evaluate_pollfd_expression ( PacketDrillExpression in,
PacketDrillExpression out,
char **  error 
)
int PacketDrill::evaluateExpressionList ( cQueue *  in_list,
cQueue *  out_list,
char **  error 
)
1692 {
1693  cQueue *node_ptr = out_list;
1694  for (cQueue::Iterator it(*in_list); !it.end(); it++) {
1695  PacketDrillExpression *outExpr = new PacketDrillExpression(((PacketDrillExpression *)(*it))->getType());
1696  if (evaluate((PacketDrillExpression *)(*it), outExpr, error)) {
1697  delete(outExpr);
1698  return STATUS_ERR;
1699  }
1700  node_ptr->insert(outExpr);
1701  }
1702  return STATUS_OK;
1703 }
Definition: PacketDrillUtils.h:529
Definition: PacketDrillUtils.h:288
int evaluate(PacketDrillExpression *in, PacketDrillExpression *out, char **error)
Definition: PacketDrill.cc:1091
Definition: PacketDrillUtils.h:287
int PacketDrill::evaluateListExpression ( PacketDrillExpression in,
PacketDrillExpression out,
char **  error 
)
1738 {
1739  assert(in->getType() == EXPR_LIST);
1740  assert(out->getType() == EXPR_LIST);
1741 
1742  out->setList(new cQueue("listExpression"));
1743  return evaluateExpressionList(in->getList(), out->getList(), error);
1744 }
int evaluateExpressionList(cQueue *in_list, cQueue *out_list, char **error)
Definition: PacketDrill.cc:1691
cQueue * getList()
Definition: PacketDrillUtils.h:565
enum expression_t getType() const
Definition: PacketDrillUtils.h:558
void setList(cQueue *queue)
Definition: PacketDrillUtils.h:566
Definition: PacketDrillUtils.h:254
IPv4Datagram * PacketDrill::makeIPPacket ( int  protocol,
enum direction_t  direction,
L3Address  localAddr,
L3Address  remoteAddr 
)
static

Referenced by buildSCTPPacket(), buildTCPPacket(), and buildUDPPacket().

50 {
51  IPv4Datagram *datagram = new IPv4Datagram("IPInject");
52  datagram->setVersion(4);
53  datagram->setHeaderLength(20);
54 
55  if (direction == DIRECTION_INBOUND) {
56  datagram->setSrcAddress(remoteAddr.toIPv4());
57  datagram->setDestAddress(localAddr.toIPv4());
58  datagram->setIdentification(pdapp->getIdInbound());
60  } else if (direction == DIRECTION_OUTBOUND) {
61  datagram->setSrcAddress(localAddr.toIPv4());
62  datagram->setDestAddress(remoteAddr.toIPv4());
65  } else
66  throw cRuntimeError("Unknown direction type %d", direction);
67  datagram->setTransportProtocol(protocol);
68  datagram->setTimeToLive(32);
69  datagram->setMoreFragments(0);
70  datagram->setDontFragment(0);
71  datagram->setFragmentOffset(0);
72  datagram->setTypeOfService(0);
73  datagram->setByteLength(20);
74  return datagram;
75 }
virtual void setMoreFragments(bool moreFragments)
static PacketDrillApp * pdapp
Definition: PacketDrill.h:41
virtual void setDontFragment(bool dontFragment)
uint8_t protocol
Definition: TCP_NSC.cc:88
virtual void setHeaderLength(short headerLength)
Definition: PacketDrillUtils.h:186
Represents an IPv4 datagram.
Definition: IPv4Datagram.h:31
virtual void setTransportProtocol(int protocol) override
Definition: IPv4Datagram.h:106
const uint32 getIdOutbound()
Definition: PacketDrillApp.h:55
virtual void setTimeToLive(short timeToLive)
Definition: PacketDrillUtils.h:185
void increaseIdOutbound()
Definition: PacketDrillApp.h:58
virtual void setVersion(short version)
virtual void setIdentification(int identification)
virtual void setSrcAddress(const IPv4Address &srcAddress)
virtual void setDestAddress(const IPv4Address &destAddress)
virtual void setTypeOfService(unsigned char typeOfService)
IPv4Address toIPv4() const
Definition: L3Address.h:76
const uint32 getIdInbound()
Definition: PacketDrillApp.h:54
virtual void setFragmentOffset(int fragmentOffset)
void increaseIdInbound()
Definition: PacketDrillApp.h:57

Member Data Documentation

PacketDrillApp * PacketDrill::pdapp = nullptr
staticprotected

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