Class: Trema::GetConfigRequest

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

Instance Method Summary collapse

Constructor Details

#initializeGetConfigRequest #initialize(transaction_id) ⇒ GetConfigRequest #initialize(options) ⇒ GetConfigRequest

Creates a Trema::GetConfigRequest instance to query configuration parameters from the switch.

Overloads:

  • #initializeGetConfigRequest

    Examples:

    GetConfigRequest.new
    
  • #initialize(transaction_id) ⇒ GetConfigRequest

    Examples:

    GetConfigRequest.new( 123 )
    

    Parameters:

    • transaction_id (Integer)

      An unsigned 32-bit integer number associated with this message.

  • #initialize(options) ⇒ GetConfigRequest

    Examples:

    GetConfigRequest.new( :xid => 123 )
    GetConfigRequest.new( :transaction_id => 123 )
    

    Parameters:

    • options (Hash)

      the options to create a message with.

    Options Hash (options):

    • :xid (Number)

      an alias to transaction_id.

    • :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.

  • (TypeError)

    if argument is not a Integer or a Hash.



63
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
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'ruby/trema/get-config-request.c', line 63

static VALUE
get_config_request_init( int argc, VALUE *argv, VALUE self ) {
  buffer *get_config_request;
  Data_Get_Struct( self, buffer, get_config_request );
  VALUE options = Qnil;


  if ( rb_scan_args( argc, argv, "01", &options ) == 0 ) {
    set_xid( get_config_request, get_transaction_id() );
  }
  else {
    if ( options == Qnil ) {
      set_xid( get_config_request, get_transaction_id() );
    }
    else if ( rb_obj_is_kind_of( options, rb_cInteger ) == Qtrue ) {
      validate_xid( options );
      set_xid( get_config_request, ( uint32_t ) NUM2UINT( options ) );
    }
    else {
      Check_Type( options, T_HASH );
      VALUE tmp = Qnil;
      VALUE xid = Qnil;

      tmp = rb_hash_aref( options, ID2SYM( rb_intern( "transaction_id" ) ) );
      if ( tmp != Qnil ) {
        xid = tmp;
      }
      tmp = rb_hash_aref( options, ID2SYM( rb_intern( "xid" ) ) );
      if ( tmp != Qnil ) {
        xid = tmp;
      }

      if ( xid != Qnil ) {
        validate_xid( xid );
        set_xid( get_config_request, ( uint32_t ) NUM2UINT( xid ) );
      }
      else {
        set_xid( get_config_request, get_transaction_id() );
      }
    }
  }

  return self;
}

Instance Method Details

#transaction_idNumber

Transaction ids, message sequence numbers matching requests to replies.

Returns:

  • (Number)

    the value of transaction id.



114
115
116
117
# File 'ruby/trema/get-config-request.c', line 114

static VALUE
get_config_request_transaction_id( VALUE self ) {
  return get_xid( self );
}