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
|
@@ -26,7 +26,7 @@ require "trema/dsl"
|
|
|
26
26
|
module Trema
|
|
27
27
|
module Shell
|
|
28
28
|
def show_stats host_name, option
|
|
29
|
-
|
|
29
|
+
assert_trema_is_built
|
|
30
30
|
|
|
31
31
|
raise "Host '#{ host_name }' is not defined." if Host[ host_name ].nil?
|
|
32
32
|
raise "Host '#{ host_name }' is not connected to any link." if Host[ host_name ].interface.nil?
|
data/ruby/trema/stats-helper.rb
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
module Trema
|
|
22
22
|
class StatsHelper
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
# Invoked by each StatsReply subclass to assign their instance attributes
|
|
24
|
+
|
|
25
|
+
# Invoked by each StatsReply subclass to assign their instance attributes
|
|
26
26
|
# to a value.
|
|
27
27
|
#
|
|
28
28
|
# @overload initialize(fields, options={})
|
|
@@ -41,7 +41,7 @@ module Trema
|
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
#
|
|
46
46
|
# @return [String]
|
|
47
47
|
# an alphabetically sorted text of attribute name/value pairs.
|
data/ruby/trema/stats-reply.c
CHANGED
|
@@ -120,17 +120,17 @@ stats_reply_flags( VALUE self ) {
|
|
|
120
120
|
/*
|
|
121
121
|
* A list of reply type objects for this message.
|
|
122
122
|
*
|
|
123
|
-
* @return [Array<FlowStatsReply>]
|
|
123
|
+
* @return [Array<FlowStatsReply>]
|
|
124
124
|
* an array of {FlowStatsReply} objects if type is +OFPST_FLOW+.
|
|
125
|
-
* @return [Array<TableStatsReply>]
|
|
125
|
+
* @return [Array<TableStatsReply>]
|
|
126
126
|
* an array of {TableStatsReply} objects if type is +OFPST_TABLE+.
|
|
127
|
-
* @return [AggregateStatsReply]
|
|
127
|
+
* @return [AggregateStatsReply]
|
|
128
128
|
* a {AggregateStatsReply} object if type is +OFPST_AGGREGATE+.
|
|
129
|
-
* @return [Array<PortStatsReply>]
|
|
129
|
+
* @return [Array<PortStatsReply>]
|
|
130
130
|
* an array of {PortStatsReply} objects if type is +OFPST_PORT+.
|
|
131
|
-
* @return [Array<QueueStatsReply>]
|
|
131
|
+
* @return [Array<QueueStatsReply>]
|
|
132
132
|
* an array of {QueueStatsReply} objects if type is +OFPST_QUEUE+.
|
|
133
|
-
* @return [VendorStatsReply]
|
|
133
|
+
* @return [VendorStatsReply]
|
|
134
134
|
* a {VendorStatsReply} object if type is +OFPST_VENDOR+.
|
|
135
135
|
*/
|
|
136
136
|
static VALUE
|
|
@@ -149,6 +149,13 @@ Init_stats_reply() {
|
|
|
149
149
|
rb_require( "trema/queue-stats-reply" );
|
|
150
150
|
rb_require( "trema/vendor-stats-reply" );
|
|
151
151
|
cStatsReply = rb_define_class_under( mTrema, "StatsReply", rb_cObject );
|
|
152
|
+
rb_define_const( cStatsReply, "OFPST_DESC", INT2NUM( OFPST_DESC ) );
|
|
153
|
+
rb_define_const( cStatsReply, "OFPST_FLOW", INT2NUM( OFPST_FLOW ) );
|
|
154
|
+
rb_define_const( cStatsReply, "OFPST_AGGREGATE", INT2NUM( OFPST_AGGREGATE ) );
|
|
155
|
+
rb_define_const( cStatsReply, "OFPST_TABLE", INT2NUM( OFPST_TABLE ) );
|
|
156
|
+
rb_define_const( cStatsReply, "OFPST_PORT", INT2NUM( OFPST_PORT ) );
|
|
157
|
+
rb_define_const( cStatsReply, "OFPST_QUEUE", INT2NUM( OFPST_QUEUE ) );
|
|
158
|
+
rb_define_const( cStatsReply, "OFPST_VENDOR", INT2NUM( OFPST_VENDOR ) );
|
|
152
159
|
rb_define_method( cStatsReply, "initialize", stats_reply_init, 1 );
|
|
153
160
|
rb_define_method( cStatsReply, "datapath_id", stats_reply_datapath_id, 0 );
|
|
154
161
|
rb_define_method( cStatsReply, "transaction_id", stats_reply_transaction_id, 0 );
|
|
@@ -203,7 +210,8 @@ get_action( const struct ofp_action_header *ah ) {
|
|
|
203
210
|
if ( ah->type == OFPAT_SET_DL_SRC ) {
|
|
204
211
|
rb_hash_aset( options, ID2SYM( rb_intern( "dl_src" ) ), dl_addr );
|
|
205
212
|
action = rb_funcall( rb_eval_string( "Trema::ActionSetDlSrc" ), rb_intern( "new" ), 1, options );
|
|
206
|
-
}
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
207
215
|
rb_hash_aset( options, ID2SYM( rb_intern( "dl_dst" ) ), dl_addr );
|
|
208
216
|
action = rb_funcall( rb_eval_string( "Trema::ActionSetDlDst" ), rb_intern( "new" ), 1, options );
|
|
209
217
|
}
|
|
@@ -219,7 +227,8 @@ get_action( const struct ofp_action_header *ah ) {
|
|
|
219
227
|
if ( ah->type == OFPAT_SET_NW_SRC ) {
|
|
220
228
|
rb_hash_aset( options, ID2SYM( rb_intern( "nw_src" ) ), nw_addr );
|
|
221
229
|
action = rb_funcall( rb_eval_string( "Trema::ActionSetNwSrc" ), rb_intern( "new" ), 1, options );
|
|
222
|
-
}
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
223
232
|
rb_hash_aset( options, ID2SYM( rb_intern( "nw_dst" ) ), nw_addr );
|
|
224
233
|
action = rb_funcall( rb_eval_string( "Trema::ActionSetNwDst" ), rb_intern( "new" ), 1, options );
|
|
225
234
|
}
|
|
@@ -305,15 +314,15 @@ handle_stats_reply(
|
|
|
305
314
|
VALUE desc_stats_arr = rb_ary_new();
|
|
306
315
|
VALUE desc_stats_reply;
|
|
307
316
|
|
|
308
|
-
rb_hash_aset( options, ID2SYM( rb_intern( "mfr_desc" ) ),
|
|
317
|
+
rb_hash_aset( options, ID2SYM( rb_intern( "mfr_desc" ) ),
|
|
309
318
|
rb_str_new( desc_stats->mfr_desc, ( long ) strnlen( desc_stats->mfr_desc, DESC_STR_LEN - 1 ) ) );
|
|
310
|
-
rb_hash_aset( options, ID2SYM( rb_intern( "hw_desc" ) ),
|
|
319
|
+
rb_hash_aset( options, ID2SYM( rb_intern( "hw_desc" ) ),
|
|
311
320
|
rb_str_new( desc_stats->hw_desc, ( long ) strnlen( desc_stats->hw_desc, DESC_STR_LEN - 1 ) ) );
|
|
312
|
-
rb_hash_aset( options, ID2SYM( rb_intern( "sw_desc" ) ),
|
|
321
|
+
rb_hash_aset( options, ID2SYM( rb_intern( "sw_desc" ) ),
|
|
313
322
|
rb_str_new( desc_stats->sw_desc, ( long ) strnlen( desc_stats->sw_desc, DESC_STR_LEN - 1 ) ) );
|
|
314
|
-
rb_hash_aset( options, ID2SYM( rb_intern( "serial_num" ) ),
|
|
323
|
+
rb_hash_aset( options, ID2SYM( rb_intern( "serial_num" ) ),
|
|
315
324
|
rb_str_new( desc_stats->serial_num, ( long ) strnlen( desc_stats->serial_num, SERIAL_NUM_LEN - 1 ) ) );
|
|
316
|
-
rb_hash_aset( options, ID2SYM( rb_intern( "dp_desc" ) ),
|
|
325
|
+
rb_hash_aset( options, ID2SYM( rb_intern( "dp_desc" ) ),
|
|
317
326
|
rb_str_new( desc_stats->dp_desc, ( long ) strnlen( desc_stats->dp_desc, DESC_STR_LEN - 1 ) ) );
|
|
318
327
|
desc_stats_reply = rb_funcall( rb_eval_string( " Trema::DescStatsReply" ), rb_intern( "new" ), 1, options );
|
|
319
328
|
rb_ary_push( desc_stats_arr, desc_stats_reply );
|
|
@@ -363,7 +372,7 @@ handle_stats_reply(
|
|
|
363
372
|
flow_stats_reply = rb_funcall( rb_eval_string( "Trema::FlowStatsReply" ), rb_intern( "new" ), 1, options );
|
|
364
373
|
rb_ary_push( flow_stats_arr, flow_stats_reply );
|
|
365
374
|
|
|
366
|
-
// here create flow_stats object and insert into array
|
|
375
|
+
// here create flow_stats object and insert into array
|
|
367
376
|
body_length = ( uint16_t ) ( body_length - flow_stats->length );
|
|
368
377
|
|
|
369
378
|
if ( body_length ) {
|
|
@@ -410,7 +419,7 @@ handle_stats_reply(
|
|
|
410
419
|
table_stats_reply = rb_funcall( rb_eval_string( "Trema::TableStatsReply" ), rb_intern( "new" ), 1, options );
|
|
411
420
|
|
|
412
421
|
rb_ary_push( table_stats_arr, table_stats_reply );
|
|
413
|
-
body_length = ( uint16_t ) ( body_length - sizeof
|
|
422
|
+
body_length = ( uint16_t ) ( body_length - sizeof( struct ofp_table_stats ) );
|
|
414
423
|
if ( body_length ) {
|
|
415
424
|
table_stats++;
|
|
416
425
|
}
|
|
@@ -444,7 +453,7 @@ handle_stats_reply(
|
|
|
444
453
|
port_stats_reply = rb_funcall( rb_eval_string( "Trema::PortStatsReply" ), rb_intern( "new" ), 1, options );
|
|
445
454
|
|
|
446
455
|
rb_ary_push( port_stats_arr, port_stats_reply );
|
|
447
|
-
body_length = ( uint16_t ) ( body_length - sizeof
|
|
456
|
+
body_length = ( uint16_t ) ( body_length - sizeof( struct ofp_port_stats ) );
|
|
448
457
|
if ( body_length ) {
|
|
449
458
|
port_stats++;
|
|
450
459
|
}
|
|
@@ -467,7 +476,7 @@ handle_stats_reply(
|
|
|
467
476
|
queue_stats_reply = rb_funcall( rb_eval_string( "Trema::QueueStatsReply" ), rb_intern( "new" ), 1, options );
|
|
468
477
|
|
|
469
478
|
rb_ary_push( queue_stats_arr, queue_stats_reply );
|
|
470
|
-
body_length = ( uint16_t ) ( body_length - sizeof
|
|
479
|
+
body_length = ( uint16_t ) ( body_length - sizeof( struct ofp_queue_stats ) );
|
|
471
480
|
if ( body_length ) {
|
|
472
481
|
queue_stats++;
|
|
473
482
|
}
|
data/ruby/trema/stats-request.c
CHANGED
|
@@ -74,7 +74,7 @@ static const uint8_t TABLE_ID = 0xff;
|
|
|
74
74
|
*
|
|
75
75
|
* @raise [ArgumentError] if supplied transaction_id is not an unsigned 32-bit integer.
|
|
76
76
|
*
|
|
77
|
-
* @return [StatsRequest]
|
|
77
|
+
* @return [StatsRequest]
|
|
78
78
|
* an object that encapsulates an +OFPT_STATS_REQUEST+ OpenFlow message.
|
|
79
79
|
*/
|
|
80
80
|
static VALUE
|
|
@@ -127,7 +127,7 @@ desc_stats_request_alloc( VALUE klass ) {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
static VALUE
|
|
130
|
+
static VALUE
|
|
131
131
|
flow_stats_request_alloc( VALUE klass ) {
|
|
132
132
|
buffer *flow_stats_request = create_flow_stats_request( MY_TRANSACTION_ID, NO_FLAGS, MATCH, TABLE_ID, OUT_PORT );
|
|
133
133
|
return Data_Wrap_Struct( klass, NULL, free_buffer, flow_stats_request );
|
|
@@ -234,7 +234,7 @@ stats_out_port( VALUE self ) {
|
|
|
234
234
|
/*
|
|
235
235
|
* Restrict port statistics to a specific port_no or to all ports.
|
|
236
236
|
*
|
|
237
|
-
|
|
237
|
+
* @return [Number] the value of port_no.
|
|
238
238
|
*/
|
|
239
239
|
static VALUE
|
|
240
240
|
stats_port_no( VALUE self ) {
|
|
@@ -285,7 +285,7 @@ get_stats_request_table_id( VALUE self ) {
|
|
|
285
285
|
static VALUE
|
|
286
286
|
parse_common_arguments( int argc, VALUE *argv, VALUE self ) {
|
|
287
287
|
VALUE options;
|
|
288
|
-
if ( !rb_scan_args( argc, argv, "01", &options )) {
|
|
288
|
+
if ( !rb_scan_args( argc, argv, "01", &options ) ) {
|
|
289
289
|
options = rb_hash_new();
|
|
290
290
|
}
|
|
291
291
|
rb_call_super( 1, &options );
|
|
@@ -300,15 +300,15 @@ parse_common_arguments( int argc, VALUE *argv, VALUE self ) {
|
|
|
300
300
|
|
|
301
301
|
|
|
302
302
|
/*
|
|
303
|
-
* A {DescStatsRequest} object instance to request descriptive information of
|
|
304
|
-
* Such information includes switch manufacturer, hardware
|
|
303
|
+
* A {DescStatsRequest} object instance to request descriptive information of
|
|
304
|
+
* OpenFlow switch. Such information includes switch manufacturer, hardware
|
|
305
|
+
* revision and serial number
|
|
305
306
|
*
|
|
306
307
|
* @overload initialize(options={})
|
|
307
308
|
*
|
|
308
|
-
* @example
|
|
309
|
-
* DescStatsRequest.new
|
|
310
|
-
*
|
|
311
|
-
* )
|
|
309
|
+
* @example
|
|
310
|
+
* DescStatsRequest.new
|
|
311
|
+
* DescStatsRequest.new( :transaction_id => 1234 )
|
|
312
312
|
*
|
|
313
313
|
* @param [Hash] options
|
|
314
314
|
* the options to create a message with.
|
|
@@ -316,8 +316,8 @@ parse_common_arguments( int argc, VALUE *argv, VALUE self ) {
|
|
|
316
316
|
* @option options [Number] :transaction_id
|
|
317
317
|
* set the transaction_id as specified or auto-generate it.
|
|
318
318
|
*
|
|
319
|
-
* @return [
|
|
320
|
-
* an object that encapsulates the +OFPT_STATS_REQUEST(
|
|
319
|
+
* @return [DescStatsRequest]
|
|
320
|
+
* an object that encapsulates the +OFPT_STATS_REQUEST(OFPST_DESC)+ OpenFlow
|
|
321
321
|
* message.
|
|
322
322
|
*/
|
|
323
323
|
static VALUE
|
|
@@ -331,9 +331,9 @@ desc_stats_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
331
331
|
*
|
|
332
332
|
* @overload initialize(options={})
|
|
333
333
|
* @example
|
|
334
|
-
* FlowStatsRequest.new(
|
|
335
|
-
*
|
|
336
|
-
* )
|
|
334
|
+
* FlowStatsRequest.new( :match => Match )
|
|
335
|
+
* FlowStatsRequest.new( :match => Match, :table_id => 1 )
|
|
336
|
+
* FlowStatsRequest.new( :match => Match, :table_id => 1, :out_port => 2 )
|
|
337
337
|
*
|
|
338
338
|
* @param [Hash] options
|
|
339
339
|
* the options to create a message with.
|
|
@@ -350,7 +350,8 @@ desc_stats_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
350
350
|
* a value of +OFPP_NONE+ would match all flow entries and is set to if not
|
|
351
351
|
* specified.
|
|
352
352
|
*
|
|
353
|
-
* @raise [ArgumentError] if option
|
|
353
|
+
* @raise [ArgumentError] if option match is not specified.
|
|
354
|
+
* @raise [TypeError] if option match is not a Trema::Match object.
|
|
354
355
|
*
|
|
355
356
|
* @return [FlowStatsRequest]
|
|
356
357
|
* an object that encapsulates the +OFPT_STATS_REQUEST(OFPST_FLOW)+ OpenFlow message.
|
|
@@ -384,9 +385,8 @@ flow_stats_request_init( VALUE self, VALUE options ) {
|
|
|
384
385
|
* A {AggregateStatsRequest} object instance to request aggregate statistics.
|
|
385
386
|
* @overload initialize(options={})
|
|
386
387
|
* @example
|
|
387
|
-
* AggregateStatsRequest.new(
|
|
388
|
-
*
|
|
389
|
-
* )
|
|
388
|
+
* AggregateStatsRequest.new( :match => Match )
|
|
389
|
+
* AggregateStatsRequest.new( :match => Match, :table_id => 1, :out_port => 2 )
|
|
390
390
|
*
|
|
391
391
|
* @param [Hash] options
|
|
392
392
|
* the options to create a message with.
|
|
@@ -403,7 +403,8 @@ flow_stats_request_init( VALUE self, VALUE options ) {
|
|
|
403
403
|
* a value of +OFPP_NONE+ would match all flow entries and is set to if not
|
|
404
404
|
* specified.
|
|
405
405
|
*
|
|
406
|
-
* @raise [ArgumentError] if option
|
|
406
|
+
* @raise [ArgumentError] if option match is not specified.
|
|
407
|
+
* @raise [TypeError] if option match is not a Trema::Match object.
|
|
407
408
|
*
|
|
408
409
|
* @return [AggregateStatsRequest]
|
|
409
410
|
* an object that encapsulates the +OFPT_STATS_REQUEST(OFPST_AGGREGATE)+ OpenFlow message.
|
|
@@ -440,10 +441,9 @@ aggregate_stats_request_init( VALUE self, VALUE options ) {
|
|
|
440
441
|
*
|
|
441
442
|
* @overload initialize(options={})
|
|
442
443
|
*
|
|
443
|
-
* @example
|
|
444
|
-
* TableStatsRequest.new
|
|
445
|
-
*
|
|
446
|
-
* )
|
|
444
|
+
* @example
|
|
445
|
+
* TableStatsRequest.new
|
|
446
|
+
* TableStatsRequest.new( :transaction_id => 1234 )
|
|
447
447
|
*
|
|
448
448
|
* @param [Hash] options
|
|
449
449
|
* the options to create a message with.
|
|
@@ -452,7 +452,7 @@ aggregate_stats_request_init( VALUE self, VALUE options ) {
|
|
|
452
452
|
* set the transaction_id as specified or auto-generate it.
|
|
453
453
|
*
|
|
454
454
|
* @return [TableStatsRequest]
|
|
455
|
-
* an object that encapsulates the +OFPT_STATS_REQUEST(OFPST_TABLE)+
|
|
455
|
+
* an object that encapsulates the +OFPT_STATS_REQUEST(OFPST_TABLE)+ OpenFlow
|
|
456
456
|
* message.
|
|
457
457
|
*/
|
|
458
458
|
static VALUE
|
|
@@ -468,9 +468,8 @@ table_stats_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
468
468
|
* @overload initialize(options={})
|
|
469
469
|
*
|
|
470
470
|
* @example
|
|
471
|
-
* PortStatsRequest.new
|
|
472
|
-
*
|
|
473
|
-
* )
|
|
471
|
+
* PortStatsRequest.new
|
|
472
|
+
* PortStatsRequest.new( :port_no => 1 )
|
|
474
473
|
*
|
|
475
474
|
* @param [Hash] options
|
|
476
475
|
* the options to create a message with.
|
|
@@ -480,13 +479,13 @@ table_stats_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
480
479
|
* to +OFPP_NONE+ for all ports.
|
|
481
480
|
*
|
|
482
481
|
* @return [PortStatsRequest]
|
|
483
|
-
* an object that encapsulates the +OFPT_STATS_REQUEST(OFPST_PORT)+ OpenFlow
|
|
482
|
+
* an object that encapsulates the +OFPT_STATS_REQUEST(OFPST_PORT)+ OpenFlow
|
|
484
483
|
* message.
|
|
485
484
|
*/
|
|
486
485
|
static VALUE
|
|
487
486
|
port_stats_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
488
487
|
VALUE options;
|
|
489
|
-
if ( !rb_scan_args( argc, argv, "01", &options )) {
|
|
488
|
+
if ( !rb_scan_args( argc, argv, "01", &options ) ) {
|
|
490
489
|
options = rb_hash_new();
|
|
491
490
|
}
|
|
492
491
|
rb_call_super( 1, &options );
|
|
@@ -515,10 +514,10 @@ port_stats_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
515
514
|
* @overload initialize(options={})
|
|
516
515
|
*
|
|
517
516
|
* @example
|
|
518
|
-
* QueueStatsRequest.new
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
* )
|
|
517
|
+
* QueueStatsRequest.new
|
|
518
|
+
* QueueStatsRequest.new( :port_no => 1, :queue_id => 123 )
|
|
519
|
+
* QueueStatsRequest.new( :port_no => 1 )
|
|
520
|
+
* QueueStatsRequest.new( :queue_id => 123 )
|
|
522
521
|
*
|
|
523
522
|
* @param [Hash] options
|
|
524
523
|
* the options to create a message with.
|
|
@@ -538,7 +537,7 @@ port_stats_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
538
537
|
static VALUE
|
|
539
538
|
queue_stats_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
540
539
|
VALUE options;
|
|
541
|
-
if ( !rb_scan_args( argc, argv, "01", &options )) {
|
|
540
|
+
if ( !rb_scan_args( argc, argv, "01", &options ) ) {
|
|
542
541
|
options = rb_hash_new();
|
|
543
542
|
}
|
|
544
543
|
rb_call_super( 1, &options );
|
|
@@ -577,9 +576,8 @@ queue_stats_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
577
576
|
* @overload initialize(options={})
|
|
578
577
|
*
|
|
579
578
|
* @example
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
* )
|
|
579
|
+
* VendorStatsRequest.new
|
|
580
|
+
* VendorStatsRequest.new( :vendor_id => 123 )
|
|
583
581
|
*
|
|
584
582
|
* @param [Hash] options
|
|
585
583
|
* the options to create a message with.
|
|
@@ -589,14 +587,14 @@ queue_stats_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
589
587
|
* to a default value of 0x00004cff.
|
|
590
588
|
*
|
|
591
589
|
* @return [VendorStatsRequest]
|
|
592
|
-
* an object that encapsulates the +OFPT_STATS_REQUEST(OFPST_VENDOR)+
|
|
590
|
+
* an object that encapsulates the +OFPT_STATS_REQUEST(OFPST_VENDOR)+ OpenFlow
|
|
593
591
|
* message.
|
|
594
592
|
*/
|
|
595
593
|
static VALUE
|
|
596
594
|
vendor_stats_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
597
595
|
VALUE options;
|
|
598
596
|
|
|
599
|
-
if ( !rb_scan_args( argc, argv, "01", &options )) {
|
|
597
|
+
if ( !rb_scan_args( argc, argv, "01", &options ) ) {
|
|
600
598
|
options = rb_hash_new();
|
|
601
599
|
}
|
|
602
600
|
rb_call_super( 1, &options );
|
|
@@ -619,7 +617,7 @@ vendor_stats_request_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
619
617
|
|
|
620
618
|
|
|
621
619
|
void
|
|
622
|
-
Init_stats_request(){
|
|
620
|
+
Init_stats_request() {
|
|
623
621
|
cStatsRequest = rb_define_class_under( mTrema, "StatsRequest", rb_cObject );
|
|
624
622
|
|
|
625
623
|
cDescStatsRequest = rb_define_class_under( mTrema, "DescStatsRequest", cStatsRequest );
|
data/ruby/trema/switch-daemon.rb
CHANGED
|
@@ -20,14 +20,37 @@
|
|
|
20
20
|
|
|
21
21
|
module Trema
|
|
22
22
|
class SwitchDaemon
|
|
23
|
+
MANDATORY_QUEUES = [ :port_status, :packet_in, :state_notify ]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
#
|
|
27
|
+
# Creates a new abstract representation of SwitchDaemon instance
|
|
28
|
+
# by accepting and validating a hash of queue options.
|
|
29
|
+
#
|
|
30
|
+
# @param [Hash] queues a hash of queue arguments to assign.
|
|
31
|
+
# @option queues [Symbol] :port_status
|
|
32
|
+
# the controller(s) to receive port status messages.
|
|
33
|
+
# @option queues [Symbol] :packet_in
|
|
34
|
+
# the controller(s) to receive packet_in messages.
|
|
35
|
+
# @option queues [Symbol] :state_notify
|
|
36
|
+
# the controller(s) to receive state notification messages.
|
|
37
|
+
#
|
|
23
38
|
def initialize queues
|
|
24
39
|
check_mandatory_options queues
|
|
25
40
|
@queues = queues
|
|
26
41
|
end
|
|
27
42
|
|
|
28
43
|
|
|
44
|
+
#
|
|
45
|
+
# Constructs switch daemon's options associating one or more controller
|
|
46
|
+
# name to a queue name.
|
|
47
|
+
#
|
|
48
|
+
# @return [Array<String>] the switch daemon's options.
|
|
29
49
|
def options
|
|
30
|
-
|
|
50
|
+
all_queues = MANDATORY_QUEUES + [ :vendor ]
|
|
51
|
+
all_queues.collect! do | each |
|
|
52
|
+
queue each
|
|
53
|
+
end.flatten!
|
|
31
54
|
end
|
|
32
55
|
|
|
33
56
|
|
|
@@ -36,42 +59,24 @@ module Trema
|
|
|
36
59
|
################################################################################
|
|
37
60
|
|
|
38
61
|
|
|
62
|
+
#
|
|
63
|
+
# @raise [RuntimeError] if a mandatory option is not found.
|
|
64
|
+
#
|
|
39
65
|
def check_mandatory_options queues
|
|
40
|
-
|
|
66
|
+
MANDATORY_QUEUES.each do | each |
|
|
41
67
|
raise ":#{ each } is a mandatory option" if queues[ each ].nil?
|
|
42
68
|
end
|
|
43
69
|
end
|
|
44
70
|
|
|
45
71
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def packetin_queue
|
|
55
|
-
controllers = @queues[ :packet_in ].split( "," )
|
|
56
|
-
controllers.collect do | each |
|
|
57
|
-
"packet_in::#{ each }"
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def statenotify_queue
|
|
63
|
-
controllers = @queues[ :state_notify ].split( "," )
|
|
64
|
-
controllers.collect do | each |
|
|
65
|
-
"state_notify::#{ each }"
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def vendor_queue
|
|
71
|
-
return [] if not @queues[ :vendor ]
|
|
72
|
-
controllers = @queues[ :vendor ].split( "," )
|
|
73
|
-
controllers.collect do | each |
|
|
74
|
-
"vendor::#{ each }"
|
|
72
|
+
#
|
|
73
|
+
# @return [Array<String>] an array of controller name strings.
|
|
74
|
+
#
|
|
75
|
+
def queue queue_type
|
|
76
|
+
return [] unless @queues[ queue_type ]
|
|
77
|
+
controllers = @queues[ queue_type ].split( "," )
|
|
78
|
+
controllers.collect! do | each |
|
|
79
|
+
"#{ queue_type.to_s }::#{ each }"
|
|
75
80
|
end
|
|
76
81
|
end
|
|
77
82
|
end
|