Comments (5)
Yes it is possible to do Trema::Messages::Hello.new( transaction_id: 123 ) but after adding an alias name Hello = Trema::Messages::Hello the following would be also possible Hello.new( transaction_id: 123 ).
from trema-edge.
Hi, I tried the following test code to test the default value of :transaction_id
but it fails with a segfault. The test code sends :pack_msg
after the Hello message creation so that its :transaction_id
is set to default value. Any suggestions?
module Trema
describe Hello, ".new"
subject { Hello.new.pack_msg( 0xabc ) } # 0xabc is for placeholder
its( :transaction_id ) { should be_unsigned_32bit }
end
end
The error log:
Trema::Messages::Hello.new
/home/yasuhito/play/trema-edge/ruby/trema/message.rb:34: [BUG] Segmentation fault
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0034 p:---- s:0141 e:000140 CFUNC :pack_hello_msg
c:0033 p:0049 s:0137 e:000136 METHOD /home/yasuhito/play/trema-edge/ruby/trema/message.rb:34
c:0032 p:0017 s:0131 e:000130 LAMBDA /home/yasuhito/play/trema-edge/spec/trema/messages/hello_spec.rb:25 [FINISH]
c:0031 p:0015 s:0129 e:000125 BLOCK /home/yasuhito/.rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.13.1/lib/rspec/core/memoized_helpers.rb:185 [FINISH]
...
``` �
from trema-edge.
Fixed in http://github.com/trema/trema-edge/commit/a4c8f4553d435a1248cc066ba3d8018bc1bf4dc8
Default attributes can be set either using a lambda block or specifying a default value. Please note that default values can be overwritten if attributes set explicitly.
class Hello
unsigned_int32 :transaction_id, default: lambda { next_transaction_id }
array :version, validate_with: :check_version, default: [ OFP_VERSION ]
end
next_transaction_id
calls the get_transaction_id() to return a default value for transaction_id.
For example:
x = Trema::Hello.new
=> #<Trema::Messages::Hello:0x9c9c058 @transaction_id=1, @version=[4]>
from trema-edge.
Thanks for the quick fix!
I checked the new version with the following simple spec but exitted with assert() failure.
module Trema
describe Hello, ".new", :nosudo => true do
subject { Hello.new.pack_msg( 0xabc ) }
it_should_behave_like "any Openflow message with default transaction ID"
end
end
The error message is:
Trema::Messages::Hello.new it should behave like any Openflow message with default transaction ID
transaction_id/home/yasuhito/.rvm/gems/ruby-2.0.0-p0/bin/rspec: /home/yasuhito/play/trema-edge/src/lib/trema.c:691: get_trema_name: Assertion `trema_name != ((void *)0)' failed.
from trema-edge.
Sorry I forgot to remove .pack_msg()
. Just Hello.new worked fine.
from trema-edge.
Related Issues (20)
- Multiple table usage error HOT 2
- make失敗およびlearning-switchの実行失敗 HOT 1
- FLOW_MODに使用するバイトオーダ HOT 1
- Trema::Match*_mask does not work HOT 6
- 生成したフレームをpacket_outのdata:として指定した際にエラーが出力される HOT 5
- ExactMatch.from is not fully implemented yet
- LoggerモジュールがSinatraと衝突して動かない HOT 1
- Trema::Controller::send_list_switches_request is not implemented yet
- send_flow_mod_delete
- Trema::Controller#switch_disconnected is not implemented
- Trema::Match#compare is not implemented
- FlowMultipartRequestがエラーになる HOT 2
- FlowMultipartRequestがエラーになる。 (Ipv4SrcAddr) HOT 1
- action buckets に複数の action を定義できない HOT 2
- OpenFLow 1.3.3 HOT 3
- Write-Action instruction does not allow to modify multiple header fields HOT 1
- TremaEdgeでPioが動作しない HOT 3
- trema-edge does not pass the unit tests
- Dumper.rb の port_status メソッド が正しく動作しない HOT 1
- trema version コマンドの出力 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trema-edge.