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
@@ -30,15 +30,6 @@ describe Trema::DSL::Syntax do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
|
33
|
-
it "should recognize 'use_tremashark' directive" do
|
34
|
-
@context.should_receive( :tremashark= ).with( an_instance_of( Tremashark ) ).once
|
35
|
-
|
36
|
-
@syntax.instance_eval do
|
37
|
-
use_tremashark
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
33
|
it "should recognize 'port' directive" do
|
43
34
|
@context.should_receive( :port= ).with( 1234 ).once
|
44
35
|
|
@@ -59,7 +50,7 @@ describe Trema::DSL::Syntax do
|
|
59
50
|
|
60
51
|
|
61
52
|
it "should recognize 'switch' directive" do
|
62
|
-
Trema::
|
53
|
+
Trema::OpenflowSwitch.should_receive( :add ).with( an_instance_of( HardwareSwitch ) ).once
|
63
54
|
|
64
55
|
@syntax.instance_eval do
|
65
56
|
switch { dpid "0xabc" }
|
@@ -68,7 +59,7 @@ describe Trema::DSL::Syntax do
|
|
68
59
|
|
69
60
|
|
70
61
|
it "should recognize 'vswitch' directive" do
|
71
|
-
Trema::
|
62
|
+
Trema::OpenflowSwitch.should_receive( :add ).with( an_instance_of( OpenVswitch ) ).once
|
72
63
|
|
73
64
|
@syntax.instance_eval do
|
74
65
|
vswitch { dpid "0xabc" }
|
@@ -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
|
@@ -22,22 +20,59 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
|
22
20
|
require "trema"
|
23
21
|
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
module Trema
|
24
|
+
describe EchoReply, ".new", :nosudo => true do
|
25
|
+
it_should_behave_like "any Openflow message with default transaction ID"
|
26
|
+
its( :user_data ) { should be_nil }
|
27
|
+
end
|
28
28
|
|
29
29
|
|
30
|
-
describe EchoReply, ".new(
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
describe EchoReply, ".new(nil)", :nosudo => true do
|
31
|
+
subject { EchoReply.new( nil ) }
|
32
|
+
it_should_behave_like "any Openflow message with default transaction ID"
|
33
|
+
its( :user_data ) { should be_nil }
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
describe EchoReply, ".new(transaction_id)", :nosudo => true do
|
38
|
+
subject { EchoReply.new( transaction_id ) }
|
39
|
+
it_should_behave_like "any Openflow message with transaction ID"
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
describe EchoReply, ".new(:transaction_id => value)", :nosudo => true do
|
44
|
+
subject { EchoReply.new( :transaction_id => transaction_id ) }
|
45
|
+
it_should_behave_like "any Openflow message with transaction ID"
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
describe EchoReply, ".new(:xid => value)", :nosudo => true do
|
50
|
+
subject { EchoReply.new( :xid => xid ) }
|
51
|
+
it_should_behave_like "any Openflow message with xid"
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
describe EchoReply, ".new(:user_data => value)", :nosudo => true do
|
56
|
+
subject { EchoReply.new( :user_data => user_data ) }
|
57
|
+
it_should_behave_like "any Openflow message with user_data"
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
describe EchoReply, ".new(:transaction_id => value, :user_data => value)", :nosudo => true do
|
62
|
+
subject { EchoReply.new( :transaction_id => transaction_id, :user_data => user_data ) }
|
63
|
+
|
64
|
+
context 'transaction_id: 123, user_data: "USER DATA"' do
|
65
|
+
let( :transaction_id ) { 123 }
|
66
|
+
let( :user_data ) { "USER DATA" }
|
67
|
+
its( :transaction_id ) { should == 123 }
|
68
|
+
its( :xid ) { should == 123 }
|
69
|
+
its( :user_data ) { should == "USER DATA" }
|
70
|
+
end
|
71
|
+
end
|
34
72
|
|
35
73
|
|
36
|
-
describe EchoReply,
|
37
|
-
|
38
|
-
expect {
|
39
|
-
EchoReply.new "INVALID OPTION"
|
40
|
-
}.to raise_error( TypeError )
|
74
|
+
describe EchoReply, '.new("INVALID OPTION")', :nosudo => true do
|
75
|
+
it { expect { EchoReply.new "INVALID OPTION" }.to raise_error( TypeError ) }
|
41
76
|
end
|
42
77
|
end
|
43
78
|
|
@@ -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
|
@@ -22,49 +20,103 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
|
22
20
|
require "trema"
|
23
21
|
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
shared_examples_for "echo reply message" do
|
24
|
+
class EchoReplyController < Controller; end
|
25
|
+
|
26
|
+
it "should be logged to the switch's log", :sudo => true do
|
27
|
+
network {
|
28
|
+
vswitch( "echo" ) { datapath_id 0xabc }
|
29
|
+
}.run( EchoReplyController ) {
|
30
|
+
controller( "EchoReplyController" ).send_message( 0xabc, subject )
|
31
|
+
IO.read( File.join( Trema.log, "openflowd.echo.log" ) ).should include( "OFPT_ECHO_REPLY" )
|
32
|
+
}
|
33
|
+
end
|
28
34
|
end
|
29
35
|
|
30
36
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
37
|
+
module Trema
|
38
|
+
describe EchoRequest, ".new" do
|
39
|
+
it_should_behave_like "any Openflow message with default transaction ID"
|
40
|
+
it_should_behave_like "echo reply message"
|
41
|
+
its( :user_data ) { should be_nil }
|
35
42
|
end
|
36
|
-
end
|
37
43
|
|
38
44
|
|
39
|
-
describe EchoRequest, ".new(
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
describe EchoRequest, ".new(nil)" do
|
46
|
+
subject { EchoRequest.new( nil ) }
|
47
|
+
it_should_behave_like "any Openflow message with default transaction ID"
|
48
|
+
it_should_behave_like "echo reply message"
|
49
|
+
its( :user_data ) { should be_nil }
|
43
50
|
end
|
44
|
-
end
|
45
51
|
|
46
52
|
|
47
|
-
describe EchoRequest, ".new(
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
53
|
+
describe EchoRequest, ".new(transaction_id)" do
|
54
|
+
subject { EchoRequest.new( transaction_id ) }
|
55
|
+
it_should_behave_like "any Openflow message with transaction ID"
|
56
|
+
|
57
|
+
context "when sent to a switch" do
|
58
|
+
let( :transaction_id ) { 123 }
|
59
|
+
it_should_behave_like "echo reply message"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
describe EchoRequest, ".new(:transaction_id => value)" do
|
65
|
+
subject { EchoRequest.new( :transaction_id => transaction_id ) }
|
66
|
+
it_should_behave_like "any Openflow message with transaction ID"
|
67
|
+
|
68
|
+
context "when sent to a switch" do
|
69
|
+
let( :transaction_id ) { 123 }
|
70
|
+
it_should_behave_like "echo reply message"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
describe EchoRequest, ".new(:xid => value)" do
|
76
|
+
subject { EchoRequest.new( :xid => xid ) }
|
77
|
+
it_should_behave_like "any Openflow message with xid"
|
78
|
+
|
79
|
+
context "when sent to a switch" do
|
80
|
+
let( :xid ) { 123 }
|
81
|
+
it_should_behave_like "echo reply message"
|
66
82
|
end
|
67
83
|
end
|
84
|
+
|
85
|
+
|
86
|
+
describe EchoRequest, ".new(:user_data => value)" do
|
87
|
+
subject { EchoRequest.new( :user_data => user_data ) }
|
88
|
+
it_should_behave_like "any Openflow message with user_data"
|
89
|
+
|
90
|
+
context "when sent to a switch" do
|
91
|
+
let( :user_data ) { "USER DATA" }
|
92
|
+
it_should_behave_like "echo reply message"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
describe EchoRequest, ".new(:transaction_id => value, :user_data => value)" do
|
98
|
+
subject { EchoRequest.new( :transaction_id => transaction_id, :user_data => user_data ) }
|
99
|
+
|
100
|
+
context 'transaction_id: 123, user_data: "USER DATA"', :nosudo => true do
|
101
|
+
let( :transaction_id ) { 123 }
|
102
|
+
let( :user_data ) { "USER DATA" }
|
103
|
+
|
104
|
+
its( :transaction_id ) { should == 123 }
|
105
|
+
its( :xid ) { should == 123 }
|
106
|
+
its( :user_data ) { should == "USER DATA" }
|
107
|
+
end
|
108
|
+
|
109
|
+
context "when sent to a switch" do
|
110
|
+
let( :transaction_id ) { 123 }
|
111
|
+
let( :user_data ) { "USER DATA" }
|
112
|
+
it_should_behave_like "echo reply message"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
describe EchoRequest, '.new("INVALID OPTION")', :nosudo => true do
|
118
|
+
it { expect { EchoRequest.new "INVALID OPTION" }.to raise_error( TypeError ) }
|
119
|
+
end
|
68
120
|
end
|
69
121
|
|
70
122
|
|
@@ -0,0 +1,76 @@
|
|
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 Enqueue, ".new( :port_number => 1 )" do
|
24
|
+
it { expect { Enqueue.new( :port_number => 1 ) }.to raise_error( ArgumentError ) }
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
describe Enqueue, ".new( :queue_id => 1 )" do
|
29
|
+
it { expect { Enqueue.new( :queue_id => 1 ) }.to raise_error( ArgumentError ) }
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
describe Enqueue, ".new( :port_number => number, :queue_id => 1 )" do
|
34
|
+
subject { Enqueue.new :port_number => port_number, :queue_id => 1 }
|
35
|
+
it_validates "option range", :port_number, 0..( 2 ** 16 - 1 )
|
36
|
+
|
37
|
+
context "when :port_number == 1" do
|
38
|
+
let( :port_number ) { 1 }
|
39
|
+
its( :port_number ) { should == 1 }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
describe Enqueue, ".new( :port_number => 1, :queue_id => number )" do
|
45
|
+
subject { Enqueue.new :port_number => 1, :queue_id => queue_id }
|
46
|
+
it_validates "option range", :queue_id, 0..( 2 ** 32 - 1 )
|
47
|
+
|
48
|
+
context "when :queue_id == 256" do
|
49
|
+
let( :queue_id ) { 256 }
|
50
|
+
its( :queue_id ) { should == 256 }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
describe Enqueue, ".new( VALID OPTIONS )" do
|
56
|
+
context "when sending #flow_mod(add) with action set to enqueue" do
|
57
|
+
it "should have a flow with action set to enqueue" do
|
58
|
+
class FlowModAddController < Controller; end
|
59
|
+
network {
|
60
|
+
vswitch { datapath_id 0xabc }
|
61
|
+
}.run( FlowModAddController ) {
|
62
|
+
controller( "FlowModAddController" ).send_flow_mod_add( 0xabc, :actions => Enqueue.new( :port_number => 1, :queue_id => 123 ) )
|
63
|
+
sleep 2 # FIXME: wait to send_flow_mod
|
64
|
+
vswitch( "0xabc" ).should have( 1 ).flows
|
65
|
+
vswitch( "0xabc" ).flows[0].actions.should match( /enqueue:1q123/ )
|
66
|
+
}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
### Local variables:
|
73
|
+
### mode: Ruby
|
74
|
+
### coding: utf-8-unix
|
75
|
+
### indent-tabs-mode: nil
|
76
|
+
### End:
|
data/spec/trema/error_spec.rb
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
|
@@ -22,19 +20,14 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
|
22
20
|
require "trema"
|
23
21
|
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
subject {
|
23
|
+
module Trema
|
24
|
+
describe Trema, ".constants", :nosudo => true do
|
25
|
+
subject { Trema.constants }
|
28
26
|
it { should include "OFPET_HELLO_FAILED" }
|
29
|
-
it { should include "OFPET_BAD_REQUEST" }
|
30
|
-
it { should include "OFPET_BAD_ACTION" }
|
31
|
-
it { should include "OFPET_FLOW_MOD_FAILED" }
|
32
|
-
it { should include "OFPET_PORT_MOD_FAILED" }
|
33
|
-
it { should include "OFPET_QUEUE_OP_FAILED" }
|
34
|
-
|
35
27
|
it { should include "OFPHFC_INCOMPATIBLE" }
|
36
28
|
it { should include "OFPHFC_EPERM" }
|
37
29
|
|
30
|
+
it { should include "OFPET_BAD_REQUEST" }
|
38
31
|
it { should include "OFPBRC_BAD_VERSION" }
|
39
32
|
it { should include "OFPBRC_BAD_TYPE" }
|
40
33
|
it { should include "OFPBRC_BAD_STAT" }
|
@@ -45,6 +38,7 @@ describe Error, ".new( VALID OPTIONS )" do
|
|
45
38
|
it { should include "OFPBRC_BUFFER_EMPTY" }
|
46
39
|
it { should include "OFPBRC_BUFFER_UNKNOWN" }
|
47
40
|
|
41
|
+
it { should include "OFPET_BAD_ACTION" }
|
48
42
|
it { should include "OFPBAC_BAD_TYPE" }
|
49
43
|
it { should include "OFPBAC_BAD_LEN" }
|
50
44
|
it { should include "OFPBAC_BAD_VENDOR" }
|
@@ -55,83 +49,74 @@ describe Error, ".new( VALID OPTIONS )" do
|
|
55
49
|
it { should include "OFPBAC_TOO_MANY" }
|
56
50
|
it { should include "OFPBAC_BAD_QUEUE" }
|
57
51
|
|
52
|
+
it { should include "OFPET_FLOW_MOD_FAILED" }
|
58
53
|
it { should include "OFPFMFC_ALL_TABLES_FULL" }
|
59
54
|
it { should include "OFPFMFC_OVERLAP" }
|
60
|
-
it { should include "OFPFMFC_OVERLAP" }
|
61
55
|
it { should include "OFPFMFC_BAD_EMERG_TIMEOUT" }
|
62
56
|
it { should include "OFPFMFC_BAD_COMMAND" }
|
63
57
|
it { should include "OFPFMFC_UNSUPPORTED" }
|
64
58
|
|
59
|
+
it { should include "OFPET_PORT_MOD_FAILED" }
|
65
60
|
it { should include "OFPPMFC_BAD_PORT" }
|
66
61
|
it { should include "OFPPMFC_BAD_HW_ADDR" }
|
67
62
|
|
63
|
+
it { should include "OFPET_QUEUE_OP_FAILED" }
|
68
64
|
it { should include "OFPQOFC_BAD_PORT" }
|
69
65
|
it { should include "OFPQOFC_BAD_QUEUE" }
|
70
66
|
it { should include "OFPQOFC_EPERM" }
|
71
67
|
end
|
72
|
-
end
|
73
68
|
|
74
69
|
|
75
|
-
describe Error, ".new
|
76
|
-
|
77
|
-
exception = "Type and code are mandatory options"
|
78
|
-
it "should raise '#{ exception }'" do
|
79
|
-
expect { subject }.to raise_error( exception )
|
70
|
+
describe Error, ".new", :nosudo => true do
|
71
|
+
it { expect { subject }.to raise_error( ArgumentError, "Type and code are mandatory options" ) }
|
80
72
|
end
|
81
|
-
end
|
82
73
|
|
83
74
|
|
84
|
-
describe Error, ".new(
|
85
|
-
|
86
|
-
exception = "Code is a mandatory option"
|
87
|
-
it "should raise '#{ exception }'" do
|
88
|
-
expect { subject }.to raise_error( exception )
|
75
|
+
describe Error, ".new(nil)", :nosudo => true do
|
76
|
+
it { expect { subject }.to raise_error( ArgumentError, "Type and code are mandatory options" ) }
|
89
77
|
end
|
90
|
-
end
|
91
78
|
|
92
79
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
exception = "Type is a mandatory option"
|
97
|
-
it "should raise '#{ exception }'" do
|
98
|
-
expect { subject }.to raise_error( exception )
|
80
|
+
describe Error, ".new(:type => value)", :nosudo => true do
|
81
|
+
subject { Error.new( :type => OFPET_BAD_REQUEST ) }
|
82
|
+
it { expect { subject }.to raise_error( ArgumentError, "Code is a mandatory option" ) }
|
99
83
|
end
|
100
|
-
end
|
101
84
|
|
102
85
|
|
103
|
-
describe Error, ".new(
|
104
|
-
|
105
|
-
|
106
|
-
end
|
86
|
+
describe Error, ".new(:code => value)", :nosudo => true do
|
87
|
+
subject { Error.new( :code => OFPBRC_BAD_TYPE ) }
|
88
|
+
it { expect { subject }.to raise_error( ArgumentError, "Type is a mandatory option" ) }
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
describe Error, ".new(:type => value, :code => value)" do
|
93
|
+
subject { Error.new( :type => OFPET_BAD_REQUEST, :code => OFPBRC_BAD_TYPE ) }
|
94
|
+
it_should_behave_like "any Openflow message with default transaction ID"
|
95
|
+
its( :error_type ) { should == OFPET_BAD_REQUEST }
|
96
|
+
its( :code ) { should == OFPBRC_BAD_TYPE }
|
97
|
+
its( :data ) { should be_nil }
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
describe Error, ".new(:type => value, :code => value, :transaction_id => value)" do
|
102
|
+
subject { Error.new( :type => OFPET_BAD_REQUEST, :code => OFPBRC_BAD_TYPE, :transaction_id => transaction_id ) }
|
103
|
+
it_should_behave_like "any Openflow message with transaction ID"
|
104
|
+
end
|
107
105
|
|
108
106
|
|
109
|
-
describe Error, ".new(
|
110
|
-
subject
|
111
|
-
|
112
|
-
:type => Error::OFPET_BAD_REQUEST,
|
113
|
-
:code => Error::OFPBRC_BAD_TYPE,
|
114
|
-
:transaction_id => 123
|
115
|
-
)
|
116
|
-
end
|
117
|
-
its( :user_data ) { should be_nil }
|
107
|
+
describe Error, ".new(:type => value, :code => value, :xid => value)" do
|
108
|
+
subject { Error.new( :type => OFPET_BAD_REQUEST, :code => OFPBRC_BAD_TYPE, :xid => xid ) }
|
109
|
+
it_should_behave_like "any Openflow message with xid"
|
118
110
|
end
|
119
111
|
|
120
112
|
|
121
|
-
describe Error, ".new(
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
:user_data => "this is a test"
|
128
|
-
)
|
113
|
+
describe Error, ".new(:type => value, :code => value, :data => value)" do
|
114
|
+
subject { Error.new( :type => OFPET_BAD_REQUEST, :code => OFPBRC_BAD_TYPE, :data => "deadbeef" ) }
|
115
|
+
it_should_behave_like "any Openflow message with default transaction ID"
|
116
|
+
its( :error_type ) { should == OFPET_BAD_REQUEST }
|
117
|
+
its( :code ) { should == OFPBRC_BAD_TYPE }
|
118
|
+
its( :data ) { should == "deadbeef" }
|
129
119
|
end
|
130
|
-
let( :transaction_id ) { 1234 }
|
131
|
-
its( :error_type ) { should == Error::OFPET_BAD_REQUEST }
|
132
|
-
its( :code ) { should == Error::OFPBRC_BAD_TYPE }
|
133
|
-
its( :user_data ) { should eq "this is a test" }
|
134
|
-
it_should_behave_like "any OpenFlow message with transaction_id option"
|
135
120
|
end
|
136
121
|
|
137
122
|
|