openflow-protocol 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openflow-protocol.rb +2 -1
- data/lib/openflow-protocol/actions/action.rb +30 -0
- data/lib/openflow-protocol/actions/action_enqueue.rb +16 -0
- data/lib/openflow-protocol/actions/action_output.rb +14 -0
- data/lib/openflow-protocol/actions/action_set_destination_port.rb +7 -0
- data/lib/openflow-protocol/actions/action_set_ip_destination.rb +7 -0
- data/lib/openflow-protocol/actions/action_set_ip_source.rb +13 -0
- data/lib/openflow-protocol/actions/action_set_ip_tos.rb +15 -0
- data/lib/openflow-protocol/actions/action_set_mac_destination.rb +7 -0
- data/lib/openflow-protocol/actions/action_set_mac_source.rb +15 -0
- data/lib/openflow-protocol/actions/action_set_source_port.rb +15 -0
- data/lib/openflow-protocol/actions/action_set_vlan_id.rb +15 -0
- data/lib/openflow-protocol/actions/action_set_vlan_pcp.rb +15 -0
- data/lib/openflow-protocol/actions/action_strip_vlan.rb +14 -0
- data/lib/openflow-protocol/actions/action_vendor.rb +13 -0
- data/lib/openflow-protocol/actions/actions.rb +9 -0
- data/lib/openflow-protocol/helpers/array_of_subclasses.rb +42 -0
- data/lib/openflow-protocol/helpers/superclass_base.rb +26 -0
- data/lib/openflow-protocol/messages/barrier_reply.rb +7 -0
- data/lib/openflow-protocol/messages/barrier_request.rb +7 -0
- data/lib/openflow-protocol/messages/echo_reply.rb +13 -0
- data/lib/openflow-protocol/messages/echo_request.rb +13 -0
- data/lib/openflow-protocol/messages/error.rb +69 -0
- data/lib/openflow-protocol/messages/features_reply.rb +44 -0
- data/lib/openflow-protocol/messages/features_request.rb +7 -0
- data/lib/openflow-protocol/messages/flow_mod.rb +24 -0
- data/lib/openflow-protocol/messages/flow_removed.rb +27 -0
- data/lib/openflow-protocol/messages/get_config_reply.rb +16 -0
- data/lib/openflow-protocol/messages/get_config_request.rb +7 -0
- data/lib/openflow-protocol/messages/hello.rb +7 -0
- data/lib/openflow-protocol/messages/message.rb +49 -0
- data/lib/openflow-protocol/messages/packet_in.rb +27 -0
- data/lib/openflow-protocol/messages/packet_out.rb +17 -0
- data/lib/openflow-protocol/messages/parser.rb +26 -0
- data/lib/openflow-protocol/messages/port_mod.rb +19 -0
- data/lib/openflow-protocol/messages/port_status.rb +18 -0
- data/lib/openflow-protocol/messages/queue_get_config_reply.rb +18 -0
- data/lib/openflow-protocol/messages/queue_get_config_request.rb +15 -0
- data/lib/openflow-protocol/messages/set_config.rb +7 -0
- data/lib/openflow-protocol/messages/statistics.rb +28 -0
- data/lib/openflow-protocol/messages/statistics/aggregate_statistics_reply.rb +14 -0
- data/lib/openflow-protocol/messages/statistics/aggregate_statistics_request.rb +7 -0
- data/lib/openflow-protocol/messages/statistics/description_statistics.rb +32 -0
- data/lib/openflow-protocol/messages/statistics/flow_statistics_reply.rb +25 -0
- data/lib/openflow-protocol/messages/statistics/flow_statistics_request.rb +14 -0
- data/lib/openflow-protocol/messages/statistics/port_statistics_reply.rb +24 -0
- data/lib/openflow-protocol/messages/statistics/port_statistics_request.rb +12 -0
- data/lib/openflow-protocol/messages/statistics/queue_statistics_reply.rb +16 -0
- data/lib/openflow-protocol/messages/statistics/queue_statistics_request.rb +13 -0
- data/lib/openflow-protocol/messages/statistics/table_statistics.rb +20 -0
- data/lib/openflow-protocol/messages/statistics/vendor_statistics.rb +11 -0
- data/lib/openflow-protocol/messages/statistics_reply.rb +26 -0
- data/lib/openflow-protocol/messages/statistics_request.rb +18 -0
- data/lib/openflow-protocol/messages/vendor.rb +14 -0
- data/lib/openflow-protocol/structs/match.rb +106 -0
- data/lib/openflow-protocol/structs/packet_queue.rb +14 -0
- data/lib/openflow-protocol/structs/physical_port.rb +50 -0
- data/lib/openflow-protocol/structs/port_number.rb +49 -0
- data/lib/openflow-protocol/structs/queue_properties/queue_properties.rb +9 -0
- data/lib/openflow-protocol/structs/queue_properties/queue_property.rb +20 -0
- data/lib/openflow-protocol/structs/queue_properties/queue_property_min_rate.rb +30 -0
- data/lib/openflow-protocol/structs/queue_properties/queue_property_none.rb +7 -0
- data/lib/openflow-protocol/version.rb +1 -1
- data/spec/actions/action_enqueue_spec.rb +4 -6
- data/spec/actions/action_output_spec.rb +4 -6
- data/spec/actions/action_set_destination_port_spec.rb +4 -6
- data/spec/actions/action_set_ip_destination_spec.rb +4 -6
- data/spec/actions/action_set_ip_source_spec.rb +4 -6
- data/spec/actions/action_set_ip_tos_spec.rb +4 -6
- data/spec/actions/action_set_mac_destination_spec.rb +4 -6
- data/spec/actions/action_set_mac_source_spec.rb +4 -6
- data/spec/actions/action_set_source_port_spec.rb +4 -6
- data/spec/actions/action_set_vlan_id_spec.rb +4 -6
- data/spec/actions/action_set_vlan_pcp_spec.rb +4 -6
- data/spec/actions/action_strip_vlan_spec.rb +3 -5
- data/spec/actions/action_vendor_spec.rb +4 -6
- data/spec/actions/actions_spec.rb +6 -8
- data/spec/messages/barrier_reply_spec.rb +9 -11
- data/spec/messages/barrier_request_spec.rb +9 -11
- data/spec/messages/echo_reply_spec.rb +13 -15
- data/spec/messages/echo_request_spec.rb +16 -18
- data/spec/messages/error_spec.rb +23 -20
- data/spec/messages/features_reply_spec.rb +11 -13
- data/spec/messages/features_request_spec.rb +9 -11
- data/spec/messages/flow_mod_spec.rb +12 -14
- data/spec/messages/flow_removed_spec.rb +9 -11
- data/spec/messages/get_config_reply_spec.rb +9 -11
- data/spec/messages/get_config_request_spec.rb +9 -11
- data/spec/messages/hello_spec.rb +9 -11
- data/spec/messages/packet_in_spec.rb +9 -11
- data/spec/messages/packet_out_spec.rb +10 -12
- data/spec/messages/parser_spec.rb +7 -9
- data/spec/messages/port_mod_spec.rb +9 -11
- data/spec/messages/port_status_spec.rb +10 -12
- data/spec/messages/queue_get_config_reply_spec.rb +9 -11
- data/spec/messages/queue_get_config_request_spec.rb +9 -11
- data/spec/messages/set_config_spec.rb +9 -11
- data/spec/messages/statistics/aggregate_statistics_reply_spec.rb +4 -6
- data/spec/messages/statistics/aggregate_statistics_request_spec.rb +4 -6
- data/spec/messages/statistics/description_statistics_spec.rb +11 -9
- data/spec/messages/statistics/flow_statistics_reply_spec.rb +4 -6
- data/spec/messages/statistics/flow_statistics_request_spec.rb +4 -6
- data/spec/messages/statistics/port_statistics_reply_spec.rb +4 -6
- data/spec/messages/statistics/port_statistics_request_spec.rb +4 -6
- data/spec/messages/statistics/queue_statistics_reply_spec.rb +4 -6
- data/spec/messages/statistics/queue_statistics_request_spec.rb +4 -6
- data/spec/messages/statistics/table_statistics_spec.rb +4 -6
- data/spec/messages/statistics/vendor_statistics_spec.rb +4 -6
- data/spec/messages/statistics_reply_spec.rb +62 -64
- data/spec/messages/statistics_request_spec.rb +45 -47
- data/spec/messages/vendor_spec.rb +13 -15
- data/spec/spec_helper.rb +1 -1
- data/spec/structs/match_spec.rb +7 -9
- data/spec/structs/packet_queue_spec.rb +5 -7
- data/spec/structs/physical_port_spec.rb +16 -18
- data/spec/structs/port_number_spec.rb +11 -13
- data/spec/structs/queue_properties/queue_properties_spec.rb +5 -7
- data/spec/structs/queue_properties/queue_property_min_rate_spec.rb +5 -7
- data/spec/structs/queue_properties/queue_property_none_spec.rb +3 -5
- metadata +78 -64
- data/lib/actions/action.rb +0 -26
- data/lib/actions/action_enqueue.rb +0 -12
- data/lib/actions/action_output.rb +0 -10
- data/lib/actions/action_set_destination_port.rb +0 -3
- data/lib/actions/action_set_ip_destination.rb +0 -3
- data/lib/actions/action_set_ip_source.rb +0 -9
- data/lib/actions/action_set_ip_tos.rb +0 -11
- data/lib/actions/action_set_mac_destination.rb +0 -3
- data/lib/actions/action_set_mac_source.rb +0 -11
- data/lib/actions/action_set_source_port.rb +0 -11
- data/lib/actions/action_set_vlan_id.rb +0 -11
- data/lib/actions/action_set_vlan_pcp.rb +0 -11
- data/lib/actions/action_strip_vlan.rb +0 -10
- data/lib/actions/action_vendor.rb +0 -9
- data/lib/actions/actions.rb +0 -5
- data/lib/helpers/array_of_subclasses.rb +0 -38
- data/lib/helpers/superclass_base.rb +0 -24
- data/lib/messages/barrier_reply.rb +0 -3
- data/lib/messages/barrier_request.rb +0 -3
- data/lib/messages/echo_reply.rb +0 -9
- data/lib/messages/echo_request.rb +0 -9
- data/lib/messages/error.rb +0 -61
- data/lib/messages/features_reply.rb +0 -40
- data/lib/messages/features_request.rb +0 -3
- data/lib/messages/flow_mod.rb +0 -20
- data/lib/messages/flow_removed.rb +0 -23
- data/lib/messages/get_config_reply.rb +0 -12
- data/lib/messages/get_config_request.rb +0 -3
- data/lib/messages/hello.rb +0 -3
- data/lib/messages/message.rb +0 -45
- data/lib/messages/packet_in.rb +0 -23
- data/lib/messages/packet_out.rb +0 -13
- data/lib/messages/parser.rb +0 -22
- data/lib/messages/port_mod.rb +0 -15
- data/lib/messages/port_status.rb +0 -14
- data/lib/messages/queue_get_config_reply.rb +0 -14
- data/lib/messages/queue_get_config_request.rb +0 -11
- data/lib/messages/set_config.rb +0 -3
- data/lib/messages/statistics.rb +0 -24
- data/lib/messages/statistics/aggregate_statistics_reply.rb +0 -10
- data/lib/messages/statistics/aggregate_statistics_request.rb +0 -3
- data/lib/messages/statistics/description_statistics.rb +0 -28
- data/lib/messages/statistics/flow_statistics_reply.rb +0 -21
- data/lib/messages/statistics/flow_statistics_request.rb +0 -10
- data/lib/messages/statistics/port_statistics_reply.rb +0 -20
- data/lib/messages/statistics/port_statistics_request.rb +0 -8
- data/lib/messages/statistics/queue_statistics_reply.rb +0 -12
- data/lib/messages/statistics/queue_statistics_request.rb +0 -9
- data/lib/messages/statistics/table_statistics.rb +0 -16
- data/lib/messages/statistics/vendor_statistics.rb +0 -7
- data/lib/messages/statistics_reply.rb +0 -22
- data/lib/messages/statistics_request.rb +0 -14
- data/lib/messages/vendor.rb +0 -10
- data/lib/structs/match.rb +0 -102
- data/lib/structs/packet_queue.rb +0 -10
- data/lib/structs/physical_port.rb +0 -46
- data/lib/structs/port_number.rb +0 -45
- data/lib/structs/queue_properties/queue_properties.rb +0 -5
- data/lib/structs/queue_properties/queue_property.rb +0 -16
- data/lib/structs/queue_properties/queue_property_min_rate.rb +0 -26
- data/lib/structs/queue_properties/queue_property_none.rb +0 -3
@@ -1,47 +1,45 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe OFEchoReply do
|
1
|
+
describe OpenFlow::Protocol::EchoReply do
|
4
2
|
let(:data) { [1, 3, 0, 8, 0, 0, 0, 1].pack('C*') }
|
5
3
|
|
6
4
|
it 'should read binary' do
|
7
|
-
msg =
|
8
|
-
expect(msg.version).to eq(
|
5
|
+
msg = OpenFlow::Protocol::EchoReply.read(data)
|
6
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
9
7
|
expect(msg.type).to eq(:echo_reply)
|
10
8
|
expect(msg.len).to eq(8)
|
11
9
|
expect(msg.xid).to eq(1)
|
12
10
|
expect(msg.data).to be_empty
|
13
11
|
end
|
14
12
|
it 'should be parsable' do
|
15
|
-
msg =
|
16
|
-
expect(msg.class).to eq(
|
13
|
+
msg = OpenFlow::Protocol::Parser.read(data)
|
14
|
+
expect(msg.class).to eq(OpenFlow::Protocol::EchoReply)
|
17
15
|
end
|
18
16
|
it 'should read binary with data' do
|
19
|
-
msg =
|
20
|
-
expect(msg.version).to eq(
|
17
|
+
msg = OpenFlow::Protocol::EchoReply.read [1, 3, 0, 10, 0, 0, 0, 1, 10, 20].pack('C*')
|
18
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
21
19
|
expect(msg.type).to eq(:echo_reply)
|
22
20
|
expect(msg.len).to eq(10)
|
23
21
|
expect(msg.xid).to eq(1)
|
24
22
|
expect(msg.data.length).to eq(2)
|
25
23
|
end
|
26
24
|
it 'should initialize with default values' do
|
27
|
-
msg =
|
28
|
-
expect(msg.version).to eq(
|
25
|
+
msg = OpenFlow::Protocol::EchoReply.new
|
26
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
29
27
|
expect(msg.type).to eq(:echo_reply)
|
30
28
|
expect(msg.len).to eq(8)
|
31
29
|
expect(msg.xid).to eq(0)
|
32
30
|
expect(msg.data).to be_empty
|
33
31
|
end
|
34
32
|
it 'should initialize with some values' do
|
35
|
-
msg =
|
36
|
-
expect(msg.version).to eq(
|
33
|
+
msg = OpenFlow::Protocol::EchoReply.new(xid: 1)
|
34
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
37
35
|
expect(msg.type).to eq(:echo_reply)
|
38
36
|
expect(msg.len).to eq(8)
|
39
37
|
expect(msg.xid).to eq(1)
|
40
38
|
expect(msg.data).to be_empty
|
41
39
|
end
|
42
40
|
it 'should initialize with data' do
|
43
|
-
msg =
|
44
|
-
expect(msg.version).to eq(
|
41
|
+
msg = OpenFlow::Protocol::EchoReply.new(data: [10, 20].pack('C*'))
|
42
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
45
43
|
expect(msg.type).to eq(:echo_reply)
|
46
44
|
expect(msg.len).to eq(10)
|
47
45
|
expect(msg.xid).to eq(0)
|
@@ -1,56 +1,54 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe OFEchoRequest do
|
1
|
+
describe OpenFlow::Protocol::EchoRequest do
|
4
2
|
let(:data) { [1, 2, 0, 8, 0, 0, 0, 1].pack('C*') }
|
5
3
|
|
6
4
|
it 'should read binary' do
|
7
|
-
msg =
|
8
|
-
expect(msg.version).to eq(
|
5
|
+
msg = OpenFlow::Protocol::EchoRequest.read(data)
|
6
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
9
7
|
expect(msg.type).to eq(:echo_request)
|
10
8
|
expect(msg.len).to eq(8)
|
11
9
|
expect(msg.xid).to eq(1)
|
12
10
|
expect(msg.data).to be_empty
|
13
11
|
end
|
14
12
|
it 'should be parsable' do
|
15
|
-
msg =
|
16
|
-
expect(msg.class).to eq(
|
13
|
+
msg = OpenFlow::Protocol::Parser.read(data)
|
14
|
+
expect(msg.class).to eq(OpenFlow::Protocol::EchoRequest)
|
17
15
|
end
|
18
16
|
it 'should read binary with data' do
|
19
|
-
msg =
|
20
|
-
expect(msg.version).to eq(
|
17
|
+
msg = OpenFlow::Protocol::EchoRequest.read [1, 2, 0, 10, 0, 0, 0, 1, 10, 20].pack('C*')
|
18
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
21
19
|
expect(msg.type).to eq(:echo_request)
|
22
20
|
expect(msg.len).to eq(10)
|
23
21
|
expect(msg.xid).to eq(1)
|
24
22
|
expect(msg.data.length).to eq(2)
|
25
23
|
end
|
26
24
|
it 'should initialize with default values' do
|
27
|
-
msg =
|
28
|
-
expect(msg.version).to eq(
|
25
|
+
msg = OpenFlow::Protocol::EchoRequest.new
|
26
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
29
27
|
expect(msg.type).to eq(:echo_request)
|
30
28
|
expect(msg.len).to eq(8)
|
31
29
|
expect(msg.xid).to eq(0)
|
32
30
|
expect(msg.data).to be_empty
|
33
31
|
end
|
34
32
|
it 'should initialize with some values' do
|
35
|
-
msg =
|
36
|
-
expect(msg.version).to eq(
|
33
|
+
msg = OpenFlow::Protocol::EchoRequest.new(xid: 1)
|
34
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
37
35
|
expect(msg.type).to eq(:echo_request)
|
38
36
|
expect(msg.len).to eq(8)
|
39
37
|
expect(msg.xid).to eq(1)
|
40
38
|
expect(msg.data).to be_empty
|
41
39
|
end
|
42
40
|
it 'should initialize with data' do
|
43
|
-
msg =
|
44
|
-
expect(msg.version).to eq(
|
41
|
+
msg = OpenFlow::Protocol::EchoRequest.new(data: [10, 20].pack('C*'))
|
42
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
45
43
|
expect(msg.type).to eq(:echo_request)
|
46
44
|
expect(msg.len).to eq(10)
|
47
45
|
expect(msg.xid).to eq(0)
|
48
46
|
expect(msg.data.length).to eq(2)
|
49
47
|
end
|
50
|
-
it 'should convert to
|
51
|
-
msg =
|
48
|
+
it 'should convert to OpenFlow::Protocol::EchoReply' do
|
49
|
+
msg = OpenFlow::Protocol::EchoRequest.new(xid: 1, data: [10, 20].pack('C*'))
|
52
50
|
msg_reply = msg.to_reply
|
53
|
-
expect(msg_reply.version).to eq(
|
51
|
+
expect(msg_reply.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
54
52
|
expect(msg_reply.type).to eq(:echo_reply)
|
55
53
|
expect(msg.len).to eq(msg_reply.len)
|
56
54
|
expect(msg.xid).to eq(msg_reply.xid)
|
data/spec/messages/error_spec.rb
CHANGED
@@ -1,36 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
describe OpenFlow::Protocol::Error do
|
2
|
+
let(:hello_msg) {
|
3
|
+
[1, 0, 0, 8, 0, 0, 0, 1].pack('C*')
|
4
|
+
}
|
4
5
|
let(:data) {
|
5
6
|
[
|
6
|
-
1, 1, 0,
|
7
|
+
1, 1, 0, 20, 0, 0, 0, 1, # header
|
7
8
|
0, 0, # type
|
8
|
-
0, 0
|
9
|
-
|
10
|
-
].pack('C*')
|
9
|
+
0, 0 # code
|
10
|
+
].pack('C*') + hello_msg
|
11
11
|
}
|
12
12
|
|
13
13
|
it 'should read binary' do
|
14
|
-
msg =
|
15
|
-
expect(msg.version).to eq(
|
14
|
+
msg = OpenFlow::Protocol::Error.read(data)
|
15
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
16
16
|
expect(msg.type).to eq(:error)
|
17
|
-
expect(msg.len).to eq(
|
17
|
+
expect(msg.len).to eq(20)
|
18
18
|
expect(msg.xid).to eq(1)
|
19
19
|
expect(msg.error_type).to eq(:hello_failed)
|
20
20
|
expect(msg.error_code).to eq(:incompatible)
|
21
|
-
expect(msg.data).to eq(
|
21
|
+
expect(msg.data).to eq(hello_msg)
|
22
|
+
hello = msg.parsed_data
|
23
|
+
expect(hello.type).to eq(:hello)
|
24
|
+
expect(hello.xid).to eq(1)
|
22
25
|
end
|
23
26
|
it 'should be parsable' do
|
24
|
-
msg =
|
25
|
-
expect(msg.class).to eq(
|
27
|
+
msg = OpenFlow::Protocol::Parser.read(data)
|
28
|
+
expect(msg.class).to eq(OpenFlow::Protocol::Error)
|
26
29
|
end
|
27
|
-
it 'should read binary' do
|
28
|
-
msg =
|
30
|
+
it 'should read another binary' do
|
31
|
+
msg = OpenFlow::Protocol::Error.read [
|
29
32
|
1, 1, 0, 12, 0, 0, 0, 1, # header
|
30
33
|
0, 2, # type
|
31
34
|
0, 4 # code
|
32
35
|
].pack('C*')
|
33
|
-
expect(msg.version).to eq(
|
36
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
34
37
|
expect(msg.type).to eq(:error)
|
35
38
|
expect(msg.len).to eq(12)
|
36
39
|
expect(msg.xid).to eq(1)
|
@@ -39,8 +42,8 @@ describe OFError do
|
|
39
42
|
expect(msg.data).to be_empty
|
40
43
|
end
|
41
44
|
it 'should initialize with default values' do
|
42
|
-
msg =
|
43
|
-
expect(msg.version).to eq(
|
45
|
+
msg = OpenFlow::Protocol::Error.new
|
46
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
44
47
|
expect(msg.type).to eq(:error)
|
45
48
|
expect(msg.len).to eq(12)
|
46
49
|
expect(msg.xid).to eq(0)
|
@@ -49,12 +52,12 @@ describe OFError do
|
|
49
52
|
expect(msg.data).to be_empty
|
50
53
|
end
|
51
54
|
it 'should initialize with some values' do
|
52
|
-
msg =
|
55
|
+
msg = OpenFlow::Protocol::Error.new(
|
53
56
|
xid: 1,
|
54
57
|
error_type: :port_mod_failed,
|
55
58
|
error_code: :bad_port
|
56
59
|
)
|
57
|
-
expect(msg.version).to eq(
|
60
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
58
61
|
expect(msg.type).to eq(:error)
|
59
62
|
expect(msg.len).to eq(12)
|
60
63
|
expect(msg.xid).to eq(1)
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe OFFeaturesReply do
|
1
|
+
describe OpenFlow::Protocol::FeaturesReply do
|
4
2
|
let(:data) {
|
5
3
|
[
|
6
4
|
1, 6, 0, 128, 0, 0, 0, 1, # header
|
@@ -90,8 +88,8 @@ describe OFFeaturesReply do
|
|
90
88
|
}
|
91
89
|
|
92
90
|
it 'should read binary' do
|
93
|
-
msg =
|
94
|
-
expect(msg.version).to eq(
|
91
|
+
msg = OpenFlow::Protocol::FeaturesReply.read(data)
|
92
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
95
93
|
expect(msg.type).to eq(:features_reply)
|
96
94
|
expect(msg.len).to eq(128)
|
97
95
|
expect(msg.xid).to eq(1)
|
@@ -127,16 +125,16 @@ describe OFFeaturesReply do
|
|
127
125
|
expect(msg.ports[1].port_number).to eq(2)
|
128
126
|
end
|
129
127
|
it 'should be parsable' do
|
130
|
-
msg =
|
131
|
-
expect(msg.class).to eq(
|
128
|
+
msg = OpenFlow::Protocol::Parser.read(data)
|
129
|
+
expect(msg.class).to eq(OpenFlow::Protocol::FeaturesReply)
|
132
130
|
end
|
133
131
|
it 'should read a real binary message' do
|
134
|
-
msg =
|
132
|
+
msg = OpenFlow::Protocol::FeaturesReply.read(real_data)
|
135
133
|
expect(msg.ports.length).to eq(3)
|
136
134
|
end
|
137
135
|
it 'should initialize with default values' do
|
138
|
-
msg =
|
139
|
-
expect(msg.version).to eq(
|
136
|
+
msg = OpenFlow::Protocol::FeaturesReply.new
|
137
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
140
138
|
expect(msg.type).to eq(:features_reply)
|
141
139
|
expect(msg.len).to eq(32)
|
142
140
|
expect(msg.xid).to eq(0)
|
@@ -148,7 +146,7 @@ describe OFFeaturesReply do
|
|
148
146
|
expect(msg.ports).to be_empty
|
149
147
|
end
|
150
148
|
it 'should initialize with some values' do
|
151
|
-
msg =
|
149
|
+
msg = OpenFlow::Protocol::FeaturesReply.new(
|
152
150
|
xid: 1,
|
153
151
|
datapath_id: 42,
|
154
152
|
n_buffers: 10,
|
@@ -177,9 +175,9 @@ describe OFFeaturesReply do
|
|
177
175
|
:set_tp_dst,
|
178
176
|
:enqueue
|
179
177
|
],
|
180
|
-
ports: [
|
178
|
+
ports: [OpenFlow::Protocol::PhysicalPort.new]
|
181
179
|
)
|
182
|
-
expect(msg.version).to eq(
|
180
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
183
181
|
expect(msg.type).to eq(:features_reply)
|
184
182
|
expect(msg.len).to eq(80)
|
185
183
|
expect(msg.xid).to eq(1)
|
@@ -1,29 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe OFFeaturesRequest do
|
1
|
+
describe OpenFlow::Protocol::FeaturesRequest do
|
4
2
|
let(:data) { [1, 5, 0, 8, 0, 0, 0, 1].pack('C*') }
|
5
3
|
|
6
4
|
it 'should read binary' do
|
7
|
-
msg =
|
8
|
-
expect(msg.version).to eq(
|
5
|
+
msg = OpenFlow::Protocol::FeaturesRequest.read(data)
|
6
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
9
7
|
expect(msg.type).to eq(:features_request)
|
10
8
|
expect(msg.len).to eq(8)
|
11
9
|
expect(msg.xid).to eq(1)
|
12
10
|
end
|
13
11
|
it 'should be parsable' do
|
14
|
-
msg =
|
15
|
-
expect(msg.class).to eq(
|
12
|
+
msg = OpenFlow::Protocol::Parser.read(data)
|
13
|
+
expect(msg.class).to eq(OpenFlow::Protocol::FeaturesRequest)
|
16
14
|
end
|
17
15
|
it 'should initialize with default values' do
|
18
|
-
msg =
|
19
|
-
expect(msg.version).to eq(
|
16
|
+
msg = OpenFlow::Protocol::FeaturesRequest.new
|
17
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
20
18
|
expect(msg.type).to eq(:features_request)
|
21
19
|
expect(msg.len).to eq(8)
|
22
20
|
expect(msg.xid).to eq(0)
|
23
21
|
end
|
24
22
|
it 'should initialize with some values' do
|
25
|
-
msg =
|
26
|
-
expect(msg.version).to eq(
|
23
|
+
msg = OpenFlow::Protocol::FeaturesRequest.new(xid: 1)
|
24
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
27
25
|
expect(msg.type).to eq(:features_request)
|
28
26
|
expect(msg.len).to eq(8)
|
29
27
|
expect(msg.xid).to eq(1)
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe OFFlowMod do
|
1
|
+
describe OpenFlow::Protocol::FlowMod do
|
4
2
|
let(:data) {
|
5
3
|
[
|
6
4
|
1, 14, 0, 80, 0, 0, 0, 1, # header
|
@@ -40,8 +38,8 @@ describe OFFlowMod do
|
|
40
38
|
}
|
41
39
|
|
42
40
|
it 'should read binary' do
|
43
|
-
msg =
|
44
|
-
expect(msg.version).to eq(
|
41
|
+
msg = OpenFlow::Protocol::FlowMod.read(data)
|
42
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
45
43
|
expect(msg.type).to eq(:flow_mod)
|
46
44
|
expect(msg.len).to eq(80)
|
47
45
|
expect(msg.xid).to eq(1)
|
@@ -58,12 +56,12 @@ describe OFFlowMod do
|
|
58
56
|
expect(msg.actions.first.type).to eq(:output)
|
59
57
|
end
|
60
58
|
it 'should be parsable' do
|
61
|
-
msg =
|
62
|
-
expect(msg.class).to eq(
|
59
|
+
msg = OpenFlow::Protocol::Parser.read(data)
|
60
|
+
expect(msg.class).to eq(OpenFlow::Protocol::FlowMod)
|
63
61
|
end
|
64
62
|
it 'should initialize with default values' do
|
65
|
-
msg =
|
66
|
-
expect(msg.version).to eq(
|
63
|
+
msg = OpenFlow::Protocol::FlowMod.new
|
64
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
67
65
|
expect(msg.type).to eq(:flow_mod)
|
68
66
|
expect(msg.len).to eq(72)
|
69
67
|
expect(msg.xid).to eq(0)
|
@@ -79,7 +77,7 @@ describe OFFlowMod do
|
|
79
77
|
expect(msg.actions).to be_empty
|
80
78
|
end
|
81
79
|
it 'should initialize with some values' do
|
82
|
-
msg =
|
80
|
+
msg = OpenFlow::Protocol::FlowMod.new(
|
83
81
|
xid: 1,
|
84
82
|
match: {
|
85
83
|
wildcards: {
|
@@ -105,9 +103,9 @@ describe OFFlowMod do
|
|
105
103
|
priority: 3000,
|
106
104
|
buffer_id: 1,
|
107
105
|
flags: [:send_flow_removed],
|
108
|
-
actions: [
|
106
|
+
actions: [OpenFlow::Protocol::ActionOutput.new(port: 1)]
|
109
107
|
)
|
110
|
-
expect(msg.version).to eq(
|
108
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
111
109
|
expect(msg.type).to eq(:flow_mod)
|
112
110
|
expect(msg.len).to eq(80)
|
113
111
|
expect(msg.xid).to eq(1)
|
@@ -124,12 +122,12 @@ describe OFFlowMod do
|
|
124
122
|
expect(msg.actions.first.type).to eq(:output)
|
125
123
|
end
|
126
124
|
it 'should initialize with some other values' do
|
127
|
-
msg =
|
125
|
+
msg = OpenFlow::Protocol::FlowMod.new(
|
128
126
|
xid: 1,
|
129
127
|
cookie: 2,
|
130
128
|
command: :delete
|
131
129
|
)
|
132
|
-
expect(msg.version).to eq(
|
130
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
133
131
|
expect(msg.type).to eq(:flow_mod)
|
134
132
|
expect(msg.len).to eq(72)
|
135
133
|
expect(msg.xid).to eq(1)
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe OFFlowRemoved do
|
1
|
+
describe OpenFlow::Protocol::FlowRemoved do
|
4
2
|
let(:data) {
|
5
3
|
[
|
6
4
|
1, 11, 0, 88, 0, 0, 0, 1, # header
|
@@ -36,8 +34,8 @@ describe OFFlowRemoved do
|
|
36
34
|
}
|
37
35
|
|
38
36
|
it 'should read binary' do
|
39
|
-
msg =
|
40
|
-
expect(msg.version).to eq(
|
37
|
+
msg = OpenFlow::Protocol::FlowRemoved.read(data)
|
38
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
41
39
|
expect(msg.type).to eq(:flow_removed)
|
42
40
|
expect(msg.len).to eq(88)
|
43
41
|
expect(msg.xid).to eq(1)
|
@@ -52,12 +50,12 @@ describe OFFlowRemoved do
|
|
52
50
|
expect(msg.byte_count).to eq(80)
|
53
51
|
end
|
54
52
|
it 'should be parsable' do
|
55
|
-
msg =
|
56
|
-
expect(msg.class).to eq(
|
53
|
+
msg = OpenFlow::Protocol::Parser.read(data)
|
54
|
+
expect(msg.class).to eq(OpenFlow::Protocol::FlowRemoved)
|
57
55
|
end
|
58
56
|
it 'should initialize with default values' do
|
59
|
-
msg =
|
60
|
-
expect(msg.version).to eq(
|
57
|
+
msg = OpenFlow::Protocol::FlowRemoved.new
|
58
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
61
59
|
expect(msg.type).to eq(:flow_removed)
|
62
60
|
expect(msg.len).to eq(88)
|
63
61
|
expect(msg.xid).to eq(0)
|
@@ -72,7 +70,7 @@ describe OFFlowRemoved do
|
|
72
70
|
expect(msg.byte_count).to eq(0)
|
73
71
|
end
|
74
72
|
it 'should initialize with some values' do
|
75
|
-
msg =
|
73
|
+
msg = OpenFlow::Protocol::FlowRemoved.new(
|
76
74
|
xid: 1,
|
77
75
|
match: {
|
78
76
|
wildcards: {
|
@@ -100,7 +98,7 @@ describe OFFlowRemoved do
|
|
100
98
|
packet_count: 10,
|
101
99
|
byte_count: 80
|
102
100
|
)
|
103
|
-
expect(msg.version).to eq(
|
101
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
104
102
|
expect(msg.type).to eq(:flow_removed)
|
105
103
|
expect(msg.len).to eq(88)
|
106
104
|
expect(msg.xid).to eq(1)
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe OFGetConfigReply do
|
1
|
+
describe OpenFlow::Protocol::GetConfigReply do
|
4
2
|
let(:data) {
|
5
3
|
[
|
6
4
|
1, 8, 0, 12, 0, 0, 0, 1, # header
|
@@ -10,8 +8,8 @@ describe OFGetConfigReply do
|
|
10
8
|
}
|
11
9
|
|
12
10
|
it 'should read binary' do
|
13
|
-
msg =
|
14
|
-
expect(msg.version).to eq(
|
11
|
+
msg = OpenFlow::Protocol::GetConfigReply.read(data)
|
12
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
15
13
|
expect(msg.type).to eq(:get_config_reply)
|
16
14
|
expect(msg.len).to eq(12)
|
17
15
|
expect(msg.xid).to eq(1)
|
@@ -19,12 +17,12 @@ describe OFGetConfigReply do
|
|
19
17
|
expect(msg.miss_send_length).to eq(0xff)
|
20
18
|
end
|
21
19
|
it 'should be parsable' do
|
22
|
-
msg =
|
23
|
-
expect(msg.class).to eq(
|
20
|
+
msg = OpenFlow::Protocol::Parser.read(data)
|
21
|
+
expect(msg.class).to eq(OpenFlow::Protocol::GetConfigReply)
|
24
22
|
end
|
25
23
|
it 'should initialize with default values' do
|
26
|
-
msg =
|
27
|
-
expect(msg.version).to eq(
|
24
|
+
msg = OpenFlow::Protocol::GetConfigReply.new
|
25
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
28
26
|
expect(msg.type).to eq(:get_config_reply)
|
29
27
|
expect(msg.len).to eq(12)
|
30
28
|
expect(msg.xid).to eq(0)
|
@@ -32,12 +30,12 @@ describe OFGetConfigReply do
|
|
32
30
|
expect(msg.miss_send_length).to eq(0)
|
33
31
|
end
|
34
32
|
it 'should initialize with some values' do
|
35
|
-
msg =
|
33
|
+
msg = OpenFlow::Protocol::GetConfigReply.new(
|
36
34
|
xid: 1,
|
37
35
|
flags: :fragments_normal,
|
38
36
|
miss_send_length: 0xff
|
39
37
|
)
|
40
|
-
expect(msg.version).to eq(
|
38
|
+
expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
|
41
39
|
expect(msg.type).to eq(:get_config_reply)
|
42
40
|
expect(msg.len).to eq(12)
|
43
41
|
expect(msg.xid).to eq(1)
|