Class: Trema::FlowMod

Inherits:
Object
  • Object
show all
Defined in:
ruby/trema/flow-mod.c

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
# File 'ruby/trema/flow-mod.c', line 48

static VALUE
flow_mod_init( int argc, VALUE *argv, VALUE self ) {
  buffer *flow_mod = NULL;
  Data_Get_Struct( self, buffer, flow_mod );
  VALUE options = Qnil;

  if ( rb_scan_args( argc, argv, "01", &options ) == 0 ) {
    set_xid( flow_mod, get_transaction_id() );
  }
  else {
    if ( options == Qnil ) {
      set_xid( flow_mod, get_transaction_id() );
    }
    else if ( rb_obj_is_kind_of( options, rb_cInteger ) == Qtrue ) {
      validate_xid( options );
      set_xid( flow_mod, ( 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;
      }

      tmp = rb_hash_aref( options, ID2SYM( rb_intern( "idle_timeout" ) ) );
      if ( tmp != Qnil ) {
        ( ( struct ofp_flow_mod * ) ( flow_mod->data ) )->idle_timeout = ( uint16_t ) NUM2UINT( tmp );
      }

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

  return self;
}

Instance Method Details

#commandObject



104
105
106
107
108
109
110
# File 'ruby/trema/flow-mod.c', line 104

static VALUE
flow_mod_command( VALUE self ) {
  buffer *flow_mod;
  Data_Get_Struct( self, buffer, flow_mod );
  uint32_t command = ntohl( ( ( struct ofp_flow_mod * ) ( flow_mod->data ) )->command );
  return UINT2NUM( command );
}

#hard_timeoutObject



122
123
124
125
126
127
128
# File 'ruby/trema/flow-mod.c', line 122

static VALUE
flow_mod_hard_timeout( VALUE self ) {
  buffer *flow_mod;
  Data_Get_Struct( self, buffer, flow_mod );
  uint32_t hard_timeout = ntohl( ( ( struct ofp_flow_mod * ) ( flow_mod->data ) )->hard_timeout );
  return UINT2NUM( hard_timeout );
}

#idle_timeoutObject



113
114
115
116
117
118
119
# File 'ruby/trema/flow-mod.c', line 113

static VALUE
flow_mod_idle_timeout( VALUE self ) {
  buffer *flow_mod;
  Data_Get_Struct( self, buffer, flow_mod );
  uint32_t idle_timeout = ntohl( ( ( struct ofp_flow_mod * ) ( flow_mod->data ) )->idle_timeout );
  return UINT2NUM( idle_timeout );
}

#transaction_idObject



98
99
100
101
# File 'ruby/trema/flow-mod.c', line 98

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