trema 0.2.2.1 → 0.2.3
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/.gitmodules +3 -0
- data/.travis.yml +13 -0
- data/.yardopts +4 -0
- data/Gemfile +2 -3
- data/README.md +43 -97
- data/Rakefile +60 -4
- data/Rantfile +11 -10
- data/cruise.rb +4 -6
- data/features/example.packetin_filter_config.feature +10 -10
- data/features/example.switch_monitor.feature +14 -2
- data/features/step_definitions/kill_steps.rb +2 -2
- data/features/step_definitions/{off_steps.rb → killall_steps.rb} +2 -2
- data/features/step_definitions/misc_steps.rb +1 -1
- data/features/step_definitions/up_steps.rb +30 -0
- data/features/trema.feature +1 -0
- data/features/trema.run.feature +1 -0
- data/locale/README.ja.md +19 -0
- data/locale/ja/yard.po +3762 -0
- data/locale/yard.pot +3740 -0
- data/ruby/extconf.rb +4 -1
- data/ruby/trema/action-common.c +3 -17
- data/ruby/trema/action-common.h +3 -7
- data/ruby/trema/action.rb +33 -0
- data/ruby/trema/app.rb +1 -1
- data/ruby/trema/barrier-request.c +1 -0
- data/ruby/trema/command/run.rb +13 -9
- data/ruby/trema/command/usage.rb +1 -0
- data/ruby/trema/command/version.rb +1 -1
- data/ruby/trema/controller.c +133 -50
- data/ruby/trema/controller.rb +2 -2
- data/ruby/trema/desc-stats-reply.rb +77 -0
- data/ruby/trema/dsl/configuration.rb +3 -14
- data/ruby/trema/dsl/rswitch.rb +47 -0
- data/ruby/trema/dsl/runner.rb +4 -1
- data/ruby/trema/dsl/syntax.rb +11 -8
- data/ruby/trema/echo-reply.c +59 -45
- data/ruby/trema/echo-reply.h +1 -3
- data/ruby/trema/echo-request.c +49 -71
- data/ruby/trema/echo-request.h +0 -2
- data/ruby/trema/echo.c +99 -0
- data/ruby/trema/{action-enqueue.h → echo.h} +6 -7
- data/ruby/trema/enqueue.rb +87 -0
- data/ruby/trema/error.c +109 -104
- data/ruby/trema/error.h +0 -2
- data/ruby/trema/features-reply.c +89 -35
- data/ruby/trema/features-reply.h +0 -6
- data/ruby/trema/features-request.c +63 -37
- data/ruby/trema/features-request.h +0 -2
- data/ruby/trema/flow-mod.c +149 -0
- data/ruby/trema/{action-output.h → flow-mod.h} +6 -6
- data/ruby/trema/get-config-request.c +1 -0
- data/ruby/trema/hardware-switch.rb +88 -0
- data/ruby/trema/hello.c +55 -31
- data/ruby/trema/hello.h +0 -2
- data/ruby/trema/ip.rb +12 -2
- data/ruby/trema/logger.rb +29 -0
- data/ruby/trema/mac.rb +57 -36
- data/ruby/trema/match.c +7 -9
- data/ruby/trema/monkey-patch/integer/ranges.rb +0 -2
- data/ruby/trema/network-component.rb +1 -1
- data/ruby/trema/open-vswitch.rb +2 -2
- data/ruby/trema/openflow-switch.rb +3 -54
- data/ruby/trema/{packet_in.c → packet-in.c} +262 -175
- data/ruby/trema/{packet_in.h → packet-in.h} +0 -2
- data/ruby/trema/packet-queue.rb +4 -3
- data/ruby/trema/port-mod.c +8 -9
- data/ruby/trema/port-status-add.rb +60 -0
- data/ruby/trema/port-status-delete.rb +60 -0
- data/ruby/trema/port-status-modify.rb +60 -0
- data/ruby/trema/port-status.c +48 -15
- data/ruby/trema/port-status.h +6 -8
- data/ruby/trema/port.c +63 -8
- data/ruby/trema/queue-get-config-request.c +1 -0
- data/ruby/trema/ruby-switch.rb +62 -0
- data/ruby/trema/send-out-port.rb +97 -0
- data/ruby/trema/set-config.c +1 -0
- data/ruby/trema/set-eth-addr.rb +45 -0
- data/ruby/trema/set-eth-dst-addr.rb +54 -0
- data/ruby/trema/set-eth-src-addr.rb +54 -0
- data/ruby/trema/set-ip-addr.rb +47 -0
- data/ruby/trema/set-ip-dst-addr.rb +53 -0
- data/ruby/trema/set-ip-src-addr.rb +52 -0
- data/ruby/trema/set-ip-tos.rb +63 -0
- data/ruby/trema/set-transport-dst-port.rb +53 -0
- data/ruby/trema/set-transport-port.rb +52 -0
- data/ruby/trema/set-transport-src-port.rb +54 -0
- data/ruby/trema/set-vlan-priority.rb +65 -0
- data/ruby/trema/set-vlan-vid.rb +64 -0
- data/ruby/trema/shell/down.rb +1 -1
- data/ruby/trema/shell/link.rb +4 -4
- data/ruby/trema/shell/run.rb +8 -6
- data/ruby/trema/shell/up.rb +3 -3
- data/ruby/trema/stats-reply.c +27 -2
- data/ruby/trema/stats-request.c +64 -23
- data/ruby/trema/strip-vlan-header.rb +41 -0
- data/ruby/trema/switch.c +196 -0
- data/ruby/trema/{action-vendor.h → switch.h} +5 -7
- data/ruby/trema/switch.rb +28 -9
- data/ruby/trema/trema-ruby-utils.c +66 -0
- data/ruby/trema/{action-set-dl-src.h → trema-ruby-utils.h} +9 -11
- data/ruby/trema/trema.c +61 -61
- data/ruby/trema/vendor-action.rb +73 -0
- data/ruby/trema/vendor.c +121 -52
- data/ruby/trema/vendor.h +6 -10
- data/ruby/trema/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/action.rb +52 -0
- data/spec/support/mandatory-option.rb +56 -0
- data/spec/support/openflow-message.rb +91 -7
- data/spec/support/port-status.rb +38 -0
- data/spec/trema/controller_spec.rb +0 -26
- data/spec/trema/dsl/configuration_spec.rb +3 -3
- data/spec/trema/dsl/runner_spec.rb +12 -32
- data/spec/trema/dsl/syntax_spec.rb +2 -11
- data/spec/trema/echo-reply_spec.rb +49 -14
- data/spec/trema/echo-request_spec.rb +86 -34
- data/spec/trema/enqueue_spec.rb +76 -0
- data/spec/trema/error_spec.rb +43 -58
- data/spec/trema/features-reply_spec.rb +58 -24
- data/spec/trema/features-request_spec.rb +54 -28
- data/spec/trema/flow-mod_spec.rb +99 -0
- data/spec/trema/{openflow-switch_spec.rb → hardware-switch_spec.rb} +3 -3
- data/spec/trema/hello_spec.rb +28 -14
- data/spec/trema/ip_spec.rb +54 -0
- data/spec/trema/mac_spec.rb +49 -64
- data/spec/trema/match_spec.rb +1 -1
- data/spec/trema/open-vswitch_spec.rb +7 -7
- data/spec/trema/packet-in_spec.rb +73 -16
- data/spec/trema/port-status-add_spec.rb +32 -0
- data/spec/trema/port-status-delete_spec.rb +32 -0
- data/spec/trema/port-status-modify_spec.rb +71 -0
- data/spec/trema/port-status_spec.rb +5 -76
- data/spec/trema/{action-output_spec.rb → send-out-port_spec.rb} +20 -47
- data/spec/trema/set-eth-dst-addr_spec.rb +75 -0
- data/spec/trema/set-eth-src-addr_spec.rb +72 -0
- data/spec/trema/set-ip-dst-addr_spec.rb +58 -0
- data/spec/trema/set-ip-src-addr_spec.rb +58 -0
- data/spec/trema/set-ip-tos_spec.rb +65 -0
- data/spec/trema/set-transport-dst-port_spec.rb +65 -0
- data/spec/trema/set-transport-src-port_spec.rb +65 -0
- data/spec/trema/set-vlan-priority_spec.rb +65 -0
- data/spec/trema/set-vlan-vid_spec.rb +65 -0
- data/spec/trema/shell/vhost_spec.rb +4 -1
- data/spec/trema/shell/vswitch_spec.rb +11 -11
- data/spec/trema/stats-reply_spec.rb +59 -13
- data/spec/trema/stats-request_spec.rb +6 -0
- data/spec/trema/{action-strip-vlan_spec.rb → strip-vlan-header_spec.rb} +3 -17
- data/spec/trema/switch-daemon_spec.rb +39 -0
- data/spec/trema/vendor-action_spec.rb +81 -0
- data/spec/trema/vendor_spec.rb +76 -0
- data/spec/trema_spec.rb +56 -0
- data/src/examples/dumper/dumper.c +0 -8
- data/src/examples/dumper/dumper.rb +52 -52
- data/src/examples/hello_trema/hello_trema.c +0 -2
- data/src/examples/learning_switch/learning-switch.rb +3 -3
- data/src/examples/multi_learning_switch/multi-learning-switch.rb +3 -3
- data/src/examples/openflow_message/features-request.rb +3 -3
- data/src/examples/packetin_filter_config/utils.c +4 -4
- data/src/examples/repeater_hub/repeater-hub.rb +3 -3
- data/src/examples/switch_info/switch_info.rb +2 -2
- data/src/examples/switch_monitor/switch_monitor.c +1 -1
- data/src/examples/traffic_monitor/traffic-monitor.rb +3 -3
- data/src/lib/arp.h +4 -1
- data/src/lib/chibach.c +391 -0
- data/src/lib/chibach.h +71 -0
- data/src/lib/chibach_private.c +170 -0
- data/src/lib/chibach_private.h +52 -0
- data/src/lib/ether.c +2 -1
- data/src/lib/ether.h +0 -1
- data/src/lib/ipv4.h +13 -14
- data/{ruby/trema/action-set-nw-src.h → src/lib/ipv6.h} +13 -9
- data/src/lib/log.c +161 -58
- data/src/lib/log.h +11 -16
- data/src/lib/messenger.c +36 -1
- data/src/lib/messenger.h +1 -0
- data/src/lib/openflow_application_interface.c +128 -28
- data/src/lib/openflow_application_interface.h +31 -6
- data/src/lib/openflow_message.c +2 -1
- data/src/lib/openflow_service_interface.h +1 -0
- data/src/lib/openflow_switch_interface.c +1380 -0
- data/src/lib/openflow_switch_interface.h +264 -0
- data/src/lib/packet_info.c +94 -11
- data/src/lib/packet_info.h +22 -3
- data/src/lib/packet_parser.c +38 -2
- data/src/lib/secure_channel.c +498 -0
- data/{ruby/trema/vendor-request.h → src/lib/secure_channel.h} +11 -10
- data/src/lib/tcp.h +0 -3
- data/src/lib/trema.c +38 -5
- data/{ruby/trema/action-set-nw-dst.h → src/lib/trema.hpp} +17 -8
- data/src/lib/trema_wrapper.c +5 -0
- data/src/lib/trema_wrapper.h +4 -0
- data/src/lib/utility.c +93 -4
- data/src/lib/utility.h +1 -0
- data/src/lib/wrapper.c +30 -7
- data/src/lib/wrapper.h +2 -0
- data/src/switch_manager/ofpmsg_recv.c +44 -30
- data/src/switch_manager/ofpmsg_send.c +40 -1
- data/src/switch_manager/ofpmsg_send.h +2 -0
- data/src/switch_manager/switch.c +153 -8
- data/src/switch_manager/switch.h +1 -0
- data/src/switch_manager/switchinfo.h +5 -0
- data/src/tremashark/README +2 -2
- data/src/tremashark/plugin/packet-trema/packet-trema.c +1 -0
- data/trema +1 -1
- data/unittests/lib/log_test.c +158 -34
- data/unittests/lib/openflow_application_interface_test.c +252 -69
- data/unittests/lib/openflow_message_test.c +3 -1
- data/unittests/lib/packet_parser_test.c +60 -15
- data/unittests/lib/test_packets/icmp6_echo_rep.cap +0 -0
- data/unittests/lib/test_packets/icmp6_echo_req.cap +0 -0
- data/unittests/lib/trema_test.c +2 -0
- data/unittests/lib/utility_test.c +65 -2
- data/unittests/lib/wrapper_test.c +29 -0
- data/vendor/{README → README.md} +2 -12
- data/vendor/packet-openflow.diff +13 -0
- metadata +86 -53
- data/GPL2 +0 -339
- data/ruby/trema/action-enqueue.c +0 -161
- data/ruby/trema/action-output.c +0 -169
- data/ruby/trema/action-set-dl-dst.c +0 -131
- data/ruby/trema/action-set-dl-dst.h +0 -44
- data/ruby/trema/action-set-dl-src.c +0 -131
- data/ruby/trema/action-set-nw-dst.c +0 -135
- data/ruby/trema/action-set-nw-src.c +0 -140
- data/ruby/trema/action-set-nw-tos.c +0 -124
- data/ruby/trema/action-set-nw-tos.h +0 -42
- data/ruby/trema/action-set-tp-dst.c +0 -122
- data/ruby/trema/action-set-tp-dst.h +0 -42
- data/ruby/trema/action-set-tp-src.c +0 -124
- data/ruby/trema/action-set-tp-src.h +0 -42
- data/ruby/trema/action-set-vlan-pcp.c +0 -128
- data/ruby/trema/action-set-vlan-pcp.h +0 -42
- data/ruby/trema/action-set-vlan-vid.c +0 -125
- data/ruby/trema/action-set-vlan-vid.h +0 -42
- data/ruby/trema/action-strip-vlan.c +0 -81
- data/ruby/trema/action-strip-vlan.h +0 -42
- data/ruby/trema/action-vendor.c +0 -121
- data/ruby/trema/vendor-request.c +0 -193
- data/spec/trema/action-enqueue_spec.rb +0 -100
- data/spec/trema/action-set-dl-dst_spec.rb +0 -95
- data/spec/trema/action-set-dl-src_spec.rb +0 -92
- data/spec/trema/action-set-nw-dst_spec.rb +0 -96
- data/spec/trema/action-set-nw-src_spec.rb +0 -97
- data/spec/trema/action-set-nw-tos_spec.rb +0 -88
- data/spec/trema/action-set-tp-dst_spec.rb +0 -88
- data/spec/trema/action-set-tp-src_spec.rb +0 -88
- data/spec/trema/action-set-vlan-pcp_spec.rb +0 -91
- data/spec/trema/action-set-vlan-vid_spec.rb +0 -91
- data/spec/trema/action-vendor_spec.rb +0 -90
- data/spec/trema/vendor-request_spec.rb +0 -79
data/ruby/trema/vendor.h
CHANGED
|
@@ -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
|
|
@@ -30,15 +28,13 @@ extern VALUE cVendor;
|
|
|
30
28
|
|
|
31
29
|
|
|
32
30
|
void Init_vendor( void );
|
|
33
|
-
|
|
34
|
-
|
|
35
31
|
void handle_vendor(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
uint64_t datapath_id,
|
|
33
|
+
uint32_t transaction_id,
|
|
34
|
+
uint32_t vendor,
|
|
35
|
+
const buffer *data,
|
|
36
|
+
void *user_data
|
|
37
|
+
);
|
|
42
38
|
|
|
43
39
|
|
|
44
40
|
#endif // VENDOR_H
|
data/ruby/trema/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) 2008-2012 NEC Corporation
|
|
3
|
+
#
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License, version 2, as
|
|
6
|
+
# published by the Free Software Foundation.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
require "rubygems"
|
|
20
|
+
require "rspec"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
shared_examples_for "option range" do | option, range |
|
|
24
|
+
context "when #{ option } is within #{ range }" do
|
|
25
|
+
let( option ) { range.first }
|
|
26
|
+
it { expect { subject }.not_to raise_error( ArgumentError ) }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
context "when #{ option } < #{ range.first }" do
|
|
31
|
+
let( option ) { range.first - 1 }
|
|
32
|
+
it { expect { subject }.to raise_error( ArgumentError ) }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
context "when #{ option } > #{ range.last }" do
|
|
37
|
+
let( option ) { range.last + 1 }
|
|
38
|
+
it { expect { subject }.to raise_error( ArgumentError ) }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
RSpec.configure do | config |
|
|
44
|
+
config.alias_it_should_behave_like_to :it_validates, "it validates"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Local variables:
|
|
49
|
+
### mode: Ruby
|
|
50
|
+
### coding: utf-8-unix
|
|
51
|
+
### indent-tabs-mode: nil
|
|
52
|
+
### End:
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) 2008-2012 NEC Corporation
|
|
3
|
+
#
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License, version 2, as
|
|
6
|
+
# published by the Free Software Foundation.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
require "rubygems"
|
|
20
|
+
require "rspec"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
shared_examples_for "any Openflow message with mandatory options" do | options |
|
|
24
|
+
subject do
|
|
25
|
+
opt_hash = {}
|
|
26
|
+
options[ :options ].each do | each |
|
|
27
|
+
opt_hash[ each[ :name ] ] = __send__( each[ :name ] )
|
|
28
|
+
end
|
|
29
|
+
options[ :klass ].new( opt_hash )
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
options[ :options ].each do | each |
|
|
33
|
+
let( each[ :name ] ) { each[ :sample_value ] }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
options[ :options ].each do | each |
|
|
38
|
+
context "with :#{ each[ :name ] } (#{ each[ :sample_value ] })" do
|
|
39
|
+
let( each[ :name ] ) { each[ :sample_value ] }
|
|
40
|
+
its( each[ :name ] ) { should == each[ :sample_value ] }
|
|
41
|
+
its( each[ :alias ] ) { should == each[ :sample_value ] } if each[ :alias ]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context "without :#{ each[ :name ] }" do
|
|
45
|
+
let( each[ :name ] ) { nil }
|
|
46
|
+
it { expect { subject }.to raise_error( ArgumentError, ":#{ each[ :name ] } is a mandatory option" ) }
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Local variables:
|
|
53
|
+
### mode: Ruby
|
|
54
|
+
### coding: utf-8-unix
|
|
55
|
+
### indent-tabs-mode: nil
|
|
56
|
+
### End:
|
|
@@ -23,8 +23,92 @@ require "rspec"
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
shared_examples_for "any Openflow message with default transaction ID" do
|
|
26
|
-
its( :transaction_id ) { should be_a_kind_of( Integer ) }
|
|
27
26
|
its( :transaction_id ) { should be_unsigned_32bit }
|
|
27
|
+
its( :xid ) { should be_unsigned_32bit }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
shared_examples_for "any Openflow message with transaction ID" do
|
|
32
|
+
context "transaction_id: -123", :nosudo => true do
|
|
33
|
+
let( :transaction_id ) { -123 }
|
|
34
|
+
it { expect { subject }.to raise_error( ArgumentError, "Transaction ID must be an unsigned 32-bit integer" ) }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context "transaction_id: 0", :nosudo => true do
|
|
38
|
+
let( :transaction_id ) { 0 }
|
|
39
|
+
its( :transaction_id ) { should == 0 }
|
|
40
|
+
its( :xid ) { should == 0 }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context "transaction_id: 123", :nosudo => true do
|
|
44
|
+
let( :transaction_id ) { 123 }
|
|
45
|
+
its( :transaction_id ) { should == 123 }
|
|
46
|
+
its( :xid ) { should == 123 }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context "transaction_id: UINT32_MAX", :nosudo => true do
|
|
50
|
+
let( :transaction_id ) { 2 ** 32 - 1 }
|
|
51
|
+
its( :transaction_id ) { should == 2 ** 32 - 1 }
|
|
52
|
+
its( :xid ) { should == 2 ** 32 - 1 }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context "transaction_id: UINT32_MAX + 1", :nosudo => true do
|
|
56
|
+
let( :transaction_id ) { 2 ** 32 }
|
|
57
|
+
it { expect { subject }.to raise_error( ArgumentError, "Transaction ID must be an unsigned 32-bit integer" ) }
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
shared_examples_for "any Openflow message with xid" do
|
|
63
|
+
context "xid: -123", :nosudo => true do
|
|
64
|
+
let( :xid ) { -123 }
|
|
65
|
+
it { expect { subject }.to raise_error( ArgumentError, "Transaction ID must be an unsigned 32-bit integer" ) }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context "xid: 0", :nosudo => true do
|
|
69
|
+
let( :xid ) { 0 }
|
|
70
|
+
its( :xid ) { should == 0 }
|
|
71
|
+
its( :transaction_id ) { should == 0 }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
context "xid: 123", :nosudo => true do
|
|
75
|
+
let( :xid ) { 123 }
|
|
76
|
+
its( :xid ) { should == 123 }
|
|
77
|
+
its( :transaction_id ) { should == 123 }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
context "xid: UINT32_MAX", :nosudo => true do
|
|
81
|
+
let( :xid ) { 2 ** 32 - 1 }
|
|
82
|
+
its( :xid ) { should == 2 ** 32 - 1 }
|
|
83
|
+
its( :transaction_id ) { should == 2 ** 32 - 1 }
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
context "xid: UINT32_MAX + 1", :nosudo => true do
|
|
87
|
+
let( :xid ) { 2 ** 32 }
|
|
88
|
+
it { expect { subject }.to raise_error( ArgumentError, "Transaction ID must be an unsigned 32-bit integer" ) }
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
shared_examples_for "any Openflow message with user_data" do
|
|
94
|
+
context "user_data: nil", :nosudo => true do
|
|
95
|
+
let( :user_data ) { nil }
|
|
96
|
+
its( :user_data ) { should be_nil }
|
|
97
|
+
it_should_behave_like "any Openflow message with default transaction ID"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
context 'user_data: "USER DATA"', :nosudo => true do
|
|
102
|
+
let( :user_data ) { "USER DATA" }
|
|
103
|
+
its( :user_data ) { should == "USER DATA" }
|
|
104
|
+
it_should_behave_like "any Openflow message with default transaction ID"
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
context "user_data: :INVALID_DATA", :nosudo => true do
|
|
109
|
+
let( :user_data ) { :INVALID_DATA }
|
|
110
|
+
it { expect { subject }.to raise_error( TypeError ) }
|
|
111
|
+
end
|
|
28
112
|
end
|
|
29
113
|
|
|
30
114
|
|
|
@@ -33,12 +117,12 @@ shared_examples_for "any OpenFlow message" do | options |
|
|
|
33
117
|
name = options[ :name ]
|
|
34
118
|
size = options[ :size ]
|
|
35
119
|
case size
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
120
|
+
when 8
|
|
121
|
+
let( :uint_max ) { 2 ** 8 - 1 }
|
|
122
|
+
when 16
|
|
123
|
+
let( :uint_max ) { 2 ** 16 - 1 }
|
|
124
|
+
when 32
|
|
125
|
+
let( :uint_max ) { 2 ** 32 - 1 }
|
|
42
126
|
end
|
|
43
127
|
|
|
44
128
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) 2008-2012 NEC Corporation
|
|
3
|
+
#
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License, version 2, as
|
|
6
|
+
# published by the Free Software Foundation.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
require "rubygems"
|
|
20
|
+
require "rspec"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
shared_examples_for "port status message" do | options |
|
|
24
|
+
it_should_behave_like(
|
|
25
|
+
"any Openflow message with mandatory options",
|
|
26
|
+
:klass => options[ :klass ],
|
|
27
|
+
:options => [ { :name => :datapath_id, :alias => :dpid, :sample_value => 0xabc },
|
|
28
|
+
{ :name => :transaction_id, :alias => :xid, :sample_value => 123 },
|
|
29
|
+
{ :name => :phy_port, :sample_value => "PHY_PORT" } ]
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Local variables:
|
|
35
|
+
### mode: Ruby
|
|
36
|
+
### coding: utf-8-unix
|
|
37
|
+
### indent-tabs-mode: nil
|
|
38
|
+
### End:
|
|
@@ -36,32 +36,6 @@ module Trema
|
|
|
36
36
|
it { should include "OFPP_CONTROLLER" }
|
|
37
37
|
it { should include "OFPP_LOCAL" }
|
|
38
38
|
it { should include "OFPP_NONE" }
|
|
39
|
-
|
|
40
|
-
it { should include "OFPPR_ADD" }
|
|
41
|
-
it { should include "OFPPR_DELETE" }
|
|
42
|
-
it { should include "OFPPR_MODIFY" }
|
|
43
|
-
|
|
44
|
-
it { should include "OFPC_FLOW_STATS" }
|
|
45
|
-
it { should include "OFPC_TABLE_STATS" }
|
|
46
|
-
it { should include "OFPC_PORT_STATS" }
|
|
47
|
-
it { should include "OFPC_STP" }
|
|
48
|
-
it { should include "OFPC_RESERVED" }
|
|
49
|
-
it { should include "OFPC_IP_REASM" }
|
|
50
|
-
it { should include "OFPC_QUEUE_STATS" }
|
|
51
|
-
it { should include "OFPC_ARP_MATCH_IP" }
|
|
52
|
-
|
|
53
|
-
it { should include "OFPAT_OUTPUT" }
|
|
54
|
-
it { should include "OFPAT_SET_VLAN_VID" }
|
|
55
|
-
it { should include "OFPAT_SET_VLAN_PCP" }
|
|
56
|
-
it { should include "OFPAT_STRIP_VLAN" }
|
|
57
|
-
it { should include "OFPAT_SET_DL_SRC" }
|
|
58
|
-
it { should include "OFPAT_SET_DL_DST" }
|
|
59
|
-
it { should include "OFPAT_SET_NW_SRC" }
|
|
60
|
-
it { should include "OFPAT_SET_NW_DST" }
|
|
61
|
-
it { should include "OFPAT_SET_NW_TOS" }
|
|
62
|
-
it { should include "OFPAT_SET_TP_DST" }
|
|
63
|
-
it { should include "OFPAT_ENQUEUE" }
|
|
64
|
-
it { should include "OFPAT_VENDOR" }
|
|
65
39
|
end
|
|
66
40
|
|
|
67
41
|
|
|
@@ -99,9 +99,9 @@ module Trema
|
|
|
99
99
|
it "should remember switches" do
|
|
100
100
|
@context.should have( 0 ).switches
|
|
101
101
|
|
|
102
|
-
Trema::
|
|
103
|
-
Trema::
|
|
104
|
-
Trema::
|
|
102
|
+
Trema::OpenflowSwitch.add mock( "switch #0", :name => "switch #0" )
|
|
103
|
+
Trema::OpenflowSwitch.add mock( "switch #1", :name => "switch #1" )
|
|
104
|
+
Trema::OpenflowSwitch.add mock( "switch #2", :name => "switch #2" )
|
|
105
105
|
|
|
106
106
|
@context.should have( 3 ).switches
|
|
107
107
|
|
|
@@ -35,26 +35,6 @@ module Trema
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
context "when running" do
|
|
38
|
-
it "should run tremashark" do
|
|
39
|
-
tremashark = mock
|
|
40
|
-
tremashark.should_receive( :run ).once
|
|
41
|
-
|
|
42
|
-
context = mock(
|
|
43
|
-
"context",
|
|
44
|
-
:tremashark => tremashark,
|
|
45
|
-
:switch_manager => nil,
|
|
46
|
-
:packetin_filter => nil,
|
|
47
|
-
:links => {},
|
|
48
|
-
:hosts => {},
|
|
49
|
-
:switches => {},
|
|
50
|
-
:apps => {},
|
|
51
|
-
:port => 6633
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
Runner.new( context ).run
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
|
|
58
38
|
it "should run switch_manager" do
|
|
59
39
|
@switch_manager.should_receive( :run! ).once
|
|
60
40
|
|
|
@@ -96,16 +76,16 @@ module Trema
|
|
|
96
76
|
|
|
97
77
|
it "should create links" do
|
|
98
78
|
link0 = mock( "link0" )
|
|
99
|
-
link0.should_receive( :delete! ).once
|
|
100
|
-
link0.should_receive( :enable! ).once
|
|
79
|
+
link0.should_receive( :delete! ).once
|
|
80
|
+
link0.should_receive( :enable! ).once
|
|
101
81
|
|
|
102
82
|
link1 = mock( "link1" )
|
|
103
|
-
link1.should_receive( :delete! ).once
|
|
104
|
-
link1.should_receive( :enable! ).once
|
|
83
|
+
link1.should_receive( :delete! ).once
|
|
84
|
+
link1.should_receive( :enable! ).once
|
|
105
85
|
|
|
106
86
|
link2 = mock( "link2" )
|
|
107
|
-
link2.should_receive( :delete! ).once
|
|
108
|
-
link2.should_receive( :enable! ).once
|
|
87
|
+
link2.should_receive( :delete! ).once
|
|
88
|
+
link2.should_receive( :enable! ).once
|
|
109
89
|
|
|
110
90
|
context = mock(
|
|
111
91
|
"context",
|
|
@@ -128,21 +108,21 @@ module Trema
|
|
|
128
108
|
host1 = mock( "host1" )
|
|
129
109
|
host2 = mock( "host2" )
|
|
130
110
|
|
|
131
|
-
host0.should_receive( :run! ).once
|
|
111
|
+
host0.should_receive( :run! ).once
|
|
132
112
|
host0.should_receive( :add_arp_entry ).with do | arg |
|
|
133
113
|
arg.size.should == 2
|
|
134
114
|
arg.should include( host1 )
|
|
135
115
|
arg.should include( host2 )
|
|
136
116
|
end
|
|
137
117
|
|
|
138
|
-
host1.should_receive( :run! ).once
|
|
118
|
+
host1.should_receive( :run! ).once
|
|
139
119
|
host1.should_receive( :add_arp_entry ).with do | arg |
|
|
140
120
|
arg.size.should == 2
|
|
141
121
|
arg.should include( host0 )
|
|
142
122
|
arg.should include( host2 )
|
|
143
123
|
end
|
|
144
124
|
|
|
145
|
-
host2.should_receive( :run! ).once
|
|
125
|
+
host2.should_receive( :run! ).once
|
|
146
126
|
host2.should_receive( :add_arp_entry ).with do | arg |
|
|
147
127
|
arg.size.should == 2
|
|
148
128
|
arg.should include( host0 )
|
|
@@ -167,13 +147,13 @@ module Trema
|
|
|
167
147
|
|
|
168
148
|
it "should run switches" do
|
|
169
149
|
switch0 = mock( "switch0" )
|
|
170
|
-
switch0.should_receive( :run! ).once
|
|
150
|
+
switch0.should_receive( :run! ).once
|
|
171
151
|
|
|
172
152
|
switch1 = mock( "switch1" )
|
|
173
|
-
switch1.should_receive( :run! ).once
|
|
153
|
+
switch1.should_receive( :run! ).once
|
|
174
154
|
|
|
175
155
|
switch2 = mock( "switch2" )
|
|
176
|
-
switch2.should_receive( :run! ).once
|
|
156
|
+
switch2.should_receive( :run! ).once
|
|
177
157
|
|
|
178
158
|
context = mock(
|
|
179
159
|
"context",
|