openflow-protocol 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/messages/echo_reply.rb +6 -0
- data/lib/openflow-protocol/version.rb +5 -0
- data/spec/actions/action_enqueue_spec.rb +30 -0
- data/spec/actions/action_output_spec.rb +29 -0
- data/spec/actions/action_set_destination_port_spec.rb +26 -0
- data/spec/actions/action_set_ip_destination_spec.rb +25 -0
- data/spec/actions/action_set_ip_source_spec.rb +25 -0
- data/spec/actions/action_set_ip_tos_spec.rb +26 -0
- data/spec/actions/action_set_mac_destination_spec.rb +26 -0
- data/spec/actions/action_set_mac_source_spec.rb +26 -0
- data/spec/actions/action_set_source_port_spec.rb +26 -0
- data/spec/actions/action_set_vlan_id_spec.rb +26 -0
- data/spec/actions/action_set_vlan_pcp_spec.rb +26 -0
- data/spec/actions/action_strip_vlan_spec.rb +17 -0
- data/spec/actions/action_vendor_spec.rb +25 -0
- data/spec/actions/actions_spec.rb +33 -0
- data/spec/messages/barrier_reply_spec.rb +25 -0
- data/spec/messages/barrier_request_spec.rb +25 -0
- data/spec/messages/echo_reply_spec.rb +44 -0
- data/spec/messages/echo_request_spec.rb +53 -0
- data/spec/messages/error_spec.rb +56 -0
- data/spec/messages/features_reply_spec.rb +204 -0
- data/spec/messages/features_request_spec.rb +25 -0
- data/spec/messages/flow_mod_spec.rb +139 -0
- data/spec/messages/flow_removed_spec.rb +109 -0
- data/spec/messages/get_config_reply_spec.rb +39 -0
- data/spec/messages/get_config_request_spec.rb +25 -0
- data/spec/messages/hello_spec.rb +25 -0
- data/spec/messages/packet_in_spec.rb +76 -0
- data/spec/messages/packet_out_spec.rb +56 -0
- data/spec/messages/parser_spec.rb +43 -0
- data/spec/messages/port_mod_spec.rb +64 -0
- data/spec/messages/port_status_spec.rb +52 -0
- data/spec/messages/set_config_spec.rb +39 -0
- data/spec/messages/statistics_reply_spec.rb +411 -0
- data/spec/messages/statistics_request_spec.rb +355 -0
- data/spec/messages/vendor_spec.rb +56 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/statistics/aggregate_statistics_reply_spec.rb +31 -0
- data/spec/statistics/aggregate_statistics_request_spec.rb +46 -0
- data/spec/statistics/description_statistics_spec.rb +38 -0
- data/spec/statistics/flow_statistics_reply_spec.rb +74 -0
- data/spec/statistics/flow_statistics_request_spec.rb +46 -0
- data/spec/statistics/port_statistics_reply_spec.rb +81 -0
- data/spec/statistics/port_statistics_request_spec.rb +19 -0
- data/spec/statistics/queue_statistics_reply_spec.rb +42 -0
- data/spec/statistics/queue_statistics_request_spec.rb +26 -0
- data/spec/statistics/table_statistics_spec.rb +54 -0
- data/spec/statistics/vendor_statistics_spec.rb +25 -0
- data/spec/structs/match_spec.rb +143 -0
- data/spec/structs/physical_port_spec.rb +63 -0
- data/spec/structs/port_number_spec.rb +19 -0
- metadata +109 -8
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OFFlowRemoved do
|
4
|
+
it 'should read binary' do
|
5
|
+
msg = OFFlowRemoved.read [
|
6
|
+
1, 11, 0, 88, 0, 0, 0, 1, # header
|
7
|
+
|
8
|
+
# match
|
9
|
+
0, 0x30, 0x20, 0x4f, # wildcards
|
10
|
+
0, 0, # in_port
|
11
|
+
0, 0, 0, 0, 0, 0, # mac_source
|
12
|
+
0, 0, 0, 0, 0, 0, # mac_destination
|
13
|
+
0xff, 0xff, # vlan_id
|
14
|
+
0, # vlan_pcp
|
15
|
+
0, # padding
|
16
|
+
8, 0, # mac_protocol
|
17
|
+
0, # ip_tos
|
18
|
+
6, # ip_protocol
|
19
|
+
0, 0, # padding
|
20
|
+
0, 0, 0, 0, # ip_source
|
21
|
+
192, 168, 0, 2, # ip_destination
|
22
|
+
0, 0, # source_port
|
23
|
+
0x0b, 0xb8, # destination_port
|
24
|
+
|
25
|
+
0, 0, 0, 0, 0, 0, 0, 1, # cookie
|
26
|
+
0x0b, 0xb8, # priority
|
27
|
+
0, # reason
|
28
|
+
0, # padding
|
29
|
+
0, 0, 0, 50, # duration_seconds
|
30
|
+
0, 0, 0, 10, # duration_nanoseconds
|
31
|
+
0, 100, # idle_timeout
|
32
|
+
0, 0, # padding
|
33
|
+
0, 0, 0, 0, 0, 0, 0, 10, # packet_count
|
34
|
+
0, 0, 0, 0, 0, 0, 0, 80 # byte_count
|
35
|
+
].pack('C*')
|
36
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
37
|
+
expect(msg.type).to eq(:flow_removed)
|
38
|
+
expect(msg.len).to eq(88)
|
39
|
+
expect(msg.xid).to eq(1)
|
40
|
+
expect(msg.match.ip_destination).to eq('192.168.0.2')
|
41
|
+
expect(msg.cookie).to eq(1)
|
42
|
+
expect(msg.priority).to eq(3000)
|
43
|
+
expect(msg.reason).to eq(:idle_timeout)
|
44
|
+
expect(msg.duration_seconds).to eq(50)
|
45
|
+
expect(msg.duration_nanoseconds).to eq(10)
|
46
|
+
expect(msg.idle_timeout).to eq(100)
|
47
|
+
expect(msg.packet_count).to eq(10)
|
48
|
+
expect(msg.byte_count).to eq(80)
|
49
|
+
end
|
50
|
+
it 'should initialize with default values' do
|
51
|
+
msg = OFFlowRemoved.new
|
52
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
53
|
+
expect(msg.type).to eq(:flow_removed)
|
54
|
+
expect(msg.len).to eq(88)
|
55
|
+
expect(msg.xid).to eq(0)
|
56
|
+
expect(msg.match.ip_destination).to eq('0.0.0.0')
|
57
|
+
expect(msg.cookie).to eq(0)
|
58
|
+
expect(msg.priority).to eq(0)
|
59
|
+
expect(msg.reason).to eq(:idle_timeout)
|
60
|
+
expect(msg.duration_seconds).to eq(0)
|
61
|
+
expect(msg.duration_nanoseconds).to eq(0)
|
62
|
+
expect(msg.idle_timeout).to eq(0)
|
63
|
+
expect(msg.packet_count).to eq(0)
|
64
|
+
expect(msg.byte_count).to eq(0)
|
65
|
+
end
|
66
|
+
it 'should initialize with some values' do
|
67
|
+
msg = OFFlowRemoved.new(
|
68
|
+
xid: 1,
|
69
|
+
match: {
|
70
|
+
wildcards: {
|
71
|
+
in_port: true,
|
72
|
+
mac_source: true,
|
73
|
+
mac_destination: true,
|
74
|
+
vlan_id: true,
|
75
|
+
vlan_pcp: true,
|
76
|
+
ip_tos: true,
|
77
|
+
ip_source_all: true,
|
78
|
+
ip_destination: 16,
|
79
|
+
destination_port: true
|
80
|
+
},
|
81
|
+
mac_protocol: :ipv4,
|
82
|
+
ip_protocol: :tcp,
|
83
|
+
ip_destination: '192.168.0.2',
|
84
|
+
destination_port: 3000
|
85
|
+
},
|
86
|
+
cookie: 1,
|
87
|
+
priority: 3000,
|
88
|
+
reason: :idle_timeout,
|
89
|
+
duration_seconds: 50,
|
90
|
+
duration_nanoseconds: 10,
|
91
|
+
idle_timeout: 100,
|
92
|
+
packet_count: 10,
|
93
|
+
byte_count: 80
|
94
|
+
)
|
95
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
96
|
+
expect(msg.type).to eq(:flow_removed)
|
97
|
+
expect(msg.len).to eq(88)
|
98
|
+
expect(msg.xid).to eq(1)
|
99
|
+
expect(msg.match.ip_destination).to eq('192.168.0.2')
|
100
|
+
expect(msg.cookie).to eq(1)
|
101
|
+
expect(msg.priority).to eq(3000)
|
102
|
+
expect(msg.reason).to eq(:idle_timeout)
|
103
|
+
expect(msg.duration_seconds).to eq(50)
|
104
|
+
expect(msg.duration_nanoseconds).to eq(10)
|
105
|
+
expect(msg.idle_timeout).to eq(100)
|
106
|
+
expect(msg.packet_count).to eq(10)
|
107
|
+
expect(msg.byte_count).to eq(80)
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OFGetConfigReply do
|
4
|
+
it 'should read binary' do
|
5
|
+
msg = OFGetConfigReply.read [
|
6
|
+
1, 8, 0, 12, 0, 0, 0, 1, # header
|
7
|
+
0, 0, # flags
|
8
|
+
0, 0xff # miss_send_length
|
9
|
+
].pack('C*')
|
10
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
11
|
+
expect(msg.type).to eq(:get_config_reply)
|
12
|
+
expect(msg.len).to eq(12)
|
13
|
+
expect(msg.xid).to eq(1)
|
14
|
+
expect(msg.flags).to eq(:fragments_normal)
|
15
|
+
expect(msg.miss_send_length).to eq(0xff)
|
16
|
+
end
|
17
|
+
it 'should initialize with default values' do
|
18
|
+
msg = OFGetConfigReply.new
|
19
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
20
|
+
expect(msg.type).to eq(:get_config_reply)
|
21
|
+
expect(msg.len).to eq(12)
|
22
|
+
expect(msg.xid).to eq(0)
|
23
|
+
expect(msg.flags).to eq(:fragments_normal)
|
24
|
+
expect(msg.miss_send_length).to eq(0)
|
25
|
+
end
|
26
|
+
it 'should initialize with some values' do
|
27
|
+
msg = OFGetConfigReply.new(
|
28
|
+
xid: 1,
|
29
|
+
flags: :fragments_normal,
|
30
|
+
miss_send_length: 0xff
|
31
|
+
)
|
32
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
33
|
+
expect(msg.type).to eq(:get_config_reply)
|
34
|
+
expect(msg.len).to eq(12)
|
35
|
+
expect(msg.xid).to eq(1)
|
36
|
+
expect(msg.flags).to eq(:fragments_normal)
|
37
|
+
expect(msg.miss_send_length).to eq(0xff)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OFGetConfigRequest do
|
4
|
+
it 'should read binary' do
|
5
|
+
msg = OFGetConfigRequest.read [1, 7, 0, 8, 0, 0, 0, 1].pack('C*')
|
6
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
7
|
+
expect(msg.type).to eq(:get_config_request)
|
8
|
+
expect(msg.len).to eq(8)
|
9
|
+
expect(msg.xid).to eq(1)
|
10
|
+
end
|
11
|
+
it 'should initialize with default values' do
|
12
|
+
msg = OFGetConfigRequest.new
|
13
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
14
|
+
expect(msg.type).to eq(:get_config_request)
|
15
|
+
expect(msg.len).to eq(8)
|
16
|
+
expect(msg.xid).to eq(0)
|
17
|
+
end
|
18
|
+
it 'should initialize with some values' do
|
19
|
+
msg = OFGetConfigRequest.new(xid: 1)
|
20
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
21
|
+
expect(msg.type).to eq(:get_config_request)
|
22
|
+
expect(msg.len).to eq(8)
|
23
|
+
expect(msg.xid).to eq(1)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OFHello do
|
4
|
+
it 'should read binary' do
|
5
|
+
msg = OFHello.read [1, 0, 0, 8, 0, 0, 0, 1].pack('C*')
|
6
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
7
|
+
expect(msg.type).to eq(:hello)
|
8
|
+
expect(msg.len).to eq(8)
|
9
|
+
expect(msg.xid).to eq(1)
|
10
|
+
end
|
11
|
+
it 'should initialize with default values' do
|
12
|
+
msg = OFHello.new
|
13
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
14
|
+
expect(msg.type).to eq(:hello)
|
15
|
+
expect(msg.len).to eq(8)
|
16
|
+
expect(msg.xid).to eq(0)
|
17
|
+
end
|
18
|
+
it 'should initialize with some values' do
|
19
|
+
msg = OFHello.new(xid: 1)
|
20
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
21
|
+
expect(msg.type).to eq(:hello)
|
22
|
+
expect(msg.len).to eq(8)
|
23
|
+
expect(msg.xid).to eq(1)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OFPacketIn do
|
4
|
+
it 'should read binary' do
|
5
|
+
msg = OFPacketIn.read [
|
6
|
+
1, 10, 0, 64, 0, 0, 0, 1, # header
|
7
|
+
0, 0, 0, 1, # buffer_id
|
8
|
+
0, 46, # total_length
|
9
|
+
0, 1, # in_port
|
10
|
+
0, # reason
|
11
|
+
0, # padding
|
12
|
+
# 1, 2 # data
|
13
|
+
|
14
|
+
# ethernet
|
15
|
+
0, 0, 0, 0, 0, 2, # mac_destination
|
16
|
+
0, 0, 0, 0, 0, 1, # mac_source
|
17
|
+
0x81, 0, # protocol
|
18
|
+
|
19
|
+
# vlan
|
20
|
+
0x20, 1, # pcp & cfi & vlan_id
|
21
|
+
8, 6, # protocol
|
22
|
+
|
23
|
+
# arp
|
24
|
+
0, 1, # hardware
|
25
|
+
8, 0, # protocol
|
26
|
+
6, # hardware_length
|
27
|
+
4, # protocol_length
|
28
|
+
0, 2, # operation
|
29
|
+
0, 0, 0, 0, 0, 1, # mac_source
|
30
|
+
192, 168, 0, 1, # ip_source
|
31
|
+
0, 0, 0, 0, 0, 2, # mac_destination
|
32
|
+
192, 168, 0, 2 # ip_destination
|
33
|
+
].pack('C*')
|
34
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
35
|
+
expect(msg.type).to eq(:packet_in)
|
36
|
+
expect(msg.len).to eq(64)
|
37
|
+
expect(msg.xid).to eq(1)
|
38
|
+
expect(msg.buffer_id).to eq(1)
|
39
|
+
expect(msg.total_length).to eq(46)
|
40
|
+
expect(msg.in_port).to eq(1)
|
41
|
+
expect(msg.reason).to eq(:no_match)
|
42
|
+
expect(msg.data.length).to eq(46)
|
43
|
+
expect(msg.parsed_data.length).to eq(46)
|
44
|
+
expect(msg.parsed_data.mac_destination).to eq('00:00:00:00:00:02')
|
45
|
+
end
|
46
|
+
it 'should initialize with default values' do
|
47
|
+
msg = OFPacketIn.new
|
48
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
49
|
+
expect(msg.type).to eq(:packet_in)
|
50
|
+
expect(msg.len).to eq(18)
|
51
|
+
expect(msg.xid).to eq(0)
|
52
|
+
expect(msg.buffer_id).to eq(:none)
|
53
|
+
expect(msg.total_length).to eq(0)
|
54
|
+
expect(msg.in_port).to eq(:none)
|
55
|
+
expect(msg.reason).to eq(:no_match)
|
56
|
+
expect(msg.data).to be_empty
|
57
|
+
end
|
58
|
+
it 'should initialize with some values' do
|
59
|
+
msg = OFPacketIn.new(
|
60
|
+
xid: 1,
|
61
|
+
buffer_id: 1,
|
62
|
+
in_port: 1,
|
63
|
+
reason: :no_match,
|
64
|
+
data: [1, 2].pack('C*')
|
65
|
+
)
|
66
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
67
|
+
expect(msg.type).to eq(:packet_in)
|
68
|
+
expect(msg.len).to eq(20)
|
69
|
+
expect(msg.xid).to eq(1)
|
70
|
+
expect(msg.buffer_id).to eq(1)
|
71
|
+
expect(msg.total_length).to eq(2)
|
72
|
+
expect(msg.in_port).to eq(1)
|
73
|
+
expect(msg.reason).to eq(:no_match)
|
74
|
+
expect(msg.data.length).to eq(2)
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OFPacketOut do
|
4
|
+
it 'should read binary' do
|
5
|
+
msg = OFPacketOut.read [
|
6
|
+
1, 13, 0, 26, 0, 0, 0, 1, # header
|
7
|
+
0xff, 0xff, 0xff, 0xff, # buffer_id
|
8
|
+
0, 1, # in_port
|
9
|
+
0, 8, # actions_length
|
10
|
+
# actions
|
11
|
+
# output
|
12
|
+
0, 0, 0, 8, # header
|
13
|
+
0, 1, # port
|
14
|
+
0xff, 0xff, # max_length
|
15
|
+
# data
|
16
|
+
1, 2
|
17
|
+
].pack('C*')
|
18
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
19
|
+
expect(msg.type).to eq(:packet_out)
|
20
|
+
expect(msg.len).to eq(26)
|
21
|
+
expect(msg.xid).to eq(1)
|
22
|
+
expect(msg.buffer_id).to eq(:none)
|
23
|
+
expect(msg.in_port).to eq(1)
|
24
|
+
expect(msg.actions.length).to eq(1)
|
25
|
+
expect(msg.actions.first.type).to eq(:output)
|
26
|
+
expect(msg.data.length).to eq(2)
|
27
|
+
end
|
28
|
+
it 'should initialize with default values' do
|
29
|
+
msg = OFPacketOut.new
|
30
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
31
|
+
expect(msg.type).to eq(:packet_out)
|
32
|
+
expect(msg.len).to eq(16)
|
33
|
+
expect(msg.xid).to eq(0)
|
34
|
+
expect(msg.buffer_id).to eq(:none)
|
35
|
+
expect(msg.in_port).to eq(:none)
|
36
|
+
expect(msg.actions).to be_empty
|
37
|
+
expect(msg.data).to be_empty
|
38
|
+
end
|
39
|
+
it 'should initialize with some values' do
|
40
|
+
msg = OFPacketOut.new(
|
41
|
+
xid: 1,
|
42
|
+
in_port: 1,
|
43
|
+
actions: [OFActionOutput.new(port: 1)],
|
44
|
+
data: [1, 2].pack('C*')
|
45
|
+
)
|
46
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
47
|
+
expect(msg.type).to eq(:packet_out)
|
48
|
+
expect(msg.len).to eq(26)
|
49
|
+
expect(msg.xid).to eq(1)
|
50
|
+
expect(msg.buffer_id).to eq(:none)
|
51
|
+
expect(msg.in_port).to eq(1)
|
52
|
+
expect(msg.actions.length).to eq(1)
|
53
|
+
expect(msg.actions.first.type).to eq(:output)
|
54
|
+
expect(msg.data.length).to eq(2)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OFParser do
|
4
|
+
let(:hello_msg) { [1, 0, 0, 8, 0, 0, 0, 1].pack('C*') }
|
5
|
+
let(:packet_out_msg) {
|
6
|
+
[
|
7
|
+
1, 13, 0, 26, 0, 0, 0, 1, # header
|
8
|
+
0xff, 0xff, 0xff, 0xff, # buffer_id
|
9
|
+
0, 1, # in_port
|
10
|
+
0, 8, # actions_length
|
11
|
+
# actions
|
12
|
+
# output
|
13
|
+
0, 0, 0, 8, # header
|
14
|
+
0, 1, # port
|
15
|
+
0xff, 0xff, # max_length
|
16
|
+
# data
|
17
|
+
1, 2
|
18
|
+
].pack('C*')
|
19
|
+
}
|
20
|
+
|
21
|
+
it 'should read binary Hello Message' do
|
22
|
+
msg = OFParser.read(hello_msg)
|
23
|
+
expect(msg.class).to be(OFHello)
|
24
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
25
|
+
expect(msg.type).to eq(:hello)
|
26
|
+
expect(msg.len).to eq(8)
|
27
|
+
expect(msg.xid).to eq(1)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should read binary PacketOut Message' do
|
31
|
+
msg = OFParser.read(packet_out_msg)
|
32
|
+
expect(msg.class).to be(OFPacketOut)
|
33
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
34
|
+
expect(msg.type).to eq(:packet_out)
|
35
|
+
expect(msg.len).to eq(26)
|
36
|
+
expect(msg.xid).to eq(1)
|
37
|
+
expect(msg.buffer_id).to eq(:none)
|
38
|
+
expect(msg.in_port).to eq(1)
|
39
|
+
expect(msg.actions.length).to eq(1)
|
40
|
+
expect(msg.actions.first.type).to eq(:output)
|
41
|
+
expect(msg.data.length).to eq(2)
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OFPortMod do
|
4
|
+
it 'should read binary' do
|
5
|
+
msg = OFPortMod.read [
|
6
|
+
1, 15, 0, 32, 0, 0, 0, 1, # header
|
7
|
+
0, 1, # port_number
|
8
|
+
0, 0, 0, 0, 0, 1, # hardware_address
|
9
|
+
0, 0, 0, 3, # config
|
10
|
+
0, 0, 0, 1, # mask
|
11
|
+
0, 0, 0, 3, # advertise
|
12
|
+
0, 0, 0, 0 # padding
|
13
|
+
].pack('C*')
|
14
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
15
|
+
expect(msg.type).to eq(:port_mod)
|
16
|
+
expect(msg.len).to eq(32)
|
17
|
+
expect(msg.xid).to eq(1)
|
18
|
+
expect(msg.port_number).to eq(1)
|
19
|
+
expect(msg.hardware_address).to eq('00:00:00:00:00:01')
|
20
|
+
expect(msg.config).to eq([:port_down, :no_spanning_tree])
|
21
|
+
expect(msg.mask).to eq([:port_down])
|
22
|
+
expect(msg.advertise).to eq([
|
23
|
+
:port_10mb_half_duplex,
|
24
|
+
:port_10mb_full_duplex
|
25
|
+
])
|
26
|
+
end
|
27
|
+
it 'should initialize with default values' do
|
28
|
+
msg = OFPortMod.new
|
29
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
30
|
+
expect(msg.type).to eq(:port_mod)
|
31
|
+
expect(msg.len).to eq(32)
|
32
|
+
expect(msg.xid).to eq(0)
|
33
|
+
expect(msg.port_number).to eq(:none)
|
34
|
+
expect(msg.hardware_address).to eq('00:00:00:00:00:00')
|
35
|
+
expect(msg.config).to be_empty
|
36
|
+
expect(msg.mask).to be_empty
|
37
|
+
expect(msg.advertise).to be_empty
|
38
|
+
end
|
39
|
+
it 'should initialize with some values' do
|
40
|
+
msg = OFPortMod.new(
|
41
|
+
xid: 1,
|
42
|
+
port_number: 1,
|
43
|
+
hardware_address: '00:00:00:00:00:01',
|
44
|
+
config: [:port_down, :no_spanning_tree],
|
45
|
+
mask: [:port_down],
|
46
|
+
advertise: [
|
47
|
+
:port_10mb_half_duplex,
|
48
|
+
:port_10mb_full_duplex
|
49
|
+
]
|
50
|
+
)
|
51
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
52
|
+
expect(msg.type).to eq(:port_mod)
|
53
|
+
expect(msg.len).to eq(32)
|
54
|
+
expect(msg.xid).to eq(1)
|
55
|
+
expect(msg.port_number).to eq(1)
|
56
|
+
expect(msg.hardware_address).to eq('00:00:00:00:00:01')
|
57
|
+
expect(msg.config).to eq([:port_down, :no_spanning_tree])
|
58
|
+
expect(msg.mask).to eq([:port_down])
|
59
|
+
expect(msg.advertise).to eq([
|
60
|
+
:port_10mb_half_duplex,
|
61
|
+
:port_10mb_full_duplex
|
62
|
+
])
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OFPortStatus do
|
4
|
+
it 'should read binary' do
|
5
|
+
msg = OFPortStatus.read [
|
6
|
+
1, 12, 0, 64, 0, 0, 0, 1, # header
|
7
|
+
1, # reason
|
8
|
+
0, 0, 0, 0, 0, 0, 0, # padding
|
9
|
+
# port
|
10
|
+
0, 1, # port_number
|
11
|
+
0, 0, 0, 0, 0, 1, # hardware_address
|
12
|
+
112, 111, 114, 116, # name
|
13
|
+
45, 49, 0, 0,
|
14
|
+
0, 0, 0, 0,
|
15
|
+
0, 0, 0, 0,
|
16
|
+
0, 0, 0, 1, # config
|
17
|
+
0, 0, 0, 1, # state
|
18
|
+
0, 0, 0x0f, 0xff, # current_features
|
19
|
+
0, 0, 0x0f, 0xff, # advertised_features
|
20
|
+
0, 0, 0x0f, 0xff, # supported_features
|
21
|
+
0, 0, 0x0f, 0xff # peer_features
|
22
|
+
].pack('C*')
|
23
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
24
|
+
expect(msg.type).to eq(:port_status)
|
25
|
+
expect(msg.len).to eq(64)
|
26
|
+
expect(msg.xid).to eq(1)
|
27
|
+
expect(msg.reason).to eq(:delete)
|
28
|
+
expect(msg.desc.port_number).to eq(1)
|
29
|
+
end
|
30
|
+
it 'should initialize with default values' do
|
31
|
+
msg = OFPortStatus.new
|
32
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
33
|
+
expect(msg.type).to eq(:port_status)
|
34
|
+
expect(msg.len).to eq(64)
|
35
|
+
expect(msg.xid).to eq(0)
|
36
|
+
expect(msg.reason).to eq(:add)
|
37
|
+
expect(msg.desc.port_number).to eq(0)
|
38
|
+
end
|
39
|
+
it 'should initialize with some values' do
|
40
|
+
msg = OFPortStatus.new(
|
41
|
+
xid: 1,
|
42
|
+
reason: :delete,
|
43
|
+
desc: OFPhysicalPort.new(port_number: 1)
|
44
|
+
)
|
45
|
+
expect(msg.version).to eq(OFMessage::OFP_VERSION)
|
46
|
+
expect(msg.type).to eq(:port_status)
|
47
|
+
expect(msg.len).to eq(64)
|
48
|
+
expect(msg.xid).to eq(1)
|
49
|
+
expect(msg.reason).to eq(:delete)
|
50
|
+
expect(msg.desc.port_number).to eq(1)
|
51
|
+
end
|
52
|
+
end
|