ruby/trema/switch.c in trema-0.3.21 vs ruby/trema/switch.c in trema-0.4.0

- old
+ new

@@ -38,35 +38,35 @@ } static void handle_controller_connected( void *rbswitch ) { - if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "controller_connected" ) ) == Qtrue ) { + if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "controller_connected" ) ) ) { rb_funcall( ( VALUE ) rbswitch, rb_intern( "controller_connected" ), 0 ); } } static void handle_hello( uint32_t transaction_id, uint8_t version, void *rbswitch ) { - if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "hello" ) ) == Qtrue ) { + if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "hello" ) ) ) { rb_funcall( ( VALUE ) rbswitch, rb_intern( "hello" ), 2, UINT2NUM( transaction_id ), UINT2NUM( version ) ); } } static void handle_features_request( uint32_t transaction_id, void *rbswitch ) { - if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "features_request" ) ) == Qtrue ) { + if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "features_request" ) ) ) { rb_funcall( ( VALUE ) rbswitch, rb_intern( "features_request" ), 1, UINT2NUM( transaction_id ) ); } } static void handle_set_config( uint32_t transaction_id, uint16_t flags, uint16_t miss_send_len, void *rbswitch ) { - if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "set_config" ) ) == Qtrue ) { + if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "set_config" ) ) ) { rb_funcall( ( VALUE ) rbswitch, rb_intern( "set_config" ), 3, UINT2NUM( transaction_id ), UINT2NUM( flags ), UINT2NUM( miss_send_len ) ); } } @@ -90,11 +90,11 @@ UNUSED( priority ); UNUSED( buffer_id ); UNUSED( out_port ); UNUSED( flags ); UNUSED( actions ); - if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "flow_mod" ) ) == Qtrue ) { + if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "flow_mod" ) ) ) { VALUE options = rb_hash_new(); rb_hash_aset( options, ID2SYM( rb_intern( "transaction_id" ) ), UINT2NUM( transaction_id ) ); rb_hash_aset( options, ID2SYM( rb_intern( "command" ) ), UINT2NUM( command ) ); rb_hash_aset( options, ID2SYM( rb_intern( "idle_timeout" ) ), UINT2NUM( idle_timeout ) ); rb_hash_aset( options, ID2SYM( rb_intern( "hard_timeout" ) ), UINT2NUM( hard_timeout ) ); @@ -104,31 +104,31 @@ } static void handle_echo_request( uint32_t transaction_id, const buffer *body, void *rbswitch ) { - if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "echo_request" ) ) == Qtrue ) { + if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "echo_request" ) ) ) { VALUE rbody = rb_str_new( body->data, ( long ) body->length ); rb_funcall( ( VALUE ) rbswitch, rb_intern( "echo_request" ), 2, UINT2NUM( transaction_id ), rbody ); } } static VALUE switch_run( VALUE self ) { - setenv( "CHIBACH_HOME", STR2CSTR( rb_funcall( mTrema, rb_intern( "home" ), 0 ) ), 1 ); + setenv( "CHIBACH_HOME", RSTRING_PTR( rb_funcall( mTrema, rb_intern( "home" ), 0 ) ), 1 ); VALUE name = rb_funcall( self, rb_intern( "name" ), 0 ); rb_gv_set( "$PROGRAM_NAME", name ); int argc = 6; char **argv = xmalloc( sizeof( char * ) * ( uint32_t ) ( argc + 1 ) ); - argv[ 0 ] = STR2CSTR( name ); + argv[ 0 ] = RSTRING_PTR( name ); argv[ 1 ] = ( char * ) ( uintptr_t ) "--name"; - argv[ 2 ] = STR2CSTR( name ); + argv[ 2 ] = RSTRING_PTR( name ); argv[ 3 ] = ( char * ) ( uintptr_t ) "--datapath_id"; - argv[ 4 ] = STR2CSTR( rb_funcall( rb_iv_get( self, "@dpid" ), rb_intern( "to_hex" ), 0 ) ); + argv[ 4 ] = RSTRING_PTR( rb_funcall( rb_iv_get( self, "@dpid" ), rb_intern( "to_hex" ), 0 ) ); argv[ 5 ] = ( char * ) ( uintptr_t ) "--daemonize"; argv[ 6 ] = NULL; init_chibach( &argc, &argv ); xfree( argv ); @@ -137,10 +137,10 @@ set_features_request_handler( handle_features_request, ( void * ) self ); set_set_config_handler( handle_set_config, ( void * ) self ); set_flow_mod_handler( handle_flow_mod, ( void * ) self ); set_echo_request_handler( handle_echo_request, ( void * ) self ); - if ( rb_respond_to( self, rb_intern( "start" ) ) == Qtrue ) { + if ( rb_respond_to( self, rb_intern( "start" ) ) ) { rb_funcall( self, rb_intern( "start" ), 0 ); } rb_funcall( self, rb_intern( "start_chibach" ), 0 );