Class: Trema::AggregateStatsRequest

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

A Trema::AggregateStatsRequest object instance to request aggregate statistics.

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

Examples:

AggregateStatsRequest.new( :match => Match )
AggregateStatsRequest.new( :match => Match, :table_id => 1, :out_port => 2 )

Parameters:

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

    the options to create a message with.

Options Hash (options):

  • :match (Match)

    a Match object to match flow fields with this request. This option is mandatory.

  • :table_id (Number)

    a table id to match and restrict returned results. A value of 0xff would return all tables and is set to if not specified.

  • :out_port (Number)

    a value of OFPP_NONE would match all flow entries and is set to if not specified.

Raises:

  • (ArgumentError)

    if option match is not specified.

  • (TypeError)

    if option match is not a Trema::Match object.



410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'ruby/trema/stats-request.c', line 410

static VALUE
aggregate_stats_request_init( VALUE self, VALUE options ) {
  buffer *message;
  Data_Get_Struct( self, buffer, message );

  subclass_stats_request_init( self, options );

  ( ( 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;
  struct ofp_aggregate_stats_request *aggregate_stats_request;
  aggregate_stats_request = ( struct ofp_aggregate_stats_request * ) stats_request->body;

  stats_request->flags = htons ( get_stats_request_num2uint16( self, "@flags" ) );

  const struct ofp_match *match;
  Data_Get_Struct( rb_iv_get( self, "@match" ), struct ofp_match, match );
  hton_match( &aggregate_stats_request->match, match );
  aggregate_stats_request->table_id = get_stats_request_table_id( self );
  aggregate_stats_request->out_port = htons( get_stats_request_num2uint16( self, "@out_port" ) );
  return self;
}

Instance Method Details

#matchMatch

Detailed description of each flow field.

Returns:

  • (Match)

    the value of match.



204
205
206
207
# File 'ruby/trema/stats-request.c', line 204

static VALUE
stats_match( VALUE self ) {
  return rb_iv_get( self, "@match" );
}

#out_portNumber

Requires flow matching if defined.

Returns:

  • (Number)

    the value of out_port.



226
227
228
229
# File 'ruby/trema/stats-request.c', line 226

static VALUE
stats_out_port( VALUE self ) {
  return rb_iv_get( self, "@out_port" );
}

#table_idNumber

An index into array of tables. 0xff for all tables.

Returns:

  • (Number)

    the value of table_id.



215
216
217
218
# File 'ruby/trema/stats-request.c', line 215

static VALUE
stats_table_id( VALUE self ) {
  return rb_iv_get( self, "@table_id" );
}