INET Framework for OMNeT++/OMNEST
PacketDrillExpression Class Reference

#include <PacketDrillUtils.h>

Inheritance diagram for PacketDrillExpression:

Public Member Functions

 PacketDrillExpression (enum expression_t type_)
 
 ~PacketDrillExpression ()
 
void setType (enum expression_t t)
 
enum expression_t getType () const
 
void setNum (int64 n)
 
int64 getNum () const
 
void setString (char *str)
 
const char * getString () const
 
void setFormat (const char *format_)
 
const char * getFormat () const
 
cQueue * getList ()
 
void setList (cQueue *queue)
 
struct binary_expressiongetBinary ()
 
void setBinary (struct binary_expression *bin)
 
void setRtoinfo (struct sctp_rtoinfo_expr *exp)
 
struct sctp_rtoinfo_exprgetRtoinfo ()
 
void setInitmsg (struct sctp_initmsg_expr *exp)
 
struct sctp_initmsg_exprgetInitmsg ()
 
void setAssocParams (struct sctp_assocparams_expr *exp)
 
struct sctp_assocparams_exprgetAssocParams ()
 
void setAssocval (struct sctp_assoc_value_expr *exp)
 
struct sctp_assoc_value_exprgetAssocval ()
 
void setSackinfo (struct sctp_sack_info_expr *exp)
 
struct sctp_sack_info_exprgetSackinfo ()
 
void setPaddrParams (struct sctp_paddrparams_expr *exp)
 
struct sctp_paddrparams_exprgetPaddrParams ()
 
void setSndRcvInfo (struct sctp_sndrcvinfo_expr *exp)
 
struct sctp_sndrcvinfo_exprgetSndRcvInfo ()
 
void setResetStreams (struct sctp_reset_streams_expr *exp)
 
struct sctp_reset_streams_exprgetResetStreams ()
 
void setIp (L3Address *exp)
 
void setStatus (struct sctp_status_expr *exp)
 
struct sctp_status_exprgetStatus ()
 
void setAddStreams (struct sctp_add_streams_expr *exp)
 
struct sctp_add_streams_exprgetAddStreams ()
 
int unescapeCstringExpression (const char *input_string, char **error)
 
int getS32 (int32 *value, char **error)
 
int getU16 (uint16 *value, char **error)
 
int getU32 (uint32 *value, char **error)
 
int symbolToInt (const char *input_symbol, int64 *output_integer, char **error)
 
bool lookupIntSymbol (const char *input_symbol, int64 *output_integer, struct int_symbol *symbols)
 

Private Attributes

enum expression_t type
 
union {
   int64   num
 
   char *   string
 
   struct binary_expression *   binary
 
   struct sctp_rtoinfo_expr *   sctp_rtoinfo
 
   struct sctp_initmsg_expr *   sctp_initmsg
 
   struct sctp_assoc_value_expr *   sctp_assoc_value
 
   struct sctp_assocparams_expr *   sctp_assocparams
 
   struct sctp_sack_info_expr *   sctp_sack_info
 
   struct sctp_paddrparams_expr *   sctp_paddr_params
 
   struct sctp_sndrcvinfo_expr *   sctp_sndrcvinfo
 
   struct sctp_reset_streams_expr *   sctp_resetstreams
 
   struct sctp_add_streams_expr *   sctp_addstreams
 
   struct sctp_status_expr *   sctp_status
 
   L3Address *   ip_address
 
