Class: Trema::QueueStatsRequest

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

Instance Method Summary collapse

Methods inherited from StatsRequest

#flags, #transaction_id

Constructor Details

#initialize(options = {}) ⇒ QueueStatsRequest

A Trema::QueueStatsRequest object instance to request queue statistics. Request queue statistics.

Returns an object that encapsulates the OFPT_STATS_REQUEST(OFPST_QUEUE) OpenFlow message.

Examples:

QueueStatsRequest.new
QueueStatsRequest.new( :port_no => 1, :queue_id => 123 )
QueueStatsRequest.new( :port_no => 1 )
QueueStatsRequest.new( :queue_id => 123 )

Parameters:

  • (defaults to: {})

    the options to create a message with.

Options Hash (options):

  • :port_no (Number)

    request statistics for a specific port if specified, otherwise set port_no to OFPP_ALL for all ports.

  • :queue_id (Number)

    request statistics for a specific queue_id or set queue_id to OFPQ_ALL for all queues.



535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
# File 'ruby/trema/stats-request.c', line 535

static VALUE
queue_stats_request_init( int argc, VALUE *argv, VALUE self ) {
  VALUE options;
  if ( !rb_scan_args( argc, argv, "01", &options ) ) {
    options = rb_hash_new();
  }
  rb_call_super( 1, &options );
  VALUE port_no = rb_hash_aref( options, ID2SYM( rb_intern( "port_no" ) ) );
  if ( port_no == Qnil ) {
    port_no = UINT2NUM( OFPP_ALL );
  }
  rb_iv_set( self, "@port_no", port_no );
  VALUE queue_id = rb_hash_aref( options, ID2SYM( rb_intern( "queue_id" ) ) );
  if ( queue_id == Qnil ) {
    queue_id = UINT2NUM( OFPQ_ALL );
  }
  rb_iv_set( self, "@queue_id", queue_id );


  buffer *message;
  Data_Get_Struct( self, buffer, message );
  ( ( struct ofp_header * ) ( message->data ) )->xid = htonl( get_stats_request_num2uint( self, "@transaction_id" ) );
  struct ofp_stats_request *stats_request;
  stats_request = ( struct ofp_stats_request * ) message->data;
  stats_request->flags = htons ( get_stats_request_num2uint16( self, "@flags" ) );

  stats_request = ( struct ofp_stats_request * ) message->data;
  struct ofp_queue_stats_request *queue_stats_request;
  queue_stats_request = ( struct ofp_queue_stats_request * ) stats_request->body;
  queue_stats_request->port_no = htons( get_stats_request_num2uint16( self, "@port_no" ) );
  queue_stats_request->queue_id = htonl( get_stats_request_num2uint( self, "@queue_id" ) );
  return self;
}

Instance Method Details

#port_noNumber

Restrict port statistics to a specific port_no or to all ports.

Returns:

  • the value of port_no.



237
238
239
240
# File 'ruby/trema/stats-request.c', line 237

static VALUE
stats_port_no( VALUE self ) {
  return rb_iv_get( self, "@port_no" );
}

#queue_idNumber

Restrict queue statistics to a specific queue_id or to all queues.

Returns:

  • the value of queue_id.



248
249
250
251
# File 'ruby/trema/stats-request.c', line 248

static VALUE
stats_queue_id( VALUE self ) {
  return rb_iv_get( self, "@queue_id" );
}