trema 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/ruby/trema/switch.c
CHANGED
data/ruby/trema/timers.rb
CHANGED
@@ -28,8 +28,8 @@ module Timers
|
|
28
28
|
module TimerMethods
|
29
29
|
lambda {
|
30
30
|
timer_event_handlers = {}
|
31
|
-
|
32
|
-
|
31
|
+
|
32
|
+
|
33
33
|
Kernel.send :define_method, :add_timer do | handler, interval, event_type |
|
34
34
|
timer_event_handlers[ handler ] = {
|
35
35
|
:interval => interval,
|
@@ -37,8 +37,8 @@ module Timers
|
|
37
37
|
:event_type => event_type
|
38
38
|
}
|
39
39
|
end
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
|
42
42
|
Kernel.send :define_method, :fire_event do
|
43
43
|
timer_event_handlers.each do | handler, data |
|
44
44
|
data[ :rest ] -= 1
|
@@ -51,38 +51,38 @@ module Timers
|
|
51
51
|
data[ :rest ] <= 0 && data[ :event_type ] == :oneshot
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
55
|
-
|
54
|
+
|
55
|
+
|
56
56
|
Kernel.send :define_method, :delete_timer do | handler |
|
57
57
|
timer_event_handlers.delete
|
58
58
|
end
|
59
59
|
}.call
|
60
60
|
|
61
|
-
|
61
|
+
|
62
62
|
def add_timer_event handler, interval, event_type
|
63
63
|
add_timer handler, interval, event_type
|
64
64
|
end
|
65
65
|
alias_method :timer_event, :add_timer_event
|
66
66
|
|
67
|
-
|
67
|
+
|
68
68
|
def delete_timer_event handler
|
69
|
-
delete_timer handler
|
69
|
+
delete_timer handler
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
|
73
73
|
# shortcut methods
|
74
74
|
def add_periodic_timer_event handler, interval
|
75
75
|
add_timer_event handler, interval, :periodic
|
76
76
|
end
|
77
77
|
alias_method :periodic_timer_event, :add_periodic_timer_event
|
78
78
|
|
79
|
-
|
79
|
+
|
80
80
|
def add_oneshot_timer_event handler, interval
|
81
81
|
add_timer_event handler, interval, :oneshot
|
82
82
|
end
|
83
83
|
alias_method :oneshot_timer_event, :add_oneshot_timer_event
|
84
|
-
|
85
|
-
|
84
|
+
|
85
|
+
|
86
86
|
def handle_timer_event
|
87
87
|
fire_event
|
88
88
|
end
|
data/ruby/trema/trema.c
CHANGED
@@ -58,7 +58,7 @@ Init_trema() {
|
|
58
58
|
rb_define_const( mTrema, "OFPC_FLOW_STATS", INT2NUM( OFPC_FLOW_STATS ) );
|
59
59
|
rb_define_const( mTrema, "OFPC_TABLE_STATS", INT2NUM( OFPC_TABLE_STATS ) );
|
60
60
|
rb_define_const( mTrema, "OFPC_PORT_STATS", INT2NUM( OFPC_PORT_STATS ) );
|
61
|
-
rb_define_const( mTrema, "OFPC_STP", INT2NUM( OFPC_STP) );
|
61
|
+
rb_define_const( mTrema, "OFPC_STP", INT2NUM( OFPC_STP ) );
|
62
62
|
rb_define_const( mTrema, "OFPC_RESERVED", INT2NUM( OFPC_RESERVED ) );
|
63
63
|
rb_define_const( mTrema, "OFPC_IP_REASM", INT2NUM( OFPC_IP_REASM ) );
|
64
64
|
rb_define_const( mTrema, "OFPC_QUEUE_STATS", INT2NUM( OFPC_QUEUE_STATS ) );
|
@@ -68,8 +68,8 @@ Init_trema() {
|
|
68
68
|
rb_define_const( mTrema, "OFPAT_SET_VLAN_VID", INT2NUM( OFPAT_SET_VLAN_VID ) );
|
69
69
|
rb_define_const( mTrema, "OFPAT_SET_VLAN_PCP", INT2NUM( OFPAT_SET_VLAN_PCP ) );
|
70
70
|
rb_define_const( mTrema, "OFPAT_STRIP_VLAN", INT2NUM( OFPAT_STRIP_VLAN ) );
|
71
|
-
rb_define_const( mTrema, "OFPAT_SET_DL_SRC", INT2NUM( OFPAT_SET_DL_SRC) );
|
72
|
-
rb_define_const( mTrema, "OFPAT_SET_DL_DST", INT2NUM( OFPAT_SET_DL_DST) );
|
71
|
+
rb_define_const( mTrema, "OFPAT_SET_DL_SRC", INT2NUM( OFPAT_SET_DL_SRC ) );
|
72
|
+
rb_define_const( mTrema, "OFPAT_SET_DL_DST", INT2NUM( OFPAT_SET_DL_DST ) );
|
73
73
|
rb_define_const( mTrema, "OFPAT_SET_NW_SRC", INT2NUM( OFPAT_SET_NW_SRC ) );
|
74
74
|
rb_define_const( mTrema, "OFPAT_SET_NW_DST", INT2NUM( OFPAT_SET_NW_DST ) );
|
75
75
|
rb_define_const( mTrema, "OFPAT_SET_NW_TOS", INT2NUM( OFPAT_SET_NW_TOS ) );
|
data/ruby/trema/tremashark.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# The controller class of tremashark.
|
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
|
@@ -24,7 +22,16 @@ require "trema/executables"
|
|
24
22
|
|
25
23
|
|
26
24
|
module Trema
|
25
|
+
#
|
26
|
+
# Represents an abstract instance to start the tremashark debugging program.
|
27
|
+
#
|
27
28
|
class Tremashark
|
29
|
+
#
|
30
|
+
# Runs the tremashark program as a daemon for debugging.
|
31
|
+
#
|
32
|
+
# @return [Boolean, Nil]
|
33
|
+
# a true or false tremashark exit status code or nil if failed to run.
|
34
|
+
#
|
28
35
|
def run
|
29
36
|
sh "#{ Executables.tremashark } --daemonize"
|
30
37
|
end
|
data/ruby/trema/util.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Common utility functions.
|
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
|
@@ -27,7 +25,16 @@ require "trema/process"
|
|
27
25
|
|
28
26
|
|
29
27
|
module Trema::Util
|
30
|
-
def
|
28
|
+
def sh cmd
|
29
|
+
ENV[ "TREMA_HOME" ] = Trema.home
|
30
|
+
puts cmd if $verbose
|
31
|
+
unless system( cmd )
|
32
|
+
raise "Command '#{ cmd }' failed!"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def assert_trema_is_built
|
31
38
|
unless Trema::Executables.compiled?
|
32
39
|
$stderr.puts <<-EOF
|
33
40
|
ERROR: Trema is not compiled yet!
|
@@ -40,15 +47,6 @@ EOF
|
|
40
47
|
end
|
41
48
|
|
42
49
|
|
43
|
-
def sh cmd
|
44
|
-
ENV[ "TREMA_HOME" ] = Trema.home
|
45
|
-
puts cmd if $verbose
|
46
|
-
unless system( cmd )
|
47
|
-
raise "Command '#{ cmd }' failed!"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
50
|
def cleanup session
|
53
51
|
# [FIXME] Use session.switch_manager
|
54
52
|
sm_pid = File.join( Trema.pid, "switch_manager.pid" )
|
@@ -67,17 +65,43 @@ EOF
|
|
67
65
|
session.links.each do | name, link |
|
68
66
|
link.delete!
|
69
67
|
end
|
68
|
+
session.netnss.each do | name, netns |
|
69
|
+
netns.shutdown!
|
70
|
+
end
|
70
71
|
|
71
72
|
Dir.glob( File.join Trema.pid, "*.pid" ).each do | each |
|
72
73
|
Trema::Process.read( each ).kill!
|
73
74
|
end
|
74
|
-
|
75
|
-
FileUtils.rm_f Trema::DSL::Context::PATH
|
76
75
|
end
|
77
76
|
|
78
77
|
|
79
78
|
def cleanup_current_session
|
80
|
-
|
79
|
+
begin
|
80
|
+
cleanup Trema::DSL::Context.load_current
|
81
|
+
ensure
|
82
|
+
FileUtils.rm_f Trema::DSL::Context::PATH
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
def find_app_by_name name
|
88
|
+
# [FIXME] Trema apps does not appear in context.apps. why?
|
89
|
+
pid_file = File.join( Trema.pid, "#{ name }.pid" )
|
90
|
+
if FileTest.exist?( pid_file )
|
91
|
+
Trema::Process.read( pid_file )
|
92
|
+
else
|
93
|
+
nil
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def find_switch_by_name name
|
99
|
+
Trema::DSL::Context.load_current.switches[ name ]
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
def find_host_by_name name
|
104
|
+
Trema::DSL::Context.load_current.hosts[ name ]
|
81
105
|
end
|
82
106
|
end
|
83
107
|
|
data/ruby/trema/vendor-action.rb
CHANGED
@@ -25,7 +25,12 @@ module Trema
|
|
25
25
|
# An action to set vendor specific extensions.
|
26
26
|
#
|
27
27
|
class VendorAction < Action
|
28
|
+
#
|
29
|
+
# @return [Array<Fixnum>] the value of attribute {#body} that represents
|
30
|
+
# binary data as an array of bytes.
|
31
|
+
#
|
28
32
|
attr_reader :body
|
33
|
+
# @return [Integer] the value of attribute {#vendor_id}
|
29
34
|
attr_reader :vendor_id
|
30
35
|
|
31
36
|
|
@@ -46,16 +51,16 @@ module Trema
|
|
46
51
|
# @raise [TypeError] if body is not an Array.
|
47
52
|
#
|
48
53
|
def initialize vendor_id, body = nil
|
49
|
-
|
54
|
+
unless vendor_id.is_a?( Integer )
|
50
55
|
raise TypeError, "Vendor ID must be an unsigned 32-bit integer"
|
51
56
|
end
|
52
|
-
|
57
|
+
unless vendor_id.unsigned_32bit?
|
53
58
|
raise ArgumentError, "Vendor ID must be an unsigned 32-bit integer"
|
54
59
|
end
|
55
60
|
if ( not body.nil? ) and ( not body.is_a?( Array ) )
|
56
61
|
raise TypeError, "Body must be an Array"
|
57
62
|
end
|
58
|
-
|
63
|
+
|
59
64
|
@vendor_id = vendor_id
|
60
65
|
@body = body
|
61
66
|
end
|
@@ -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
|
@@ -26,7 +24,7 @@ module Trema
|
|
26
24
|
FIELDS = %w(vendor_id)
|
27
25
|
FIELDS.each { |field| attr_reader field.intern }
|
28
26
|
|
29
|
-
|
27
|
+
|
30
28
|
# Vendor statistics reply.
|
31
29
|
# A user would not explicitly instantiate a {VendorStatsReply} object but would
|
32
30
|
# be created as a result of parsing the +OFPT_STATS_REPLY(OFPST_VENDOR)+
|
@@ -34,7 +32,7 @@ module Trema
|
|
34
32
|
#
|
35
33
|
# @overload initialize(otions={})
|
36
34
|
#
|
37
|
-
# @example
|
35
|
+
# @example
|
38
36
|
# VendorStatsReply.new(
|
39
37
|
# :vendor_id => 123
|
40
38
|
# )
|
@@ -45,8 +43,8 @@ module Trema
|
|
45
43
|
# @option options [Number] :vendor_id
|
46
44
|
# the specific vendor identifier.
|
47
45
|
#
|
48
|
-
# @return [VendorStatsReply]
|
49
|
-
# an object that encapsulates the OFPST_STATS_REPLY(
|
46
|
+
# @return [VendorStatsReply]
|
47
|
+
# an object that encapsulates the OFPST_STATS_REPLY(OFPST_VENDOR) OpenFlow message.
|
50
48
|
#
|
51
49
|
def initialize options
|
52
50
|
super FIELDS, options
|
data/ruby/trema/vendor.c
CHANGED
@@ -33,7 +33,7 @@ vendor_alloc( VALUE klass ) {
|
|
33
33
|
|
34
34
|
|
35
35
|
/*
|
36
|
-
* Creates a Vendor
|
36
|
+
* Creates a Vendor Request message. This message can be used
|
37
37
|
* to facilitate sending of vendor-defined arbitrary data.
|
38
38
|
*
|
39
39
|
* @overload initialize
|
data/ruby/trema/version.rb
CHANGED
@@ -20,56 +20,66 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
|
20
20
|
require "trema"
|
21
21
|
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
shared_examples_for "barrier request message" do
|
24
|
+
class BarrierRequestController < Controller; end
|
25
|
+
|
26
|
+
it "should be logged to the switch's log", :sudo => true do
|
27
|
+
network {
|
28
|
+
vswitch( "barrier-request" ) { datapath_id 0xabc }
|
29
|
+
}.run( BarrierRequestController ) {
|
30
|
+
controller( "BarrierRequestController" ).send_message( 0xabc, subject )
|
31
|
+
IO.read( File.join( Trema.log, "openflowd.barrier-request.log" ) ).should include( "OFPT_BARRIER_REQUEST" )
|
32
|
+
}
|
33
|
+
end
|
25
34
|
end
|
26
35
|
|
27
36
|
|
28
|
-
|
29
|
-
|
30
|
-
|
37
|
+
module Trema
|
38
|
+
describe BarrierRequest, ".new" do
|
39
|
+
it_should_behave_like "any Openflow message with default transaction ID"
|
40
|
+
it_should_behave_like "barrier request message"
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
describe BarrierRequest, ".new(nil)" do
|
45
|
+
subject { BarrierRequest.new( nil ) }
|
46
|
+
it_should_behave_like "any Openflow message with default transaction ID"
|
47
|
+
it_should_behave_like "barrier request message"
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
describe BarrierRequest, ".new(transaction_id)" do
|
52
|
+
subject { BarrierRequest.new( transaction_id ) }
|
53
|
+
it_should_behave_like "any Openflow message with transaction ID"
|
54
|
+
context "when sent to a switch" do
|
55
|
+
let( :transaction_id ) { 123 }
|
56
|
+
it_should_behave_like "barrier request message"
|
57
|
+
end
|
58
|
+
end
|
31
59
|
|
32
60
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
controller( "BarrierController" ).should_receive( :barrier_reply )
|
40
|
-
controller( "BarrierController" ).send_message( 0xabc, BarrierRequest.new )
|
41
|
-
sleep 2 # FIXME: wait to send_message
|
42
|
-
}
|
61
|
+
describe BarrierRequest, ".new(:transaction_id => value)" do
|
62
|
+
subject { BarrierRequest.new( :transaction_id => transaction_id ) }
|
63
|
+
it_should_behave_like "any Openflow message with transaction ID"
|
64
|
+
context "when sent to a switch" do
|
65
|
+
let( :transaction_id ) { 123 }
|
66
|
+
it_should_behave_like "barrier request message"
|
43
67
|
end
|
44
68
|
end
|
45
|
-
end
|
46
69
|
|
47
70
|
|
48
|
-
describe BarrierRequest, ".new(
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}.run( BarrierController ) {
|
55
|
-
controller( "BarrierController" ).should_receive( :barrier_reply ) do | datapath_id, message |
|
56
|
-
datapath_id.should == 0xabc
|
57
|
-
message.transaction_id.should == 1234
|
58
|
-
end
|
59
|
-
barrier_request = BarrierRequest.new( :transaction_id => 1234 )
|
60
|
-
controller( "BarrierController" ).send_message( 0xabc, barrier_request )
|
61
|
-
sleep 2 # FIXME: wait to send_message
|
62
|
-
}
|
71
|
+
describe BarrierRequest, ".new(:xid => value)" do
|
72
|
+
subject { BarrierRequest.new( :xid => xid ) }
|
73
|
+
it_should_behave_like "any Openflow message with xid"
|
74
|
+
context "when sent to a switch" do
|
75
|
+
let( :xid ) { 123 }
|
76
|
+
it_should_behave_like "barrier request message"
|
63
77
|
end
|
64
78
|
end
|
65
|
-
end
|
66
79
|
|
67
80
|
|
68
|
-
describe BarrierRequest,
|
69
|
-
|
70
|
-
expect {
|
71
|
-
BarrierRequest.new "INVALID_OPTION"
|
72
|
-
}.to raise_error( TypeError )
|
81
|
+
describe BarrierRequest, '.new("INVALID OPTION")', :nosudo => true do
|
82
|
+
it { expect { BarrierRequest.new "INVALID OPTION" }.to raise_error( TypeError ) }
|
73
83
|
end
|
74
84
|
end
|
75
85
|
|
@@ -1,6 +1,4 @@
|
|
1
1
|
#
|
2
|
-
# Author: Yasuhito Takamiya <yasuhito@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
|
@@ -47,7 +45,8 @@ module Trema
|
|
47
45
|
:links => {},
|
48
46
|
:hosts => {},
|
49
47
|
:switches => {},
|
50
|
-
:apps => {}
|
48
|
+
:apps => {},
|
49
|
+
:netnss => {}
|
51
50
|
)
|
52
51
|
|
53
52
|
Runner.new( context ).run
|
@@ -67,6 +66,7 @@ module Trema
|
|
67
66
|
:hosts => {},
|
68
67
|
:switches => {},
|
69
68
|
:apps => {},
|
69
|
+
:netnss => {},
|
70
70
|
:port => 6633
|
71
71
|
)
|
72
72
|
|
@@ -96,6 +96,7 @@ module Trema
|
|
96
96
|
:hosts => {},
|
97
97
|
:switches => {},
|
98
98
|
:apps => {},
|
99
|
+
:netnss => {},
|
99
100
|
:port => 6633
|
100
101
|
)
|
101
102
|
|
@@ -138,6 +139,7 @@ module Trema
|
|
138
139
|
:hosts => { "host0" => host0, "host1" => host1, "host2" => host2 },
|
139
140
|
:switches => {},
|
140
141
|
:apps => {},
|
142
|
+
:netnss => {},
|
141
143
|
:port => 6633
|
142
144
|
)
|
143
145
|
|
@@ -164,6 +166,7 @@ module Trema
|
|
164
166
|
:hosts => {},
|
165
167
|
:switches => { "switch0" => switch0, "switch1" => switch1, "switch 2" => switch2 },
|
166
168
|
:apps => {},
|
169
|
+
:netnss => {},
|
167
170
|
:port => 6633
|
168
171
|
)
|
169
172
|
|
@@ -194,6 +197,7 @@ module Trema
|
|
194
197
|
:links => {},
|
195
198
|
:hosts => {},
|
196
199
|
:switches => {},
|
200
|
+
:netnss => {},
|
197
201
|
:apps => apps
|
198
202
|
)
|
199
203
|
|
@@ -224,6 +228,7 @@ module Trema
|
|
224
228
|
:links => {},
|
225
229
|
:hosts => {},
|
226
230
|
:switches => {},
|
231
|
+
:netnss => {},
|
227
232
|
:apps => apps
|
228
233
|
)
|
229
234
|
|