   cQueue *   list
 
value
 
const char * format
 

Constructor & Destructor Documentation

PacketDrillExpression::PacketDrillExpression ( enum expression_t  type_)
121 {
122  type = type_;
123  format = nullptr;
124  if (type == EXPR_SCTP_SNDRCVINFO)
125  value.sctp_sndrcvinfo = (struct sctp_sndrcvinfo_expr *)malloc(sizeof(struct sctp_sndrcvinfo_expr));
126 }
Definition: PacketDrillUtils.h:260
void * malloc(YYSIZE_T)
Definition: PacketDrillUtils.h:401
const char * format
Definition: PacketDrillUtils.h:554
enum expression_t type
Definition: PacketDrillUtils.h:536
union PacketDrillExpression::@1 value
PacketDrillExpression::~PacketDrillExpression ( )
129 {
130  if (type == EXPR_LIST) {
131  for (cQueue::Iterator iter(*value.list); !iter.end(); iter++)
132  value.list->remove((*iter));
133  delete value.list;
134  }
135 }
enum expression_t type
Definition: PacketDrillUtils.h:536
Definition: PacketDrillUtils.h:254
union PacketDrillExpression::@1 value

Member Function Documentation

struct sctp_add_streams_expr* PacketDrillExpression::getAddStreams ( )
inline

Referenced by PacketDrill::evaluate(), and inet::PacketDrillApp::syscallSetsockopt().

589 { return value.sctp_addstreams; };
union PacketDrillExpression::@1 value
struct sctp_assocparams_expr* PacketDrillExpression::getAssocParams ( )
inline

Referenced by PacketDrill::evaluate(), and inet::PacketDrillApp::syscallSetsockopt().

574 { return value.sctp_assocparams; };
union PacketDrillExpression::@1 value
struct sctp_assoc_value_expr* PacketDrillExpression::getAssocval ( )
inline

Referenced by PacketDrill::evaluate(), and inet::PacketDrillApp::syscallSetsockopt().

576 { return value.sctp_assoc_value; };
union PacketDrillExpression::@1 value
struct binary_expression* PacketDrillExpression::getBinary ( )
inline

Referenced by PacketDrill::evaluate_binary_expression().

567 { return value.binary; };
union PacketDrillExpression::@1 value
const char* PacketDrillExpression::getFormat ( ) const
inline
564 { return format; };
const char * format
Definition: PacketDrillUtils.h:554
struct sctp_initmsg_expr* PacketDrillExpression::getInitmsg ( )
inline

Referenced by PacketDrill::evaluate(), and inet::PacketDrillApp::syscallSetsockopt().

572 { return value.sctp_initmsg; };
union PacketDrillExpression::@1 value
cQueue* PacketDrillExpression::getList ( )
inline
struct sctp_paddrparams_expr* PacketDrillExpression::getPaddrParams ( )
inline

Referenced by PacketDrill::evaluate(), and inet::PacketDrillApp::syscallSetsockopt().

580 { return value.sctp_paddr_params; };
union PacketDrillExpression::@1 value
struct sctp_reset_streams_expr* PacketDrillExpression::getResetStreams ( )
inline

Referenced by PacketDrill::evaluate(), and inet::PacketDrillApp::syscallSetsockopt().

584 { return value.sctp_resetstreams; };
union PacketDrillExpression::@1 value
struct sctp_rtoinfo_expr* PacketDrillExpression::getRtoinfo ( )
inline

Referenced by PacketDrill::evaluate(), and inet::PacketDrillApp::syscallSetsockopt().

570 { return value.sctp_rtoinfo; };
union PacketDrillExpression::@1 value
int PacketDrillExpression::getS32 ( int32 value,
char **  error 
)
struct sctp_sack_info_expr* PacketDrillExpression::getSackinfo ( )
inline

Referenced by PacketDrill::evaluate(), and inet::PacketDrillApp::syscallSetsockopt().

578 { return value.sctp_sack_info; };
union PacketDrillExpression::@1 value
struct sctp_sndrcvinfo_expr* PacketDrillExpression::getSndRcvInfo ( )
inline

Referenced by PacketDrill::evaluate(), and inet::PacketDrillApp::syscallSctpSend().

582 { return value.sctp_sndrcvinfo; };
union PacketDrillExpression::@1 value
struct sctp_status_expr* PacketDrillExpression::getStatus ( )
inline

Referenced by PacketDrill::evaluate(), and inet::PacketDrillApp::syscallGetsockopt().

587 { return value.sctp_status; };
union PacketDrillExpression::@1 value
const char* PacketDrillExpression::getString ( ) const
inline

Referenced by PacketDrill::evaluate().

562 { return value.string; };
union PacketDrillExpression::@1 value
int PacketDrillExpression::getU16 ( uint16 value,
char **  error 
)

Referenced by inet::PacketDrillApp::syscallSctpSendmsg().

222 {
223  if (type != EXPR_INTEGER)
224  return STATUS_ERR;
225  if ((value.num > UINT16_MAX) || (value.num < 0)) {
226  EV_DEBUG << "Value out of range for 16-bit unsigned integer: " << value.num << endl;
227  return STATUS_ERR;
228  }
229  *val = value.num;
230  return STATUS_OK;
231 }
Definition: PacketDrillUtils.h:288
Definition: PacketDrillUtils.h:247
#define UINT16_MAX
Definition: lexer.cc:81
Definition: PacketDrillUtils.h:287
enum expression_t type
Definition: PacketDrillUtils.h:536
union PacketDrillExpression::@1 value
int PacketDrillExpression::getU32 ( uint32 value,
char **  error 
)

Referenced by inet::PacketDrillApp::syscallSctpSendmsg().

210 {
211  if (type != EXPR_INTEGER)
212  return STATUS_ERR;
213  if ((value.num > UINT32_MAX) || (value.num < 0)) {
214  EV_DEBUG << "Value out of range for 32-bit unsigned integer: " << value.num << endl;
215  return STATUS_ERR;
216  }
217  *val = value.num;
218  return STATUS_OK;
219 }
Definition: PacketDrillUtils.h:288
Definition: PacketDrillUtils.h:247
Definition: PacketDrillUtils.h:287
#define UINT32_MAX
Definition: lexer.cc:84
enum expression_t type
Definition: PacketDrillUtils.h:536
union PacketDrillExpression::@1 value
bool PacketDrillExpression::lookupIntSymbol ( const char *  input_symbol,
int64 output_integer,
struct int_symbol symbols 
)
236 {
237  int i;
238  for (i = 0; symbols[i].name != NULL ; ++i) {
239  if (strcmp(input_symbol, symbols[i].name) == 0) {
240  *output_integer = symbols[i].value;
241  return true;
242  }
243  }
244  return false;
245 }
int64 value
Definition: PacketDrillUtils.h:40
const char * name
Definition: PacketDrillUtils.h:41
void PacketDrillExpression::setAddStreams ( struct sctp_add_streams_expr exp)
inline

Referenced by PacketDrill::evaluate().

588 {value.sctp_addstreams = exp; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setAssocParams ( struct sctp_assocparams_expr exp)
inline

Referenced by PacketDrill::evaluate().

573 { value.sctp_assocparams = exp; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setAssocval ( struct sctp_assoc_value_expr exp)
inline

Referenced by PacketDrill::evaluate().

575 { value.sctp_assoc_value = exp; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setBinary ( struct binary_expression bin)
inline
568 { value.binary = bin; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setFormat ( const char *  format_)
inline

Referenced by parse_and_finalize_config().

563 { format = format_; };
const char * format
Definition: PacketDrillUtils.h:554
void PacketDrillExpression::setInitmsg ( struct sctp_initmsg_expr exp)
inline

Referenced by PacketDrill::evaluate().

571 { value.sctp_initmsg = exp; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setIp ( L3Address exp)
inline
585 {value.ip_address = exp; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setList ( cQueue *  queue)
inline

Referenced by PacketDrill::evaluateListExpression().

566 { value.list = queue; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setNum ( int64  n)
inline
void PacketDrillExpression::setPaddrParams ( struct sctp_paddrparams_expr exp)
inline

Referenced by PacketDrill::evaluate().

579 {value.sctp_paddr_params = exp; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setResetStreams ( struct sctp_reset_streams_expr exp)
inline

Referenced by PacketDrill::evaluate().

583 {value.sctp_resetstreams = exp; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setRtoinfo ( struct sctp_rtoinfo_expr exp)
inline

Referenced by PacketDrill::evaluate().

569 { value.sctp_rtoinfo = exp; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setSackinfo ( struct sctp_sack_info_expr exp)
inline

Referenced by PacketDrill::evaluate().

577 { value.sctp_sack_info = exp; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setSndRcvInfo ( struct sctp_sndrcvinfo_expr exp)
inline

Referenced by PacketDrill::evaluate().

581 {value.sctp_sndrcvinfo = exp; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setStatus ( struct sctp_status_expr exp)
inline

Referenced by PacketDrill::evaluate().

586 {value.sctp_status = exp; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setString ( char *  str)
inline
561 { value.string = str; };
union PacketDrillExpression::@1 value
void PacketDrillExpression::setType ( enum expression_t  t)
inline

Referenced by PacketDrill::evaluate(), and PacketDrill::evaluate_binary_expression().

557 { type = t; };
enum expression_t type
Definition: PacketDrillUtils.h:536
int PacketDrillExpression::symbolToInt ( const char *  input_symbol,
int64 output_integer,
char **  error 
)

Referenced by PacketDrill::evaluate().

248 {
249  if (lookupIntSymbol(input_symbol, output_integer, platform_symbols()))
250  return STATUS_OK;
251 
252  return STATUS_ERR;
253 }
Definition: PacketDrillUtils.h:288
bool lookupIntSymbol(const char *input_symbol, int64 *output_integer, struct int_symbol *symbols)
Definition: PacketDrillUtils.cc:235
struct int_symbol * platform_symbols(void)
Definition: PacketDrillUtils.cc:84
Definition: PacketDrillUtils.h:287
int PacketDrillExpression::unescapeCstringExpression ( const char *  input_string,
char **  error 
)

Referenced by PacketDrill::evaluate().

142 {
143  int bytes = strlen(input_string) + 1;
144  type = EXPR_STRING;
145  value.string = (char *)malloc(bytes);
146  const char *c_in = input_string;
147  char *c_out = value.string;
148  while (*c_in != '\0') {
149  if (*c_in == '\\') {
150  ++c_in;
151  switch (*c_in) {
152  case '\\':
153  *c_out = '\\';
154  break;
155 
156  case '"':
157  *c_out = '"';
158  break;
159 
160  case 'f':
161  *c_out = '\f';
162  break;
163 
164  case 'n':
165  *c_out = '\n';
166  break;
167 
168  case 'r':
169  *c_out = '\r';
170  break;
171 
172  case 't':
173  *c_out = '\t';
174  break;
175 
176  case 'v':
177  *c_out = '\v';
178  break;
179 
180  default:
181  EV_DEBUG << "Unsupported escape code: " << *c_in << endl;
182  return STATUS_ERR;
183  }
184  } else {
185  *c_out = *c_in;
186  }
187  ++c_in;
188  ++c_out;
189  }
190  return STATUS_OK;
191 }
Definition: PacketDrillUtils.h:288
void * malloc(YYSIZE_T)
Definition: PacketDrillUtils.h:287
enum expression_t type
Definition: PacketDrillUtils.h:536
union PacketDrillExpression::@1 value
Definition: PacketDrillUtils.h:250

Member Data Documentation

struct binary_expression* PacketDrillExpression::binary
const char* PacketDrillExpression::format
private
L3Address* PacketDrillExpression::ip_address
cQueue* PacketDrillExpression::list
int64 PacketDrillExpression::num
struct sctp_add_streams_expr* PacketDrillExpression::sctp_addstreams
struct sctp_assoc_value_expr* PacketDrillExpression::sctp_assoc_value
struct sctp_assocparams_expr* PacketDrillExpression::sctp_assocparams
struct sctp_initmsg_expr* PacketDrillExpression::sctp_initmsg
struct sctp_paddrparams_expr* PacketDrillExpression::sctp_paddr_params
struct sctp_reset_streams_expr* PacketDrillExpression::sctp_resetstreams
struct sctp_rtoinfo_expr* PacketDrillExpression::sctp_rtoinfo
struct sctp_sack_info_expr* PacketDrillExpression::sctp_sack_info
struct sctp_sndrcvinfo_expr* PacketDrillExpression::sctp_sndrcvinfo
struct sctp_status_expr* PacketDrillExpression::sctp_status
char* PacketDrillExpression::string
enum expression_t PacketDrillExpression::type
private
union { ... } PacketDrillExpression::value

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