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.
Files changed (58) hide show
  1. data/Gemfile +1 -0
  2. data/Rakefile +9 -0
  3. data/Rantfile +0 -2
  4. data/bin/trema +8 -0
  5. data/features/.nav +34 -0
  6. data/features/README.md +7 -0
  7. data/features/{packetin_filter.feature → core/packetin_filter.feature} +0 -0
  8. data/features/{switch_manager.feature → core/switch_manager.feature} +0 -0
  9. data/features/{trema-config.feature → core/trema-config.feature} +0 -0
  10. data/features/{example.dumper.feature → examples/dumper.feature} +0 -0
  11. data/features/examples/hello_trema.feature +23 -0
  12. data/features/{example.learning_switch.feature → examples/learning_switch.feature} +0 -0
  13. data/features/{example.list_switches.feature → examples/list_switches.feature} +0 -0
  14. data/features/{example.message.set_config.feature → examples/message.set_config.feature} +0 -0
  15. data/features/{example.message.vendor-action.feature → examples/message.vendor-action.feature} +0 -0
  16. data/features/{example.multi_learning_switch.feature → examples/multi_learning_switch.feature} +0 -0
  17. data/features/{example.openflow_message.echo.feature → examples/openflow_message.echo.feature} +0 -0
  18. data/features/{example.openflow_message.features_request.feature → examples/openflow_message.features_request.feature} +0 -0
  19. data/features/{example.openflow_message.hello.feature → examples/openflow_message.hello.feature} +0 -0
  20. data/features/{example.packet_in.feature → examples/packet_in.feature} +0 -0
  21. data/features/{example.packetin_filter_config.feature → examples/packetin_filter_config.feature} +0 -0
  22. data/features/{example.patch_panel.feature → examples/patch_panel.feature} +0 -0
  23. data/features/{example.repeater_hub.feature → examples/repeater_hub.feature} +0 -0
  24. data/features/{example.switch_info.feature → examples/switch_info.feature} +0 -0
  25. data/features/{example.switch_monitor.feature → examples/switch_monitor.feature} +0 -0
  26. data/features/step_definitions/misc_steps.rb +10 -0
  27. data/features/trema_commands/README.md +8 -0
  28. data/features/{trema.dump_flows.feature → trema_commands/dump_flows.feature} +1 -1
  29. data/features/{trema.help.feature → trema_commands/help.feature} +1 -1
  30. data/features/trema_commands/help_option.feature +19 -0
  31. data/features/{trema.kill.feature → trema_commands/kill.feature} +1 -1
  32. data/features/{trema.killall.feature → trema_commands/killall.feature} +1 -1
  33. data/features/{trema.reset_stats.feature → trema_commands/reset_stats.feature} +1 -1
  34. data/features/{trema.run.feature → trema_commands/run.feature} +1 -1
  35. data/features/{trema.send_packets.feature → trema_commands/send_packets.feature} +1 -1
  36. data/features/{trema.show_stats.feature → trema_commands/show_stats.feature} +1 -1
  37. data/features/{trema.up.feature → trema_commands/up.feature} +1 -1
  38. data/features/{trema.version.feature → trema_commands/version.feature} +1 -1
  39. data/features/trema_commands/version_option.feature +7 -0
  40. data/ruby/trema/set-ip-addr.rb +5 -0
  41. data/ruby/trema/set-ip-dst-addr.rb +2 -3
  42. data/ruby/trema/set-ip-src-addr.rb +2 -3
  43. data/ruby/trema/version.rb +1 -1
  44. data/spec/trema/set-ip-addr_spec.rb +81 -0
  45. data/src/examples/hello_trema/.gitignore +2 -0
  46. data/src/examples/hello_trema/README.md +2 -0
  47. data/src/examples/hello_trema/hello-trema.rb +0 -1
  48. data/src/examples/hello_trema/hello_trema.c +0 -1
  49. data/src/examples/hello_trema/sample.conf +1 -0
  50. data/src/lib/linked_list.c +0 -3
  51. data/trema.gemspec +1 -1
  52. data/unittests/lib/linked_list_test.c +13 -0
  53. metadata +45 -40
  54. data/features/example.hello_trema.feature +0 -21
  55. data/spec/trema/set-ip-dst-addr_spec.rb +0 -63
  56. data/spec/trema/set-ip-src-addr_spec.rb +0 -63
  57. data/src/examples/hello_trema/README +0 -13
  58. data/src/examples/hello_trema/hello_trema.conf +0 -3
data/Gemfile CHANGED
@@ -22,6 +22,7 @@ group :development do
22
22
  gem "rdoc", "~> 3.12"
23
23
  gem "redcarpet", "~> 2.2.2"
24
24
  gem "reek", "~> 1.2.13"
25
+ gem "relish", "~> 0.6"
25
26
  gem "roodi", "~> 2.1.0"
26
27
  gem "rspec", "~> 2.12.0"
27
28
  gem "yard", "~> 0.8.3"
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
@@ -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).
@@ -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
@@ -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,8 @@
1
+ The `trema` command comes with several sub-commands you can use to
2
+ run your own controllers on emulated network envrionments.
3
+
4
+ For a full list of sub-commands, run the `trema` command with no arguments:
5
+
6
+ ```
7
+ $ ./trema
8
+ ```
@@ -1,4 +1,4 @@
1
- Feature: trema dump_flows command
1
+ Feature: dump_flows command
2
2
 
