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
data/ruby/trema/packet-queue.rb
CHANGED
|
@@ -26,21 +26,21 @@ class Queue
|
|
|
26
26
|
attr_accessor :queues
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
# Add queue to list.
|
|
31
31
|
# @param [PacketQueue] queue a {PacketQueue} instance.
|
|
32
32
|
def self.append queue
|
|
33
33
|
@queues ||= []
|
|
34
34
|
@queues << queue unless @queues.include?(queue)
|
|
35
35
|
end
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
|
|
37
|
+
|
|
38
38
|
# @return [Array]
|
|
39
39
|
# an array of {PacketQueue} objects.
|
|
40
40
|
def self.queues
|
|
41
41
|
@queues
|
|
42
42
|
end
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
|
|
45
45
|
# Iterate over each {PacketQueue} item.
|
|
46
46
|
# @return [Array] a list of {PacketQueue} items.
|
|
@@ -57,11 +57,11 @@ class PacketQueue
|
|
|
57
57
|
OFPQT_NONE = 0
|
|
58
58
|
# Minimum datarate guaranteed.
|
|
59
59
|
OFPQT_MIN_RATE = 1
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
|
|
61
|
+
|
|
62
62
|
# Id for the specific queue.
|
|
63
63
|
# @return [Number] queue_id
|
|
64
|
-
# the value of attribute queue_id.
|
|
64
|
+
# the value of attribute queue_id.
|
|
65
65
|
attr_accessor :queue_id
|
|
66
66
|
# Queue description's length in bytes.
|
|
67
67
|
# @return [Number] len
|
|
@@ -79,7 +79,7 @@ class PacketQueue
|
|
|
79
79
|
# id for the specific queue.
|
|
80
80
|
# @option options [Symbol] :len
|
|
81
81
|
# queue description's length in bytes.
|
|
82
|
-
#
|
|
82
|
+
#
|
|
83
83
|
def initialize options
|
|
84
84
|
@queue_id = options[ :queue_id ]
|
|
85
85
|
@len = options[ :len ]
|
|
@@ -146,7 +146,7 @@ class MinRateQueue < QueueProperty
|
|
|
146
146
|
# the value of attribute rate.
|
|
147
147
|
attr_accessor :rate
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
|
|
150
150
|
# An object that encapsulates the minimum rate queue property description.
|
|
151
151
|
# @param [Number] property
|
|
152
152
|
# property queue id.
|
data/ruby/trema/phost.rb
CHANGED
|
@@ -25,36 +25,45 @@ require "trema/executables"
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
module Trema
|
|
28
|
+
#
|
|
29
|
+
# An interface class to phost emulation utility program.
|
|
30
|
+
#
|
|
28
31
|
class Phost
|
|
29
32
|
include Trema::Daemon
|
|
30
33
|
|
|
31
34
|
|
|
32
|
-
command { | phost | "sudo #{ Executables.phost } -i #{ phost.interface } -p #{ Trema.pid } -l #{ Trema.log } -D" }
|
|
35
|
+
command { | phost | "sudo #{ Executables.phost } -i #{ phost.interface } -p #{ Trema.pid } -l #{ Trema.log } -n #{ phost.name } -D" }
|
|
33
36
|
wait_until_up
|
|
34
|
-
daemon_id :
|
|
37
|
+
daemon_id :name
|
|
35
38
|
|
|
36
39
|
|
|
40
|
+
#
|
|
41
|
+
# Creates a new instance of Phost for each virtual host.
|
|
42
|
+
#
|
|
37
43
|
def initialize host
|
|
38
44
|
@host = host
|
|
39
45
|
end
|
|
40
46
|
|
|
41
47
|
|
|
48
|
+
#
|
|
49
|
+
# @raise [RuntimeError] if no interface defined for virtual host.
|
|
50
|
+
#
|
|
51
|
+
# @return [String] the virtual host's interface name.
|
|
52
|
+
#
|
|
42
53
|
def interface
|
|
43
54
|
raise "The link(s) for vhost '#{ name }' is not defined." if @host.interface.nil?
|
|
44
55
|
@host.interface
|
|
45
56
|
end
|
|
46
57
|
|
|
47
58
|
|
|
59
|
+
#
|
|
60
|
+
# @return [Boolean] whether phost is running or not.
|
|
61
|
+
#
|
|
48
62
|
def running?
|
|
49
63
|
not @host.interface.nil? and super
|
|
50
64
|
end
|
|
51
65
|
|
|
52
66
|
|
|
53
|
-
################################################################################
|
|
54
|
-
private
|
|
55
|
-
################################################################################
|
|
56
|
-
|
|
57
|
-
|
|
58
67
|
def name
|
|
59
68
|
@host.name
|
|
60
69
|
end
|
data/ruby/trema/port-mod.c
CHANGED
|
@@ -93,10 +93,11 @@ port_mod_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
93
93
|
if ( rb_obj_is_kind_of( hw_addr, rb_cString ) == Qtrue ||
|
|
94
94
|
rb_obj_is_kind_of( hw_addr, rb_cInteger ) == Qtrue ) {
|
|
95
95
|
mac = rb_funcall( rb_eval_string( "Trema::Mac" ), rb_intern( "new" ), 1, hw_addr );
|
|
96
|
-
}
|
|
96
|
+
}
|
|
97
|
+
else if ( rb_obj_is_instance_of( hw_addr, rb_eval_string( "Trema::Mac" ) ) == Qfalse ) {
|
|
97
98
|
rb_raise( rb_eArgError, "hw_addr must be a string or an integer or Mac object" );
|
|
98
99
|
}
|
|
99
|
-
ptr = ( uint8_t* ) dl_addr_to_a( mac, haddr );
|
|
100
|
+
ptr = ( uint8_t * ) dl_addr_to_a( mac, haddr );
|
|
100
101
|
rb_iv_set( self, "@hw_addr", mac );
|
|
101
102
|
}
|
|
102
103
|
VALUE port_no;
|
|
@@ -107,15 +108,15 @@ port_mod_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
107
108
|
rb_iv_set( self, "@port_no", port_no );
|
|
108
109
|
}
|
|
109
110
|
VALUE config;
|
|
110
|
-
if ( ( config = rb_hash_aref( options, ID2SYM( rb_intern( "config" ) ) ) ) != Qnil ){
|
|
111
|
+
if ( ( config = rb_hash_aref( options, ID2SYM( rb_intern( "config" ) ) ) ) != Qnil ) {
|
|
111
112
|
rb_iv_set( self, "@config", config );
|
|
112
113
|
}
|
|
113
114
|
VALUE mask;
|
|
114
|
-
if ( ( mask = rb_hash_aref( options, ID2SYM( rb_intern( "mask" ) ) ) ) != Qnil ){
|
|
115
|
+
if ( ( mask = rb_hash_aref( options, ID2SYM( rb_intern( "mask" ) ) ) ) != Qnil ) {
|
|
115
116
|
rb_iv_set( self, "@mask", mask );
|
|
116
117
|
}
|
|
117
118
|
VALUE advertise;
|
|
118
|
-
if ( ( advertise = rb_hash_aref( options, ID2SYM( rb_intern( "advertise" ) ) ) ) != Qnil ){
|
|
119
|
+
if ( ( advertise = rb_hash_aref( options, ID2SYM( rb_intern( "advertise" ) ) ) ) != Qnil ) {
|
|
119
120
|
rb_iv_set( self, "@advertise", advertise );
|
|
120
121
|
}
|
|
121
122
|
uint32_t xid = get_transaction_id();
|
|
@@ -35,7 +35,7 @@ module Trema
|
|
|
35
35
|
#
|
|
36
36
|
# @overload initialize(options={})
|
|
37
37
|
#
|
|
38
|
-
# @example
|
|
38
|
+
# @example
|
|
39
39
|
# PortStatsReply.new(
|
|
40
40
|
# :port_no => 1,
|
|
41
41
|
# :rx_packets => 7,
|
|
@@ -97,7 +97,7 @@ module Trema
|
|
|
97
97
|
# @return [PortStatsReply]
|
|
98
98
|
# an object that encapsulates the OFPST_STATS_REPLY(OFPST_PORT) OpenFlow message.
|
|
99
99
|
#
|
|
100
|
-
def initialize options
|
|
100
|
+
def initialize options
|
|
101
101
|
super FIELDS, options
|
|
102
102
|
end
|
|
103
103
|
end
|
data/ruby/trema/process.rb
CHANGED
|
@@ -21,7 +21,25 @@
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
module Trema
|
|
24
|
+
#
|
|
25
|
+
# A class responsible for terminating processes.
|
|
26
|
+
#
|
|
24
27
|
class Process
|
|
28
|
+
#
|
|
29
|
+
# @overload read(pid_file)
|
|
30
|
+
# Reads a process identification file and saves the process name
|
|
31
|
+
# process id and effective user id. The process name is inferred from the
|
|
32
|
+
# +:pid_file+.
|
|
33
|
+
# @param [String] pid_file the full path name of the pid file.
|
|
34
|
+
#
|
|
35
|
+
# @overload read(pid_file, name)
|
|
36
|
+
# Reads a process identification file and saves the process name
|
|
37
|
+
# process id and effective user id.
|
|
38
|
+
# @param [String] pid_file the full path name of the pid file.
|
|
39
|
+
# @param [String] name the process name.
|
|
40
|
+
#
|
|
41
|
+
# @return [Process] the object that encapsulates the process details.
|
|
42
|
+
#
|
|
25
43
|
def self.read pid_file, name = nil
|
|
26
44
|
name = File.basename( pid_file, ".pid" ) if name.nil?
|
|
27
45
|
return new( pid_file, name )
|
|
@@ -40,6 +58,14 @@ module Trema
|
|
|
40
58
|
end
|
|
41
59
|
|
|
42
60
|
|
|
61
|
+
#
|
|
62
|
+
# kills an active process.
|
|
63
|
+
#
|
|
64
|
+
# @raise [RuntimeError] if failed to kill the process after a
|
|
65
|
+
# maximum number of attempts.
|
|
66
|
+
#
|
|
67
|
+
# @return [void]
|
|
68
|
+
#
|
|
43
69
|
def kill!
|
|
44
70
|
return if @pid_file.nil?
|
|
45
71
|
return if dead?
|
|
@@ -62,6 +88,9 @@ module Trema
|
|
|
62
88
|
################################################################################
|
|
63
89
|
|
|
64
90
|
|
|
91
|
+
#
|
|
92
|
+
# @return [Boolean] whether a process is not alive or not.
|
|
93
|
+
#
|
|
65
94
|
def dead?
|
|
66
95
|
`ps ax | grep -E "^[[:blank:]]*#{ @pid }"`.empty?
|
|
67
96
|
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
|
|
@@ -34,7 +32,7 @@ module Trema
|
|
|
34
32
|
#
|
|
35
33
|
# @overload initialize(options={})
|
|
36
34
|
#
|
|
37
|
-
# @example
|
|
35
|
+
# @example
|
|
38
36
|
# QueueStatsReply.new(
|
|
39
37
|
# :port_no => 1,
|
|
40
38
|
# :queue_id => 123,
|
|
@@ -62,7 +60,7 @@ module Trema
|
|
|
62
60
|
# a counter of transmitted errors.
|
|
63
61
|
#
|
|
64
62
|
# @return [QueueStatsReply]
|
|
65
|
-
# an object that encapsulates the OFPST_STATS_REPLY(
|
|
63
|
+
# an object that encapsulates the OFPST_STATS_REPLY(OFPST_QUEUE) OpenFlow message.
|
|
66
64
|
#
|
|
67
65
|
def initialize options
|
|
68
66
|
super FIELDS, options
|
data/ruby/trema/send-out-port.rb
CHANGED
|
@@ -28,7 +28,9 @@ module Trema
|
|
|
28
28
|
DEFAULT_MAX_LEN = 2 ** 16 - 1
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
# @return [Fixnum] the value of attribute {#max_len}
|
|
31
32
|
attr_reader :max_len
|
|
33
|
+
# @return [Fixnum] the value of attribute {#port_number}
|
|
32
34
|
attr_reader :port_number
|
|
33
35
|
|
|
34
36
|
|
|
@@ -38,7 +40,7 @@ module Trema
|
|
|
38
40
|
# @example
|
|
39
41
|
# SendOutPort.new( 1 )
|
|
40
42
|
# SendOutPort.new( :port_number => 1 )
|
|
41
|
-
# SendOutPort.new( :port_number =>
|
|
43
|
+
# SendOutPort.new( :port_number => OFPP_CONTROLLER, :max_len => 256 )
|
|
42
44
|
#
|
|
43
45
|
# @param [Integer|Hash] options
|
|
44
46
|
# the port number or the options hash to create this action class instance with.
|
|
@@ -81,14 +83,14 @@ module Trema
|
|
|
81
83
|
if @port_number.nil?
|
|
82
84
|
raise ArgumentError, "Port number is a mandatory option"
|
|
83
85
|
end
|
|
84
|
-
|
|
86
|
+
unless @port_number.unsigned_16bit?
|
|
85
87
|
raise ArgumentError, "Port number must be an unsigned 16-bit integer"
|
|
86
88
|
end
|
|
87
89
|
end
|
|
88
90
|
|
|
89
91
|
|
|
90
92
|
def check_max_len
|
|
91
|
-
|
|
93
|
+
unless @max_len.unsigned_16bit?
|
|
92
94
|
raise ArgumentError, "Max length must be an unsigned 16-bit integer"
|
|
93
95
|
end
|
|
94
96
|
end
|
data/ruby/trema/set-eth-addr.rb
CHANGED
|
@@ -25,6 +25,10 @@ module Trema
|
|
|
25
25
|
# @abstract The base class of {SetEthSrcAddr} and {SetEthDstAddr} action.
|
|
26
26
|
#
|
|
27
27
|
class SetEthAddr < Action
|
|
28
|
+
#
|
|
29
|
+
# @return [Trema::Mac] the object that holds {#mac_address}'s
|
|
30
|
+
# internal representation.
|
|
31
|
+
#
|
|
28
32
|
attr_reader :mac_address
|
|
29
33
|
|
|
30
34
|
|
data/ruby/trema/set-ip-addr.rb
CHANGED
|
@@ -24,6 +24,8 @@ module Trema
|
|
|
24
24
|
# @abstract The base class of {SetIpSrcAddr} and {SetIpDstAddr} action.
|
|
25
25
|
#
|
|
26
26
|
class SetIpAddr < Action
|
|
27
|
+
# @return [IPAddr] the object that holds {#ip_address}'s
|
|
28
|
+
# internal representation.
|
|
27
29
|
attr_reader :ip_address
|
|
28
30
|
|
|
29
31
|
|
|
@@ -31,8 +33,8 @@ module Trema
|
|
|
31
33
|
# @private
|
|
32
34
|
#
|
|
33
35
|
def initialize ip_address
|
|
34
|
-
|
|
35
|
-
raise TypeError, "Source IP address must be
|
|
36
|
+
unless ip_address.is_a?( String )
|
|
37
|
+
raise TypeError, "Source IP address must be a String"
|
|
36
38
|
end
|
|
37
39
|
@ip_address = IPAddr.new( ip_address )
|
|
38
40
|
end
|
|
@@ -34,7 +34,8 @@ module Trema
|
|
|
34
34
|
# @param [String] ip_address
|
|
35
35
|
# the IPv4 address to create this action with.
|
|
36
36
|
#
|
|
37
|
-
# @raise [
|
|
37
|
+
# @raise [ArgumentError] if ip_address is an invalid IPv4 address.
|
|
38
|
+
# @raise [TypeError] if ip_address is not a String.
|
|
38
39
|
#
|
|
39
40
|
def initialize ip_address
|
|
40
41
|
super ip_address
|
|
@@ -33,7 +33,8 @@ module Trema
|
|
|
33
33
|
# @param [String] ip_address
|
|
34
34
|
# the IPv4 address to create this action with.
|
|
35
35
|
#
|
|
36
|
-
# @raise [
|
|
36
|
+
# @raise [ArgumentError] if ip_address is an invalid IPv4 address.
|
|
37
|
+
# @raise [TypeError] if ip_address is not a String.
|
|
37
38
|
#
|
|
38
39
|
def initialize ip_address
|
|
39
40
|
super ip_address
|
data/ruby/trema/set-ip-tos.rb
CHANGED
|
@@ -25,6 +25,7 @@ module Trema
|
|
|
25
25
|
# An action to modify the IP ToS/DSCP field of a packet.
|
|
26
26
|
#
|
|
27
27
|
class SetIpTos < Action
|
|
28
|
+
# @return [Fixnum] the value of attribute {#type_of_service}
|
|
28
29
|
attr_reader :type_of_service
|
|
29
30
|
|
|
30
31
|
|
|
@@ -41,10 +42,10 @@ module Trema
|
|
|
41
42
|
# @raise [TypeError] if type_of_service argument is not an Integer.
|
|
42
43
|
#
|
|
43
44
|
def initialize type_of_service
|
|
44
|
-
|
|
45
|
+
unless type_of_service.is_a?( Integer )
|
|
45
46
|
raise TypeError, "ToS must be an unsigned 8-bit integer"
|
|
46
47
|
end
|
|
47
|
-
|
|
48
|
+
unless type_of_service.unsigned_8bit?
|
|
48
49
|
raise ArgumentError, "ToS must be an unsigned 8-bit integer"
|
|
49
50
|
end
|
|
50
51
|
@type_of_service = type_of_service
|
|
@@ -25,6 +25,7 @@ module Trema
|
|
|
25
25
|
# @abstract The base class of {SetTransportSrcPort} and {SetTransportDstPort} action.
|
|
26
26
|
#
|
|
27
27
|
class SetTransportPort < Action
|
|
28
|
+
# @return [Fixnum] the value of attribute {#port_number}
|
|
28
29
|
attr_reader :port_number
|
|
29
30
|
|
|
30
31
|
|
|
@@ -33,10 +34,10 @@ module Trema
|
|
|
33
34
|
#
|
|
34
35
|
def initialize port_number
|
|
35
36
|
error_message = "TCP/UDP port must be an unsigned 16-bit integer"
|
|
36
|
-
|
|
37
|
+
unless port_number.is_a?( Integer )
|
|
37
38
|
raise TypeError, error_message
|
|
38
39
|
end
|
|
39
|
-
|
|
40
|
+
unless port_number.unsigned_16bit?
|
|
40
41
|
raise ArgumentError, error_message
|
|
41
42
|
end
|
|
42
43
|
@port_number = port_number
|
|
@@ -24,6 +24,7 @@ module Trema
|
|
|
24
24
|
# An action to modify the VLAN priority of a packet.
|
|
25
25
|
#
|
|
26
26
|
class SetVlanPriority < Action
|
|
27
|
+
# @return [Fixnum] the value of attribute {#vlan_priority}
|
|
27
28
|
attr_reader :vlan_priority
|
|
28
29
|
|
|
29
30
|
|
|
@@ -43,10 +44,10 @@ module Trema
|
|
|
43
44
|
# @raise [TypeError] if vlan_priority is not an Integer.
|
|
44
45
|
#
|
|
45
46
|
def initialize vlan_priority
|
|
46
|
-
|
|
47
|
+
unless vlan_priority.is_a?( Integer )
|
|
47
48
|
raise TypeError, "VLAN priority must be an unsigned 8-bit Integer"
|
|
48
49
|
end
|
|
49
|
-
|
|
50
|
+
unless ( vlan_priority >= 0 and vlan_priority <= 7 )
|
|
50
51
|
raise ArgumentError, "Valid VLAN priority values are 0 to 7 inclusive"
|
|
51
52
|
end
|
|
52
53
|
@vlan_priority = vlan_priority
|
data/ruby/trema/set-vlan-vid.rb
CHANGED
|
@@ -24,6 +24,7 @@ module Trema
|
|
|
24
24
|
# An action to modify the VLAN ID of a packet.
|
|
25
25
|
#
|
|
26
26
|
class SetVlanVid < Action
|
|
27
|
+
# @return [Fixnum] the value of attribute {#vlan_id}
|
|
27
28
|
attr_reader :vlan_id
|
|
28
29
|
|
|
29
30
|
|
|
@@ -38,15 +39,15 @@ module Trema
|
|
|
38
39
|
# @param [Integer] vlan_id
|
|
39
40
|
# the VLAN ID to set to. Only the lower 12-bits are used.
|
|
40
41
|
#
|
|
41
|
-
# @raise [ArgumentError] if vlan_id not within 1 and
|
|
42
|
+
# @raise [ArgumentError] if vlan_id not within 1 and 4095 inclusive.
|
|
42
43
|
# @raise [TypeError] if vlan_id is not an Integer.
|
|
43
44
|
#
|
|
44
45
|
def initialize vlan_id
|
|
45
|
-
|
|
46
|
+
unless vlan_id.is_a?( Integer )
|
|
46
47
|
raise TypeError, "VLAN ID argument must be an Integer"
|
|
47
48
|
end
|
|
48
|
-
|
|
49
|
-
raise ArgumentError, "Valid VLAN ID values between 1 to
|
|
49
|
+
unless ( vlan_id >= 1 and vlan_id <= 4095 )
|
|
50
|
+
raise ArgumentError, "Valid VLAN ID values between 1 to 4095 inclusive"
|
|
50
51
|
end
|
|
51
52
|
@vlan_id = vlan_id
|
|
52
53
|
end
|