Class: Trema::StatsRequest

Inherits:
Object
  • Object
show all
Defined in:
ruby/trema/stats-request.c

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ StatsRequest

A OPPT_STATS_REQUEST message is sent to collect statistics for a type element from the datapath. This type element can be a flow port, queue, or vendor. All stats. request messages share a common header followed by additional fields that further describe the request type. There is a derived class for each associated type. All stats. requests encapsulate their instances as a buffer object that can be converted to a packet to be used for transmission.

Parameters:

  • options (Hash) (defaults to: {})

    the options to create a message with.

Options Hash (options):

  • :transaction_id (Number)

    transaction_id for this request or auto-generated if not specified.

  • :flags (Number)

    flags not defined yet should be set to zero.

Raises:

  • (ArgumentError)

    if supplied transaction_id is not an unsigned 32-bit integer.

See Also:



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'ruby/trema/stats-request.c', line 78

static VALUE
stats_request_init( VALUE self, VALUE options ) {
  VALUE transaction_id;
  if ( ( transaction_id = rb_hash_aref( options, ID2SYM( rb_intern( "transaction_id" ) ) ) ) != Qnil ) {
    if ( rb_funcall( transaction_id, rb_intern( "unsigned_32bit?" ), 0 ) == Qfalse ) {
      rb_raise( rb_eArgError, "Transaction ID must be an unsigned 32-bit integer" );
    }
  }
  else {
    transaction_id = UINT2NUM( get_transaction_id() );
  }
  rb_iv_set( self, "@transaction_id", transaction_id );
  VALUE flags = rb_hash_aref( options, ID2SYM( rb_intern( "flags" ) ) );
  if ( flags == Qnil ) {
    flags = UINT2NUM( 0 );
  }
  rb_iv_set( self, "@flags", flags );
  return self;
}

Instance Method Details

#flagsNumber

Not yet defined. Set to zero.

Returns:

  • (Number)

    the value of flags.



193
194
195
196
# File 'ruby/trema/stats-request.c', line 193

static VALUE
stats_flags( VALUE self ) {
  return rb_iv_get( self, "@flags" );
}

#transaction_idNumber

Transaction ids, message sequence numbers matching requests to replies.

Returns:

  • (Number)

    the value of transaction_id.



182
183
184
185
# File 'ruby/trema/stats-request.c', line 182

static VALUE
stats_transaction_id( VALUE self ) {
  return rb_iv_get( self, "@transaction_id" );
}