trema 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -1
- data/Doxyfile +1 -1
- data/Gemfile +18 -6
- data/README.md +112 -5
- data/Rakefile +3 -1
- data/Rantfile +88 -1
- data/bin/trema +248 -0
- data/bin/trema-config +59 -0
- data/cruise.rb +1 -1
- data/features/example.dumper.feature +45 -65
- data/features/example.hello_trema.feature +21 -0
- data/features/example.learning_switch.feature +26 -28
- data/features/example.list_switches.feature +19 -33
- data/features/example.message.echo_reply.feature +10 -10
- data/features/example.message.echo_request.feature +2 -2
- data/features/example.message.features_request.feature +6 -5
- data/features/example.message.hello.feature +47 -13
- data/features/example.message.set_config.feature +4 -4
- data/features/example.message.vendor-action.feature +23 -0
- data/features/example.multi_learning_switch.feature +14 -42
- data/features/example.packet_in.feature +31 -0
- data/features/example.packetin_filter_config.feature +11 -7
- data/features/example.patch_panel.feature +29 -0
- data/features/example.repeater_hub.feature +43 -40
- data/features/example.switch_info.feature +51 -0
- data/features/example.switch_monitor.feature +24 -42
- data/features/packetin_filter.feature +28 -22
- data/features/step_definitions/misc_steps.rb +19 -8
- data/features/step_definitions/send_packets_steps.rb +1 -10
- data/features/step_definitions/stats_steps.rb +4 -4
- data/features/support/env.rb +2 -1
- data/features/support/hooks.rb +35 -2
- data/features/switch_manager.feature +18 -12
- data/features/trema-config.feature +26 -39
- data/features/trema.dump_flows.feature +26 -12
- data/features/trema.help.feature +26 -0
- data/features/trema.kill.feature +39 -41
- data/features/trema.killall.feature +23 -23
- data/features/trema.reset_stats.feature +50 -10
- data/features/trema.run.feature +28 -39
- data/features/trema.send_packets.feature +29 -40
- data/features/trema.show_stats.feature +30 -33
- data/features/trema.up.feature +33 -0
- data/features/trema.version.feature +9 -0
- data/ruby/extconf.rb +7 -0
- data/ruby/trema/aggregate-stats-reply.rb +3 -3
- data/ruby/trema/app.rb +5 -1
- data/ruby/trema/barrier-request.c +55 -30
- data/ruby/trema/cli.rb +8 -8
- data/ruby/trema/command.rb +1 -3
- data/ruby/trema/command/dump_flows.rb +5 -24
- data/ruby/trema/command/kill.rb +31 -36
- data/ruby/trema/command/killall.rb +1 -19
- data/{features/step_definitions/kill_steps.rb → ruby/trema/command/netns.rb} +13 -5
- data/ruby/trema/command/reset_stats.rb +3 -23
- data/ruby/trema/command/ruby.rb +2 -19
- data/ruby/trema/command/run.rb +6 -27
- data/ruby/trema/command/send_packets.rb +6 -90
- data/ruby/trema/command/show_stats.rb +21 -40
- data/ruby/trema/command/up.rb +5 -26
- data/ruby/trema/command/version.rb +1 -5
- data/ruby/trema/controller.c +14 -16
- data/ruby/trema/custom-switch.rb +56 -0
- data/ruby/trema/desc-stats-reply.rb +5 -5
- data/ruby/trema/dsl/configuration.rb +4 -0
- data/{features/step_definitions/up_steps.rb → ruby/trema/dsl/custom-switch.rb} +18 -4
- data/ruby/trema/dsl/netns.rb +78 -0
- data/ruby/trema/dsl/parser.rb +2 -0
- data/ruby/trema/dsl/runner.rb +8 -0
- data/ruby/trema/dsl/syntax.rb +18 -0
- data/ruby/trema/echo-reply.h +2 -2
- data/ruby/trema/echo-request.c +3 -5
- data/ruby/trema/enqueue.rb +2 -2
- data/ruby/trema/error.c +3 -3
- data/ruby/trema/executables.rb +26 -2
- data/ruby/trema/features-request.c +3 -5
- data/ruby/trema/flow-removed.c +6 -6
- data/ruby/trema/flow-stats-reply.rb +6 -8
- data/ruby/trema/flow.rb +12 -1
- data/ruby/trema/get-config-request.c +55 -28
- data/ruby/trema/hello.c +3 -5
- data/ruby/trema/host.rb +8 -0
- data/ruby/trema/list-switches-reply.c +1 -1
- data/ruby/trema/mac.rb +1 -1
- data/ruby/trema/match.c +15 -14
- data/ruby/trema/monkey-patch/module/deprecation.rb +0 -2
- data/ruby/trema/netns.rb +127 -0
- data/ruby/trema/ordered-hash.rb +5 -4
- data/ruby/trema/packet-in.c +136 -113
- data/ruby/trema/packet-queue.rb +9 -9
- data/ruby/trema/packetin-filter.rb +1 -1
- data/ruby/trema/phost.rb +16 -7
- data/ruby/trema/port-mod.c +6 -5
- data/ruby/trema/port-stats-reply.rb +2 -2
- data/ruby/trema/process.rb +29 -0
- data/ruby/trema/queue-stats-reply.rb +2 -4
- data/ruby/trema/send-out-port.rb +5 -3
- data/ruby/trema/set-eth-addr.rb +4 -0
- data/ruby/trema/set-ip-addr.rb +4 -2
- data/ruby/trema/set-ip-dst-addr.rb +2 -1
- data/ruby/trema/set-ip-src-addr.rb +2 -1
- data/ruby/trema/set-ip-tos.rb +3 -2
- data/ruby/trema/set-transport-port.rb +3 -2
- data/ruby/trema/set-vlan-priority.rb +3 -2
- data/ruby/trema/set-vlan-vid.rb +5 -4
- data/ruby/trema/shell/reset_stats.rb +2 -1
- data/ruby/trema/shell/run.rb +1 -1
- data/ruby/trema/shell/send_packets.rb +1 -1
- data/ruby/trema/shell/show_stats.rb +1 -1
- data/ruby/trema/stats-helper.rb +3 -3
- data/ruby/trema/stats-reply.c +26 -17
- data/ruby/trema/stats-request.c +39 -41
- data/ruby/trema/switch-daemon.rb +36 -31
- data/ruby/trema/switch.c +1 -1
- data/ruby/trema/table-stats-reply.rb +1 -1
- data/ruby/trema/timers.rb +13 -13
- data/ruby/trema/trema.c +3 -3
- data/ruby/trema/tremashark.rb +9 -2
- data/ruby/trema/util.rb +39 -15
- data/ruby/trema/vendor-action.rb +8 -3
- data/ruby/trema/vendor-stats-reply.rb +4 -6
- data/ruby/trema/vendor.c +1 -1
- data/ruby/trema/version.rb +1 -1
- data/spec/trema/barrier-request_spec.rb +47 -37
- data/spec/trema/controller_spec.rb +1 -0
- data/spec/trema/dsl/runner_spec.rb +8 -3
- data/spec/trema/dsl/vhost_spec.rb +8 -8
- data/spec/trema/echo-request_spec.rb +1 -0
- data/spec/trema/features-request_spec.rb +1 -0
- data/spec/trema/flow-removed_spec.rb +9 -9
- data/spec/trema/get-config-request_spec.rb +51 -39
- data/spec/trema/match_spec.rb +1 -1
- data/spec/trema/openflow-error_spec.rb +11 -11
- data/spec/trema/packet-out_spec.rb +5 -5
- data/spec/trema/queue-get-config-reply_spec.rb +1 -1
- data/spec/trema/queue-get-config-request_spec.rb +1 -1
- data/spec/trema/set-eth-dst-addr_spec.rb +1 -1
- data/spec/trema/set-eth-src-addr_spec.rb +1 -1
- data/spec/trema/set-ip-dst-addr_spec.rb +1 -0
- data/spec/trema/set-ip-src-addr_spec.rb +1 -0
- data/spec/trema/set-ip-tos_spec.rb +1 -0
- data/spec/trema/set-transport-dst-port_spec.rb +1 -0
- data/spec/trema/set-transport-src-port_spec.rb +1 -0
- data/spec/trema/set-vlan-priority_spec.rb +1 -0
- data/spec/trema/set-vlan-vid_spec.rb +2 -1
- data/spec/trema/stats-reply_spec.rb +38 -36
- data/spec/trema/stats-request_spec.rb +6 -6
- data/spec/trema/strip-vlan-header_spec.rb +1 -0
- data/spec/trema/util_spec.rb +3 -2
- data/spec/trema/vendor-action_spec.rb +9 -8
- data/src/examples/dumper/dumper.c +8 -6
- data/src/examples/dumper/dumper.rb +1 -1
- data/{features/step_definitions/killall_steps.rb → src/examples/hello_trema/hello-trema.rb} +6 -5
- data/src/examples/hello_trema/hello_trema.c +4 -4
- data/src/examples/learning_switch/learning_switch.c +1 -1
- data/src/examples/list_switches/list_switches.c +2 -2
- data/src/examples/match_compare/match-compare.rb +2 -2
- data/src/examples/multi_learning_switch/multi-learning-switch.rb +1 -1
- data/src/examples/multi_learning_switch/multi_learning_switch.c +3 -3
- data/src/examples/openflow_message/README +1 -1
- data/src/examples/openflow_message/echo-request.rb +1 -1
- data/src/examples/openflow_message/features_request.c +21 -21
- data/src/examples/openflow_message/hello.c +1 -3
- data/src/examples/openflow_message/hello.rb +9 -24
- data/src/examples/{hello_trema/hello_trema.rb → openflow_message/vendor-action.rb} +17 -7
- data/src/examples/openflow_message/vendor_action.c +105 -0
- data/src/examples/openflow_switch/hello_switch.c +81 -0
- data/src/examples/packet_in/packet-in.rb +9 -13
- data/src/examples/packetin_filter_config/packetin_filter_config.c +2 -2
- data/src/examples/patch_panel/network.conf +14 -0
- data/src/examples/patch_panel/patch-panel.conf +1 -0
- data/{features/step_definitions/show_stats_steps.rb → src/examples/patch_panel/patch-panel.rb} +29 -13
- data/src/examples/switch_info/{switch_info.rb → switch-info.rb} +2 -2
- data/src/examples/switch_info/switch_info.c +4 -4
- data/src/examples/switch_monitor/switch_monitor.c +3 -3
- data/src/examples/traffic_monitor/counter.c +9 -9
- data/src/examples/traffic_monitor/fdb.c +9 -9
- data/src/lib/arp.h +1 -1
- data/src/lib/buffer.c +4 -3
- data/src/lib/byteorder.c +31 -5
- data/src/lib/byteorder.h +2 -2
- data/src/lib/chibach.c +8 -6
- data/src/lib/daemon.c +29 -3
- data/src/lib/doubly_linked_list.c +6 -1
- data/src/lib/ether.c +1 -1
- data/src/lib/ether.h +1 -1
- data/src/lib/event_handler.c +3 -3
- data/src/lib/hash_table.c +1 -1
- data/src/lib/linked_list.c +50 -2
- data/src/lib/linked_list.h +2 -2
- data/src/lib/log.c +122 -22
- data/src/lib/log.h +13 -9
- data/src/lib/management_interface.c +361 -0
- data/src/lib/management_interface.h +42 -0
- data/src/lib/management_service_interface.c +104 -0
- data/src/lib/management_service_interface.h +136 -0
- data/src/lib/match_table.c +5 -5
- data/src/lib/message_queue.c +5 -3
- data/src/lib/message_queue.h +1 -1
- data/src/lib/messenger.c +73 -39
- data/src/lib/messenger.h +3 -2
- data/src/lib/openflow_application_interface.c +17 -17
- data/src/lib/openflow_message.c +175 -23
- data/src/lib/openflow_message.h +2 -1
- data/src/lib/openflow_switch_interface.c +12 -12
- data/src/lib/packet_parser.c +11 -32
- data/src/lib/packetin_filter_interface.c +5 -5
- data/src/lib/persistent_storage.c +7 -7
- data/src/lib/secure_channel.c +6 -6
- data/src/lib/secure_channel.h +1 -1
- data/src/lib/stat.c +54 -17
- data/src/lib/stat.h +9 -0
- data/src/lib/timer.c +11 -10
- data/src/lib/trema.c +38 -9
- data/src/lib/trema.h +1 -0
- data/src/lib/trema_private.h +6 -0
- data/src/lib/trema_wrapper.c +4 -4
- data/src/lib/trema_wrapper.h +10 -10
- data/src/lib/utility.c +6 -6
- data/src/management/application.c +224 -0
- data/src/management/echo.c +185 -0
- data/src/management/set_logging_level.c +153 -0
- data/src/management/show_stats.c +150 -0
- data/src/management/trema_manager +184 -0
- data/src/packetin_filter/packetin_filter.c +31 -29
- data/src/switch_manager/cookie_table.c +7 -7
- data/src/switch_manager/dpid_table.c +3 -3
- data/src/switch_manager/dpid_table.h +0 -1
- data/src/switch_manager/management_interface.h +0 -1
- data/src/switch_manager/ofpmsg_recv.c +3 -3
- data/src/switch_manager/ofpmsg_recv.h +0 -1
- data/src/switch_manager/ofpmsg_send.c +2 -2
- data/src/switch_manager/ofpmsg_send.h +0 -1
- data/src/switch_manager/secure_channel_listener.c +2 -2
- data/src/switch_manager/secure_channel_receiver.c +2 -2
- data/src/switch_manager/secure_channel_receiver.h +0 -1
- data/src/switch_manager/secure_channel_sender.c +8 -1
- data/src/switch_manager/service_interface.c +5 -4
- data/src/switch_manager/switch.c +79 -53
- data/src/switch_manager/switch_manager.c +24 -22
- data/src/switch_manager/xid_table.c +6 -6
- data/src/switch_manager/xid_table.h +0 -1
- data/src/tremashark/README +4 -3
- data/src/tremashark/packet_capture.c +11 -9
- data/src/tremashark/pcap_queue.c +2 -2
- data/src/tremashark/pcap_queue.h +2 -2
- data/src/tremashark/plugin/packet-trema/Makefile +1 -1
- data/src/tremashark/plugin/packet-trema/Makefile.common +1 -1
- data/src/tremashark/plugin/packet-trema/packet-trema.c +50 -37
- data/src/tremashark/queue.c +5 -4
- data/src/tremashark/queue.h +1 -1
- data/src/tremashark/stdin_relay.c +10 -8
- data/src/tremashark/syslog_relay.c +14 -12
- data/src/tremashark/tremashark.c +15 -18
- data/trema +2 -96
- data/trema-config +2 -52
- data/trema.gemspec +12 -1
- data/unittests/cmockery_trema.h +14 -13
- data/unittests/lib/buffer_test.c +1 -1
- data/unittests/lib/byteorder_test.c +108 -25
- data/unittests/lib/daemon_test.c +141 -5
- data/unittests/lib/doubly_linked_list_test.c +5 -1
- data/unittests/lib/ether_test.c +4 -4
- data/unittests/lib/hash_table_test.c +5 -3
- data/unittests/lib/linked_list_test.c +82 -4
- data/unittests/lib/log_test.c +96 -5
- data/unittests/lib/management_interface_test.c +240 -0
- data/unittests/lib/management_service_interface_test.c +319 -0
- data/unittests/lib/message_queue_test.c +6 -2
- data/unittests/lib/messenger_test.c +167 -2
- data/unittests/lib/openflow_application_interface_test.c +16 -22
- data/unittests/lib/openflow_message_test.c +721 -24
- data/unittests/lib/packet_info_test.c +2 -2
- data/unittests/lib/packet_parser_test.c +15 -16
- data/unittests/lib/packetin_filter_interface_test.c +6 -6
- data/unittests/lib/persistent_storage_test.c +11 -11
- data/unittests/lib/stat_test.c +151 -7
- data/unittests/lib/timer_test.c +1 -1
- data/unittests/lib/trema_private_test.c +2 -2
- data/unittests/lib/trema_test.c +40 -12
- data/unittests/lib/utility_test.c +3 -3
- data/unittests/lib/wrapper_test.c +3 -3
- data/unittests/packetin_filter/packetin_filter_test.c +12 -11
- data/unittests/switch_manager/switch_manager_test.c +29 -22
- metadata +99 -20
- data/features/step_definitions/log_steps.rb +0 -90
- data/features/step_definitions/run_steps.rb +0 -91
- data/features/trema.feature +0 -27
- data/features/tutorial.hello_trema.feature +0 -27
- data/features/tutorial.packet_in.feature +0 -47
- data/features/tutorial.switch_info.feature +0 -55
- data/ruby/trema/command/usage.rb +0 -63
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
Feature:
|
|
2
|
-
|
|
3
|
-
As a Trema user
|
|
4
|
-
I want to get packet stats with `trema show_stats' command
|
|
5
|
-
So that I can easily debug trema applications
|
|
1
|
+
Feature: trema show_stats command
|
|
6
2
|
|
|
3
|
+
In order to get the stats of sent/received packets
|
|
4
|
+
As a developer using Trema
|
|
5
|
+
I want to execute "trema show_stats" command
|
|
7
6
|
|
|
8
7
|
Background:
|
|
9
|
-
Given
|
|
8
|
+
Given a file named "learning_switch.conf" with:
|
|
10
9
|
"""
|
|
11
|
-
vswitch { datapath_id
|
|
10
|
+
vswitch { datapath_id 0xabc }
|
|
12
11
|
|
|
13
12
|
vhost("host1") { ip "192.168.0.1" }
|
|
14
13
|
vhost("host2") { ip "192.168.0.2" }
|
|
@@ -16,11 +15,13 @@ Feature: show network stats with `trema show_stats' command
|
|
|
16
15
|
link "0xabc", "host1"
|
|
17
16
|
link "0xabc", "host2"
|
|
18
17
|
"""
|
|
18
|
+
And I run `trema run ../../src/examples/learning_switch/learning-switch.rb -c learning_switch.conf -d`
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
Scenario: show_stats
|
|
22
|
-
When I
|
|
23
|
-
|
|
20
|
+
@slow_process
|
|
21
|
+
Scenario: show_stats hostname
|
|
22
|
+
When I run `trema send_packets --source host1 --dest host2`
|
|
23
|
+
And I run `trema show_stats host1`
|
|
24
|
+
Then the output should contain:
|
|
24
25
|
"""
|
|
25
26
|
Sent packets:
|
|
26
27
|
ip_dst,tp_dst,ip_src,tp_src,n_pkts,n_octets
|
|
@@ -28,40 +29,36 @@ Feature: show network stats with `trema show_stats' command
|
|
|
28
29
|
Received packets:
|
|
29
30
|
"""
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
Scenario: show_stats --tx
|
|
33
|
-
When I
|
|
34
|
-
|
|
32
|
+
@slow_process
|
|
33
|
+
Scenario: show_stats hostname --tx
|
|
34
|
+
When I run `trema send_packets --source host1 --dest host2`
|
|
35
|
+
And I run `trema show_stats host1 --tx`
|
|
36
|
+
Then the output should contain:
|
|
35
37
|
"""
|
|
36
38
|
ip_dst,tp_dst,ip_src,tp_src,n_pkts,n_octets
|
|
37
39
|
192.168.0.2,1,192.168.0.1,1,1,50
|
|
38
40
|
"""
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
Scenario: show_stats --rx
|
|
42
|
-
When I
|
|
43
|
-
|
|
42
|
+
@slow_process
|
|
43
|
+
Scenario: show_stats hostname --rx
|
|
44
|
+
When I run `trema send_packets --source host1 --dest host2`
|
|
45
|
+
And I run `trema show_stats host2 --rx`
|
|
46
|
+
Then the output should contain:
|
|
44
47
|
"""
|
|
45
48
|
ip_dst,tp_dst,ip_src,tp_src,n_pkts,n_octets
|
|
46
49
|
192.168.0.2,1,192.168.0.1,1,1,50
|
|
47
50
|
"""
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Then
|
|
52
|
+
Scenario: argument error
|
|
53
|
+
Then I run `trema show_stats`
|
|
54
|
+
Then the output should contain:
|
|
52
55
|
"""
|
|
53
|
-
|
|
56
|
+
host is required
|
|
54
57
|
"""
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Then the output should be:
|
|
59
|
+
Scenario: unknown host error
|
|
60
|
+
Then I run `trema show_stats NO_SUCH_HOST`
|
|
61
|
+
Then the output should contain:
|
|
60
62
|
"""
|
|
61
|
-
|
|
62
|
-
-t, --tx
|
|
63
|
-
-r, --rx
|
|
64
|
-
|
|
65
|
-
-h, --help
|
|
66
|
-
-v, --verbose
|
|
63
|
+
unknown host: NO_SUCH_HOST
|
|
67
64
|
"""
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Feature: trema up command
|
|
2
|
+
|
|
3
|
+
In order to restart killed processes
|
|
4
|
+
As a developer using Trema
|
|
5
|
+
I want to execute "trema up" command
|
|
6
|
+
|
|
7
|
+
Background:
|
|
8
|
+
Given a file named "switch_monitor.conf" with:
|
|
9
|
+
"""
|
|
10
|
+
vswitch { datapath_id 0x1 }
|
|
11
|
+
vswitch { datapath_id 0x2 }
|
|
12
|
+
vswitch { datapath_id 0x3 }
|
|
13
|
+
|
|
14
|
+
vhost "host1"
|
|
15
|
+
vhost "host2"
|
|
16
|
+
vhost "host3"
|
|
17
|
+
|
|
18
|
+
link "0x1", "host1"
|
|
19
|
+
link "0x2", "host2"
|
|
20
|
+
link "0x3", "host3"
|
|
21
|
+
"""
|
|
22
|
+
And I successfully run `trema run ../../src/examples/switch_monitor/switch-monitor.rb -c switch_monitor.conf -d`
|
|
23
|
+
And I run `trema kill 0x1 0x2 0x3`
|
|
24
|
+
And I run `trema kill host1 host2 host3`
|
|
25
|
+
|
|
26
|
+
@slow_process
|
|
27
|
+
Scenario: up a switch
|
|
28
|
+
When I run `trema up 0x1`
|
|
29
|
+
Then the vswitch "0x1" is running
|
|
30
|
+
|
|
31
|
+
@wip
|
|
32
|
+
Scenario: up a host
|
|
33
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Feature: trema version command
|
|
2
|
+
|
|
3
|
+
In order to know the current version of Trema
|
|
4
|
+
As a developer using Trema
|
|
5
|
+
I want to execute "trema version" command
|
|
6
|
+
|
|
7
|
+
Scenario: trema version
|
|
8
|
+
When I run `trema version`
|
|
9
|
+
Then the output should match /trema version \d+\.\d+.\d+/
|
data/ruby/extconf.rb
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
18
|
#
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
require "trema/stats-helper"
|
|
22
22
|
|
|
23
23
|
|
|
@@ -34,14 +34,14 @@ module Trema
|
|
|
34
34
|
#
|
|
35
35
|
# @overload initialize(options={})
|
|
36
36
|
#
|
|
37
|
-
# @example
|
|
37
|
+
# @example
|
|
38
38
|
# AggregateStatsReply.new(
|
|
39
39
|
# :packet_count => 10,
|
|
40
40
|
# :byte_count => 640,
|
|
41
41
|
# :flow_count => 2
|
|
42
42
|
# )
|
|
43
43
|
#
|
|
44
|
-
# @param [Hash] options
|
|
44
|
+
# @param [Hash] options
|
|
45
45
|
# the options to create this instance with.
|
|
46
46
|
#
|
|
47
47
|
# @option options [Number] :packet_count
|
data/ruby/trema/app.rb
CHANGED
|
@@ -30,6 +30,10 @@ module Trema
|
|
|
30
30
|
include Trema::Daemon
|
|
31
31
|
|
|
32
32
|
|
|
33
|
+
#
|
|
34
|
+
# @return [Trema::DSL::Stanza] a map of key-value pair settings
|
|
35
|
+
# for trema's dsl run{} syntax.
|
|
36
|
+
#
|
|
33
37
|
attr_reader :stanza
|
|
34
38
|
|
|
35
39
|
|
|
@@ -37,7 +41,7 @@ module Trema
|
|
|
37
41
|
|
|
38
42
|
|
|
39
43
|
#
|
|
40
|
-
# Creates a new Trema application from {Trema::DSL::
|
|
44
|
+
# Creates a new Trema application from {Trema::DSL::Run}
|
|
41
45
|
#
|
|
42
46
|
# @example
|
|
43
47
|
# app = Trema::App.new( stanza )
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
|
3
|
-
*
|
|
4
2
|
* Copyright (C) 2008-2012 NEC Corporation
|
|
5
3
|
*
|
|
6
4
|
* This program is free software; you can redistribute it and/or modify
|
|
@@ -18,8 +16,7 @@
|
|
|
18
16
|
*/
|
|
19
17
|
|
|
20
18
|
|
|
21
|
-
#include "trema.h"
|
|
22
|
-
#include "ruby.h"
|
|
19
|
+
#include "trema-ruby-utils.h"
|
|
23
20
|
|
|
24
21
|
|
|
25
22
|
extern VALUE mTrema;
|
|
@@ -37,42 +34,73 @@ barrier_request_alloc( VALUE klass ) {
|
|
|
37
34
|
* A barrier request message could be sent to ensure that an operation
|
|
38
35
|
* completed successfully signaled with the reception of a barrier reply message.
|
|
39
36
|
*
|
|
40
|
-
* @overload initialize(
|
|
41
|
-
* @example
|
|
37
|
+
* @overload initialize()
|
|
38
|
+
* @example
|
|
42
39
|
* BarrierRequest.new
|
|
43
|
-
* BarrierRequest.new( :transaction_id => 123 )
|
|
44
40
|
*
|
|
41
|
+
* @overload initialize(transaction_id)
|
|
42
|
+
* @example
|
|
43
|
+
* BarrierRequest.new( 123 )
|
|
44
|
+
* @param [Integer] transaction_id
|
|
45
|
+
* An unsigned 32-bit integer number associated with this message.
|
|
46
|
+
*
|
|
47
|
+
* @overload initialize(options)
|
|
48
|
+
* @example
|
|
49
|
+
* BarrierRequest.new( :xid => 123 )
|
|
50
|
+
* BarrierRequest.new( :transaction_id => 123 )
|
|
45
51
|
* @param [Hash] options
|
|
46
52
|
* the options to create a message with.
|
|
47
|
-
*
|
|
53
|
+
* @option options [Number] :xid an alias to transaction_id.
|
|
48
54
|
* @option options [Number] :transaction_id
|
|
49
|
-
*
|
|
55
|
+
* An unsigned 32-bit integer number associated with this message.
|
|
50
56
|
* If not specified, an auto-generated value is set.
|
|
51
57
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* an object that encapsulates the +OPFT_BARRIER_REQUEST+ OpenFlow message.
|
|
58
|
+
* @raise [ArgumentError] if transaction ID is not an unsigned 32-bit integer.
|
|
59
|
+
* @raise [TypeError] if argument is not a Integer or a Hash.
|
|
60
|
+
* @return [BarrierRequest]
|
|
61
|
+
* an object that encapsulates the +OPFT_BARRIER_REQUEST+ OpenFlow message.
|
|
57
62
|
*/
|
|
58
63
|
static VALUE
|
|
59
64
|
barrier_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
60
|
-
buffer *barrier_request;
|
|
65
|
+
buffer *barrier_request = NULL;
|
|
61
66
|
Data_Get_Struct( self, buffer, barrier_request );
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
VALUE options = Qnil;
|
|
68
|
+
|
|
69
|
+
if ( rb_scan_args( argc, argv, "01", &options ) == 0 ) {
|
|
70
|
+
set_xid( barrier_request, get_transaction_id() );
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
if ( options == Qnil ) {
|
|
74
|
+
set_xid( barrier_request, get_transaction_id() );
|
|
75
|
+
}
|
|
76
|
+
else if ( rb_obj_is_kind_of( options, rb_cInteger ) == Qtrue ) {
|
|
77
|
+
validate_xid( options );
|
|
78
|
+
set_xid( barrier_request, ( uint32_t ) NUM2UINT( options ) );
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
Check_Type( options, T_HASH );
|
|
82
|
+
VALUE tmp = Qnil;
|
|
83
|
+
VALUE xid = Qnil;
|
|
84
|
+
|
|
85
|
+
tmp = rb_hash_aref( options, ID2SYM( rb_intern( "transaction_id" ) ) );
|
|
86
|
+
if ( tmp != Qnil ) {
|
|
87
|
+
xid = tmp;
|
|
88
|
+
}
|
|
89
|
+
tmp = rb_hash_aref( options, ID2SYM( rb_intern( "xid" ) ) );
|
|
90
|
+
if ( tmp != Qnil ) {
|
|
91
|
+
xid = tmp;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if ( xid != Qnil ) {
|
|
95
|
+
validate_xid( xid );
|
|
96
|
+
set_xid( barrier_request, ( uint32_t ) NUM2UINT( xid ) );
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
set_xid( barrier_request, get_transaction_id() );
|
|
71
100
|
}
|
|
72
|
-
xid = ( uint32_t ) NUM2UINT( xid_ruby );
|
|
73
101
|
}
|
|
74
102
|
}
|
|
75
|
-
|
|
103
|
+
|
|
76
104
|
return self;
|
|
77
105
|
}
|
|
78
106
|
|
|
@@ -84,10 +112,7 @@ barrier_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
84
112
|
*/
|
|
85
113
|
static VALUE
|
|
86
114
|
barrier_request_transaction_id( VALUE self ) {
|
|
87
|
-
|
|
88
|
-
Data_Get_Struct( self, buffer, barrier_request );
|
|
89
|
-
uint32_t xid = ntohl( ( ( struct ofp_header * ) ( barrier_request->data ) )->xid );
|
|
90
|
-
return UINT2NUM( xid );
|
|
115
|
+
return get_xid( self );
|
|
91
116
|
}
|
|
92
117
|
|
|
93
118
|
|
data/ruby/trema/cli.rb
CHANGED
|
@@ -28,7 +28,7 @@ module Trema
|
|
|
28
28
|
class Packet
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
attr_reader :ip_dst
|
|
33
33
|
attr_reader :tp_dst
|
|
34
34
|
attr_reader :ip_src
|
|
@@ -36,7 +36,7 @@ module Trema
|
|
|
36
36
|
attr_reader :n_pkts
|
|
37
37
|
attr_reader :n_octets
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
def initialize ip_dst, tp_dst, ip_src, tp_src, n_pkts, n_octets
|
|
41
41
|
@ip_dst = ip_dst
|
|
42
42
|
@tp_dst = tp_dst.to_i
|
|
@@ -71,7 +71,7 @@ module Trema
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
sh( "#{ Executables.cli } -i #{ @host.interface } send_packets " +
|
|
74
|
-
"--ip_src #{ @host.ip } --ip_dst #{ dest.ip } " +
|
|
74
|
+
"--ip_src #{ @host.ip } --ip_dst #{ dest.ip } " +
|
|
75
75
|
send_packets_options( options ) )
|
|
76
76
|
end
|
|
77
77
|
|
|
@@ -84,12 +84,12 @@ module Trema
|
|
|
84
84
|
def show_rx_stats
|
|
85
85
|
puts stats( :rx )
|
|
86
86
|
end
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
|
|
89
89
|
def tx_stats
|
|
90
90
|
stat = stats( :tx ).split( "\n" )[ 1 ]
|
|
91
91
|
if stat
|
|
92
|
-
Trema::Stats.new *stat.split( "," )
|
|
92
|
+
Trema::Stats.new *stat.split( "," )
|
|
93
93
|
else
|
|
94
94
|
nil
|
|
95
95
|
end
|
|
@@ -99,7 +99,7 @@ module Trema
|
|
|
99
99
|
def rx_stats
|
|
100
100
|
stat = stats( :rx ).split( "\n" )[ 1 ]
|
|
101
101
|
if stat
|
|
102
|
-
Trema::Stats.new *stat.split( "," )
|
|
102
|
+
Trema::Stats.new *stat.split( "," )
|
|
103
103
|
else
|
|
104
104
|
Trema::Stats.new nil, nil, nil, nil, 0, 0
|
|
105
105
|
end
|
|
@@ -115,7 +115,7 @@ module Trema
|
|
|
115
115
|
def add_arp_entry other
|
|
116
116
|
sh "sudo #{ Executables.cli } -i #{ @host.interface } add_arp_entry --ip_addr #{ other.ip } --mac_addr #{ other.mac }"
|
|
117
117
|
end
|
|
118
|
-
|
|
118
|
+
|
|
119
119
|
|
|
120
120
|
def set_ip_and_mac_address
|
|
121
121
|
sh "sudo #{ Executables.cli } -i #{ @host.interface } set_host_addr --ip_addr #{ @host.ip } --ip_mask #{ @host.netmask } --mac_addr #{ @host.mac }"
|
|
@@ -125,7 +125,7 @@ module Trema
|
|
|
125
125
|
def enable_promisc
|
|
126
126
|
sh "sudo #{ Executables.cli } -i #{ @host.interface } enable_promisc"
|
|
127
127
|
end
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
|
|
130
130
|
################################################################################
|
|
131
131
|
private
|
data/ruby/trema/command.rb
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
#
|
|
2
2
|
# Trema sub-commands.
|
|
3
3
|
#
|
|
4
|
-
# Author: Yasuhito Takamiya <yasuhito@gmail.com>
|
|
5
|
-
#
|
|
6
4
|
# Copyright (C) 2008-2012 NEC Corporation
|
|
7
5
|
#
|
|
8
6
|
# This program is free software; you can redistribute it and/or modify
|
|
@@ -23,6 +21,7 @@
|
|
|
23
21
|
require "trema/command/dump_flows"
|
|
24
22
|
require "trema/command/kill"
|
|
25
23
|
require "trema/command/killall"
|
|
24
|
+
require "trema/command/netns"
|
|
26
25
|
require "trema/command/reset_stats"
|
|
27
26
|
require "trema/command/ruby"
|
|
28
27
|
require "trema/command/run"
|
|
@@ -30,7 +29,6 @@ require "trema/command/send_packets"
|
|
|
30
29
|
require "trema/command/shell"
|
|
31
30
|
require "trema/command/show_stats"
|
|
32
31
|
require "trema/command/up"
|
|
33
|
-
require "trema/command/usage"
|
|
34
32
|
require "trema/command/version"
|
|
35
33
|
|
|
36
34
|
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
#
|
|
2
|
-
# trema dump_flows command.
|
|
3
|
-
#
|
|
4
|
-
# Author: Yasuhito Takamiya <yasuhito@gmail.com>
|
|
5
|
-
#
|
|
6
2
|
# Copyright (C) 2008-2012 NEC Corporation
|
|
7
3
|
#
|
|
8
4
|
# This program is free software; you can redistribute it and/or modify
|
|
@@ -20,8 +16,6 @@
|
|
|
20
16
|
#
|
|
21
17
|
|
|
22
18
|
|
|
23
|
-
require "optparse"
|
|
24
|
-
require "trema/dsl"
|
|
25
19
|
require "trema/ofctl"
|
|
26
20
|
require "trema/util"
|
|
27
21
|
|
|
@@ -31,25 +25,12 @@ module Trema
|
|
|
31
25
|
include Trema::Util
|
|
32
26
|
|
|
33
27
|
|
|
34
|
-
def
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
options = OptionParser.new
|
|
40
|
-
options.banner = "Usage: trema dump_flows SWITCH [OPTIONS ...]"
|
|
41
|
-
|
|
42
|
-
options.on( "-h", "--help" ) do
|
|
43
|
-
puts options.to_s
|
|
44
|
-
exit 0
|
|
45
|
-
end
|
|
46
|
-
options.on( "-v", "--verbose" ) do
|
|
47
|
-
$verbose = true
|
|
28
|
+
def trema_dump_flows switches
|
|
29
|
+
switches.each do | each |
|
|
30
|
+
switch = find_switch_by_name( each )
|
|
31
|
+
exit_now! "No switch named `#{ each }` found!" if switch.nil?
|
|
32
|
+
puts Trema::Ofctl.new.dump_flows( switch )
|
|
48
33
|
end
|
|
49
|
-
|
|
50
|
-
options.parse! ARGV
|
|
51
|
-
|
|
52
|
-
puts Trema::Ofctl.new.dump_flows( switch )
|
|
53
34
|
end
|
|
54
35
|
end
|
|
55
36
|
end
|