trema 0.2.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- 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/spec/trema/match_spec.rb
CHANGED
@@ -53,7 +53,7 @@ describe Match, ".new" do
|
|
53
53
|
its( :nw_dst ) { subject.prefixlen.should == 24 }
|
54
54
|
its( :tp_src ) { should == 10 }
|
55
55
|
its( :tp_dst ) { should == 20 }
|
56
|
-
its( :to_s ) { should == "wildcards = 0x20000, in_port = 1, dl_src = 00:00:00:00:00:01, dl_dst = 00:00:00:00:00:02, dl_vlan = 65535, dl_vlan_pcp = 0, dl_type = 0x800, nw_tos = 0, nw_proto = 17, nw_src = 192.168.0.1/32, nw_dst = 192.168.0.0/24, tp_src = 10, tp_dst = 20" }
|
56
|
+
its( :to_s ) { should == "wildcards = 0x20000(nw_dst(8)), in_port = 1, dl_src = 00:00:00:00:00:01, dl_dst = 00:00:00:00:00:02, dl_vlan = 65535, dl_vlan_pcp = 0, dl_type = 0x800, nw_tos = 0, nw_proto = 17, nw_src = 192.168.0.1/32, nw_dst = 192.168.0.0/24, tp_src = 10, tp_dst = 20" }
|
57
57
|
end
|
58
58
|
|
59
59
|
|
@@ -23,13 +23,13 @@ require "trema/open-vswitch"
|
|
23
23
|
|
24
24
|
|
25
25
|
module Trema
|
26
|
-
describe
|
26
|
+
describe OpenflowSwitch do
|
27
27
|
around do | example |
|
28
28
|
begin
|
29
|
-
|
29
|
+
OpenflowSwitch.clear
|
30
30
|
example.run
|
31
31
|
ensure
|
32
|
-
|
32
|
+
OpenflowSwitch.clear
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -38,10 +38,10 @@ module Trema
|
|
38
38
|
OpenVswitch.new mock( "stanza 1", :name => "vswitch 1", :validate => true )
|
39
39
|
OpenVswitch.new mock( "stanza 2", :name => "vswitch 2", :validate => true )
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
OpenflowSwitch.should have( 3 ).vswitches
|
42
|
+
OpenflowSwitch[ "vswitch 0" ].should_not be_nil
|
43
|
+
OpenflowSwitch[ "vswitch 1" ].should_not be_nil
|
44
|
+
OpenflowSwitch[ "vswitch 2" ].should_not be_nil
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -27,11 +27,11 @@ describe Trema::PacketIn do
|
|
27
27
|
send_packets "host1", "host2"
|
28
28
|
sleep 2
|
29
29
|
end
|
30
|
-
|
31
|
-
|
30
|
+
|
31
|
+
|
32
32
|
class PacketInController < Controller; end
|
33
33
|
|
34
|
-
class PacketInSendController < Controller
|
34
|
+
class PacketInSendController < Controller
|
35
35
|
def packet_in datapath_id, message
|
36
36
|
send_flow_mod_add(
|
37
37
|
datapath_id,
|
@@ -45,7 +45,7 @@ describe Trema::PacketIn do
|
|
45
45
|
)
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
context "when instance is created" do
|
50
50
|
it "should have valid datapath_id and in_port" do
|
51
51
|
network {
|
@@ -55,7 +55,7 @@ describe Trema::PacketIn do
|
|
55
55
|
link "test", "host1"
|
56
56
|
link "test", "host2"
|
57
57
|
}.run( PacketInController ) {
|
58
|
-
controller( "PacketInController" ).should_receive( :packet_in ) do | datapath_id, message |
|
58
|
+
controller( "PacketInController" ).should_receive( :packet_in ) do | datapath_id, message |
|
59
59
|
datapath_id.should == 0xabc
|
60
60
|
message.datapath_id.should == 0xabc
|
61
61
|
message.in_port.should > 0
|
@@ -63,19 +63,19 @@ describe Trema::PacketIn do
|
|
63
63
|
send_and_wait
|
64
64
|
}
|
65
65
|
end
|
66
|
-
|
67
|
-
|
66
|
+
|
67
|
+
|
68
68
|
it "should have vaild user data" do
|
69
69
|
network {
|
70
70
|
vswitch( "test" ) { datapath_id 0xabc }
|
71
|
-
vhost( "host1" ) { mac "00:00:00:00:00:01"
|
71
|
+
vhost( "host1" ) { mac "00:00:00:00:00:01"
|
72
72
|
ip "192.168.1.1" }
|
73
|
-
vhost( "host2" ) { mac "00:00:00:00:00:02"
|
73
|
+
vhost( "host2" ) { mac "00:00:00:00:00:02"
|
74
74
|
ip "192.168.1.2" }
|
75
75
|
link "test", "host1"
|
76
76
|
link "test", "host2"
|
77
77
|
}.run( PacketInController ) {
|
78
|
-
controller( "PacketInController" ).should_receive( :packet_in ) do | datapath_id, message |
|
78
|
+
controller( "PacketInController" ).should_receive( :packet_in ) do | datapath_id, message |
|
79
79
|
# packet_in expected to have data portion.
|
80
80
|
message.total_len.should > 20
|
81
81
|
message.data.should be_instance_of( String )
|
@@ -129,7 +129,7 @@ describe Trema::PacketIn do
|
|
129
129
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
130
130
|
0x00, 0x00
|
131
131
|
].pack( "C*" )
|
132
|
-
controller( "PacketInSendController" ).should_receive( :packet_in ) do | datapath_id, message |
|
132
|
+
controller( "PacketInSendController" ).should_receive( :packet_in ) do | datapath_id, message |
|
133
133
|
message.in_port.should > 0
|
134
134
|
message.vtag?.should be_false
|
135
135
|
message.arp?.should be_true
|
@@ -144,6 +144,52 @@ describe Trema::PacketIn do
|
|
144
144
|
message.arp_spa.to_s.should == "192.168.0.1"
|
145
145
|
message.arp_tha.to_s.should == "00:00:00:00:00:02"
|
146
146
|
message.arp_tpa.to_s.should == "192.168.0.2"
|
147
|
+
message.arp_request?.should be_false
|
148
|
+
message.arp_reply?.should be_true
|
149
|
+
|
150
|
+
message.vlan_tpid.should be_nil
|
151
|
+
message.vlan_tci.should be_nil
|
152
|
+
message.vlan_prio.should be_nil
|
153
|
+
message.vlan_cfi.should be_nil
|
154
|
+
message.vlan_vid.should be_nil
|
155
|
+
|
156
|
+
message.ipv4_version.should be_nil
|
157
|
+
message.ipv4_ihl.should be_nil
|
158
|
+
message.ipv4_tos.should be_nil
|
159
|
+
message.ipv4_tot_len.should be_nil
|
160
|
+
message.ipv4_id.should be_nil
|
161
|
+
message.ipv4_frag_off.should be_nil
|
162
|
+
message.ipv4_ttl.should be_nil
|
163
|
+
message.ipv4_protocol.should be_nil
|
164
|
+
message.ipv4_checksum.should be_nil
|
165
|
+
message.ipv4_saddr.should be_nil
|
166
|
+
message.ipv4_daddr.should be_nil
|
167
|
+
|
168
|
+
message.icmpv4_type.should be_nil
|
169
|
+
message.icmpv4_code.should be_nil
|
170
|
+
message.icmpv4_checksum.should be_nil
|
171
|
+
message.icmpv4_id.should be_nil
|
172
|
+
message.icmpv4_seq.should be_nil
|
173
|
+
message.icmpv4_gateway.should be_nil
|
174
|
+
|
175
|
+
message.igmp_type.should be_nil
|
176
|
+
message.igmp_checksum.should be_nil
|
177
|
+
message.igmp_group.should be_nil
|
178
|
+
|
179
|
+
message.tcp_src_port.should be_nil
|
180
|
+
message.tcp_dst_port.should be_nil
|
181
|
+
message.tcp_seq_no.should be_nil
|
182
|
+
message.tcp_ack_no.should be_nil
|
183
|
+
message.tcp_offset.should be_nil
|
184
|
+
message.tcp_flags.should be_nil
|
185
|
+
message.tcp_window.should be_nil
|
186
|
+
message.tcp_checksum.should be_nil
|
187
|
+
message.tcp_urgent.should be_nil
|
188
|
+
|
189
|
+
message.udp_src_port.should be_nil
|
190
|
+
message.udp_dst_port.should be_nil
|
191
|
+
message.udp_checksum.should be_nil
|
192
|
+
message.udp_len.should be_nil
|
147
193
|
end
|
148
194
|
|
149
195
|
controller( "PacketInSendController" ).send_packet_out(
|
@@ -186,14 +232,14 @@ describe Trema::PacketIn do
|
|
186
232
|
0x00, 0x02, # dst port
|
187
233
|
0x00, 0x00, 0x00, 0x00, # sequence number
|
188
234
|
0x00, 0x00, 0x00, 0x00, # acknowledgement number
|
189
|
-
0x50, # data offset,
|
235
|
+
0x50, # data offset,
|
190
236
|
0x00, # flags
|
191
237
|
0x00, 0x00, # window size
|
192
238
|
0x2e, 0x86, # checksum
|
193
239
|
0x00, 0x00, # urgent pointer
|
194
240
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
195
241
|
].pack( "C*" )
|
196
|
-
controller( "PacketInSendController" ).should_receive( :packet_in ) do | datapath_id, message |
|
242
|
+
controller( "PacketInSendController" ).should_receive( :packet_in ) do | datapath_id, message |
|
197
243
|
message.in_port.should > 0
|
198
244
|
message.vtag?.should be_false
|
199
245
|
message.arp?.should be_false
|
@@ -224,6 +270,12 @@ describe Trema::PacketIn do
|
|
224
270
|
message.tcp_window.should == 0
|
225
271
|
message.tcp_checksum.should == 11910 # 0x2e86
|
226
272
|
message.tcp_urgent.should == 0
|
273
|
+
|
274
|
+
message.arp_oper.should be_nil
|
275
|
+
message.arp_sha.should be_nil
|
276
|
+
message.arp_spa.should be_nil
|
277
|
+
message.arp_tha.should be_nil
|
278
|
+
message.arp_tpa.should be_nil
|
227
279
|
end
|
228
280
|
|
229
281
|
controller( "PacketInSendController" ).send_packet_out(
|
@@ -270,7 +322,7 @@ describe Trema::PacketIn do
|
|
270
322
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
271
323
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
272
324
|
].pack( "C*" )
|
273
|
-
controller( "PacketInSendController" ).should_receive( :packet_in ) do | datapath_id, message |
|
325
|
+
controller( "PacketInSendController" ).should_receive( :packet_in ) do | datapath_id, message |
|
274
326
|
message.in_port.should > 0
|
275
327
|
message.vtag?.should be_false
|
276
328
|
message.arp?.should be_false
|
@@ -347,7 +399,7 @@ describe Trema::PacketIn do
|
|
347
399
|
0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61,
|
348
400
|
0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69
|
349
401
|
].pack( "C*" )
|
350
|
-
controller( "PacketInSendController" ).should_receive( :packet_in ) do | datapath_id, message |
|
402
|
+
controller( "PacketInSendController" ).should_receive( :packet_in ) do | datapath_id, message |
|
351
403
|
message.in_port.should > 0
|
352
404
|
message.vtag?.should be_true
|
353
405
|
message.arp?.should be_false
|
@@ -381,6 +433,11 @@ describe Trema::PacketIn do
|
|
381
433
|
message.icmpv4_checksum.should == 0xe95b
|
382
434
|
message.icmpv4_id.should == 0x0400
|
383
435
|
message.icmpv4_seq.should == 0x6000
|
436
|
+
|
437
|
+
message.icmpv4_echo_reply?.should be_false
|
438
|
+
message.icmpv4_dst_unreach?.should be_false
|
439
|
+
message.icmpv4_redirect?.should be_false
|
440
|
+
message.icmpv4_echo_request?.should be_true
|
384
441
|
end
|
385
442
|
|
386
443
|
controller( "PacketInSendController" ).send_packet_out(
|
@@ -425,7 +482,7 @@ describe Trema::PacketIn do
|
|
425
482
|
0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61,
|
426
483
|
0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69
|
427
484
|
].pack( "C*" )
|
428
|
-
controller( "PacketInSendController" ).should_receive( :packet_in ) do | datapath_id, message |
|
485
|
+
controller( "PacketInSendController" ).should_receive( :packet_in ) do | datapath_id, message |
|
429
486
|
message.in_port.should > 0
|
430
487
|
message.vtag?.should be_false
|
431
488
|
message.arp?.should be_false
|
@@ -0,0 +1,32 @@
|
|
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 File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
20
|
+
require "trema"
|
21
|
+
|
22
|
+
|
23
|
+
describe Trema::PortStatusAdd do
|
24
|
+
it_should_behave_like "port status message", :klass => Trema::PortStatusAdd
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
### Local variables:
|
29
|
+
### mode: Ruby
|
30
|
+
### coding: utf-8-unix
|
31
|
+
### indent-tabs-mode: nil
|
32
|
+
### End:
|
@@ -0,0 +1,32 @@
|
|
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 File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
20
|
+
require "trema"
|
21
|
+
|
22
|
+
|
23
|
+
describe Trema::PortStatusDelete do
|
24
|
+
it_should_behave_like "port status message", :klass => Trema::PortStatusDelete
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
### Local variables:
|
29
|
+
### mode: Ruby
|
30
|
+
### coding: utf-8-unix
|
31
|
+
### indent-tabs-mode: nil
|
32
|
+
### End:
|
@@ -0,0 +1,71 @@
|
|
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 File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
20
|
+
require "trema"
|
21
|
+
|
22
|
+
|
23
|
+
describe Trema::PortStatusModify do
|
24
|
+
it_should_behave_like "port status message", :klass => Trema::PortStatusModify
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
module Trema
|
29
|
+
class PortStatusController < Controller
|
30
|
+
def features_reply dpid, message
|
31
|
+
message.ports.select( &:up? ).each do | each |
|
32
|
+
port_mod = PortMod.new(
|
33
|
+
:port_no => each.number,
|
34
|
+
:hw_addr => each.hw_addr,
|
35
|
+
:config => Port::OFPPC_PORT_DOWN,
|
36
|
+
:mask => Port::OFPPC_PORT_DOWN,
|
37
|
+
:advertise => 0
|
38
|
+
)
|
39
|
+
send_message dpid, port_mod
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
describe Controller do
|
46
|
+
context "when one port goes down" do
|
47
|
+
it "should receive port_status (modify)" do
|
48
|
+
network {
|
49
|
+
vswitch { datapath_id 0xabc }
|
50
|
+
vhost "host"
|
51
|
+
link "host", "0xabc"
|
52
|
+
}.run( PortStatusController ) {
|
53
|
+
controller( "PortStatusController" ).should_receive( :port_status ).with do | dpid, message |
|
54
|
+
dpid.should == 0xabc
|
55
|
+
message.should be_an_instance_of( PortStatusModify )
|
56
|
+
end
|
57
|
+
|
58
|
+
controller( "PortStatusController" ).send_message 0xabc, FeaturesRequest.new
|
59
|
+
sleep 2 # FIXME: wait to receive port_status
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
### Local variables:
|
68
|
+
### mode: Ruby
|
69
|
+
### coding: utf-8-unix
|
70
|
+
### indent-tabs-mode: nil
|
71
|
+
### End:
|
@@ -22,82 +22,11 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
|
22
22
|
require "trema"
|
23
23
|
|
24
24
|
|
25
|
-
describe Trema::PortStatus
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
port_mod = PortMod.new(
|
31
|
-
:port_no => ports[0].number,
|
32
|
-
:hw_addr => ports[0].hw_addr,
|
33
|
-
:config => 1, #config port down
|
34
|
-
:mask => 1, #mask
|
35
|
-
:advertise => 0
|
36
|
-
)
|
37
|
-
send_message message.datapath_id, port_mod
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
it "should have datapath_id" do
|
44
|
-
PortStatus.new( :datapath_id => 0xabc ).datapath_id.should == 0xabc
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
it "should have transaction_id" do
|
49
|
-
PortStatus.new( :transaction_id => 123 ).transaction_id.should == 123
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
it "should have reason" do
|
54
|
-
PortStatus.new( :reason => 2 ).reason.should == 2
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
it "should have phy_port" do
|
59
|
-
port = mock( "port" )
|
60
|
-
PortStatus.new( :phy_port => port ).phy_port.should == port
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
context "when #port_mod is sent" do
|
65
|
-
it "should #port_status" do
|
66
|
-
network {
|
67
|
-
vswitch("port-status") { datapath_id 0xabc }
|
68
|
-
vhost "host1"
|
69
|
-
vhost "host2"
|
70
|
-
link "host1", "port-status"
|
71
|
-
link "host2", "port-status"
|
72
|
-
}.run( PortStatusController ) {
|
73
|
-
controller( "PortStatusController" ).should_receive( :port_status )
|
74
|
-
controller( "PortStatusController" ).send_message( 0xabc, FeaturesRequest.new )
|
75
|
-
sleep 2 # FIXME: wait to receive port_status
|
76
|
-
}
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
|
81
|
-
context "when #port_mod(port#1,down) is sent" do
|
82
|
-
it "should #port_status(port#1,down)" do
|
83
|
-
network {
|
84
|
-
vswitch( "port-status" ) { datapath_id 0xabc }
|
85
|
-
vhost "host1"
|
86
|
-
vhost "host2"
|
87
|
-
link "host1", "port-status"
|
88
|
-
link "host2", "port-status"
|
89
|
-
}.run( PortStatusController ) {
|
90
|
-
controller( "PortStatusController" ).send_message( 0xabc, FeaturesRequest.new )
|
91
|
-
controller( "PortStatusController" ).should_receive( :port_status ) do | message |
|
92
|
-
message.datapath_id.should == 0xabc
|
93
|
-
message.phy_port.number.should == 1
|
94
|
-
message.phy_port.config.should == 1
|
95
|
-
message.reason.should == 2
|
96
|
-
end
|
97
|
-
sleep 1 # FIXME: wait to receive port_status
|
98
|
-
}
|
99
|
-
end
|
100
|
-
end
|
25
|
+
describe Trema::PortStatus do
|
26
|
+
subject { Trema::PortStatus }
|
27
|
+
its( :constants ) { should include "OFPPR_ADD" }
|
28
|
+
its( :constants ) { should include "OFPPR_DELETE" }
|
29
|
+
its( :constants ) { should include "OFPPR_MODIFY" }
|
101
30
|
end
|
102
31
|
|
103
32
|
|