Code Monkey home page Code Monkey logo

Comments (5)

sugyo avatar sugyo commented on August 9, 2024

ついでにですが、
message-helper.cにあるsend_message(send_controller_message)以外のsend_xxxは、
message-helper.rbにもっていくのはだめですか?(rubyで書いた方がいいような気がするためです)

from trema-edge.

sugyo avatar sugyo commented on August 9, 2024

send_messageもmessage-helper.rbにいれてみました。
私のイメージは下記のような感じです
https://github.com/sugyo/trema-edge/commit/902f9616719224d3a166133c377501db5fc81909

from trema-edge.

proshiba avatar proshiba commented on August 9, 2024

以下2つを実行して、とりあえず回避が出来ました。
PacketDataをStringで渡せれば、もっとスマートなのですが、そうはいかず。。。
(STR2CSTRなど試しましたが、NGでした。。。)

・ send_packet_outにて、:data => packet.unpack("C*") (unpackして渡す)
・ /ruby/trema/message-helper.cに以下を追記してrake

// 以下1行を追記(add)
VALUE r_opt_data = HASH_REF( options, data );
// 以下110行目から9行は変更無し
if ( !NIL_P( r_opt_message ) ) {

  if ( datapath_id == rb_iv_get( r_opt_message, "@datapath_id" ) ) {
    buffer_id = NUM2UINT( rb_iv_get( r_opt_message, "@buffer_id" ) );
    VALUE match = rb_iv_get( r_opt_message, "@match" );
    in_port = NUM2UINT( rb_iv_get( match, "@in_port" ) );
  }
  VALUE r_data = rb_iv_get( r_opt_message, "@data" );
  data = r_array_to_buffer( r_data );
}

// 以下3行を追記(add)
else if( !NIL_P(r_opt_data) ){
data = r_array_to_buffer( r_opt_data );
}
buffer *packet_out;
// 以下の判定条件を追加( || !NIL_P(r_opt_data) )
if ( buffer_id == OFP_NO_BUFFER &&
( !NIL_P( r_opt_message ) || !NIL_P(r_opt_data) )) {
// 以下省略

一応send_packet_out全体もそのまま載せておきます。

static VALUE
send_packet_out( int argc, VALUE *argv, VALUE self ) {
VALUE datapath_id = Qnil;
VALUE options = Qnil;
rb_scan_args( argc, argv, "11", &datapath_id, &options );

uint32_t buffer_id = OFP_NO_BUFFER;
buffer *data = NULL;
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 ); //add
if ( !NIL_P( r_opt_message ) ) {

  if ( datapath_id == rb_iv_get( r_opt_message, "@datapath_id" ) ) {
    buffer_id = NUM2UINT( rb_iv_get( r_opt_message, "@buffer_id" ) );
    VALUE match = rb_iv_get( r_opt_message, "@match" );
    in_port = NUM2UINT( rb_iv_get( match, "@in_port" ) );
  }
  VALUE r_data = rb_iv_get( r_opt_message, "@data" );
  data = r_array_to_buffer( r_data );
}
// add following els if
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 )  || !NIL_P(r_opt_data) )) {  // add more 1 condition
  buffer *frame = duplicate_buffer( data );
  fill_ether_padding( frame );
  packet_out = create_packet_out(
    get_transaction_id(),
    buffer_id,
    in_port,
    actions,
    frame
  );
  free_buffer( data );
  free_buffer( frame );
} 
else {
  packet_out = create_packet_out(
    get_transaction_id(),
    buffer_id, 
    in_port,
    actions,
    NULL
  );
}
send_openflow_message( NUM2ULL( datapath_id ), packet_out );

free_buffer( packet_out );
delete_actions( actions );

}
return self;
}

from trema-edge.

yasuhito avatar yasuhito commented on August 9, 2024

@proshiba @sugyo @shun159 すみません遅くなりました。
この修正がすぐ欲しいという人がいるので、とりあえず大芝さんの修正を入れておいて、のちほどすぎょうさん方式で修正します。

from trema-edge.

yasuhito avatar yasuhito commented on August 9, 2024

ひとまず @proshiba さんの修正を入れておきました。@shun159 @sugyo

from trema-edge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.