trema 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +10 -2
- data/ruby/trema/version.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/trema/send-out-port_spec.rb +37 -39
- data/spec/trema/set-eth-dst-addr_spec.rb +32 -37
- data/spec/trema/set-eth-src-addr_spec.rb +32 -34
- data/src/lib/openflow_message.c +4 -4
- metadata +4 -8
- data/.gitmodules +0 -3
- data/locale/README.ja.md +0 -19
- data/locale/ja/yard.po +0 -3762
- data/locale/yard.pot +0 -3740
data/Rakefile
CHANGED
@@ -54,8 +54,16 @@ begin
|
|
54
54
|
require "rspec/core"
|
55
55
|
require "rspec/core/rake_task"
|
56
56
|
|
57
|
-
RSpec::Core::RakeTask.new
|
58
|
-
|
57
|
+
RSpec::Core::RakeTask.new do | task |
|
58
|
+
task.verbose = $trace
|
59
|
+
task.pattern = FileList[ "spec/**/*_spec.rb" ]
|
60
|
+
task.rspec_opts = "--format documentation --color"
|
61
|
+
end
|
62
|
+
|
63
|
+
RSpec::Core::RakeTask.new( "spec:actions" ) do | task |
|
64
|
+
task.verbose = $trace
|
65
|
+
task.pattern = FileList[ "spec/**/*_spec.rb" ]
|
66
|
+
task.rspec_opts = "--tag type:actions --format documentation --color"
|
59
67
|
end
|
60
68
|
|
61
69
|
RSpec::Core::RakeTask.new( "spec:travis" ) do | spec |
|
data/ruby/trema/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -121,14 +121,14 @@ class Network
|
|
121
121
|
@th_controller = Thread.start do
|
122
122
|
controller.run!
|
123
123
|
end
|
124
|
-
sleep
|
124
|
+
sleep 5 # FIXME: wait until controller.up?
|
125
125
|
end
|
126
126
|
|
127
127
|
|
128
128
|
def trema_kill
|
129
129
|
cleanup_current_session
|
130
130
|
@th_controller.join if @th_controller
|
131
|
-
sleep
|
131
|
+
sleep 5 # FIXME: wait until switch_manager.down?
|
132
132
|
end
|
133
133
|
|
134
134
|
|
@@ -20,65 +20,63 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
|
20
20
|
require "trema"
|
21
21
|
|
22
22
|
|
23
|
-
describe SendOutPort,
|
24
|
-
|
25
|
-
|
26
|
-
its( :max_len ) { should == 2 ** 16 - 1 }
|
27
|
-
its( :to_s ) { should == "SendOutPort: port=1, max_len=65535" }
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
describe SendOutPort, ".new( :port_number => number )" do
|
32
|
-
subject { SendOutPort.new :port_number => port_number }
|
33
|
-
it_validates "option range", :port_number, 0..( 2 ** 16 - 1 )
|
23
|
+
describe SendOutPort, :type => "actions" do
|
24
|
+
context "#new( 1 )" do
|
25
|
+
subject { SendOutPort.new( 1 ) }
|
34
26
|
|
35
|
-
context "when :port_number == 1" do
|
36
|
-
let( :port_number ) { 1 }
|
37
27
|
its( :port_number ) { should == 1 }
|
28
|
+
its( :max_len ) { should == 2 ** 16 - 1 }
|
38
29
|
its( :to_s ) { should == "SendOutPort: port=1, max_len=65535" }
|
39
30
|
end
|
40
|
-
end
|
41
31
|
|
32
|
+
context "#new( :port_number => number )" do
|
33
|
+
subject { SendOutPort.new( :port_number => number ) }
|
42
34
|
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
context "with port number (1)" do
|
36
|
+
let( :number ) { 1 }
|
37
|
+
its( :port_number ) { should == 1 }
|
38
|
+
its( :to_s ) { should == "SendOutPort: port=1, max_len=65535" }
|
39
|
+
end
|
46
40
|
|
47
|
-
|
48
|
-
let( :max_len ) { 256 }
|
49
|
-
its( :max_len ) { should == 256 }
|
50
|
-
its( :to_s ) { should == "SendOutPort: port=1, max_len=256" }
|
41
|
+
it_validates "option range", :number, 0..( 2 ** 16 - 1 )
|
51
42
|
end
|
52
|
-
end
|
53
43
|
|
44
|
+
context "#new( :port_number => 1, :max_len => number )" do
|
45
|
+
subject { SendOutPort.new( :port_number => 1, :max_len => max_len ) }
|
54
46
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
47
|
+
context "with :max_len == 256" do
|
48
|
+
let( :max_len ) { 256 }
|
49
|
+
its( :max_len ) { should == 256 }
|
50
|
+
its( :to_s ) { should == "SendOutPort: port=1, max_len=256" }
|
51
|
+
end
|
52
|
+
|
53
|
+
it_validates "option range", :max_len, 0..( 2 ** 16 - 1 )
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when sending a Flow Mod with SendOutPort action" do
|
57
|
+
it "should insert a new flow entry with action (output:1)" do
|
58
|
+
class TestController < Controller; end
|
59
59
|
network {
|
60
60
|
vswitch { datapath_id 0xabc }
|
61
|
-
}.run(
|
62
|
-
controller( "
|
63
|
-
|
64
|
-
sleep 2 # FIXME: wait to send_flow_mod_add
|
61
|
+
}.run( TestController ) {
|
62
|
+
controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => SendOutPort.new( 1 ) )
|
63
|
+
sleep 2
|
65
64
|
vswitch( "0xabc" ).should have( 1 ).flows
|
66
|
-
vswitch( "0xabc" ).flows[0].actions.should
|
65
|
+
vswitch( "0xabc" ).flows[ 0 ].actions.should == "output:1"
|
67
66
|
}
|
68
67
|
end
|
69
68
|
end
|
70
69
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
class FlowModAddController < Controller; end
|
70
|
+
context "when sending a Flow Mod with multiple SendOutPort actions" do
|
71
|
+
it "should insert a new flow entry with actions (output:1\/output:2)" do
|
72
|
+
class TestController < Controller; end
|
75
73
|
network {
|
76
74
|
vswitch { datapath_id 0xabc }
|
77
|
-
}.run(
|
78
|
-
controller( "
|
79
|
-
sleep 2
|
75
|
+
}.run( TestController ) {
|
76
|
+
controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => [ SendOutPort.new( 1 ), SendOutPort.new( 2 ) ] )
|
77
|
+
sleep 2
|
80
78
|
vswitch( "0xabc" ).should have( 1 ).flows
|
81
|
-
vswitch( "0xabc" ).flows[0].actions.should match( /output:1\/output:2/ )
|
79
|
+
vswitch( "0xabc" ).flows[ 0 ].actions.should match( /output:1\/output:2/ )
|
82
80
|
}
|
83
81
|
end
|
84
82
|
end
|
@@ -20,56 +20,51 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
|
20
20
|
require "trema"
|
21
21
|
|
22
22
|
|
23
|
-
describe SetEthDstAddr,
|
24
|
-
subject { SetEthDstAddr.new(
|
25
|
-
its( :mac_address ) { should == Mac.new( "52:54:00:a8:ad:8c" ) }
|
26
|
-
its( :to_s ) { should == "SetEthDstAddr: mac_address=52:54:00:a8:ad:8c" }
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
describe SetEthDstAddr, %{.new( Mac.new( "52:54:00:a8:ad:8c" ) )} do
|
31
|
-
subject { SetEthDstAddr.new( Mac.new( "52:54:00:a8:ad:8c" ) )}
|
32
|
-
its( :mac_address ) { should == Mac.new( "52:54:00:a8:ad:8c" ) }
|
33
|
-
its( :to_s ) { should == "SetEthDstAddr: mac_address=52:54:00:a8:ad:8c" }
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
describe SetEthDstAddr, %{.new( "INVALID MAC STRING" )} do
|
38
|
-
it { expect { SetEthDstAddr.new( "INVALID MAC STRING" ) }.to raise_error( ArgumentError ) }
|
39
|
-
end
|
23
|
+
describe SetEthDstAddr, ".new( mac_address )", :type => "actions" do
|
24
|
+
subject { SetEthDstAddr.new( mac_address ) }
|
40
25
|
|
26
|
+
context "with mac_address (52:54:00:a8:ad:8c)" do
|
27
|
+
let( :mac_address ) { "52:54:00:a8:ad:8c" }
|
28
|
+
its( "mac_address.to_s" ) { should == "52:54:00:a8:ad:8c" }
|
29
|
+
its( :to_s ) { should == "SetEthDstAddr: mac_address=52:54:00:a8:ad:8c" }
|
30
|
+
end
|
41
31
|
|
42
|
-
|
43
|
-
|
32
|
+
context %q{with mac_address (Mac.new("52:54:00:a8:ad:8c"))} do
|
33
|
+
let( :mac_address ) { Mac.new("52:54:00:a8:ad:8c") }
|
34
|
+
its( "mac_address.to_s" ) { should == "52:54:00:a8:ad:8c" }
|
35
|
+
its( :to_s ) { should == "SetEthDstAddr: mac_address=52:54:00:a8:ad:8c" }
|
36
|
+
end
|
44
37
|
|
45
|
-
context "
|
38
|
+
context "with mac_address (0x525400a8ad8c)" do
|
46
39
|
let( :mac_address ) { 0x525400a8ad8c }
|
47
|
-
its(
|
40
|
+
its( "mac_address.to_s" ) { should == "52:54:00:a8:ad:8c" }
|
41
|
+
its( :to_s ) { should == "SetEthDstAddr: mac_address=52:54:00:a8:ad:8c" }
|
48
42
|
end
|
49
43
|
|
50
|
-
|
51
|
-
|
44
|
+
context %q{with invalid mac_address ("INVALID MAC STRING")} do
|
45
|
+
let( :mac_address ) { "INVALID MAC STRING" }
|
46
|
+
it { expect { subject }.to raise_error( ArgumentError ) }
|
47
|
+
end
|
52
48
|
|
49
|
+
context "with invalid mac_address ([1, 2, 3])" do
|
50
|
+
let( :mac_address ) { [ 1, 2, 3 ] }
|
51
|
+
it { expect { subject }.to raise_error( TypeError ) }
|
52
|
+
end
|
53
53
|
|
54
|
-
|
55
|
-
it { expect { SetEthDstAddr.new( [ 1, 2, 3 ] ) }.to raise_error( TypeError ) }
|
56
|
-
end
|
54
|
+
it_validates "option range", :mac_address, 0..0xffffffffffff
|
57
55
|
|
56
|
+
context "when sending a Flow Mod with action set to SetEthDstAddr" do
|
57
|
+
let( :mac_address ) { "52:54:00:a8:ad:8c" }
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
it "should have a flow with action set to mod_dl_dst" do
|
62
|
-
class FlowModAddController < Controller; end
|
59
|
+
it "should insert a new flow with action set to mod_dl_dst" do
|
60
|
+
class TestController < Controller; end
|
63
61
|
network {
|
64
62
|
vswitch { datapath_id 0xabc }
|
65
|
-
}.run(
|
66
|
-
controller( "
|
67
|
-
|
68
|
-
:actions => SetEthDstAddr.new( "52:54:00:a8:ad:8c" )
|
69
|
-
)
|
70
|
-
sleep 20 # FIXME: wait to send_flow_mod
|
63
|
+
}.run( TestController ) {
|
64
|
+
controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
|
65
|
+
sleep 2
|
71
66
|
vswitch( "0xabc" ).should have( 1 ).flows
|
72
|
-
vswitch( "0xabc" ).flows[0].actions.should
|
67
|
+
vswitch( "0xabc" ).flows[ 0 ].actions.should == "mod_dl_dst:52:54:00:a8:ad:8c"
|
73
68
|
}
|
74
69
|
end
|
75
70
|
end
|
@@ -20,53 +20,51 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
|
20
20
|
require "trema"
|
21
21
|
|
22
22
|
|
23
|
-
describe SetEthSrcAddr,
|
24
|
-
subject { SetEthSrcAddr.new(
|
25
|
-
its( :mac_address ) { should == Mac.new( "52:54:00:a8:ad:8c" ) }
|
26
|
-
its( :to_s ) { should == "SetEthSrcAddr: mac_address=52:54:00:a8:ad:8c" }
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
describe SetEthSrcAddr, %{.new( Mac.new( "52:54:00:a8:ad:8c" ) )} do
|
31
|
-
subject { SetEthSrcAddr.new( Mac.new( "52:54:00:a8:ad:8c" ) )}
|
32
|
-
its( :mac_address ) { should == Mac.new( "52:54:00:a8:ad:8c" ) }
|
33
|
-
its( :to_s ) { should == "SetEthSrcAddr: mac_address=52:54:00:a8:ad:8c" }
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
describe SetEthSrcAddr, %{.new( "INVALID MAC STRING" )} do
|
38
|
-
it { expect { SetEthSrcAddr.new( "INVALID MAC STRING" ) }.to raise_error( ArgumentError ) }
|
39
|
-
end
|
23
|
+
describe SetEthSrcAddr, ".new( mac_address )", :type => "actions" do
|
24
|
+
subject { SetEthSrcAddr.new( mac_address ) }
|
40
25
|
|
26
|
+
context "with mac_address (52:54:00:a8:ad:8c)" do
|
27
|
+
let( :mac_address ) { "52:54:00:a8:ad:8c" }
|
28
|
+
its( "mac_address.to_s" ) { should == "52:54:00:a8:ad:8c" }
|
29
|
+
its( :to_s ) { should == "SetEthSrcAddr: mac_address=52:54:00:a8:ad:8c" }
|
30
|
+
end
|
41
31
|
|
42
|
-
|
43
|
-
|
32
|
+
context %q{with mac_address (Mac.new("52:54:00:a8:ad:8c"))} do
|
33
|
+
let( :mac_address ) { Mac.new("52:54:00:a8:ad:8c") }
|
34
|
+
its( "mac_address.to_s" ) { should == "52:54:00:a8:ad:8c" }
|
35
|
+
its( :to_s ) { should == "SetEthSrcAddr: mac_address=52:54:00:a8:ad:8c" }
|
36
|
+
end
|
44
37
|
|
45
|
-
context "
|
38
|
+
context "with mac_address (0x525400a8ad8c)" do
|
46
39
|
let( :mac_address ) { 0x525400a8ad8c }
|
47
|
-
its(
|
40
|
+
its( "mac_address.to_s" ) { should == "52:54:00:a8:ad:8c" }
|
41
|
+
its( :to_s ) { should == "SetEthSrcAddr: mac_address=52:54:00:a8:ad:8c" }
|
48
42
|
end
|
49
43
|
|
50
|
-
|
51
|
-
|
44
|
+
context %q{with invalid mac_address ("INVALID MAC STRING")} do
|
45
|
+
let( :mac_address ) { "INVALID MAC STRING" }
|
46
|
+
it { expect { subject }.to raise_error( ArgumentError ) }
|
47
|
+
end
|
52
48
|
|
49
|
+
context "with invalid mac_address ([1, 2, 3])" do
|
50
|
+
let( :mac_address ) { [ 1, 2, 3 ] }
|
51
|
+
it { expect { subject }.to raise_error( TypeError ) }
|
52
|
+
end
|
53
53
|
|
54
|
-
|
55
|
-
it { expect { SetEthSrcAddr.new( [ 1, 2, 3 ] ) }.to raise_error( TypeError ) }
|
56
|
-
end
|
54
|
+
it_validates "option range", :mac_address, 0..0xffffffffffff
|
57
55
|
|
56
|
+
context "when sending a Flow Mod with action set to SetEthSrcAddr" do
|
57
|
+
let( :mac_address ) { "52:54:00:a8:ad:8c" }
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
it "should have a flow with action set to mod_dl_src" do
|
62
|
-
class FlowModAddController < Controller; end
|
59
|
+
it "should insert a new flow with action set to mod_dl_src" do
|
60
|
+
class TestController < Controller; end
|
63
61
|
network {
|
64
62
|
vswitch { datapath_id 0xabc }
|
65
|
-
}.run(
|
66
|
-
controller( "
|
67
|
-
sleep
|
63
|
+
}.run( TestController ) {
|
64
|
+
controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
|
65
|
+
sleep 2
|
68
66
|
vswitch( "0xabc" ).should have( 1 ).flows
|
69
|
-
vswitch( "0xabc" ).flows[0].actions.should
|
67
|
+
vswitch( "0xabc" ).flows[ 0 ].actions.should == "mod_dl_src:52:54:00:a8:ad:8c"
|
70
68
|
}
|
71
69
|
end
|
72
70
|
end
|
data/src/lib/openflow_message.c
CHANGED
@@ -2565,7 +2565,7 @@ validate_desc_stats_reply( const buffer *message ) {
|
|
2565
2565
|
assert( message != NULL );
|
2566
2566
|
|
2567
2567
|
ret = validate_header( message, OFPT_STATS_REPLY,
|
2568
|
-
offsetof( struct ofp_stats_reply, body )
|
2568
|
+
offsetof( struct ofp_stats_reply, body ),
|
2569
2569
|
offsetof( struct ofp_stats_reply, body ) + sizeof( struct ofp_desc_stats ) );
|
2570
2570
|
if ( ret < 0 ) {
|
2571
2571
|
return ret;
|
@@ -2662,7 +2662,7 @@ validate_aggregate_stats_reply( const buffer *message ) {
|
|
2662
2662
|
assert( message != NULL );
|
2663
2663
|
|
2664
2664
|
ret = validate_header( message, OFPT_STATS_REPLY,
|
2665
|
-
offsetof( struct ofp_stats_reply, body )
|
2665
|
+
offsetof( struct ofp_stats_reply, body ),
|
2666
2666
|
offsetof( struct ofp_stats_reply, body ) + sizeof( struct ofp_aggregate_stats_reply ) );
|
2667
2667
|
if ( ret < 0 ) {
|
2668
2668
|
return ret;
|
@@ -2697,7 +2697,7 @@ validate_table_stats_reply( const buffer *message ) {
|
|
2697
2697
|
assert( message != NULL );
|
2698
2698
|
|
2699
2699
|
ret = validate_header( message, OFPT_STATS_REPLY,
|
2700
|
-
offsetof( struct ofp_stats_reply, body )
|
2700
|
+
offsetof( struct ofp_stats_reply, body ),
|
2701
2701
|
UINT16_MAX );
|
2702
2702
|
if ( ret < 0 ) {
|
2703
2703
|
return ret;
|
@@ -2863,7 +2863,7 @@ validate_vendor_stats_reply( const buffer *message ) {
|
|
2863
2863
|
assert( message != NULL );
|
2864
2864
|
|
2865
2865
|
ret = validate_header( message, OFPT_STATS_REPLY,
|
2866
|
-
offsetof( struct ofp_stats_reply, body )
|
2866
|
+
offsetof( struct ofp_stats_reply, body ),
|
2867
2867
|
UINT16_MAX );
|
2868
2868
|
if ( ret < 0 ) {
|
2869
2869
|
return ret;
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Yasuhito Takamiya
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: .
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-01-
|
18
|
+
date: 2013-01-17 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
prerelease: false
|
@@ -101,7 +101,6 @@ extra_rdoc_files:
|
|
101
101
|
- README.md
|
102
102
|
files:
|
103
103
|
- .gitignore
|
104
|
-
- .gitmodules
|
105
104
|
- .mono.rant
|
106
105
|
- .travis.yml
|
107
106
|
- .yardopts
|
@@ -149,9 +148,6 @@ files:
|
|
149
148
|
- features/trema.show_stats.feature
|
150
149
|
- features/trema.up.feature
|
151
150
|
- features/trema.version.feature
|
152
|
-
- locale/README.ja.md
|
153
|
-
- locale/ja/yard.po
|
154
|
-
- locale/yard.pot
|
155
151
|
- ruby/.gitignore
|
156
152
|
- ruby/blocker.rb
|
157
153
|
- ruby/extconf.rb
|
data/.gitmodules
DELETED
data/locale/README.ja.md
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
YARD の翻訳作業の進めかた
|
2
|
-
====================
|
3
|
-
|
4
|
-
翻訳は gettext + YARD の仕組みを使っています。基本的にすべて rake コマンドだけでできます。
|
5
|
-
|
6
|
-
1. YARD で .rb と .c のコメントを書く
|
7
|
-
2. rake yard:po で locale/ja/yard.po を更新
|
8
|
-
3. locale/ja/yard.po に日本語訳を書く。Emacs だと po-mode が便利。
|
9
|
-
4. rake yard:ja で日本語対応した html が [trema]/doc に生成される
|
10
|
-
5. html に間違いが無いことを確認したあと、更新した .po などを git commit
|
11
|
-
|
12
|
-
つぎのことをこころがけてください。
|
13
|
-
|
14
|
-
1. 生成物はそのまま公開されます。わかりやすく書こう (訳語の統一、むずかしい言葉を使わない、など)
|
15
|
-
2. 元の英語ドキュメントが足りない場合には、英語のほうを書き足してから翻訳しよう。Floodlight や OpenFaucet のドキュメントが参考になると思います
|
16
|
-
3. できれば spec/ のテストと見比べて、ドキュメントに書いてあることがテストされていなければ書き足そう
|
17
|
-
|
18
|
-
すべてを最初から完璧にする必要は無いです。
|
19
|
-
あとまわしにした箇所は TODO コメントを残す、チケットを切る等々、後で見てわかるように進めてください!
|