From 9bee68128191b920b236c0c626c4094a2b5c5820 Mon Sep 17 00:00:00 2001 From: Yasuhito Takamiya Date: Fri, 28 Nov 2014 14:21:05 +0900 Subject: [PATCH] Fix errors when passing :data option to send_packet_out (refs #52). --- ruby/trema/message-helper.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ruby/trema/message-helper.c b/ruby/trema/message-helper.c index ef59c404..a37048c5 100644 --- a/ruby/trema/message-helper.c +++ b/ruby/trema/message-helper.c @@ -97,13 +97,13 @@ send_packet_out( int argc, VALUE *argv, VALUE self ) { openflow_actions *actions = NULL; uint32_t in_port = OFPP_ANY; if ( !NIL_P( options ) ) { - VALUE r_opt_action = HASH_REF( options, actions ); if ( !NIL_P( r_opt_action ) ) { actions = pack_basic_action( r_opt_action ); } VALUE r_opt_message = HASH_REF( options, packet_in ); + VALUE r_opt_data = HASH_REF( options, data ); if ( !NIL_P( r_opt_message ) ) { if ( datapath_id == rb_iv_get( r_opt_message, "@datapath_id" ) ) { @@ -115,10 +115,13 @@ send_packet_out( int argc, VALUE *argv, VALUE self ) { VALUE r_data = rb_iv_get( r_opt_message, "@data" ); data = r_array_to_buffer( r_data ); } - + else if ( !NIL_P( r_opt_data ) ) { + data = r_array_to_buffer( r_opt_data ); + } buffer *packet_out; - if ( buffer_id == OFP_NO_BUFFER && !NIL_P( r_opt_message ) ) { + if ( buffer_id == OFP_NO_BUFFER && + ( !NIL_P( r_opt_message ) || !NIL_P( r_opt_data ) )) { buffer *frame = duplicate_buffer( data ); fill_ether_padding( frame );