3
3
  In order to inspect all flow entries in a Trema virtual switch
4
4
  As a developer using Trema
@@ -1,4 +1,4 @@
1
- Feature: trema help
1
+ Feature: help command
2
2
 
3
3
  In order to understand how to use Trema
4
4
  As a developer using Trema
@@ -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/
@@ -1,4 +1,4 @@
1
- Feature: trema kill command
1
+ Feature: kill command
2
2
 
3
3
  In order to test event handling or just kill unwanted processes
4
4
  As a developer using Trema
@@ -1,4 +1,4 @@
1
- Feature: trema killall command
1
+ Feature: killall command
2
2
 
3
3
  In order to cleanup the previous trema session
4
4
  As a developer using Trema
@@ -1,4 +1,4 @@
1
- Feature: trema reset_stats command
1
+ Feature: reset_stats command
2
2
 
3
3
  In order to reset the stats of sent/received packets
4
4
  As a developer using Trema
@@ -1,4 +1,4 @@
1
- Feature: trema run command
1
+ Feature: run command
2
2
 
3
3
  In order to launch trema applications
4
4
  As a developer using Trema
@@ -1,4 +1,4 @@
1
- Feature: trema send_packets command
1
+ Feature: send_packets command
2
2
 
3
3
  In order to send/receive packets between virtual hosts
4
4
  As a developer using Trema
@@ -1,4 +1,4 @@
1
- Feature: trema show_stats command
1
+ Feature: show_stats command
2
2
 
3
3
  In order to get the stats of sent/received packets
4
4
  As a developer using Trema
@@ -1,4 +1,4 @@
1
- Feature: trema up command
1
+ Feature: up command
2
2
 
3
3
  In order to restart killed processes
4
4
  As a developer using Trema
@@ -1,4 +1,4 @@
1
- Feature: trema version command
1
+ Feature: version command
2
2
 
3
3
  In order to know the current version of Trema
4
4
  As a developer using Trema
@@ -0,0 +1,7 @@
1
+ Feature: --version option
2
+
3
+ Use the --version option to display the current runtime version.
4
+
5
+ Scenario: trema --version
6
+ When I run `trema --version`
7
+ Then the output should match /trema version \d+\.\d+.\d+/
@@ -38,6 +38,11 @@ module Trema
38
38
  end
39
39
  @ip_address = IPAddr.new( ip_address )
40
40
  end
41
+
42
+
43
+ def to_s
44
+ "#{ self.class.to_s }: ip_address=#{ @ip_address }"
45
+ end
41
46
  end
42
47
  end
43
48
 
@@ -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
 
@@ -17,7 +17,7 @@
17
17
 
18
18
 
19
19
  module Trema
20
- VERSION = "0.3.5"
20
+ VERSION = "0.3.6"
21
21
  end
22
22
 
23
23
 
@@ -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,2 @@
1
+ hello_trema
2
+
@@ -0,0 +1,2 @@
1
+ See https://www.relishapp.com/trema/trema/docs/examples/hello-trema-example
2
+
@@ -19,7 +19,6 @@
19
19
  class HelloTrema < Controller
20
20
  def switch_ready datapath_id
21
21
  info "Hello %#x!" % datapath_id
22
- shutdown!
23
22
  end
24
23
  end
25
24
 
@@ -25,7 +25,6 @@ handle_switch_ready( uint64_t datapath_id, void *user_data ) {
25
25
  UNUSED( user_data );
26
26
 
27
27
  info( "Hello %#" PRIx64 "!", datapath_id );
28
- stop_trema();
29
28
  }
30
29
 
31
30
 
@@ -0,0 +1 @@
1
+ vswitch { datapath_id "0xabc" }
@@ -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.2"
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: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 5
10
- version: 0.3.5
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-01-30 00:00:00 Z
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: 31
42
+ hash: 19
43
43
  segments:
44
44
  - 2
45
45
  - 5
46
- - 2
47
- version: 2.5.2
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/example.dumper.feature
133
- - features/example.hello_trema.feature
134
- - features/example.learning_switch.feature
135
- - features/example.list_switches.feature
136
- - features/example.message.set_config.feature
137
- - features/example.message.vendor-action.feature
138
- - features/example.multi_learning_switch.feature
139
- - features/example.openflow_message.echo.feature
140
- - features/example.openflow_message.features_request.feature
141
- - features/example.openflow_message.hello.feature
142
- - features/example.packet_in.feature
143
- - features/example.packetin_filter_config.feature
144
- - features/example.patch_panel.feature
145
- - features/example.repeater_hub.feature
146
- - features/example.switch_info.feature
147
- - features/example.switch_monitor.feature
148
- - features/packetin_filter.feature
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/switch_manager.feature
155
- - features/trema-config.feature
156
- - features/trema.dump_flows.feature
157
- - features/trema.help.feature
158
- - features/trema.kill.feature
159
- - features/trema.killall.feature
160
- - features/trema.reset_stats.feature
161
- - features/trema.run.feature
162
- - features/trema.send_packets.feature
163
- - features/trema.show_stats.feature
164
- - features/trema.up.feature
165
- - features/trema.version.feature
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-dst-addr_spec.rb
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/README
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/hello_trema.conf
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!
@@ -1,3 +0,0 @@
1
- vswitch {
2
- datapath_id "0xabc"
3
- }