Class: Trema::OpenflowError

Inherits:
Object
  • Object
show all
Defined in:
ruby/trema/openflow-error.c

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ OpenflowError

The occurence of reported errors/exceptions manifested as an instance - a Trema::OpenflowError object. The user would not explicitly instantiate a Trema::OpenflowError but would be created while parsing the OFPT_ERROR message.

Returns an object that encapsulates the OFPT_ERROR OpenFlow message.

Examples:

OpenflowError.new(
  :datapath_id => 0xabc,
  :transaction_id => 123,
  :type => OFPET_BAD_REQUEST,
  :code => OFPBRC_BAD_SUBTYPE,
  :data => data
)

Parameters:

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

    the options to create a message with.

Options Hash (options):

  • :datapath_id (Number)

    message originator identifier. This idenfier is typed as a 64-bit number and must be unique in a given domain of application deployment.

  • :transaction_id (Number)

    the transaction_id of the offended message.

  • :type (Number)

    the command or action that failed signifies the kind of error.

  • :code (Number)

    the reason of the failed type error.

  • :data (String)

    variable length data interpreted based on type and code.



65
66
67
68
69
# File 'ruby/trema/openflow-error.c', line 65

static VALUE
openflow_error_init( VALUE self, VALUE options ) {
  rb_iv_set( self, "@attribute", options );
  return self;
}

Instance Method Details

#codeNumber

The reason of the failed type error.

Returns:

  • (Number)

    the value of code.



110
111
112
113
# File 'ruby/trema/openflow-error.c', line 110

static VALUE
openflow_error_code( VALUE self ) {
  return rb_hash_aref( rb_iv_get( self, "@attribute" ), ID2SYM( rb_intern( "code" ) ) );
}

#dataString, Array

Variable length data interpreted based on type and code.

Returns:

  • (String)

    if error type is OFPET_HELLO_FAILED.

  • (Array)

    an array of bytes of the offending message for any other error type.



122
123
124
125
# File 'ruby/trema/openflow-error.c', line 122

static VALUE
openflow_error_data( VALUE self ) {
  return rb_hash_aref( rb_iv_get( self, "@attribute" ), ID2SYM( rb_intern( "data" ) ) );
}

#datapath_idNumber

Message originator identifier.

Returns:

  • (Number)

    the value of datapath_id.



77
78
79
80
# File 'ruby/trema/openflow-error.c', line 77

static VALUE
openflow_error_datapath_id( VALUE self ) {
  return rb_hash_aref( rb_iv_get( self, "@attribute" ), ID2SYM( rb_intern( "datapath_id" ) ) );
}

#transaction_idNumber

The transaction_id of the offended message.

Returns:

  • (Number)

    the value of transaction_id.



88
89
90
91
# File 'ruby/trema/openflow-error.c', line 88

static VALUE
openflow_error_transaction_id( VALUE self ) {
  return rb_hash_aref( rb_iv_get( self, "@attribute" ), ID2SYM( rb_intern( "transaction_id" ) ) );
}

#typeNumber

The command or action that failed.

Returns:

  • (Number)

    the value of type.



99
100
101
102
# File 'ruby/trema/openflow-error.c', line 99

static VALUE
openflow_error_type( VALUE self ) {
  return rb_hash_aref( rb_iv_get( self, "@attribute" ), ID2SYM( rb_intern( "type" ) ) );
}