Class: Trema::PortStatsRequest

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 = {}) ⇒ PortStatsRequest

A Trema::PortStatsRequest object instance to request port statistics. Request port statistics.

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

Examples:

PortStatsRequest.new
PortStatsRequest.new( :port_no => 1 )

Parameters:

  • options (Hash) (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_NONE for all ports.



483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'ruby/trema/stats-request.c', line 483

static VALUE
port_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_NONE );
  }
  rb_iv_set( self, "@port_no", port_no );

  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" ) );
  struct ofp_port_stats_request *port_stats_request = ( struct ofp_port_stats_request * ) stats_request->body;
  port_stats_request->port_no = htons( get_stats_request_num2uint16( self, "@port_no" ) );
  return self;
}

Instance Method Details

#port_noNumber

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

Returns:

  • (Number)

    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" );
}