Class: Trema::QueueGetConfigRequest

Inherits:
Object
  • Object
show all
Defined in:
ruby/trema/queue-get-config-request.c

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ QueueGetConfigRequest

Request message to retrieve configuration about a queue port setting that quantifies a QoS. Each flow entry contains a queue that a flow is mapped to set constraints to define some restriction like maximum/minimum data rate.

Returns an object that encapsulates the OFPT_GET_CONFIG_REQUEST OpenFlow message.

Examples:

QueueGetConfigRequest.new
QueueGetConfigRequest.new( :port => 1 )
QueueGetConfigRequest.new( :port => 1, :transaction_id => 123 )

Parameters:

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

    the options to create a message with.

Options Hash (options):

  • :port (Number)

    a port number to query (defaults to 1).

  • :transaction_id (Number)

    An unsigned 32-bit integer number associated with this message. If not specified, an auto-generated value is set.

Raises:

  • (ArgumentError)

    if transaction_id is not an unsigned 32-bit integer.

  • (ArgumentError)

    if port is not an unsigned 16-bit integer.

  • (TypeError)

    if options is not a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'ruby/trema/queue-get-config-request.c', line 64

static VALUE
queue_get_config_request_init( int argc, VALUE *argv, VALUE self ) {
  buffer *queue_get_config_request;
  Data_Get_Struct( self, buffer, queue_get_config_request );
  uint32_t xid = get_transaction_id();
  uint16_t port = 1;

  VALUE options;

  if ( rb_scan_args( argc, argv, "01", &options ) == 1 ) {
    Check_Type( options, T_HASH );
    VALUE xid_ruby;
    if ( ( xid_ruby = rb_hash_aref( options, ID2SYM( rb_intern( "transaction_id" ) ) ) ) != Qnil ) {
      if ( rb_funcall( xid_ruby, rb_intern( "unsigned_32bit?" ), 0 ) == Qfalse ) {
        rb_raise( rb_eArgError, "Transaction ID must be an unsigned 32-bit integer" );
      }
      xid = ( uint32_t ) NUM2UINT( xid_ruby );
    }
    VALUE port_ruby;
    if ( ( port_ruby = rb_hash_aref( options, ID2SYM( rb_intern( "port" ) ) ) ) != Qnil ) {
      if ( rb_funcall( port_ruby, rb_intern( "unsigned_16bit?" ), 0 ) == Qfalse ) {
        rb_raise( rb_eArgError, "Port must be an unsigned 16-bit integer" );
      }
      port = ( uint16_t ) NUM2UINT( port_ruby );
    }
  }
  ( ( struct ofp_header * ) ( queue_get_config_request->data ) )->xid = htonl( xid );
  ( ( struct ofp_queue_get_config_request * ) ( queue_get_config_request->data ) )->port = htons( port );
  return self;
}

Instance Method Details

#portNumber

The port the queue is attached to.

Returns:

  • (Number)

    the value of port.



115
116
117
118
119
120
121
# File 'ruby/trema/queue-get-config-request.c', line 115

static VALUE
queue_get_config_request_port( VALUE self ) {
  buffer *queue_get_config_request;
  Data_Get_Struct( self, buffer, queue_get_config_request );
  uint16_t port = ntohs( ( ( struct ofp_queue_get_config_request * ) ( queue_get_config_request->data ) )->port );
  return UINT2NUM( port );
}

#transaction_idNumber

Transaction ids, message sequence numbers matching requests to replies.

Returns:

  • (Number)

    the value of transaction id.



101
102
103
104
105
106
107
# File 'ruby/trema/queue-get-config-request.c', line 101

static VALUE
queue_get_config_request_transaction_id( VALUE self ) {
  buffer *queue_get_config_request;
  Data_Get_Struct( self, buffer, queue_get_config_request );
  uint32_t xid = ntohl( ( ( struct ofp_header * ) ( queue_get_config_request->data ) )->xid );
  return UINT2NUM( xid );
}