trema 0.3.5 → 0.3.6
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/Gemfile +1 -0
- data/Rakefile +9 -0
- data/Rantfile +0 -2
- data/bin/trema +8 -0
- data/features/.nav +34 -0
- data/features/README.md +7 -0
- data/features/{packetin_filter.feature → core/packetin_filter.feature} +0 -0
- data/features/{switch_manager.feature → core/switch_manager.feature} +0 -0
- data/features/{trema-config.feature → core/trema-config.feature} +0 -0
- data/features/{example.dumper.feature → examples/dumper.feature} +0 -0
- data/features/examples/hello_trema.feature +23 -0
- data/features/{example.learning_switch.feature → examples/learning_switch.feature} +0 -0
- data/features/{example.list_switches.feature → examples/list_switches.feature} +0 -0
- data/features/{example.message.set_config.feature → examples/message.set_config.feature} +0 -0
- data/features/{example.message.vendor-action.feature → examples/message.vendor-action.feature} +0 -0
- data/features/{example.multi_learning_switch.feature → examples/multi_learning_switch.feature} +0 -0
- data/features/{example.openflow_message.echo.feature → examples/openflow_message.echo.feature} +0 -0
- data/features/{example.openflow_message.features_request.feature → examples/openflow_message.features_request.feature} +0 -0
- data/features/{example.openflow_message.hello.feature → examples/openflow_message.hello.feature} +0 -0
- data/features/{example.packet_in.feature → examples/packet_in.feature} +0 -0
- data/features/{example.packetin_filter_config.feature → examples/packetin_filter_config.feature} +0 -0
- data/features/{example.patch_panel.feature → examples/patch_panel.feature} +0 -0
- data/features/{example.repeater_hub.feature → examples/repeater_hub.feature} +0 -0
- data/features/{example.switch_info.feature → examples/switch_info.feature} +0 -0
- data/features/{example.switch_monitor.feature → examples/switch_monitor.feature} +0 -0
- data/features/step_definitions/misc_steps.rb +10 -0
- data/features/trema_commands/README.md +8 -0
- data/features/{trema.dump_flows.feature → trema_commands/dump_flows.feature} +1 -1
- data/features/{trema.help.feature → trema_commands/help.feature} +1 -1
- data/features/trema_commands/help_option.feature +19 -0
- data/features/{trema.kill.feature → trema_commands/kill.feature} +1 -1
- data/features/{trema.killall.feature → trema_commands/killall.feature} +1 -1
- data/features/{trema.reset_stats.feature → trema_commands/reset_stats.feature} +1 -1
- data/features/{trema.run.feature → trema_commands/run.feature} +1 -1
- data/features/{trema.send_packets.feature → trema_commands/send_packets.feature} +1 -1
- data/features/{trema.show_stats.feature → trema_commands/show_stats.feature} +1 -1
- data/features/{trema.up.feature → trema_commands/up.feature} +1 -1
- data/features/{trema.version.feature → trema_commands/version.feature} +1 -1
- data/features/trema_commands/version_option.feature +7 -0
- data/ruby/trema/set-ip-addr.rb +5 -0
- data/ruby/trema/set-ip-dst-addr.rb +2 -3
- data/ruby/trema/set-ip-src-addr.rb +2 -3
- data/ruby/trema/version.rb +1 -1
- data/spec/trema/set-ip-addr_spec.rb +81 -0
- data/src/examples/hello_trema/.gitignore +2 -0
- data/src/examples/hello_trema/README.md +2 -0
- data/src/examples/hello_trema/hello-trema.rb +0 -1
- data/src/examples/hello_trema/hello_trema.c +0 -1
- data/src/examples/hello_trema/sample.conf +1 -0
- data/src/lib/linked_list.c +0 -3
- data/trema.gemspec +1 -1
- data/unittests/lib/linked_list_test.c +13 -0
- metadata +45 -40
- data/features/example.hello_trema.feature +0 -21
- data/spec/trema/set-ip-dst-addr_spec.rb +0 -63
- data/spec/trema/set-ip-src-addr_spec.rb +0 -63
- data/src/examples/hello_trema/README +0 -13
- data/src/examples/hello_trema/hello_trema.conf +0 -3
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -43,6 +43,15 @@ rescue LoadError
|
|
43
43
|
end
|
44
44
|
|
45
45
|
|
46
|
+
################################################################################
|
47
|
+
# Relish
|
48
|
+
################################################################################
|
49
|
+
|
50
|
+
task :relish do
|
51
|
+
sh "relish push trema/trema"
|
52
|
+
end
|
53
|
+
|
54
|
+
|
46
55
|
################################################################################
|
47
56
|
# Tests
|
48
57
|
################################################################################
|
data/Rantfile
CHANGED
@@ -54,7 +54,6 @@ task :default => [
|
|
54
54
|
task :examples => [
|
55
55
|
"examples:cbench_switch",
|
56
56
|
"examples:dumper",
|
57
|
-
"examples:hello_trema",
|
58
57
|
"examples:learning_switch",
|
59
58
|
"examples:list_switches",
|
60
59
|
"examples:multi_learning_switch",
|
@@ -645,7 +644,6 @@ end
|
|
645
644
|
standalone_examples = [
|
646
645
|
"cbench_switch",
|
647
646
|
"dumper",
|
648
|
-
"hello_trema",
|
649
647
|
"learning_switch",
|
650
648
|
"list_switches",
|
651
649
|
"multi_learning_switch",
|
data/bin/trema
CHANGED
@@ -213,9 +213,17 @@ command :version do | c |
|
|
213
213
|
end
|
214
214
|
|
215
215
|
|
216
|
+
GLI::Commands::Help.skips_pre = false
|
217
|
+
|
218
|
+
|
216
219
|
pre do | global, command, options, args |
|
217
220
|
$verbose = global[ :verbose ]
|
218
221
|
|
222
|
+
if global[ :version ]
|
223
|
+
trema_version
|
224
|
+
exit_now! nil, 0
|
225
|
+
end
|
226
|
+
|
219
227
|
assert_trema_is_built
|
220
228
|
|
221
229
|
if FileTest.exist?( Trema.tmp ) and not FileTest.writable?( Trema.tmp )
|
data/features/.nav
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
- trema_commands:
|
2
|
+
- version_option.feature
|
3
|
+
- help_option.feature
|
4
|
+
- run.feature
|
5
|
+
- kill.feature
|
6
|
+
- up.feature
|
7
|
+
- killall.feature
|
8
|
+
- send_packets.feature
|
9
|
+
- show_stats.feature
|
10
|
+
- reset_stats.feature
|
11
|
+
- dump_flows.feature
|
12
|
+
- version.feature
|
13
|
+
- help.feature
|
14
|
+
- examples:
|
15
|
+
- hello_trema.feature
|
16
|
+
- list_switches.feature
|
17
|
+
- switch_monitor.feature
|
18
|
+
- switch_info.feature
|
19
|
+
- patch_panel.feature
|
20
|
+
- packet_in.feature
|
21
|
+
- dumper.feature
|
22
|
+
- repeater_hub.feature
|
23
|
+
- learning_switch.feature
|
24
|
+
- multi_learning_switch.feature
|
25
|
+
- openflow_message.hello.feature
|
26
|
+
- openflow_message.echo.feature
|
27
|
+
- openflow_message.features_request.feature
|
28
|
+
- message.set_config.feature
|
29
|
+
- message.vendor-action.feature
|
30
|
+
- packetin_filter_config.feature
|
31
|
+
- core:
|
32
|
+
- switch_manager.feature
|
33
|
+
- packetin_filter.feature
|
34
|
+
- trema-config.feature
|
data/features/README.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
## Issues
|
2
|
+
|
3
|
+
This documentation is
|
4
|
+
[open source](https://github.com/trema/trema/tree/develop/features),
|
5
|
+
and a work in progress. If you find it incomplete or confusing, please
|
6
|
+
[submit an isssue](https://github.com/trema/trema/issues), or, better
|
7
|
+
yet, [a pull request](https://github.com/trema/trema/pulls).
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Feature: "Hello Trema!" example
|
2
|
+
|
3
|
+
The "Hello Trema!" example ([trema]/src/examples/hello_trema/) is one
|
4
|
+
of the simplest OpenFlow controller implementation. The basic
|
5
|
+
functionality of this controller is to establish a secure channel connection
|
6
|
+
with an OpenFlow switch and output the "Hello [switch's dpid]!" message.
|
7
|
+
|
8
|
+
This demonstrates a minimum template for Trema applications written in Ruby
|
9
|
+
or C. Hence it's a good starting point to learn about Trema programming.
|
10
|
+
|
11
|
+
Background:
|
12
|
+
Given I cd to "../../src/examples/hello_trema/"
|
13
|
+
|
14
|
+
@slow_process
|
15
|
+
Scenario: Run the Ruby example
|
16
|
+
When I run `trema run ./hello-trema.rb -c sample.conf` interactively
|
17
|
+
Then the output should contain "Hello 0xabc!" within the timeout period
|
18
|
+
|
19
|
+
@slow_process
|
20
|
+
Scenario: Run the C example
|
21
|
+
Given I compile "hello_trema.c" into "hello_trema"
|
22
|
+
When I run `trema run ./hello_trema -c sample.conf` interactively
|
23
|
+
Then the output should contain "Hello 0xabc!" within the timeout period
|
File without changes
|
File without changes
|
File without changes
|
data/features/{example.message.vendor-action.feature → examples/message.vendor-action.feature}
RENAMED
File without changes
|
data/features/{example.multi_learning_switch.feature → examples/multi_learning_switch.feature}
RENAMED
File without changes
|
data/features/{example.openflow_message.echo.feature → examples/openflow_message.echo.feature}
RENAMED
File without changes
|
File without changes
|
data/features/{example.openflow_message.hello.feature → examples/openflow_message.hello.feature}
RENAMED
File without changes
|
File without changes
|
data/features/{example.packetin_filter_config.feature → examples/packetin_filter_config.feature}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -16,6 +16,11 @@
|
|
16
16
|
#
|
17
17
|
|
18
18
|
|
19
|
+
Given /^I compile "(.*?)" into "(.*?)"$/ do | c_source, executable |
|
20
|
+
run_simple "gcc #{ c_source } #{`trema-config -c -l`} -o #{ executable }", true
|
21
|
+
end
|
22
|
+
|
23
|
+
|
19
24
|
When /^\*\*\* sleep (\d+) \*\*\*$/ do | sec |
|
20
25
|
sleep sec.to_i
|
21
26
|
end
|
@@ -34,6 +39,11 @@ When /^wait until "([^"]*)" is up$/ do | process |
|
|
34
39
|
end
|
35
40
|
|
36
41
|
|
42
|
+
Then /^the output should contain "(.*?)" within the timeout period$/ do | expected |
|
43
|
+
step %{I wait for output to contain "#{ expected }"}
|
44
|
+
end
|
45
|
+
|
46
|
+
|
37
47
|
Then /^([^\s]*) is terminated$/ do | name |
|
38
48
|
ps_entry_of( name ).should be_empty
|
39
49
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: --help option
|
2
|
+
|
3
|
+
Use the --help option or just type trema to display the usage of trema command.
|
4
|
+
|
5
|
+
Scenario: trema --help
|
6
|
+
When I run `trema --help`
|
7
|
+
Then the output should match /^NAME/
|
8
|
+
And the output should match /^SYNOPSIS/
|
9
|
+
And the output should match /^VERSION/
|
10
|
+
And the output should match /^GLOBAL OPTIONS/
|
11
|
+
And the output should match /^COMMANDS/
|
12
|
+
|
13
|
+
Scenario: trema
|
14
|
+
When I run `trema`
|
15
|
+
Then the output should match /^NAME/
|
16
|
+
And the output should match /^SYNOPSIS/
|
17
|
+
And the output should match /^VERSION/
|
18
|
+
And the output should match /^GLOBAL OPTIONS/
|
19
|
+
And the output should match /^COMMANDS/
|
data/ruby/trema/set-ip-addr.rb
CHANGED
@@ -28,6 +28,8 @@ module Trema
|
|
28
28
|
# Creates an action to modify the IPv4 destination address of a
|
29
29
|
# packet.
|
30
30
|
#
|
31
|
+
# @overload initialize(ip_address)
|
32
|
+
#
|
31
33
|
# @example
|
32
34
|
# SetIpDstAddr.new("192.168.1.1")
|
33
35
|
#
|
@@ -37,9 +39,6 @@ module Trema
|
|
37
39
|
# @raise [ArgumentError] if ip_address is an invalid IPv4 address.
|
38
40
|
# @raise [TypeError] if ip_address is not a String.
|
39
41
|
#
|
40
|
-
def initialize ip_address
|
41
|
-
super ip_address
|
42
|
-
end
|
43
42
|
end
|
44
43
|
|
45
44
|
|
@@ -27,6 +27,8 @@ module Trema
|
|
27
27
|
#
|
28
28
|
# Creates an action to modify the IPv4 source address of a packet.
|
29
29
|
#
|
30
|
+
# @overload initialize(ip_address)
|
31
|
+
#
|
30
32
|
# @example
|
31
33
|
# SetIpSrcAddr.new("192.168.1.1")
|
32
34
|
#
|
@@ -36,9 +38,6 @@ module Trema
|
|
36
38
|
# @raise [ArgumentError] if ip_address is an invalid IPv4 address.
|
37
39
|
# @raise [TypeError] if ip_address is not a String.
|
38
40
|
#
|
39
|
-
def initialize ip_address
|
40
|
-
super ip_address
|
41
|
-
end
|
42
41
|
end
|
43
42
|
|
44
43
|
|
data/ruby/trema/version.rb
CHANGED
@@ -0,0 +1,81 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2008-2012 NEC Corporation
|
3
|
+
#
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License, version 2, as
|
6
|
+
# published by the Free Software Foundation.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
+
#
|
17
|
+
|
18
|
+
|
19
|
+
require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
20
|
+
require "trema"
|
21
|
+
|
22
|
+
|
23
|
+
[ SetIpSrcAddr, SetIpDstAddr ].each do | klass |
|
24
|
+
describe klass, "#new(ip_address)", :type => "actions" do
|
25
|
+
subject { klass.new( ip_address ) }
|
26
|
+
|
27
|
+
|
28
|
+
context %{with ip_address ("192.168.1.1")} do
|
29
|
+
let( :ip_address ) { "192.168.1.1" }
|
30
|
+
|
31
|
+
its( "ip_address.to_s" ) { should == "192.168.1.1" }
|
32
|
+
its( :to_s ) { should eq( "#{ klass.to_s }: ip_address=192.168.1.1" ) }
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
context %{with ip_address ("192.168.1.10")} do
|
37
|
+
let( :ip_address ) { "192.168.1.10" }
|
38
|
+
|
39
|
+
context "when set as FlowMod's action", :sudo => true do
|
40
|
+
it "should insert a new flow entry with action (mod_nw_{src,dst}:192.168.1.10)" do
|
41
|
+
class TestController < Controller; end
|
42
|
+
network {
|
43
|
+
vswitch { datapath_id 0xabc }
|
44
|
+
}.run( TestController ) {
|
45
|
+
controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
|
46
|
+
sleep 2
|
47
|
+
expect( vswitch( "0xabc" ) ).to have( 1 ).flows
|
48
|
+
expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to match( /mod_nw_(src|dst):192.168.1.10/ )
|
49
|
+
pending( "Test actions as an object using Trema::Switch" ) do
|
50
|
+
expect( vswitch( "0xabc" ) ).to have( 1 ).flows
|
51
|
+
expect( vswitch( "0xabc" ).flows[ 0 ] ).to have( 1 ).actions
|
52
|
+
expect( vswitch( "0xabc" ).flows[ 0 ].actions[ 0 ] ).to be_a( klass )
|
53
|
+
expect( vswitch( "0xabc" ).flows[ 0 ].actions[ 0 ].ip_address.to_s ).to eq( "192.168.1.10" )
|
54
|
+
end
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
context %{with invalid ip_address ("1000.1000.1000.1000")} do
|
62
|
+
let( :ip_address ) { "1000.1000.1000.1000" }
|
63
|
+
|
64
|
+
it { expect { subject }.to raise_error( ArgumentError ) }
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
context "with invalid ip_address ([1, 2, 3])" do
|
69
|
+
let( :ip_address ) { [ 1, 2, 3 ] }
|
70
|
+
|
71
|
+
it { expect { subject }.to raise_error( TypeError ) }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
### Local variables:
|
78
|
+
### mode: Ruby
|
79
|
+
### coding: utf-8-unix
|
80
|
+
### indent-tabs-mode: nil
|
81
|
+
### End:
|
@@ -0,0 +1 @@
|
|
1
|
+
vswitch { datapath_id "0xabc" }
|
data/src/lib/linked_list.c
CHANGED
@@ -145,9 +145,6 @@ list_length_of( const list_element *head ) {
|
|
145
145
|
*/
|
146
146
|
void
|
147
147
|
iterate_list( list_element *head, void function( void *data, void *user_data ), void *user_data ) {
|
148
|
-
if ( head == NULL ) {
|
149
|
-
die( "head must not be NULL" );
|
150
|
-
}
|
151
148
|
if ( function != NULL ) {
|
152
149
|
for ( list_element *e = head; e != NULL; e = e->next ) {
|
153
150
|
function( e->data, user_data );
|
data/trema.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do | s |
|
|
22
22
|
# specify any dependencies here; for example:
|
23
23
|
# s.add_development_dependency "rspec"
|
24
24
|
s.add_runtime_dependency "rake"
|
25
|
-
s.add_runtime_dependency "gli", "~> 2.5.
|
25
|
+
s.add_runtime_dependency "gli", "~> 2.5.4"
|
26
26
|
s.add_runtime_dependency "rdoc", "~> 3.12"
|
27
27
|
|
28
28
|
s.add_development_dependency "rake"
|
@@ -303,6 +303,18 @@ test_iterate_list() {
|
|
303
303
|
}
|
304
304
|
|
305
305
|
|
306
|
+
static void
|
307
|
+
test_iterate_list_on_empty_list() {
|
308
|
+
create_list( &new_list );
|
309
|
+
|
310
|
+
size_t sum_length = 0;
|
311
|
+
iterate_list( new_list, get_sum_length, &sum_length );
|
312
|
+
assert_int_equal( 0, sum_length );
|
313
|
+
|
314
|
+
delete_list( new_list );
|
315
|
+
}
|
316
|
+
|
317
|
+
|
306
318
|
static bool
|
307
319
|
find_bravo( void *data, void *user_data ) {
|
308
320
|
UNUSED( user_data );
|
@@ -403,6 +415,7 @@ main() {
|
|
403
415
|
unit_test( test_list_length_of_empty_list ),
|
404
416
|
|
405
417
|
unit_test( test_iterate_list ),
|
418
|
+
unit_test( test_iterate_list_on_empty_list ),
|
406
419
|
unit_test( test_find_list_custom ),
|
407
420
|
unit_test( test_find_list_custom_fail ),
|
408
421
|
|
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: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 6
|
10
|
+
version: 0.3.6
|
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-
|
18
|
+
date: 2013-02-03 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
prerelease: false
|
@@ -39,12 +39,12 @@ dependencies:
|
|
39
39
|
requirements:
|
40
40
|
- - ~>
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
hash:
|
42
|
+
hash: 19
|
43
43
|
segments:
|
44
44
|
- 2
|
45
45
|
- 5
|
46
|
-
-
|
47
|
-
version: 2.5.
|
46
|
+
- 4
|
47
|
+
version: 2.5.4
|
48
48
|
requirement: *id002
|
49
49
|
type: :runtime
|
50
50
|
- !ruby/object:Gem::Dependency
|
@@ -129,40 +129,45 @@ files:
|
|
129
129
|
- bin/trema-config
|
130
130
|
- build.rb
|
131
131
|
- cruise.rb
|
132
|
-
- features
|
133
|
-
- features/
|
134
|
-
- features/
|
135
|
-
- features/
|
136
|
-
- features/
|
137
|
-
- features/
|
138
|
-
- features/
|
139
|
-
- features/
|
140
|
-
- features/
|
141
|
-
- features/
|
142
|
-
- features/
|
143
|
-
- features/
|
144
|
-
- features/
|
145
|
-
- features/
|
146
|
-
- features/
|
147
|
-
- features/
|
148
|
-
- features/
|
132
|
+
- features/.nav
|
133
|
+
- features/README.md
|
134
|
+
- features/core/packetin_filter.feature
|
135
|
+
- features/core/switch_manager.feature
|
136
|
+
- features/core/trema-config.feature
|
137
|
+
- features/examples/dumper.feature
|
138
|
+
- features/examples/hello_trema.feature
|
139
|
+
- features/examples/learning_switch.feature
|
140
|
+
- features/examples/list_switches.feature
|
141
|
+
- features/examples/message.set_config.feature
|
142
|
+
- features/examples/message.vendor-action.feature
|
143
|
+
- features/examples/multi_learning_switch.feature
|
144
|
+
- features/examples/openflow_message.echo.feature
|
145
|
+
- features/examples/openflow_message.features_request.feature
|
146
|
+
- features/examples/openflow_message.hello.feature
|
147
|
+
- features/examples/packet_in.feature
|
148
|
+
- features/examples/packetin_filter_config.feature
|
149
|
+
- features/examples/patch_panel.feature
|
150
|
+
- features/examples/repeater_hub.feature
|
151
|
+
- features/examples/switch_info.feature
|
152
|
+
- features/examples/switch_monitor.feature
|
149
153
|
- features/step_definitions/misc_steps.rb
|
150
154
|
- features/step_definitions/send_packets_steps.rb
|
151
155
|
- features/step_definitions/stats_steps.rb
|
152
156
|
- features/support/env.rb
|
153
157
|
- features/support/hooks.rb
|
154
|
-
- features/
|
155
|
-
- features/
|
156
|
-
- features/
|
157
|
-
- features/
|
158
|
-
- features/
|
159
|
-
- features/
|
160
|
-
- features/
|
161
|
-
- features/
|
162
|
-
- features/
|
163
|
-
- features/
|
164
|
-
- features/
|
165
|
-
- features/
|
158
|
+
- features/trema_commands/README.md
|
159
|
+
- features/trema_commands/dump_flows.feature
|
160
|
+
- features/trema_commands/help.feature
|
161
|
+
- features/trema_commands/help_option.feature
|
162
|
+
- features/trema_commands/kill.feature
|
163
|
+
- features/trema_commands/killall.feature
|
164
|
+
- features/trema_commands/reset_stats.feature
|
165
|
+
- features/trema_commands/run.feature
|
166
|
+
- features/trema_commands/send_packets.feature
|
167
|
+
- features/trema_commands/show_stats.feature
|
168
|
+
- features/trema_commands/up.feature
|
169
|
+
- features/trema_commands/version.feature
|
170
|
+
- features/trema_commands/version_option.feature
|
166
171
|
- ruby/.gitignore
|
167
172
|
- ruby/blocker.rb
|
168
173
|
- ruby/extconf.rb
|
@@ -396,8 +401,7 @@ files:
|
|
396
401
|
- spec/trema/send-out-port_spec.rb
|
397
402
|
- spec/trema/set-config_spec.rb
|
398
403
|
- spec/trema/set-eth-addr_spec.rb
|
399
|
-
- spec/trema/set-ip-
|
400
|
-
- spec/trema/set-ip-src-addr_spec.rb
|
404
|
+
- spec/trema/set-ip-addr_spec.rb
|
401
405
|
- spec/trema/set-ip-tos_spec.rb
|
402
406
|
- spec/trema/set-transport-dst-port_spec.rb
|
403
407
|
- spec/trema/set-transport-src-port_spec.rb
|
@@ -422,10 +426,11 @@ files:
|
|
422
426
|
- src/examples/dumper/dumper.c
|
423
427
|
- src/examples/dumper/dumper.conf
|
424
428
|
- src/examples/dumper/dumper.rb
|
425
|
-
- src/examples/hello_trema
|
429
|
+
- src/examples/hello_trema/.gitignore
|
430
|
+
- src/examples/hello_trema/README.md
|
426
431
|
- src/examples/hello_trema/hello-trema.rb
|
427
432
|
- src/examples/hello_trema/hello_trema.c
|
428
|
-
- src/examples/hello_trema/
|
433
|
+
- src/examples/hello_trema/sample.conf
|
429
434
|
- src/examples/learning_switch/README
|
430
435
|
- src/examples/learning_switch/fdb.rb
|
431
436
|
- src/examples/learning_switch/learning-switch.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
Feature: "Hello Trema!" sample application
|
2
|
-
|
3
|
-
In order to learn how to write minimum Trema application
|
4
|
-
As a developer using Trema
|
5
|
-
I want to execute "Hello Trema" sample application
|
6
|
-
|
7
|
-
Background:
|
8
|
-
Given a file named "hello.conf" with:
|
9
|
-
"""
|
10
|
-
vswitch { datapath_id "0xabc" }
|
11
|
-
"""
|
12
|
-
|
13
|
-
@slow_process
|
14
|
-
Scenario: Run "Hello Trema!" C example
|
15
|
-
When I run `trema run ../../objects/examples/hello_trema/hello_trema -c hello.conf`
|
16
|
-
Then the output should contain exactly "Hello 0xabc!\n"
|
17
|
-
|
18
|
-
@slow_process
|
19
|
-
Scenario: Run "Hello Trema!" Ruby example
|
20
|
-
When I run `trema run ../../src/examples/hello_trema/hello-trema.rb -c hello.conf`
|
21
|
-
Then the output should contain exactly "Hello 0xabc!\n"
|
@@ -1,63 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (C) 2008-2012 NEC Corporation
|
3
|
-
#
|
4
|
-
# This program is free software; you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU General Public License, version 2, as
|
6
|
-
# published by the Free Software Foundation.
|
7
|
-
#
|
8
|
-
# This program is distributed in the hope that it will be useful,
|
9
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
-
# GNU General Public License for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU General Public License along
|
14
|
-
# with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
-
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
20
|
-
require "trema"
|
21
|
-
|
22
|
-
|
23
|
-
describe SetIpDstAddr, ".new(ip_address)", :type => "actions" do
|
24
|
-
subject { SetIpDstAddr.new( ip_address ) }
|
25
|
-
|
26
|
-
context %{with ip_address ("192.168.1.1")} do
|
27
|
-
let( :ip_address ) { "192.168.1.1" }
|
28
|
-
its( "ip_address.to_s" ) { should == "192.168.1.1" }
|
29
|
-
end
|
30
|
-
|
31
|
-
context %{with invalid ip_address ("192.168.1")} do
|
32
|
-
let( :ip_address ) { "192.168.1" }
|
33
|
-
it { expect { subject }.to raise_error( ArgumentError ) }
|
34
|
-
end
|
35
|
-
|
36
|
-
context "with invalid ip_address ([1, 2, 3])" do
|
37
|
-
let( :ip_address ) { [ 1, 2, 3 ] }
|
38
|
-
it { expect { subject }.to raise_error( TypeError ) }
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when sending a Flow Mod with SetIpDstAddr" do
|
42
|
-
let( :ip_address ) { "192.168.1.1" }
|
43
|
-
|
44
|
-
it "should insert a flow entry with action (mod_nw_dst:192.168.1.1)" do
|
45
|
-
class TestController < Controller; end
|
46
|
-
network {
|
47
|
-
vswitch { datapath_id 0xabc }
|
48
|
-
}.run( TestController ) {
|
49
|
-
controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
|
50
|
-
sleep 2
|
51
|
-
expect( vswitch( "0xabc" ) ).to have( 1 ).flows
|
52
|
-
expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to eq( "mod_nw_dst:192.168.1.1" )
|
53
|
-
}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
### Local variables:
|
60
|
-
### mode: Ruby
|
61
|
-
### coding: utf-8-unix
|
62
|
-
### indent-tabs-mode: nil
|
63
|
-
### End:
|
@@ -1,63 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (C) 2008-2012 NEC Corporation
|
3
|
-
#
|
4
|
-
# This program is free software; you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU General Public License, version 2, as
|
6
|
-
# published by the Free Software Foundation.
|
7
|
-
#
|
8
|
-
# This program is distributed in the hope that it will be useful,
|
9
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
-
# GNU General Public License for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU General Public License along
|
14
|
-
# with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
-
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
20
|
-
require "trema"
|
21
|
-
|
22
|
-
|
23
|
-
describe SetIpSrcAddr, ".new(ip_address)", :type => "actions" do
|
24
|
-
subject { SetIpSrcAddr.new( ip_address ) }
|
25
|
-
|
26
|
-
context %{with ip_address ("192.168.1.1")} do
|
27
|
-
let( :ip_address ) { "192.168.1.1" }
|
28
|
-
its( "ip_address.to_s" ) { should == "192.168.1.1" }
|
29
|
-
end
|
30
|
-
|
31
|
-
context %{with invalid ip_address ("192.168.1")} do
|
32
|
-
let( :ip_address ) { "192.168.1" }
|
33
|
-
it { expect { subject }.to raise_error( ArgumentError ) }
|
34
|
-
end
|
35
|
-
|
36
|
-
context "with invalid ip_address ([1, 2, 3])" do
|
37
|
-
let( :ip_address ) { [ 1, 2, 3 ] }
|
38
|
-
it { expect { subject }.to raise_error( TypeError ) }
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when sending a Flow Mod with SetIpSrcAddr" do
|
42
|
-
let( :ip_address ) { "192.168.1.1" }
|
43
|
-
|
44
|
-
it "should insert a flow entry with action (mod_nw_src:192.168.1.1)" do
|
45
|
-
class TestController < Controller; end
|
46
|
-
network {
|
47
|
-
vswitch { datapath_id 0xabc }
|
48
|
-
}.run( TestController ) {
|
49
|
-
controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
|
50
|
-
sleep 2
|
51
|
-
expect( vswitch( "0xabc" ) ).to have( 1 ).flows
|
52
|
-
expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to eq( "mod_nw_src:192.168.1.1" )
|
53
|
-
}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
### Local variables:
|
60
|
-
### mode: Ruby
|
61
|
-
### coding: utf-8-unix
|
62
|
-
### indent-tabs-mode: nil
|
63
|
-
### End:
|
@@ -1,13 +0,0 @@
|
|
1
|
-
This directory includes minimum examples of Trema controller in C and Ruby.
|
2
|
-
|
3
|
-
|
4
|
-
# How to run (C version)
|
5
|
-
|
6
|
-
% ./trema run ./objects/examples/hello_trema/hello_trema -c src/examples/hello_trema/hello_trema.conf
|
7
|
-
|
8
|
-
# How to run (Ruby version)
|
9
|
-
|
10
|
-
% ./trema run ./src/examples/hello_trema/hello_trema.rb -c src/examples/hello_trema/hello_trema.conf
|
11
|
-
|
12
|
-
|
13
|
-
Enjoy!
|