trema 0.4.6 → 0.4.7
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.travis.yml +24 -7
- data/Gemfile +19 -27
- data/Guardfile +6 -0
- data/README.md +13 -5
- data/Rakefile +418 -415
- data/bin/quality +2 -2
- data/bin/trema +103 -105
- data/bin/trema-config +7 -7
- data/build.rb +2 -2
- data/cruise.rb +109 -83
- data/features/dsl/switch_port_specifier.feature +1 -1
- data/features/examples/dumper.feature +9 -41
- data/features/examples/hello_trema.feature +1 -1
- data/features/examples/learning_switch.feature +7 -7
- data/features/examples/list_switches.feature +5 -5
- data/features/examples/message.set_config.feature +11 -11
- data/features/examples/message.vendor-action.feature +7 -7
- data/features/examples/message.vendor-stats-request.feature +1 -1
- data/features/examples/multi_learning_switch.feature +7 -7
- data/features/examples/openflow_message.echo.feature +15 -15
- data/features/examples/openflow_message.features_request.feature +12 -12
- data/features/examples/openflow_message.hello.feature +13 -13
- data/features/examples/packet_in.feature +8 -8
- data/features/examples/patch_panel.feature +1 -1
- data/features/examples/repeater_hub.feature +7 -7
- data/features/examples/switch_info.feature +16 -16
- data/features/examples/switch_monitor.feature +11 -11
- data/features/examples/transparent_firewall.feature +73 -0
- data/features/handlers/switch_ready.feature +1 -1
- data/features/step_definitions/misc_steps.rb +24 -24
- data/features/step_definitions/send_packets_steps.rb +2 -2
- data/features/step_definitions/stats_steps.rb +6 -6
- data/features/support/env.rb +15 -15
- data/features/support/hooks.rb +9 -9
- data/features/switch_event/add_forward_entry.feature +3 -3
- data/features/switch_event/delete_forward_entry.feature +3 -3
- data/features/switch_event/dump_forward_entries.feature +2 -2
- data/features/switch_event/set_forward_entries.feature +2 -2
- data/features/trema_commands/dump_flows.feature +1 -0
- data/features/trema_commands/help.feature +1 -0
- data/features/trema_commands/help_option.feature +1 -0
- data/features/trema_commands/kill.feature +1 -0
- data/features/trema_commands/killall.feature +1 -0
- data/features/trema_commands/port_down.feature +1 -0
- data/features/trema_commands/port_up.feature +1 -0
- data/features/trema_commands/reset_stats.feature +1 -0
- data/features/trema_commands/run.feature +1 -0
- data/features/trema_commands/send_packets.feature +2 -1
- data/features/trema_commands/show_stats.feature +1 -0
- data/features/trema_commands/up.feature +1 -0
- data/features/trema_commands/version.feature +1 -0
- data/features/trema_commands/version_option.feature +1 -0
- data/rubocop-todo.yml +159 -0
- data/ruby/blocker.rb +15 -17
- data/ruby/extconf.rb +19 -19
- data/ruby/sub-process.rb +29 -29
- data/ruby/trema/aggregate-stats-reply.rb +2 -2
- data/ruby/trema/app.rb +13 -13
- data/ruby/trema/cli.rb +45 -45
- data/ruby/trema/command.rb +14 -14
- data/ruby/trema/command/dump_flows.rb +5 -5
- data/ruby/trema/command/kill.rb +13 -13
- data/ruby/trema/command/killall.rb +1 -1
- data/ruby/trema/command/netns.rb +3 -3
- data/ruby/trema/command/port_down.rb +7 -7
- data/ruby/trema/command/port_up.rb +7 -7
- data/ruby/trema/command/reset_stats.rb +6 -6
- data/ruby/trema/command/ruby.rb +2 -2
- data/ruby/trema/command/run.rb +23 -23
- data/ruby/trema/command/send_packets.rb +9 -9
- data/ruby/trema/command/shell.rb +14 -16
- data/ruby/trema/command/show_stats.rb +9 -9
- data/ruby/trema/command/up.rb +4 -4
- data/ruby/trema/command/version.rb +1 -1
- data/ruby/trema/controller.rb +10 -10
- data/ruby/trema/custom-switch.rb +4 -4
- data/ruby/trema/daemon.rb +21 -21
- data/ruby/trema/desc-stats-reply.rb +2 -2
- data/ruby/trema/dsl.rb +5 -5
- data/ruby/trema/dsl/configuration.rb +7 -7
- data/ruby/trema/dsl/context.rb +10 -10
- data/ruby/trema/dsl/custom-switch.rb +3 -3
- data/ruby/trema/dsl/link.rb +2 -2
- data/ruby/trema/dsl/netns.rb +9 -9
- data/ruby/trema/dsl/parser.rb +14 -14
- data/ruby/trema/dsl/rswitch.rb +3 -3
- data/ruby/trema/dsl/run.rb +4 -4
- data/ruby/trema/dsl/runner.rb +20 -20
- data/ruby/trema/dsl/stanza.rb +5 -5
- data/ruby/trema/dsl/switch.rb +14 -14
- data/ruby/trema/dsl/syntax.rb +54 -54
- data/ruby/trema/dsl/vhost.rb +9 -9
- data/ruby/trema/dsl/vswitch.rb +4 -4
- data/ruby/trema/enqueue.rb +11 -11
- data/ruby/trema/exact-match.rb +1 -1
- data/ruby/trema/executables.rb +19 -19
- data/ruby/trema/flow-stats-reply.rb +2 -2
- data/ruby/trema/flow.rb +8 -8
- data/ruby/trema/hardware-switch.rb +2 -2
- data/ruby/trema/host.rb +18 -18
- data/ruby/trema/link.rb +9 -9
- data/ruby/trema/mac.rb +1 -5
- data/ruby/trema/match.c +0 -1
- data/ruby/trema/monkey-patch/integer.rb +3 -3
- data/ruby/trema/monkey-patch/integer/base-conversions.rb +1 -1
- data/ruby/trema/monkey-patch/integer/ranges.rb +2 -2
- data/ruby/trema/monkey-patch/integer/validators.rb +1 -1
- data/ruby/trema/monkey-patch/module.rb +2 -2
- data/ruby/trema/monkey-patch/module/class-method.rb +2 -2
- data/ruby/trema/monkey-patch/module/deprecation.rb +1 -1
- data/ruby/trema/monkey-patch/string.rb +1 -1
- data/ruby/trema/monkey-patch/string/inflectors.rb +7 -7
- data/ruby/trema/netns.rb +6 -6
- data/ruby/trema/network-component.rb +7 -7
- data/ruby/trema/ofctl.rb +13 -13
- data/ruby/trema/open-vswitch.rb +25 -25
- data/ruby/trema/openflow-switch.rb +1 -1
- data/ruby/trema/ordered-hash.rb +8 -8
- data/ruby/trema/packet-in.c +0 -1
- data/ruby/trema/packet-queue.rb +8 -8
- data/ruby/trema/packetin-filter.rb +9 -9
- data/ruby/trema/path.rb +32 -32
- data/ruby/trema/phost.rb +5 -5
- data/ruby/trema/port-mod.c +0 -1
- data/ruby/trema/port-stats-reply.rb +2 -2
- data/ruby/trema/port-status-add.rb +2 -2
- data/ruby/trema/port-status-delete.rb +2 -2
- data/ruby/trema/port-status-modify.rb +2 -2
- data/ruby/trema/port.c +0 -1
- data/ruby/trema/process.rb +7 -7
- data/ruby/trema/queue-stats-reply.rb +2 -2
- data/ruby/trema/ruby-switch.rb +6 -6
- data/ruby/trema/send-out-port.rb +11 -11
- data/ruby/trema/set-eth-addr.rb +5 -5
- data/ruby/trema/set-eth-dst-addr.rb +1 -1
- data/ruby/trema/set-eth-src-addr.rb +1 -1
- data/ruby/trema/set-ip-addr.rb +6 -6
- data/ruby/trema/set-ip-dst-addr.rb +1 -1
- data/ruby/trema/set-ip-src-addr.rb +1 -1
- data/ruby/trema/set-ip-tos.rb +6 -6
- data/ruby/trema/set-transport-dst-port.rb +2 -2
- data/ruby/trema/set-transport-port.rb +7 -7
- data/ruby/trema/set-transport-src-port.rb +3 -3
- data/ruby/trema/set-vlan-priority.rb +6 -6
- data/ruby/trema/set-vlan-vid.rb +6 -6
- data/ruby/trema/shell.rb +10 -10
- data/ruby/trema/shell/down.rb +3 -3
- data/ruby/trema/shell/killall.rb +1 -1
- data/ruby/trema/shell/link.rb +14 -14
- data/ruby/trema/shell/reset_stats.rb +6 -6
- data/ruby/trema/shell/run.rb +7 -7
- data/ruby/trema/shell/send_packets.rb +3 -3
- data/ruby/trema/shell/show_stats.rb +7 -7
- data/ruby/trema/shell/up.rb +5 -5
- data/ruby/trema/shell/vhost.rb +4 -4
- data/ruby/trema/shell/vswitch.rb +7 -7
- data/ruby/trema/stats-helper.rb +3 -3
- data/ruby/trema/stats-reply.c +0 -1
- data/ruby/trema/strip-vlan-header.rb +1 -1
- data/ruby/trema/switch-daemon.rb +9 -9
- data/ruby/trema/switch-manager.rb +9 -9
- data/ruby/trema/switch.rb +7 -7
- data/ruby/trema/table-stats-reply.rb +2 -2
- data/ruby/trema/timers.rb +12 -12
- data/ruby/trema/trema.c +0 -1
- data/ruby/trema/tremashark.rb +1 -1
- data/ruby/trema/util.rb +25 -27
- data/ruby/trema/vendor-action.rb +10 -10
- data/ruby/trema/vendor-stats-reply.rb +2 -2
- data/ruby/trema/version.rb +1 -1
- data/spec/spec_helper.rb +50 -52
- data/spec/support/action.rb +9 -12
- data/spec/support/mandatory-option.rb +15 -18
- data/spec/support/matchers/constant.rb +7 -7
- data/spec/support/openflow-message.rb +76 -79
- data/spec/support/port-status.rb +7 -10
- data/spec/trema/app_spec.rb +27 -27
- data/spec/trema/barrier-reply_spec.rb +10 -10
- data/spec/trema/barrier-request_spec.rb +35 -35
- data/spec/trema/cli_spec.rb +63 -63
- data/spec/trema/controller_spec.rb +3 -3
- data/spec/trema/default-logger_spec.rb +4 -4
- data/spec/trema/dsl/configuration_spec.rb +47 -47
- data/spec/trema/dsl/link_spec.rb +11 -11
- data/spec/trema/dsl/run_spec.rb +19 -19
- data/spec/trema/dsl/runner_spec.rb +91 -91
- data/spec/trema/dsl/switch_spec.rb +16 -16
- data/spec/trema/dsl/syntax_spec.rb +22 -22
- data/spec/trema/dsl/vhost_spec.rb +37 -37
- data/spec/trema/dsl/vswitch_spec.rb +21 -21
- data/spec/trema/echo-reply_spec.rb +29 -29
- data/spec/trema/echo-request_spec.rb +54 -54
- data/spec/trema/enqueue_spec.rb +25 -25
- data/spec/trema/error_spec.rb +30 -30
- data/spec/trema/executables_spec.rb +20 -20
- data/spec/trema/features-reply_spec.rb +41 -41
- data/spec/trema/features-request_spec.rb +35 -35
- data/spec/trema/flow-mod_spec.rb +32 -32
- data/spec/trema/flow-removed_spec.rb +62 -62
- data/spec/trema/get-config-reply_spec.rb +14 -12
- data/spec/trema/get-config-request_spec.rb +35 -35
- data/spec/trema/hardware-switch_spec.rb +12 -12
- data/spec/trema/hello_spec.rb +17 -17
- data/spec/trema/host_spec.rb +71 -71
- data/spec/trema/link_spec.rb +13 -13
- data/spec/trema/list-switches-reply_spec.rb +10 -10
- data/spec/trema/match_spec.rb +41 -41
- data/spec/trema/open-vswitch_spec.rb +45 -45
- data/spec/trema/openflow-error_spec.rb +67 -65
- data/spec/trema/packet-in_spec.rb +450 -446
- data/spec/trema/packet-out_spec.rb +42 -42
- data/spec/trema/packetin-filter_spec.rb +5 -5
- data/spec/trema/port-mod_spec.rb +32 -32
- data/spec/trema/port-status-add_spec.rb +3 -3
- data/spec/trema/port-status-delete_spec.rb +3 -3
- data/spec/trema/port-status-modify_spec.rb +16 -16
- data/spec/trema/port-status_spec.rb +2 -2
- data/spec/trema/port_spec.rb +21 -21
- data/spec/trema/process_spec.rb +22 -22
- data/spec/trema/queue-get-config-reply_spec.rb +21 -20
- data/spec/trema/queue-get-config-request_spec.rb +24 -24
- data/spec/trema/send-out-port_spec.rb +42 -42
- data/spec/trema/set-config_spec.rb +31 -31
- data/spec/trema/set-eth-addr_spec.rb +21 -21
- data/spec/trema/set-ip-addr_spec.rb +29 -29
- data/spec/trema/set-ip-tos_spec.rb +26 -26
- data/spec/trema/set-transport-dst-port_spec.rb +22 -22
- data/spec/trema/set-transport-src-port_spec.rb +22 -22
- data/spec/trema/set-vlan-priority_spec.rb +23 -23
- data/spec/trema/set-vlan-vid_spec.rb +23 -23
- data/spec/trema/shell/vhost_spec.rb +21 -21
- data/spec/trema/shell/vswitch_spec.rb +30 -30
- data/spec/trema/stats-reply_spec.rb +183 -173
- data/spec/trema/stats-request_spec.rb +66 -66
- data/spec/trema/strip-vlan-header_spec.rb +11 -11
- data/spec/trema/switch-daemon_spec.rb +34 -34
- data/spec/trema/switch-disconnected_spec.rb +17 -17
- data/spec/trema/switch-manager_spec.rb +6 -6
- data/spec/trema/tremashark_spec.rb +4 -4
- data/spec/trema/util_spec.rb +35 -35
- data/spec/trema/vendor-action_spec.rb +26 -26
- data/spec/trema/vendor_spec.rb +27 -27
- data/spec/trema_spec.rb +2 -2
- data/src/examples/cbench_switch/cbench-switch.rb +3 -3
- data/src/examples/dumper/dumper.rb +31 -31
- data/src/examples/hello_trema/hello-trema.rb +2 -2
- data/src/examples/learning_switch/fdb.rb +14 -14
- data/src/examples/learning_switch/learning-switch.rb +12 -10
- data/src/examples/learning_switch/learning_switch.c +22 -39
- data/src/examples/list_switches/list-switches.rb +3 -3
- data/src/examples/match_compare/match-compare.rb +20 -20
- data/src/examples/multi_learning_switch/multi-learning-switch.rb +12 -12
- data/src/examples/openflow_message/echo.rb +4 -4
- data/src/examples/openflow_message/example.rb +7 -7
- data/src/examples/openflow_message/features-request.rb +31 -31
- data/src/examples/openflow_message/hello.rb +2 -2
- data/src/examples/openflow_message/set-config.rb +4 -4
- data/src/examples/openflow_message/vendor-action.rb +3 -3
- data/src/examples/openflow_message/vendor-stats-request.rb +9 -9
- data/src/examples/packet_in/packet-in.rb +2 -2
- data/src/examples/patch_panel/patch-panel.rb +9 -9
- data/src/examples/repeater_hub/repeater-hub.rb +4 -4
- data/src/examples/repeater_hub/repeater-hub_spec.rb +65 -65
- data/src/examples/simple_router/arp-table.rb +7 -7
- data/src/examples/simple_router/interface.rb +10 -10
- data/src/examples/simple_router/routing-table.rb +4 -4
- data/src/examples/simple_router/simple-router.rb +3 -3
- data/src/examples/switch_info/switch-info.rb +9 -9
- data/src/examples/switch_monitor/switch-monitor.rb +4 -4
- data/src/examples/traffic_monitor/counter.rb +6 -6
- data/src/examples/traffic_monitor/fdb.rb +4 -4
- data/src/examples/traffic_monitor/traffic-monitor.rb +12 -12
- data/src/examples/transparent_firewall/README.md +61 -0
- data/src/examples/transparent_firewall/aggregated-delegated-afrinic.txt +713 -0
- data/src/examples/transparent_firewall/aggregated-delegated-apnic.txt +3440 -0
- data/src/examples/transparent_firewall/aggregated-delegated-arin.txt +11342 -0
- data/src/examples/transparent_firewall/aggregated-delegated-lacnic.txt +1937 -0
- data/src/examples/transparent_firewall/aggregated-delegated-ripencc.txt +7329 -0
- data/src/examples/transparent_firewall/block-rfc1918.rb +86 -0
- data/src/examples/transparent_firewall/pass-delegated.rb +178 -0
- data/src/examples/transparent_firewall/regen_aggregated.sh +53 -0
- data/src/examples/transparent_firewall/stats-to-cidrs.rb +59 -0
- data/src/lib/messenger.c +14 -5
- data/src/lib/openflow_message.c +0 -5
- data/tasks/rubocop.rake +22 -0
- data/trema +1 -1
- data/trema-config +1 -1
- data/trema.gemspec +22 -22
- metadata +30 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ae1944272fd94df71dde7f37cae09d3adc26caec
|
|
4
|
+
data.tar.gz: 4e93bf7477c418a53cb9bdf2365776ce8e866419
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 908ea883109bb2c7a65b556f9d700634a0668837c1400d1daa849bbdf915ff44896fb6d40ff32516940950448bc4daf0bf8dff213de1eae9b02028812d293aa9
|
|
7
|
+
data.tar.gz: fecf42a4b7599f5b8f9177ffc8625b28faf7cd65650591fb57f08608328f04f641d4cf1ececf51e8422fe418626ddac99c130a01502b1afc741f0195de1a04c6
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
inherit_from: rubocop-todo.yml
|
data/.travis.yml
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
1
1
|
language: ruby
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
before_install:
|
|
4
|
+
- gem update bundler
|
|
5
|
+
- sudo apt-get update -qq
|
|
6
|
+
- sudo apt-get install libpcap-dev -qq
|
|
7
|
+
bundler_args: --without development
|
|
8
|
+
|
|
9
|
+
env:
|
|
10
|
+
global:
|
|
11
|
+
- secure: "roJa3FuYA6gLdV0vtUe1GyuAU2WQ+E+jraT9QeKKHRQSU2TKYgeJ7MmxG3vSpIoZsHEdmrZh0UVTrMO436UHAG5V+qbSmP2gld0vSI2qDQ2dXbNoAIVUHex2oCDTa5OC0sJbz9W8Yrd0XoTY0O5gObPn6QfTzAHKgPz7ZC9bBwo="
|
|
4
12
|
|
|
5
13
|
rvm:
|
|
6
|
-
- 1.8.7
|
|
7
14
|
- 1.9.3
|
|
8
15
|
- 2.0.0
|
|
16
|
+
- 2.1.0
|
|
17
|
+
- ruby-head
|
|
9
18
|
|
|
10
19
|
branches:
|
|
11
20
|
only:
|
|
12
21
|
- master
|
|
13
22
|
- develop
|
|
14
23
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
matrix:
|
|
25
|
+
allow_failures:
|
|
26
|
+
- rvm: 2.1.0
|
|
27
|
+
- rvm: ruby-head
|
|
28
|
+
fast_finish: true
|
|
29
|
+
|
|
30
|
+
script: bundle exec rake travis
|
|
19
31
|
|
|
20
32
|
notifications:
|
|
21
|
-
webhooks:
|
|
33
|
+
webhooks:
|
|
34
|
+
urls:
|
|
35
|
+
- https://webhooks.gitter.im/e/ca7b2e631cab5cddce0d
|
|
36
|
+
on_success: always
|
|
37
|
+
on_failure: always
|
|
38
|
+
on_start: always
|
data/Gemfile
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
|
-
source
|
|
2
|
-
|
|
1
|
+
source 'https://rubygems.org'
|
|
3
2
|
|
|
4
3
|
# Include dependencies from trema.gemspec. DRY!
|
|
5
4
|
gemspec
|
|
6
5
|
|
|
7
6
|
# Add dependencies required to use your gem here.
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
gem "aruba", "~> 0.5.3"
|
|
13
|
-
gem "cucumber", "~> 1.3.8"
|
|
14
|
-
gem "flay", "~> 2.4.0"
|
|
15
|
-
gem "flog", "~> 4.2.0"
|
|
16
|
-
gem "rcov", "~> 1.0.0" if RUBY_VERSION < "1.9.0"
|
|
17
|
-
gem "redcarpet", "~> 2.3.0" if RUBY_VERSION < "1.9.0"
|
|
18
|
-
gem "redcarpet", "~> 3.0.0" if RUBY_VERSION >= "1.9.0"
|
|
19
|
-
gem "reek", "~> 1.3.4"
|
|
20
|
-
gem "relish", "~> 0.7"
|
|
21
|
-
gem "rspec", "~> 2.14.1"
|
|
22
|
-
gem "yard", "~> 0.8.7.2"
|
|
23
|
-
gem 'guard', '~> 1.8.3' if RUBY_VERSION < '1.9.0'
|
|
24
|
-
gem 'guard', '~> 2.2.2' if RUBY_VERSION >= '1.9.0'
|
|
25
|
-
gem 'guard-bundler', '~> 1.0.0' if RUBY_VERSION < '1.9.0'
|
|
26
|
-
gem 'guard-bundler', '~> 2.0.0' if RUBY_VERSION >= '1.9.0'
|
|
27
|
-
gem 'mime-types', '~> 1.25' if RUBY_VERSION < '1.9.0'
|
|
28
|
-
gem 'mime-types', '~> 2.0' if RUBY_VERSION >= '1.9.0'
|
|
8
|
+
group :docs do
|
|
9
|
+
gem 'relish', '~> 0.7'
|
|
10
|
+
gem 'yard', '~> 0.8.7.4'
|
|
29
11
|
end
|
|
30
12
|
|
|
13
|
+
group :development do
|
|
14
|
+
gem 'guard', '~> 2.6.1'
|
|
15
|
+
gem 'guard-bundler', '~> 2.0.0'
|
|
16
|
+
gem 'guard-rubocop', '~> 1.1.0'
|
|
17
|
+
end
|
|
31
18
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
19
|
+
group :test do
|
|
20
|
+
gem 'aruba', '~> 0.5.4'
|
|
21
|
+
gem 'codeclimate-test-reporter', require: nil
|
|
22
|
+
gem 'cucumber', '~> 1.3.15'
|
|
23
|
+
gem 'flay', '~> 2.4.0'
|
|
24
|
+
gem 'flog', '~> 4.2.0'
|
|
25
|
+
gem 'reek', '~> 1.3.7'
|
|
26
|
+
gem 'rspec', '~> 2.14.1'
|
|
27
|
+
gem 'rubocop', '~> 0.20.1', platforms: [:ruby_19, :ruby_20, :ruby_21]
|
|
28
|
+
end
|
data/Guardfile
CHANGED
data/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
Welcome to Trema
|
|
2
2
|
================
|
|
3
3
|
|
|
4
|
-
[][gem]
|
|
5
|
+
[][travis]
|
|
6
|
+
[][codeclimate]
|
|
7
|
+
[][codeclimate]
|
|
8
|
+
[][gemnasium]
|
|
9
|
+
[][gitter]
|
|
8
10
|
|
|
9
11
|
Trema is a OpenFlow controller framework that includes everything
|
|
10
12
|
needed to create OpenFlow controllers in Ruby and C.
|
|
@@ -21,6 +23,12 @@ emulates an OpenFlow-based network and end-hosts is provided for
|
|
|
21
23
|
testing your own controllers. For debugging, a wireshark plug-in to
|
|
22
24
|
diagnose internal data-flows among functional modules is provided.
|
|
23
25
|
|
|
26
|
+
[gem]: https://rubygems.org/gems/trema
|
|
27
|
+
[travis]: http://travis-ci.org/trema/trema
|
|
28
|
+
[codeclimate]: https://codeclimate.com/github/trema/trema
|
|
29
|
+
[gemnasium]: https://gemnasium.com/trema/trema
|
|
30
|
+
[gitter]: https://gitter.im/trema/trema
|
|
31
|
+
|
|
24
32
|
|
|
25
33
|
Supported Platforms
|
|
26
34
|
-------------------
|
|
@@ -57,7 +65,7 @@ Getting Started
|
|
|
57
65
|
$ sudo /var/lib/gems/1.8/bin/update_rubygems
|
|
58
66
|
|
|
59
67
|
(In Fedora 16-19)
|
|
60
|
-
$ sudo yum install gcc make git ruby rubygems ruby-devel libpcap-devel libsqlite3x-devel glib2-devel
|
|
68
|
+
$ sudo yum install tar gcc make git ruby rubygems ruby-devel libpcap-devel libsqlite3x-devel glib2-devel
|
|
61
69
|
|
|
62
70
|
2.Install Trema at the command prompt:
|
|
63
71
|
|
data/Rakefile
CHANGED
|
@@ -16,13 +16,12 @@
|
|
|
16
16
|
#
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
$LOAD_PATH.unshift(
|
|
19
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/ruby'))
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
require
|
|
23
|
-
require
|
|
24
|
-
require
|
|
25
|
-
require "trema/path"
|
|
22
|
+
require 'rake'
|
|
23
|
+
require 'trema/executables'
|
|
24
|
+
require 'trema/path'
|
|
26
25
|
|
|
27
26
|
|
|
28
27
|
task :default => :build_trema
|
|
@@ -31,7 +30,7 @@ directory Trema.log
|
|
|
31
30
|
directory Trema.pid
|
|
32
31
|
directory Trema.sock
|
|
33
32
|
|
|
34
|
-
desc
|
|
33
|
+
desc 'Build Trema'
|
|
35
34
|
task :build_trema => [
|
|
36
35
|
Trema.log,
|
|
37
36
|
Trema.pid,
|
|
@@ -47,135 +46,135 @@ task :build_trema => [
|
|
|
47
46
|
]
|
|
48
47
|
|
|
49
48
|
|
|
50
|
-
require
|
|
51
|
-
require
|
|
49
|
+
require 'paper_house'
|
|
50
|
+
require 'trema/version'
|
|
52
51
|
|
|
53
52
|
|
|
54
53
|
CFLAGS = [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
'-g',
|
|
55
|
+
'-std=gnu99',
|
|
56
|
+
'-D_GNU_SOURCE',
|
|
57
|
+
'-fno-strict-aliasing',
|
|
58
|
+
'-Wall',
|
|
59
|
+
'-Wextra',
|
|
60
|
+
'-Wformat=2',
|
|
61
|
+
'-Wcast-qual',
|
|
62
|
+
'-Wcast-align',
|
|
63
|
+
'-Wwrite-strings',
|
|
64
|
+
'-Wconversion',
|
|
65
|
+
'-Wfloat-equal',
|
|
66
|
+
'-Wpointer-arith'
|
|
68
67
|
]
|
|
69
|
-
CFLAGS <<
|
|
68
|
+
CFLAGS << '-Werror' if RUBY_VERSION < '1.9.0'
|
|
70
69
|
|
|
71
70
|
|
|
72
|
-
desc
|
|
73
|
-
task
|
|
74
|
-
PaperHouse::StaticLibraryTask.new
|
|
75
|
-
task.library_name =
|
|
71
|
+
desc 'Build Trema C library (static library).'
|
|
72
|
+
task 'libtrema:static' => 'vendor:openflow'
|
|
73
|
+
PaperHouse::StaticLibraryTask.new 'libtrema:static' do | task |
|
|
74
|
+
task.library_name = 'libtrema'
|
|
76
75
|
task.target_directory = Trema.lib
|
|
77
76
|
task.sources = "#{ Trema.include }/*.c"
|
|
78
77
|
task.cflags = CFLAGS
|
|
79
|
-
task.includes = [
|
|
78
|
+
task.includes = [Trema.openflow]
|
|
80
79
|
end
|
|
81
80
|
|
|
82
81
|
|
|
83
|
-
desc
|
|
84
|
-
task
|
|
85
|
-
PaperHouse::StaticLibraryTask.new
|
|
86
|
-
task.library_name =
|
|
82
|
+
desc 'Build Trema C library (coverage).'
|
|
83
|
+
task 'libtrema:gcov' => ['vendor:openflow']
|
|
84
|
+
PaperHouse::StaticLibraryTask.new 'libtrema:gcov' do | task |
|
|
85
|
+
task.library_name = 'libtrema'
|
|
87
86
|
task.target_directory = "#{ Trema.home }/objects/unittests"
|
|
88
87
|
task.sources = "#{ Trema.include }/*.c"
|
|
89
|
-
task.includes = [
|
|
90
|
-
task.cflags = [
|
|
88
|
+
task.includes = [Trema.openflow]
|
|
89
|
+
task.cflags = ['--coverage'] + CFLAGS
|
|
91
90
|
end
|
|
92
91
|
|
|
93
92
|
|
|
94
|
-
desc
|
|
95
|
-
task
|
|
96
|
-
PaperHouse::SharedLibraryTask.new
|
|
97
|
-
task.library_name =
|
|
93
|
+
desc 'Build Trema C library (shared library).'
|
|
94
|
+
task 'libtrema:shared' => 'vendor:openflow'
|
|
95
|
+
PaperHouse::SharedLibraryTask.new 'libtrema:shared' do | task |
|
|
96
|
+
task.library_name = 'libtrema'
|
|
98
97
|
task.target_directory = Trema.lib
|
|
99
98
|
task.version = Trema::VERSION
|
|
100
99
|
task.sources = "#{ Trema.include }/*.c"
|
|
101
|
-
task.includes = [
|
|
100
|
+
task.includes = [Trema.openflow]
|
|
102
101
|
task.cflags = CFLAGS
|
|
103
102
|
end
|
|
104
103
|
|
|
105
104
|
|
|
106
|
-
desc
|
|
107
|
-
task
|
|
108
|
-
PaperHouse::RubyExtensionTask.new
|
|
109
|
-
task.library_name =
|
|
105
|
+
desc 'Build Trema Ruby library.'
|
|
106
|
+
task 'rubylib' => 'libtrema:static'
|
|
107
|
+
PaperHouse::RubyExtensionTask.new 'rubylib' do | task |
|
|
108
|
+
task.library_name = 'trema'
|
|
110
109
|
task.target_directory = Trema.ruby
|
|
111
110
|
task.sources = "#{ Trema.ruby }/trema/*.c"
|
|
112
|
-
task.includes = [
|
|
111
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
113
112
|
task.cflags = CFLAGS
|
|
114
|
-
task.ldflags = [
|
|
113
|
+
task.ldflags = ['-Wl,-Bsymbolic', "-L#{ Trema.lib }"]
|
|
115
114
|
task.library_dependencies = [
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
'trema',
|
|
116
|
+
'sqlite3',
|
|
117
|
+
'pthread',
|
|
118
|
+
'rt',
|
|
119
|
+
'dl',
|
|
120
|
+
'crypt',
|
|
121
|
+
'm'
|
|
123
122
|
]
|
|
124
123
|
end
|
|
125
124
|
|
|
126
125
|
|
|
127
|
-
desc
|
|
128
|
-
task :switch_manager =>
|
|
126
|
+
desc 'Build switch manager.'
|
|
127
|
+
task :switch_manager => 'libtrema:static'
|
|
129
128
|
|
|
130
129
|
PaperHouse::ExecutableTask.new :switch_manager do | task |
|
|
131
|
-
task.target_directory = File.dirname(
|
|
130
|
+
task.target_directory = File.dirname(Trema::Executables.switch_manager)
|
|
132
131
|
task.sources = [
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
'src/switch_manager/dpid_table.c',
|
|
133
|
+
'src/switch_manager/event_forward_entry_manipulation.c',
|
|
134
|
+
'src/switch_manager/secure_channel_listener.c',
|
|
135
|
+
'src/switch_manager/switch_manager.c',
|
|
136
|
+
'src/switch_manager/switch_option.c'
|
|
138
137
|
]
|
|
139
|
-
task.includes = [
|
|
138
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
140
139
|
task.cflags = CFLAGS
|
|
141
140
|
task.ldflags = "-L#{ Trema.lib }"
|
|
142
141
|
task.library_dependencies = [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
142
|
+
'trema',
|
|
143
|
+
'sqlite3',
|
|
144
|
+
'pthread',
|
|
145
|
+
'rt',
|
|
146
|
+
'dl'
|
|
148
147
|
]
|
|
149
148
|
end
|
|
150
149
|
|
|
151
150
|
|
|
152
|
-
desc
|
|
153
|
-
task :switch_daemon =>
|
|
151
|
+
desc 'Build switch daemon.'
|
|
152
|
+
task :switch_daemon => 'libtrema:static'
|
|
154
153
|
|
|
155
154
|
PaperHouse::ExecutableTask.new :switch_daemon do | task |
|
|
156
|
-
task.executable_name = File.basename(
|
|
157
|
-
task.target_directory = File.dirname(
|
|
155
|
+
task.executable_name = File.basename(Trema::Executables.switch)
|
|
156
|
+
task.target_directory = File.dirname(Trema::Executables.switch)
|
|
158
157
|
task.sources = [
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
158
|
+
'src/switch_manager/cookie_table.c',
|
|
159
|
+
'src/switch_manager/event_forward_entry_manipulation.c',
|
|
160
|
+
'src/switch_manager/ofpmsg_recv.c',
|
|
161
|
+
'src/switch_manager/ofpmsg_send.c',
|
|
162
|
+
'src/switch_manager/secure_channel_receiver.c',
|
|
163
|
+
'src/switch_manager/secure_channel_sender.c',
|
|
164
|
+
'src/switch_manager/service_interface.c',
|
|
165
|
+
'src/switch_manager/switch.c',
|
|
166
|
+
'src/switch_manager/switch_option.c',
|
|
167
|
+
'src/switch_manager/xid_table.c'
|
|
169
168
|
]
|
|
170
|
-
task.includes = [
|
|
169
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
171
170
|
task.cflags = CFLAGS
|
|
172
171
|
task.ldflags = "-L#{ Trema.lib }"
|
|
173
172
|
task.library_dependencies = [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
'trema',
|
|
174
|
+
'sqlite3',
|
|
175
|
+
'pthread',
|
|
176
|
+
'rt',
|
|
177
|
+
'dl'
|
|
179
178
|
]
|
|
180
179
|
end
|
|
181
180
|
|
|
@@ -184,63 +183,63 @@ end
|
|
|
184
183
|
# Extract OpenFlow reference implementation
|
|
185
184
|
################################################################################
|
|
186
185
|
|
|
187
|
-
task
|
|
186
|
+
task 'vendor:openflow' => Trema.openflow_h
|
|
188
187
|
file Trema.openflow_h => Trema.objects do
|
|
189
188
|
sh "tar xzf #{ Trema.vendor_openflow }.tar.gz -C #{ Trema.vendor }"
|
|
190
189
|
cp_r "#{ Trema.vendor_openflow }/include/openflow", Trema.objects
|
|
191
190
|
end
|
|
192
191
|
directory Trema.objects
|
|
193
192
|
|
|
194
|
-
CLOBBER.include(
|
|
195
|
-
CLOBBER.include(
|
|
193
|
+
CLOBBER.include(Trema.vendor_openflow) if FileTest.exists?(Trema.vendor_openflow)
|
|
194
|
+
CLOBBER.include(File.join(Trema.objects, 'openflow')) if FileTest.exists?(File.join(Trema.objects, 'openflow'))
|
|
196
195
|
|
|
197
196
|
|
|
198
197
|
################################################################################
|
|
199
198
|
# Build phost
|
|
200
199
|
################################################################################
|
|
201
200
|
|
|
202
|
-
task
|
|
201
|
+
task 'vendor:phost' => [Trema::Executables.phost, Trema::Executables.cli]
|
|
203
202
|
|
|
204
203
|
def phost_src
|
|
205
|
-
File.join Trema.vendor_phost,
|
|
204
|
+
File.join Trema.vendor_phost, 'src'
|
|
206
205
|
end
|
|
207
206
|
|
|
208
207
|
def phost_objects
|
|
209
|
-
FileList[ File.join(
|
|
208
|
+
FileList[ File.join(phost_src, '*.o')]
|
|
210
209
|
end
|
|
211
210
|
|
|
212
211
|
def phost_vendor_binary
|
|
213
|
-
File.join phost_src,
|
|
212
|
+
File.join phost_src, 'phost'
|
|
214
213
|
end
|
|
215
214
|
|
|
216
215
|
def phost_cli_vendor_binary
|
|
217
|
-
File.join phost_src,
|
|
216
|
+
File.join phost_src, 'cli'
|
|
218
217
|
end
|
|
219
218
|
|
|
220
219
|
def phost_clean_targets
|
|
221
|
-
( phost_objects + [
|
|
220
|
+
( phost_objects + [phost_vendor_binary, phost_cli_vendor_binary]).select do | each |
|
|
222
221
|
FileTest.exists? each
|
|
223
222
|
end
|
|
224
223
|
end
|
|
225
224
|
|
|
226
225
|
file Trema::Executables.phost do
|
|
227
226
|
cd phost_src do
|
|
228
|
-
sh
|
|
227
|
+
sh 'make'
|
|
229
228
|
end
|
|
230
|
-
mkdir_p File.dirname(
|
|
231
|
-
install File.join(
|
|
229
|
+
mkdir_p File.dirname(Trema::Executables.phost)
|
|
230
|
+
install File.join(phost_src, 'phost'), Trema::Executables.phost, :mode => 0755
|
|
232
231
|
end
|
|
233
232
|
|
|
234
233
|
file Trema::Executables.cli do
|
|
235
234
|
cd phost_src do
|
|
236
|
-
sh
|
|
235
|
+
sh 'make'
|
|
237
236
|
end
|
|
238
|
-
mkdir_p File.dirname(
|
|
239
|
-
install File.join(
|
|
237
|
+
mkdir_p File.dirname(Trema::Executables.cli)
|
|
238
|
+
install File.join(phost_src, 'cli'), Trema::Executables.cli, :mode => 0755
|
|
240
239
|
end
|
|
241
240
|
|
|
242
241
|
CLEAN.include phost_clean_targets
|
|
243
|
-
CLOBBER.include(
|
|
242
|
+
CLOBBER.include(Trema.phost) if FileTest.exists?(Trema.phost)
|
|
244
243
|
|
|
245
244
|
|
|
246
245
|
################################################################################
|
|
@@ -248,10 +247,10 @@ CLOBBER.include( Trema.phost ) if FileTest.exists?( Trema.phost )
|
|
|
248
247
|
################################################################################
|
|
249
248
|
|
|
250
249
|
task :vendor => [
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
250
|
+
'vendor:oflops',
|
|
251
|
+
'vendor:openflow',
|
|
252
|
+
'vendor:openvswitch',
|
|
253
|
+
'vendor:phost'
|
|
255
254
|
]
|
|
256
255
|
|
|
257
256
|
|
|
@@ -259,40 +258,40 @@ task :vendor => [
|
|
|
259
258
|
# Build Open vSwitch
|
|
260
259
|
################################################################################
|
|
261
260
|
|
|
262
|
-
task
|
|
261
|
+
task 'vendor:openvswitch' => Trema::Executables.ovs_openflowd
|
|
263
262
|
file Trema::Executables.ovs_openflowd do
|
|
264
263
|
sh "tar xzf #{ Trema.vendor_openvswitch }.tar.gz -C #{ Trema.vendor }"
|
|
265
264
|
cd Trema.vendor_openvswitch do
|
|
266
265
|
sh "./configure --prefix=#{ Trema.openvswitch } --with-rundir=#{ Trema.sock }"
|
|
267
|
-
sh
|
|
268
|
-
cp
|
|
266
|
+
sh 'make install'
|
|
267
|
+
cp './tests/test-openflowd', Trema::Executables.ovs_openflowd
|
|
269
268
|
end
|
|
270
269
|
end
|
|
271
270
|
|
|
272
|
-
CLEAN.include(
|
|
273
|
-
CLOBBER.include(
|
|
271
|
+
CLEAN.include(Trema.vendor_openvswitch) if FileTest.exists?(Trema.vendor_openvswitch)
|
|
272
|
+
CLOBBER.include(Trema.openvswitch) if FileTest.exists?(Trema.openvswitch)
|
|
274
273
|
|
|
275
274
|
|
|
276
275
|
################################################################################
|
|
277
276
|
# Build packetin filter
|
|
278
277
|
################################################################################
|
|
279
278
|
|
|
280
|
-
desc
|
|
281
|
-
task :packetin_filter =>
|
|
279
|
+
desc 'Build packetin filter.'
|
|
280
|
+
task :packetin_filter => 'libtrema:static'
|
|
282
281
|
|
|
283
282
|
PaperHouse::ExecutableTask.new :packetin_filter do | task |
|
|
284
|
-
task.executable_name = File.basename(
|
|
285
|
-
task.target_directory = File.dirname(
|
|
286
|
-
task.sources = [
|
|
287
|
-
task.includes = [
|
|
283
|
+
task.executable_name = File.basename(Trema::Executables.packetin_filter)
|
|
284
|
+
task.target_directory = File.dirname(Trema::Executables.packetin_filter)
|
|
285
|
+
task.sources = ['src/packetin_filter/*.c']
|
|
286
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
288
287
|
task.cflags = CFLAGS
|
|
289
288
|
task.ldflags = "-L#{ Trema.lib }"
|
|
290
289
|
task.library_dependencies = [
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
290
|
+
'trema',
|
|
291
|
+
'sqlite3',
|
|
292
|
+
'pthread',
|
|
293
|
+
'rt',
|
|
294
|
+
'dl'
|
|
296
295
|
]
|
|
297
296
|
end
|
|
298
297
|
|
|
@@ -302,37 +301,37 @@ end
|
|
|
302
301
|
################################################################################
|
|
303
302
|
|
|
304
303
|
def cbench_command
|
|
305
|
-
File.join Trema.objects,
|
|
304
|
+
File.join Trema.objects, 'oflops/bin/cbench'
|
|
306
305
|
end
|
|
307
306
|
|
|
308
|
-
task
|
|
307
|
+
task 'vendor:oflops' => cbench_command
|
|
309
308
|
file cbench_command => Trema.openflow_h do
|
|
310
309
|
sh "tar xzf #{ Trema.vendor_oflops }.tar.gz -C #{ Trema.vendor }"
|
|
311
310
|
cd Trema.vendor_oflops do
|
|
312
311
|
sh "./configure --prefix=#{ Trema.oflops } --with-openflow-src-dir=#{ Trema.vendor_openflow }"
|
|
313
|
-
sh
|
|
312
|
+
sh 'make install'
|
|
314
313
|
end
|
|
315
314
|
end
|
|
316
315
|
|
|
317
|
-
CLEAN.include(
|
|
318
|
-
CLOBBER.include(
|
|
316
|
+
CLEAN.include(Trema.oflops) if FileTest.exists?(Trema.oflops)
|
|
317
|
+
CLOBBER.include(Trema.vendor_oflops) if FileTest.exists?(Trema.vendor_oflops)
|
|
319
318
|
|
|
320
319
|
|
|
321
320
|
################################################################################
|
|
322
321
|
# cmockery
|
|
323
322
|
################################################################################
|
|
324
323
|
|
|
325
|
-
task
|
|
324
|
+
task 'vendor:cmockery' => Trema.libcmockery_a
|
|
326
325
|
file Trema.libcmockery_a do
|
|
327
326
|
sh "tar xzf #{ Trema.vendor_cmockery }.tar.gz -C #{ Trema.vendor }"
|
|
328
327
|
cd Trema.vendor_cmockery do
|
|
329
|
-
sh "./configure --prefix=#{ Trema.cmockery }"
|
|
330
|
-
sh
|
|
328
|
+
sh "./configure --disable-shared --prefix=#{ Trema.cmockery }"
|
|
329
|
+
sh 'make install'
|
|
331
330
|
end
|
|
332
331
|
end
|
|
333
332
|
|
|
334
|
-
CLEAN.include(
|
|
335
|
-
CLOBBER.include(
|
|
333
|
+
CLEAN.include(Trema.vendor_cmockery) if FileTest.exists?(Trema.vendor_cmockery)
|
|
334
|
+
CLOBBER.include(Trema.cmockery) if FileTest.exists?(Trema.cmockery)
|
|
336
335
|
|
|
337
336
|
|
|
338
337
|
################################################################################
|
|
@@ -340,45 +339,45 @@ CLOBBER.include( Trema.cmockery ) if FileTest.exists?( Trema.cmockery )
|
|
|
340
339
|
################################################################################
|
|
341
340
|
|
|
342
341
|
$standalone_examples = [
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
342
|
+
'cbench_switch',
|
|
343
|
+
'dumper',
|
|
344
|
+
'learning_switch',
|
|
345
|
+
'list_switches',
|
|
346
|
+
'multi_learning_switch',
|
|
347
|
+
'packet_in',
|
|
348
|
+
'repeater_hub',
|
|
349
|
+
'switch_info',
|
|
350
|
+
'switch_monitor',
|
|
351
|
+
'traffic_monitor'
|
|
353
352
|
]
|
|
354
353
|
|
|
355
|
-
desc
|
|
354
|
+
desc 'Build examples.'
|
|
356
355
|
task :examples =>
|
|
357
356
|
$standalone_examples.map { | each | "examples:#{ each }" } +
|
|
358
357
|
[
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
358
|
+
'examples:openflow_switch',
|
|
359
|
+
'examples:openflow_message',
|
|
360
|
+
'examples:switch_event_config',
|
|
361
|
+
'examples:packetin_filter_config'
|
|
363
362
|
]
|
|
364
363
|
|
|
365
364
|
$standalone_examples.each do | each |
|
|
366
365
|
name = "examples:#{ each }"
|
|
367
366
|
|
|
368
|
-
task name =>
|
|
367
|
+
task name => 'libtrema:static'
|
|
369
368
|
PaperHouse::ExecutableTask.new name do | task |
|
|
370
369
|
task.executable_name = each
|
|
371
|
-
task.target_directory = File.join(
|
|
372
|
-
task.sources = [
|
|
373
|
-
task.includes = [
|
|
370
|
+
task.target_directory = File.join(Trema.objects, 'examples', each)
|
|
371
|
+
task.sources = ["src/examples/#{ each }/*.c"]
|
|
372
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
374
373
|
task.cflags = CFLAGS
|
|
375
374
|
task.ldflags = "-L#{ Trema.lib }"
|
|
376
375
|
task.library_dependencies = [
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
376
|
+
'trema',
|
|
377
|
+
'sqlite3',
|
|
378
|
+
'pthread',
|
|
379
|
+
'rt',
|
|
380
|
+
'dl'
|
|
382
381
|
]
|
|
383
382
|
end
|
|
384
383
|
end
|
|
@@ -389,29 +388,29 @@ end
|
|
|
389
388
|
################################################################################
|
|
390
389
|
|
|
391
390
|
$openflow_switches = [
|
|
392
|
-
|
|
393
|
-
|
|
391
|
+
'hello_switch',
|
|
392
|
+
'echo_switch'
|
|
394
393
|
]
|
|
395
394
|
|
|
396
|
-
task
|
|
395
|
+
task 'examples:openflow_switch' => $openflow_switches.map { | each | "examples:openflow_switch:#{ each }" }
|
|
397
396
|
|
|
398
397
|
$openflow_switches.each do | each |
|
|
399
398
|
name = "examples:openflow_switch:#{ each }"
|
|
400
399
|
|
|
401
|
-
task name =>
|
|
400
|
+
task name => 'libtrema:static'
|
|
402
401
|
PaperHouse::ExecutableTask.new name do | task |
|
|
403
402
|
task.executable_name = each
|
|
404
|
-
task.target_directory = File.join(
|
|
405
|
-
task.sources = [
|
|
406
|
-
task.includes = [
|
|
403
|
+
task.target_directory = File.join(Trema.objects, 'examples', 'openflow_switch')
|
|
404
|
+
task.sources = ["src/examples/openflow_switch/#{ each }.c"]
|
|
405
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
407
406
|
task.cflags = CFLAGS
|
|
408
407
|
task.ldflags = "-L#{ Trema.lib }"
|
|
409
408
|
task.library_dependencies = [
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
409
|
+
'trema',
|
|
410
|
+
'sqlite3',
|
|
411
|
+
'pthread',
|
|
412
|
+
'rt',
|
|
413
|
+
'dl'
|
|
415
414
|
]
|
|
416
415
|
end
|
|
417
416
|
end
|
|
@@ -422,32 +421,32 @@ end
|
|
|
422
421
|
################################################################################
|
|
423
422
|
|
|
424
423
|
$openflow_messages = [
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
424
|
+
'echo',
|
|
425
|
+
'features_request',
|
|
426
|
+
'hello',
|
|
427
|
+
'set_config',
|
|
428
|
+
'vendor_action'
|
|
430
429
|
]
|
|
431
430
|
|
|
432
|
-
task
|
|
431
|
+
task 'examples:openflow_message' => $openflow_messages.map { | each | "examples:openflow_message:#{ each }" }
|
|
433
432
|
|
|
434
433
|
$openflow_messages.each do | each |
|
|
435
434
|
name = "examples:openflow_message:#{ each }"
|
|
436
435
|
|
|
437
|
-
task name =>
|
|
436
|
+
task name => 'libtrema:static'
|
|
438
437
|
PaperHouse::ExecutableTask.new name do | task |
|
|
439
438
|
task.executable_name = each
|
|
440
|
-
task.target_directory = File.join(
|
|
441
|
-
task.sources = [
|
|
442
|
-
task.includes = [
|
|
439
|
+
task.target_directory = File.join(Trema.objects, 'examples', 'openflow_message')
|
|
440
|
+
task.sources = ["src/examples/openflow_message/#{ each }.c"]
|
|
441
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
443
442
|
task.cflags = CFLAGS
|
|
444
443
|
task.ldflags = "-L#{ Trema.lib }"
|
|
445
444
|
task.library_dependencies = [
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
445
|
+
'trema',
|
|
446
|
+
'sqlite3',
|
|
447
|
+
'pthread',
|
|
448
|
+
'rt',
|
|
449
|
+
'dl'
|
|
451
450
|
]
|
|
452
451
|
end
|
|
453
452
|
end
|
|
@@ -458,31 +457,31 @@ end
|
|
|
458
457
|
###############################################################################
|
|
459
458
|
|
|
460
459
|
$switch_event_config = [
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
460
|
+
'add_forward_entry',
|
|
461
|
+
'delete_forward_entry',
|
|
462
|
+
'set_forward_entries',
|
|
463
|
+
'dump_forward_entries'
|
|
465
464
|
]
|
|
466
465
|
|
|
467
|
-
task
|
|
466
|
+
task 'examples:switch_event_config' => $switch_event_config.map { | each | "examples:switch_event_config:#{ each }" }
|
|
468
467
|
|
|
469
468
|
$switch_event_config.each do | each |
|
|
470
469
|
name = "examples:switch_event_config:#{ each }"
|
|
471
470
|
|
|
472
|
-
task name =>
|
|
471
|
+
task name => 'libtrema:static'
|
|
473
472
|
PaperHouse::ExecutableTask.new name do | task |
|
|
474
473
|
task.executable_name = each
|
|
475
|
-
task.target_directory = File.join(
|
|
476
|
-
task.sources = [
|
|
477
|
-
task.includes = [
|
|
474
|
+
task.target_directory = File.join(Trema.objects, 'examples', 'switch_event_config')
|
|
475
|
+
task.sources = ["src/examples/switch_event_config/#{ each }.c"]
|
|
476
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
478
477
|
task.cflags = CFLAGS
|
|
479
478
|
task.ldflags = "-L#{ Trema.lib }"
|
|
480
479
|
task.library_dependencies = [
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
480
|
+
'trema',
|
|
481
|
+
'sqlite3',
|
|
482
|
+
'pthread',
|
|
483
|
+
'rt',
|
|
484
|
+
'dl'
|
|
486
485
|
]
|
|
487
486
|
end
|
|
488
487
|
end
|
|
@@ -493,32 +492,32 @@ end
|
|
|
493
492
|
################################################################################
|
|
494
493
|
|
|
495
494
|
$packetin_filter_config = [
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
495
|
+
'add_filter',
|
|
496
|
+
'delete_filter',
|
|
497
|
+
'delete_filter_strict',
|
|
498
|
+
'dump_filter',
|
|
499
|
+
'dump_filter_strict'
|
|
501
500
|
]
|
|
502
501
|
|
|
503
|
-
task
|
|
502
|
+
task 'examples:packetin_filter_config' => $packetin_filter_config.map { | each | "examples:packetin_filter_config:#{ each }" }
|
|
504
503
|
|
|
505
504
|
$packetin_filter_config.each do | each |
|
|
506
505
|
name = "examples:packetin_filter_config:#{ each }"
|
|
507
506
|
|
|
508
|
-
task name =>
|
|
507
|
+
task name => 'libtrema:static'
|
|
509
508
|
PaperHouse::ExecutableTask.new name do | task |
|
|
510
509
|
task.executable_name = each
|
|
511
|
-
task.target_directory = File.join(
|
|
512
|
-
task.sources = [
|
|
513
|
-
task.includes = [
|
|
510
|
+
task.target_directory = File.join(Trema.objects, 'examples', 'packetin_filter_config')
|
|
511
|
+
task.sources = ["src/examples/packetin_filter_config/#{ each }.c", 'src/examples/packetin_filter_config/utils.c']
|
|
512
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
514
513
|
task.cflags = CFLAGS
|
|
515
514
|
task.ldflags = "-L#{ Trema.lib }"
|
|
516
515
|
task.library_dependencies = [
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
516
|
+
'trema',
|
|
517
|
+
'sqlite3',
|
|
518
|
+
'pthread',
|
|
519
|
+
'rt',
|
|
520
|
+
'dl'
|
|
522
521
|
]
|
|
523
522
|
end
|
|
524
523
|
end
|
|
@@ -529,77 +528,75 @@ end
|
|
|
529
528
|
################################################################################
|
|
530
529
|
|
|
531
530
|
def cbench_command
|
|
532
|
-
File.join Trema.objects,
|
|
531
|
+
File.join Trema.objects, 'oflops/bin/cbench'
|
|
533
532
|
end
|
|
534
533
|
|
|
535
534
|
|
|
536
535
|
def cbench_latency_mode_options
|
|
537
|
-
|
|
536
|
+
'--port 6653 --switches 1 --loops 10 --delay 1000'
|
|
538
537
|
end
|
|
539
538
|
|
|
540
539
|
|
|
541
540
|
def cbench_throughput_mode_options
|
|
542
|
-
cbench_latency_mode_options +
|
|
541
|
+
cbench_latency_mode_options + ' --throughput'
|
|
543
542
|
end
|
|
544
543
|
|
|
545
544
|
|
|
546
|
-
def cbench
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
sh "./trema killall"
|
|
552
|
-
end
|
|
545
|
+
def cbench(controller, options)
|
|
546
|
+
sh "#{ controller }"
|
|
547
|
+
sh "#{ cbench_command } #{ options }"
|
|
548
|
+
ensure
|
|
549
|
+
sh './trema killall'
|
|
553
550
|
end
|
|
554
551
|
|
|
555
552
|
|
|
556
553
|
def cbench_c_controller
|
|
557
|
-
|
|
554
|
+
'./trema run ./objects/examples/cbench_switch/cbench_switch -d'
|
|
558
555
|
end
|
|
559
556
|
|
|
560
557
|
|
|
561
558
|
def cbench_ruby_controller
|
|
562
|
-
|
|
559
|
+
'./trema run src/examples/cbench_switch/cbench-switch.rb -d'
|
|
563
560
|
end
|
|
564
561
|
|
|
565
562
|
|
|
566
|
-
def run_cbench
|
|
563
|
+
def run_cbench(controller)
|
|
567
564
|
cbench controller, cbench_latency_mode_options
|
|
568
565
|
cbench controller, cbench_throughput_mode_options
|
|
569
566
|
end
|
|
570
567
|
|
|
571
568
|
|
|
572
|
-
def cbench_profile
|
|
573
|
-
valgrind =
|
|
569
|
+
def cbench_profile(options)
|
|
570
|
+
valgrind = 'valgrind --tool=callgrind --trace-children=yes'
|
|
574
571
|
begin
|
|
575
572
|
sh "#{ valgrind } #{ cbench_c_controller }"
|
|
576
573
|
sh "#{ cbench_command } #{ options }"
|
|
577
574
|
ensure
|
|
578
|
-
sh
|
|
575
|
+
sh './trema killall'
|
|
579
576
|
end
|
|
580
577
|
end
|
|
581
578
|
|
|
582
|
-
CLEAN.include FileList[
|
|
579
|
+
CLEAN.include FileList[ 'callgrind.out.*']
|
|
583
580
|
|
|
584
581
|
|
|
585
|
-
desc
|
|
586
|
-
task
|
|
582
|
+
desc 'Run the c cbench switch controller to benchmark'
|
|
583
|
+
task 'cbench' => 'cbench:ruby'
|
|
587
584
|
|
|
588
585
|
|
|
589
|
-
desc
|
|
590
|
-
task
|
|
586
|
+
desc 'Run the c cbench switch controller to benchmark'
|
|
587
|
+
task 'cbench:c' => :default do
|
|
591
588
|
run_cbench cbench_c_controller
|
|
592
589
|
end
|
|
593
590
|
|
|
594
591
|
|
|
595
|
-
desc
|
|
596
|
-
task
|
|
592
|
+
desc 'Run the ruby cbench switch controller to benchmark'
|
|
593
|
+
task 'cbench:ruby' => :default do
|
|
597
594
|
run_cbench cbench_ruby_controller
|
|
598
595
|
end
|
|
599
596
|
|
|
600
597
|
|
|
601
|
-
desc
|
|
602
|
-
task
|
|
598
|
+
desc 'Run cbench with profiling enabled.'
|
|
599
|
+
task 'cbench:profile' => :default do
|
|
603
600
|
cbench_profile cbench_latency_mode_options
|
|
604
601
|
cbench_profile cbench_throughput_mode_options
|
|
605
602
|
end
|
|
@@ -610,32 +607,32 @@ end
|
|
|
610
607
|
################################################################################
|
|
611
608
|
|
|
612
609
|
$management_commands = [
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
610
|
+
'application',
|
|
611
|
+
'echo',
|
|
612
|
+
'set_logging_level',
|
|
613
|
+
'show_stats'
|
|
617
614
|
]
|
|
618
615
|
|
|
619
|
-
desc
|
|
616
|
+
desc 'Build management commands.'
|
|
620
617
|
task :management_commands => $management_commands.map { | each | "management:#{ each }" }
|
|
621
618
|
|
|
622
619
|
$management_commands.each do | each |
|
|
623
620
|
name = "management:#{ each }"
|
|
624
621
|
|
|
625
|
-
task name =>
|
|
622
|
+
task name => 'libtrema:static'
|
|
626
623
|
PaperHouse::ExecutableTask.new name do | task |
|
|
627
624
|
task.executable_name = each
|
|
628
|
-
task.target_directory = File.join(
|
|
629
|
-
task.sources = [
|
|
630
|
-
task.includes = [
|
|
625
|
+
task.target_directory = File.join(Trema.objects, 'management')
|
|
626
|
+
task.sources = ["src/management/#{ each }.c"]
|
|
627
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
631
628
|
task.cflags = CFLAGS
|
|
632
629
|
task.ldflags = "-L#{ Trema.lib }"
|
|
633
630
|
task.library_dependencies = [
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
631
|
+
'trema',
|
|
632
|
+
'sqlite3',
|
|
633
|
+
'pthread',
|
|
634
|
+
'rt',
|
|
635
|
+
'dl'
|
|
639
636
|
]
|
|
640
637
|
end
|
|
641
638
|
end
|
|
@@ -645,106 +642,106 @@ end
|
|
|
645
642
|
# Tremashark
|
|
646
643
|
################################################################################
|
|
647
644
|
|
|
648
|
-
desc
|
|
649
|
-
task :tremashark => [
|
|
645
|
+
desc 'Build tremashark.'
|
|
646
|
+
task :tremashark => [:packet_capture, :syslog_relay, :stdin_relay, :openflow_wireshark_plugin, 'libtrema:static']
|
|
650
647
|
|
|
651
648
|
PaperHouse::ExecutableTask.new :tremashark do | task |
|
|
652
|
-
task.executable_name = File.basename(
|
|
653
|
-
task.target_directory = File.dirname(
|
|
649
|
+
task.executable_name = File.basename(Trema::Executables.tremashark)
|
|
650
|
+
task.target_directory = File.dirname(Trema::Executables.tremashark)
|
|
654
651
|
task.sources = [
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
652
|
+
'src/tremashark/pcap_queue.c',
|
|
653
|
+
'src/tremashark/queue.c',
|
|
654
|
+
'src/tremashark/tremashark.c'
|
|
658
655
|
]
|
|
659
|
-
task.includes = [
|
|
656
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
660
657
|
task.cflags = CFLAGS
|
|
661
658
|
task.ldflags = "-L#{ Trema.lib }"
|
|
662
659
|
task.library_dependencies = [
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
660
|
+
'trema',
|
|
661
|
+
'sqlite3',
|
|
662
|
+
'pthread',
|
|
663
|
+
'rt',
|
|
664
|
+
'dl',
|
|
665
|
+
'pcap'
|
|
669
666
|
]
|
|
670
667
|
end
|
|
671
668
|
|
|
672
669
|
|
|
673
|
-
task :packet_capture =>
|
|
670
|
+
task :packet_capture => 'libtrema:static'
|
|
674
671
|
|
|
675
672
|
PaperHouse::ExecutableTask.new :packet_capture do | task |
|
|
676
|
-
task.executable_name = File.basename(
|
|
677
|
-
task.target_directory = File.dirname(
|
|
673
|
+
task.executable_name = File.basename(Trema::Executables.packet_capture)
|
|
674
|
+
task.target_directory = File.dirname(Trema::Executables.packet_capture)
|
|
678
675
|
task.sources = [
|
|
679
|
-
|
|
680
|
-
|
|
676
|
+
'src/tremashark/packet_capture.c',
|
|
677
|
+
'src/tremashark/queue.c'
|
|
681
678
|
]
|
|
682
|
-
task.includes = [
|
|
679
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
683
680
|
task.cflags = CFLAGS
|
|
684
681
|
task.ldflags = "-L#{ Trema.lib }"
|
|
685
682
|
task.library_dependencies = [
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
683
|
+
'trema',
|
|
684
|
+
'sqlite3',
|
|
685
|
+
'pthread',
|
|
686
|
+
'rt',
|
|
687
|
+
'dl',
|
|
688
|
+
'pcap'
|
|
692
689
|
]
|
|
693
690
|
end
|
|
694
691
|
|
|
695
692
|
|
|
696
|
-
task :syslog_relay =>
|
|
693
|
+
task :syslog_relay => 'libtrema:static'
|
|
697
694
|
|
|
698
695
|
PaperHouse::ExecutableTask.new :syslog_relay do | task |
|
|
699
|
-
task.executable_name = File.basename(
|
|
700
|
-
task.target_directory = File.dirname(
|
|
701
|
-
task.sources = [
|
|
702
|
-
task.includes = [
|
|
696
|
+
task.executable_name = File.basename(Trema::Executables.syslog_relay)
|
|
697
|
+
task.target_directory = File.dirname(Trema::Executables.syslog_relay)
|
|
698
|
+
task.sources = ['src/tremashark/syslog_relay.c']
|
|
699
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
703
700
|
task.cflags = CFLAGS
|
|
704
701
|
task.ldflags = "-L#{ Trema.lib }"
|
|
705
702
|
task.library_dependencies = [
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
703
|
+
'trema',
|
|
704
|
+
'sqlite3',
|
|
705
|
+
'pthread',
|
|
706
|
+
'rt',
|
|
707
|
+
'dl',
|
|
708
|
+
'pcap'
|
|
712
709
|
]
|
|
713
710
|
end
|
|
714
711
|
|
|
715
712
|
|
|
716
|
-
task :stdin_relay =>
|
|
713
|
+
task :stdin_relay => 'libtrema:static'
|
|
717
714
|
|
|
718
715
|
PaperHouse::ExecutableTask.new :stdin_relay do | task |
|
|
719
|
-
task.executable_name = File.basename(
|
|
720
|
-
task.target_directory = File.dirname(
|
|
721
|
-
task.sources = [
|
|
722
|
-
task.includes = [
|
|
716
|
+
task.executable_name = File.basename(Trema::Executables.stdin_relay)
|
|
717
|
+
task.target_directory = File.dirname(Trema::Executables.stdin_relay)
|
|
718
|
+
task.sources = ['src/tremashark/stdin_relay.c']
|
|
719
|
+
task.includes = [Trema.include, Trema.openflow]
|
|
723
720
|
task.cflags = CFLAGS
|
|
724
721
|
task.ldflags = "-L#{ Trema.lib }"
|
|
725
722
|
task.library_dependencies = [
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
723
|
+
'trema',
|
|
724
|
+
'sqlite3',
|
|
725
|
+
'pthread',
|
|
726
|
+
'rt',
|
|
727
|
+
'dl',
|
|
728
|
+
'pcap'
|
|
732
729
|
]
|
|
733
730
|
end
|
|
734
731
|
|
|
735
732
|
|
|
736
|
-
$packet_openflow_so = File.join(
|
|
737
|
-
$wireshark_plugins_dir = File.join(
|
|
738
|
-
$wireshark_plugin = File.join(
|
|
733
|
+
$packet_openflow_so = File.join(Trema.vendor_openflow_git, 'utilities', 'wireshark_dissectors', 'openflow', 'packet-openflow.so')
|
|
734
|
+
$wireshark_plugins_dir = File.join(File.expand_path('~'), '.wireshark', 'plugins')
|
|
735
|
+
$wireshark_plugin = File.join($wireshark_plugins_dir, File.basename($packet_openflow_so))
|
|
739
736
|
|
|
740
737
|
file $packet_openflow_so do
|
|
741
738
|
sh "tar xzf #{ Trema.vendor_openflow_git }.tar.gz -C #{ Trema.vendor }"
|
|
742
|
-
cd File.dirname(
|
|
743
|
-
sh
|
|
739
|
+
cd File.dirname($packet_openflow_so) do
|
|
740
|
+
sh 'make'
|
|
744
741
|
end
|
|
745
742
|
end
|
|
746
743
|
|
|
747
|
-
file $wireshark_plugin => [
|
|
744
|
+
file $wireshark_plugin => [$packet_openflow_so, $wireshark_plugins_dir] do
|
|
748
745
|
cp $packet_openflow_so, $wireshark_plugins_dir
|
|
749
746
|
end
|
|
750
747
|
|
|
@@ -752,7 +749,7 @@ directory $wireshark_plugins_dir
|
|
|
752
749
|
|
|
753
750
|
task :openflow_wireshark_plugin => $wireshark_plugin
|
|
754
751
|
|
|
755
|
-
CLEAN.include(
|
|
752
|
+
CLEAN.include(Trema.vendor_openflow_git) if FileTest.exists?(Trema.vendor_openflow_git)
|
|
756
753
|
|
|
757
754
|
|
|
758
755
|
################################################################################
|
|
@@ -760,7 +757,7 @@ CLEAN.include( Trema.vendor_openflow_git ) if FileTest.exists?( Trema.vendor_ope
|
|
|
760
757
|
################################################################################
|
|
761
758
|
|
|
762
759
|
begin
|
|
763
|
-
require
|
|
760
|
+
require 'bundler/gem_tasks'
|
|
764
761
|
rescue LoadError
|
|
765
762
|
$stderr.puts $!.to_s
|
|
766
763
|
end
|
|
@@ -771,7 +768,7 @@ end
|
|
|
771
768
|
################################################################################
|
|
772
769
|
|
|
773
770
|
task :relish do
|
|
774
|
-
sh
|
|
771
|
+
sh 'relish push trema/trema'
|
|
775
772
|
end
|
|
776
773
|
|
|
777
774
|
|
|
@@ -781,28 +778,28 @@ end
|
|
|
781
778
|
|
|
782
779
|
def libtrema_unit_tests
|
|
783
780
|
{
|
|
784
|
-
:byteorder_test => [
|
|
785
|
-
:daemon_test => [
|
|
786
|
-
:ether_test => [
|
|
781
|
+
:byteorder_test => [:log, :utility, :wrapper, :trema_wrapper],
|
|
782
|
+
:daemon_test => [:log, :utility, :wrapper, :trema_wrapper],
|
|
783
|
+
:ether_test => [:buffer, :log, :utility, :wrapper, :trema_wrapper],
|
|
787
784
|
:external_callback_test => [],
|
|
788
|
-
:messenger_test => [
|
|
789
|
-
:openflow_application_interface_test => [
|
|
790
|
-
:openflow_message_test => [
|
|
791
|
-
:packet_info_test => [
|
|
792
|
-
:stat_test => [
|
|
793
|
-
:timer_test => [
|
|
794
|
-
:trema_test => [
|
|
785
|
+
:messenger_test => [:doubly_linked_list, :hash_table, :event_handler, :linked_list, :utility, :wrapper, :timer, :log, :trema_wrapper],
|
|
786
|
+
:openflow_application_interface_test => [:buffer, :byteorder, :hash_table, :doubly_linked_list, :linked_list, :log, :openflow_message, :packet_info, :stat, :trema_wrapper, :utility, :wrapper],
|
|
787
|
+
:openflow_message_test => [:buffer, :byteorder, :linked_list, :log, :packet_info, :utility, :wrapper, :trema_wrapper],
|
|
788
|
+
:packet_info_test => [:buffer, :log, :utility, :wrapper, :trema_wrapper],
|
|
789
|
+
:stat_test => [:hash_table, :doubly_linked_list, :log, :utility, :wrapper, :trema_wrapper],
|
|
790
|
+
:timer_test => [:log, :utility, :wrapper, :doubly_linked_list, :trema_wrapper],
|
|
791
|
+
:trema_test => [:utility, :log, :wrapper, :doubly_linked_list, :trema_private, :trema_wrapper]
|
|
795
792
|
}
|
|
796
793
|
end
|
|
797
794
|
|
|
798
795
|
|
|
799
|
-
def test_c_files
|
|
800
|
-
names = [
|
|
796
|
+
def test_c_files(test)
|
|
797
|
+
names = [test.to_s.gsub(/_test$/, '')] + libtrema_unit_tests[ test]
|
|
801
798
|
names.collect do | each |
|
|
802
799
|
if each == :buffer
|
|
803
|
-
[
|
|
800
|
+
['src/lib/buffer.c', 'unittests/buffer_stubs.c']
|
|
804
801
|
elsif each == :wrapper
|
|
805
|
-
[
|
|
802
|
+
['src/lib/wrapper.c', 'unittests/wrapper_stubs.c']
|
|
806
803
|
else
|
|
807
804
|
"src/lib/#{ each }.c"
|
|
808
805
|
end
|
|
@@ -810,28 +807,28 @@ def test_c_files test
|
|
|
810
807
|
end
|
|
811
808
|
|
|
812
809
|
|
|
813
|
-
directory
|
|
810
|
+
directory 'objects/unittests'
|
|
814
811
|
|
|
815
812
|
task :build_old_unittests => libtrema_unit_tests.keys.map { | each | "unittests:#{ each }" }
|
|
816
813
|
|
|
817
814
|
libtrema_unit_tests.keys.each do | each |
|
|
818
815
|
PaperHouse::ExecutableTask.new "unittests:#{ each }" do | task |
|
|
819
816
|
name = "unittests:#{ each }"
|
|
820
|
-
task name => [
|
|
817
|
+
task name => ['vendor:cmockery', 'vendor:openflow', 'objects/unittests']
|
|
821
818
|
|
|
822
819
|
task.executable_name = each.to_s
|
|
823
|
-
task.target_directory = File.join(
|
|
824
|
-
task.sources = test_c_files(
|
|
825
|
-
task.includes = [
|
|
826
|
-
task.cflags = [
|
|
827
|
-
task.ldflags = "-DUNIT_TESTING -L#{ File.dirname Trema.libcmockery_a } --coverage
|
|
820
|
+
task.target_directory = File.join(Trema.home, 'unittests/objects')
|
|
821
|
+
task.sources = test_c_files(each) + ["unittests/lib/#{ each }.c"]
|
|
822
|
+
task.includes = [Trema.include, Trema.openflow, File.dirname(Trema.cmockery_h), 'unittests']
|
|
823
|
+
task.cflags = ['-DUNIT_TESTING', '--coverage', CFLAGS]
|
|
824
|
+
task.ldflags = "-DUNIT_TESTING -L#{ File.dirname Trema.libcmockery_a } --coverage"
|
|
828
825
|
task.library_dependencies = [
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
826
|
+
'cmockery',
|
|
827
|
+
'sqlite3',
|
|
828
|
+
'pthread',
|
|
829
|
+
'rt',
|
|
830
|
+
'dl',
|
|
831
|
+
'pcap'
|
|
835
832
|
]
|
|
836
833
|
end
|
|
837
834
|
end
|
|
@@ -839,54 +836,54 @@ end
|
|
|
839
836
|
|
|
840
837
|
# new unittest
|
|
841
838
|
$tests = [
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
839
|
+
'objects/unittests/buffer_test',
|
|
840
|
+
'objects/unittests/doubly_linked_list_test',
|
|
841
|
+
'objects/unittests/ether_test',
|
|
842
|
+
'objects/unittests/event_forward_interface_test',
|
|
843
|
+
'objects/unittests/hash_table_test',
|
|
844
|
+
'objects/unittests/linked_list_test',
|
|
845
|
+
'objects/unittests/log_test',
|
|
846
|
+
'objects/unittests/packetin_filter_interface_test',
|
|
847
|
+
'objects/unittests/packet_info_test',
|
|
848
|
+
'objects/unittests/packet_parser_test',
|
|
849
|
+
'objects/unittests/persistent_storage_test',
|
|
850
|
+
'objects/unittests/trema_private_test',
|
|
851
|
+
'objects/unittests/utility_test',
|
|
852
|
+
'objects/unittests/wrapper_test',
|
|
853
|
+
'objects/unittests/match_table_test',
|
|
854
|
+
'objects/unittests/message_queue_test',
|
|
855
|
+
'objects/unittests/management_interface_test',
|
|
856
|
+
'objects/unittests/management_service_interface_test'
|
|
860
857
|
]
|
|
861
858
|
|
|
862
|
-
task :build_unittests => $tests.map { | each |
|
|
859
|
+
task :build_unittests => $tests.map { | each | 'unittests:' + File.basename(each) }
|
|
863
860
|
|
|
864
861
|
$tests.each do | _each |
|
|
865
|
-
each = File.basename(
|
|
862
|
+
each = File.basename(_each)
|
|
866
863
|
|
|
867
|
-
task "unittests:#{ each }" => [
|
|
864
|
+
task "unittests:#{ each }" => ['libtrema:gcov', 'vendor:cmockery']
|
|
868
865
|
PaperHouse::ExecutableTask.new "unittests:#{ each }" do | task |
|
|
869
866
|
task.executable_name = each.to_s
|
|
870
|
-
task.target_directory = File.join(
|
|
871
|
-
task.sources = [
|
|
872
|
-
task.includes = [
|
|
873
|
-
task.cflags = [
|
|
874
|
-
task.ldflags = "-L#{ File.dirname Trema.libcmockery_a } -Lobjects/unittests --coverage
|
|
867
|
+
task.target_directory = File.join(Trema.home, 'unittests/objects')
|
|
868
|
+
task.sources = ["unittests/lib/#{ each }.c", 'unittests/cmockery_trema.c']
|
|
869
|
+
task.includes = [Trema.include, Trema.openflow, File.dirname(Trema.cmockery_h), 'unittests']
|
|
870
|
+
task.cflags = ['--coverage', CFLAGS]
|
|
871
|
+
task.ldflags = "-L#{ File.dirname Trema.libcmockery_a } -Lobjects/unittests --coverage"
|
|
875
872
|
task.library_dependencies = [
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
873
|
+
'trema',
|
|
874
|
+
'cmockery',
|
|
875
|
+
'sqlite3',
|
|
876
|
+
'pthread',
|
|
877
|
+
'rt',
|
|
878
|
+
'dl'
|
|
882
879
|
]
|
|
883
880
|
end
|
|
884
881
|
end
|
|
885
882
|
|
|
886
883
|
|
|
887
|
-
desc
|
|
888
|
-
task :unittests => [
|
|
889
|
-
Dir.glob(
|
|
884
|
+
desc 'Run unittests'
|
|
885
|
+
task :unittests => [:build_old_unittests, :build_unittests] do
|
|
886
|
+
Dir.glob('unittests/objects/*_test').each do | each |
|
|
890
887
|
puts "Running #{ each }..."
|
|
891
888
|
sh each
|
|
892
889
|
end
|
|
@@ -897,41 +894,41 @@ end
|
|
|
897
894
|
# Tests
|
|
898
895
|
################################################################################
|
|
899
896
|
|
|
900
|
-
task :travis => [
|
|
897
|
+
task :travis => [:clobber, :build_trema, 'spec:travis']
|
|
901
898
|
|
|
902
899
|
|
|
903
900
|
begin
|
|
904
|
-
require
|
|
905
|
-
require
|
|
901
|
+
require 'rspec/core'
|
|
902
|
+
require 'rspec/core/rake_task'
|
|
906
903
|
|
|
907
904
|
task :spec => :build_trema
|
|
908
905
|
RSpec::Core::RakeTask.new do | task |
|
|
909
906
|
task.verbose = $trace
|
|
910
|
-
task.pattern = FileList[
|
|
911
|
-
task.rspec_opts =
|
|
907
|
+
task.pattern = FileList[ 'spec/**/*_spec.rb']
|
|
908
|
+
task.rspec_opts = '--format documentation --color'
|
|
912
909
|
end
|
|
913
910
|
|
|
914
|
-
task
|
|
915
|
-
RSpec::Core::RakeTask.new(
|
|
911
|
+
task 'spec:actions' => :build_trema
|
|
912
|
+
RSpec::Core::RakeTask.new('spec:actions') do | task |
|
|
916
913
|
task.verbose = $trace
|
|
917
|
-
task.pattern = FileList[
|
|
918
|
-
task.rspec_opts =
|
|
914
|
+
task.pattern = FileList[ 'spec/**/*_spec.rb']
|
|
915
|
+
task.rspec_opts = '--tag type:actions --format documentation --color'
|
|
919
916
|
end
|
|
920
917
|
|
|
921
918
|
|
|
922
|
-
task
|
|
923
|
-
RSpec::Core::RakeTask.new(
|
|
919
|
+
task 'spec:travis' => :build_trema
|
|
920
|
+
RSpec::Core::RakeTask.new('spec:travis') do | task |
|
|
924
921
|
task.verbose = $trace
|
|
925
|
-
task.pattern = FileList[
|
|
926
|
-
task.rspec_opts =
|
|
922
|
+
task.pattern = FileList[ 'spec/trema/hello_spec.rb', 'spec/trema/echo-*_spec.rb']
|
|
923
|
+
task.rspec_opts = '--tag ~sudo --format documentation --color'
|
|
927
924
|
end
|
|
928
925
|
|
|
929
926
|
|
|
930
927
|
task :rcov => :build_trema
|
|
931
|
-
RSpec::Core::RakeTask.new(
|
|
932
|
-
spec.pattern =
|
|
928
|
+
RSpec::Core::RakeTask.new(:rcov) do | spec |
|
|
929
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
933
930
|
spec.rcov = true
|
|
934
|
-
spec.rcov_opts = [
|
|
931
|
+
spec.rcov_opts = ['-x', 'gems']
|
|
935
932
|
end
|
|
936
933
|
rescue LoadError
|
|
937
934
|
$stderr.puts $!.to_s
|
|
@@ -939,10 +936,16 @@ end
|
|
|
939
936
|
|
|
940
937
|
|
|
941
938
|
begin
|
|
942
|
-
require
|
|
939
|
+
require 'cucumber/rake/task'
|
|
940
|
+
|
|
943
941
|
task :features => :build_trema
|
|
944
|
-
Cucumber::Rake::Task.new(
|
|
945
|
-
t.cucumber_opts =
|
|
942
|
+
Cucumber::Rake::Task.new(:features) do | t |
|
|
943
|
+
t.cucumber_opts = '--tags @critical --tags ~@wip'
|
|
944
|
+
end
|
|
945
|
+
|
|
946
|
+
task 'features:all' => :build_trema
|
|
947
|
+
Cucumber::Rake::Task.new('features:all') do | t |
|
|
948
|
+
t.cucumber_opts = '--tags ~@wip'
|
|
946
949
|
end
|
|
947
950
|
rescue LoadError
|
|
948
951
|
$stderr.puts $!.to_s
|
|
@@ -953,21 +956,21 @@ end
|
|
|
953
956
|
# Code Quality Tasks
|
|
954
957
|
################################################################################
|
|
955
958
|
|
|
956
|
-
$ruby_sources = FileList[
|
|
959
|
+
$ruby_sources = FileList[ 'ruby/**/*.rb', 'src/**/*.rb']
|
|
957
960
|
|
|
958
961
|
|
|
959
|
-
desc
|
|
960
|
-
task :quality => [
|
|
962
|
+
desc 'Enforce Ruby code quality with static analysis of code'
|
|
963
|
+
task :quality => [:reek, :flog, :flay]
|
|
961
964
|
|
|
962
965
|
|
|
963
966
|
begin
|
|
964
|
-
require
|
|
967
|
+
require 'reek/rake/task'
|
|
965
968
|
|
|
966
969
|
Reek::Rake::Task.new do | t |
|
|
967
970
|
t.fail_on_error = false
|
|
968
971
|
t.verbose = false
|
|
969
|
-
t.ruby_opts = [
|
|
970
|
-
t.reek_opts =
|
|
972
|
+
t.ruby_opts = ['-rubygems']
|
|
973
|
+
t.reek_opts = '--quiet'
|
|
971
974
|
t.source_files = $ruby_sources
|
|
972
975
|
end
|
|
973
976
|
rescue LoadError
|
|
@@ -976,21 +979,21 @@ end
|
|
|
976
979
|
|
|
977
980
|
|
|
978
981
|
begin
|
|
979
|
-
require
|
|
982
|
+
require 'flog'
|
|
980
983
|
|
|
981
|
-
desc
|
|
984
|
+
desc 'Analyze for code complexity'
|
|
982
985
|
task :flog do
|
|
983
|
-
flog = Flog.new(
|
|
984
|
-
flog.flog
|
|
986
|
+
flog = Flog.new(:continue => true)
|
|
987
|
+
flog.flog(*$ruby_sources)
|
|
985
988
|
threshold = 10
|
|
986
989
|
|
|
987
990
|
bad_methods = flog.totals.select do | name, score |
|
|
988
|
-
( not ( /##{flog.no_method}
|
|
991
|
+
( not ( /##{flog.no_method}$/ =~ name)) && score > threshold
|
|
989
992
|
end
|
|
990
993
|
bad_methods.sort do | a, b |
|
|
991
|
-
a[ 1
|
|
994
|
+
a[ 1] <=> b[ 1]
|
|
992
995
|
end.reverse.each do | name, score |
|
|
993
|
-
puts
|
|
996
|
+
puts '%8.1f: %s' % [score, name]
|
|
994
997
|
end
|
|
995
998
|
unless bad_methods.empty?
|
|
996
999
|
$stderr.puts "#{ bad_methods.size } methods have a flog complexity > #{ threshold }"
|
|
@@ -1002,12 +1005,12 @@ end
|
|
|
1002
1005
|
|
|
1003
1006
|
|
|
1004
1007
|
begin
|
|
1005
|
-
require
|
|
1006
|
-
require
|
|
1008
|
+
require 'flay'
|
|
1009
|
+
require 'flay_task'
|
|
1007
1010
|
|
|
1008
1011
|
FlayTask.new do | t |
|
|
1009
1012
|
t.dirs = $ruby_sources.collect do | each |
|
|
1010
|
-
each[ /[^\/]+/
|
|
1013
|
+
each[ /[^\/]+/]
|
|
1011
1014
|
end.uniq
|
|
1012
1015
|
t.threshold = 0
|
|
1013
1016
|
t.verbose = true
|
|
@@ -1017,17 +1020,21 @@ rescue LoadError
|
|
|
1017
1020
|
end
|
|
1018
1021
|
|
|
1019
1022
|
|
|
1023
|
+
task :travis => :rubocop
|
|
1024
|
+
task :quality => :rubocop
|
|
1025
|
+
|
|
1026
|
+
|
|
1020
1027
|
################################################################################
|
|
1021
1028
|
# YARD
|
|
1022
1029
|
################################################################################
|
|
1023
1030
|
|
|
1024
1031
|
begin
|
|
1025
|
-
require
|
|
1032
|
+
require 'yard'
|
|
1026
1033
|
|
|
1027
1034
|
YARD::Rake::YardocTask.new do | t |
|
|
1028
|
-
t.files = [
|
|
1029
|
-
t.options = [
|
|
1030
|
-
t.options <<
|
|
1035
|
+
t.files = ['ruby/trema/**/*.c', 'ruby/trema/**/*.rb']
|
|
1036
|
+
t.options = ['--no-private']
|
|
1037
|
+
t.options << '--debug' << '--verbose' if $trace
|
|
1031
1038
|
end
|
|
1032
1039
|
rescue LoadError
|
|
1033
1040
|
$stderr.puts $!.to_s
|
|
@@ -1038,9 +1045,9 @@ end
|
|
|
1038
1045
|
# TODO, FIXME etc.
|
|
1039
1046
|
################################################################################
|
|
1040
1047
|
|
|
1041
|
-
desc
|
|
1048
|
+
desc 'Print list of notes.'
|
|
1042
1049
|
task :notes do
|
|
1043
|
-
keywords = [
|
|
1050
|
+
keywords = ['TODO', 'FIXME', 'XXX']
|
|
1044
1051
|
keywords.each do | each |
|
|
1045
1052
|
system "find src unittests -name '*.c' | xargs grep -n #{ each }"
|
|
1046
1053
|
system "find ruby spec features -name '*.rb' | xargs grep -n #{ each }"
|
|
@@ -1048,8 +1055,4 @@ task :notes do
|
|
|
1048
1055
|
end
|
|
1049
1056
|
|
|
1050
1057
|
|
|
1051
|
-
|
|
1052
|
-
### mode: Ruby
|
|
1053
|
-
### coding: utf-8-unix
|
|
1054
|
-
### indent-tabs-mode: nil
|
|
1055
|
-
### End:
|
|
1058
|
+
Dir.glob('tasks/*.rake').each { |each| import each }
|