Class: Trema::PortStatus

Inherits:
Object
  • Object
show all
Defined in:
ruby/trema/port-status.c

Direct Known Subclasses

PortStatusAdd, PortStatusDelete, PortStatusModify

Constant Summary collapse

OFPPR_ADD =
INT2NUM( OFPPR_ADD )
OFPPR_DELETE =
INT2NUM( OFPPR_DELETE )
OFPPR_MODIFY =
INT2NUM( OFPPR_MODIFY )

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ PortStatus

Creates a port status message.

Examples:

PortStatus.new(
  :datapath_id => 0xabc,
  :transaction_id => 123,
  :reason => PortStatus::OFPPR_ADD,
  :phy_port => port
)

Parameters:

  • options (Hash)

    the options to create a message with.

Options Hash (options):

  • :datapath_id (Number)

    message originator identifier.

  • :transaction_id (Number)

    unsolicited message transaction_id is zero.

  • :reason (Number)

    the reason why this message was sent.

  • :phy_port (Port)

    a Trema::Port object describing the properties of the port.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'ruby/trema/port-status.c', line 57

static VALUE
port_status_init( VALUE self, VALUE options ) {
  if ( rb_hash_aref( options, ID2SYM( rb_intern( "datapath_id" ) ) ) == Qnil ) {
    rb_raise( rb_eArgError, ":datapath_id is a mandatory option" );
  }
  if ( rb_hash_aref( options, ID2SYM( rb_intern( "transaction_id" ) ) ) == Qnil ) {
    rb_raise( rb_eArgError, ":transaction_id is a mandatory option" );
  }
  if ( rb_hash_aref( options, ID2SYM( rb_intern( "reason" ) ) ) == Qnil ) {
    rb_raise( rb_eArgError, ":reason is a mandatory option" );
  }
  if ( rb_hash_aref( options, ID2SYM( rb_intern( "phy_port" ) ) ) == Qnil ) {
    rb_raise( rb_eArgError, ":phy_port is a mandatory option" );
  }

  rb_iv_set( self, "@attribute", options );
  return self;
}

Instance Method Details

#datapath_idNumber

Message originator identifier.

Returns:

  • (Number)

    the value of datapath_id.



82
83
84
85
# File 'ruby/trema/port-status.c', line 82

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

#phy_portPort

Port detailed description, state.

Returns:

  • (Port)

    the value of phy_port.



115
116
117
118
# File 'ruby/trema/port-status.c', line 115

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

#reasonNumber

The reason value specifies an addition, deletion or modification to a port.

Returns:

  • (Number)

    the value of reason.



104
105
106
107
# File 'ruby/trema/port-status.c', line 104

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

#transaction_idNumber

For this asynchronous message the transaction_id is set to zero.

Returns:

  • (Number)

    the value of transaction_id.



93
94
95
96
# File 'ruby/trema/port-status.c', line 93

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