pio 0.18.2 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +40 -344
- data/Rakefile +32 -0
- data/bin/_guard-core +16 -0
- data/bin/byebug +16 -0
- data/bin/cc-tddium-post-worker +16 -0
- data/bin/cdiff +16 -0
- data/bin/coderay +16 -0
- data/bin/colortab +16 -0
- data/bin/coveralls +16 -0
- data/bin/cucumber +16 -0
- data/bin/decolor +16 -0
- data/bin/flay +16 -0
- data/bin/flog +16 -0
- data/bin/guard +16 -0
- data/bin/htmldiff +16 -0
- data/bin/inch +16 -0
- data/bin/ldiff +16 -0
- data/bin/listen +16 -0
- data/bin/minitar +16 -0
- data/bin/pry +16 -0
- data/bin/rake +16 -0
- data/bin/reek +16 -0
- data/bin/relish +16 -0
- data/bin/restclient +16 -0
- data/bin/rspec +16 -0
- data/bin/rubocop +16 -0
- data/bin/ruby-parse +16 -0
- data/bin/ruby-rewrite +16 -0
- data/bin/ruby_parse +16 -0
- data/bin/ruby_parse_extract_error +16 -0
- data/bin/sparkr +16 -0
- data/bin/term_display +16 -0
- data/bin/term_mandel +16 -0
- data/bin/thor +16 -0
- data/bin/unparser +16 -0
- data/bin/yard +16 -0
- data/bin/yardoc +16 -0
- data/bin/yri +16 -0
- data/features/arp.feature +61 -0
- data/features/dhcp.feature +4 -0
- data/features/icmp.feature +130 -0
- data/features/lldp.feature +47 -0
- data/features/open_flow10/echo_reply.feature +95 -0
- data/features/open_flow10/echo_request.feature +95 -0
- data/features/open_flow10/exact_match.feature +36 -0
- data/features/{features_read.feature → open_flow10/features_reply.feature} +54 -17
- data/features/open_flow10/features_request.feature +79 -0
- data/features/{flow_mod_read.feature → open_flow10/flow_mod.feature} +16 -21
- data/features/open_flow10/hello.feature +79 -0
- data/features/open_flow10/packet_in.feature +58 -0
- data/features/{packet_out_read.feature → open_flow10/packet_out.feature} +4 -5
- data/features/open_flow10/port_status.feature +23 -0
- data/features/open_flow13/echo_reply.feature +115 -0
- data/features/open_flow13/echo_request.feature +115 -0
- data/features/open_flow13/hello.feature +74 -0
- data/features/packet_data/echo13_reply_body.raw +0 -0
- data/features/packet_data/echo13_reply_no_body.raw +0 -0
- data/features/packet_data/echo13_request_body.raw +0 -0
- data/features/packet_data/echo13_request_no_body.raw +0 -0
- data/features/packet_data/hello13_no_version_bitmap.raw +0 -0
- data/features/packet_data/hello13_version_bitmap.raw +0 -0
- data/features/packet_data/udp_no_payload.raw +0 -0
- data/features/packet_data/udp_with_payload.raw +0 -0
- data/features/step_definitions/packet_data_steps.rb +49 -29
- data/features/support/env.rb +3 -0
- data/features/{udp_read.feature → udp.feature} +3 -4
- data/lib/pio.rb +1 -0
- data/lib/pio/echo.rb +67 -0
- data/lib/pio/hello13.rb +111 -0
- data/lib/pio/open_flow/message.rb +2 -1
- data/lib/pio/open_flow/open_flow_header.rb +21 -38
- data/lib/pio/open_flow/transaction_id.rb +25 -0
- data/lib/pio/version.rb +1 -1
- data/pio.gemspec +9 -14
- data/spec/pio/flow_mod_spec.rb +1 -1
- data/spec/pio/hello13_spec.rb +114 -0
- metadata +182 -138
- data/examples/arp_new.rb +0 -16
- data/examples/arp_read.rb +0 -4
- data/examples/dhcp_new.rb +0 -34
- data/examples/dhcp_read.rb +0 -4
- data/examples/echo_new.rb +0 -9
- data/examples/echo_read.rb +0 -4
- data/examples/features_new.rb +0 -28
- data/examples/features_read.rb +0 -4
- data/examples/flow_mod_new.rb +0 -13
- data/examples/flow_mod_read.rb +0 -6
- data/examples/hello_new.rb +0 -4
- data/examples/hello_read.rb +0 -4
- data/examples/icmp_new.rb +0 -21
- data/examples/icmp_read.rb +0 -4
- data/examples/lldp_new.rb +0 -4
- data/examples/lldp_read.rb +0 -4
- data/examples/packet_in_new.rb +0 -17
- data/examples/packet_in_read.rb +0 -5
- data/examples/packet_out_new.rb +0 -18
- data/examples/packet_out_read.rb +0 -6
- data/features/arp_read.feature +0 -10
- data/features/dhcp_read.feature +0 -6
- data/features/echo_read.feature +0 -29
- data/features/exact_match.feature +0 -38
- data/features/hello_read.feature +0 -14
- data/features/icmp_read.feature +0 -55
- data/features/lldp_read.feature +0 -26
- data/features/packet_in_read.feature +0 -22
- data/features/port_status_read.feature +0 -24
- data/features/step_definitions/pending_steps.rb +0 -3
- data/spec/pio/echo/reply_spec.rb +0 -135
- data/spec/pio/echo/request_spec.rb +0 -137
- data/spec/pio/features/reply_spec.rb +0 -137
- data/spec/pio/features/request_spec.rb +0 -112
- data/spec/pio/hello_spec.rb +0 -106
- data/spec/pio/lldp_spec.rb +0 -244
- data/spec/pio/packet_in_spec.rb +0 -146
data/spec/pio/hello_spec.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
require 'pio/hello'
|
2
|
-
|
3
|
-
describe Pio::Hello do
|
4
|
-
describe '.read' do
|
5
|
-
When(:result) { Pio::Hello.read(binary) }
|
6
|
-
|
7
|
-
context 'with a hello message' do
|
8
|
-
Given(:binary) { [1, 0, 0, 8, 0, 0, 0, 0].pack('C*') }
|
9
|
-
|
10
|
-
Then { result.class == Pio::Hello }
|
11
|
-
Then { result.ofp_version == 1 }
|
12
|
-
Then { result.message_type == 0 }
|
13
|
-
Then { result.message_length == 8 }
|
14
|
-
Then { result.transaction_id == 0 }
|
15
|
-
Then { result.xid == 0 }
|
16
|
-
Then { result.body.empty? }
|
17
|
-
Then { result.body == '' }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'with a features-request message' do
|
21
|
-
Given(:binary) { [1, 5, 0, 8, 0, 0, 0, 0].pack('C*') }
|
22
|
-
|
23
|
-
Then { result == Failure(Pio::ParseError, 'Invalid Hello message.') }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '.new' do
|
28
|
-
context 'with no arguments' do
|
29
|
-
When(:result) { Pio::Hello.new }
|
30
|
-
|
31
|
-
Then { result.ofp_version == 1 }
|
32
|
-
Then { result.message_type == 0 }
|
33
|
-
Then { result.message_length == 8 }
|
34
|
-
Then { result.transaction_id == 0 }
|
35
|
-
Then { result.xid == 0 }
|
36
|
-
Then { result.body.empty? }
|
37
|
-
Then { result.body == '' }
|
38
|
-
Then { result.to_binary == [1, 0, 0, 8, 0, 0, 0, 0].pack('C*') }
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'with 123' do
|
42
|
-
When(:result) { Pio::Hello.new(123) }
|
43
|
-
|
44
|
-
Then { result.ofp_version == 1 }
|
45
|
-
Then { result.message_type == 0 }
|
46
|
-
Then { result.message_length == 8 }
|
47
|
-
Then { result.transaction_id == 123 }
|
48
|
-
Then { result.xid == 123 }
|
49
|
-
Then { result.body.empty? }
|
50
|
-
Then { result.body == '' }
|
51
|
-
Then { result.to_binary == [1, 0, 0, 8, 0, 0, 0, 123].pack('C*') }
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'with transaction_id: 123' do
|
55
|
-
When(:result) { Pio::Hello.new(transaction_id: 123) }
|
56
|
-
|
57
|
-
Then { result.ofp_version == 1 }
|
58
|
-
Then { result.message_type == 0 }
|
59
|
-
Then { result.message_length == 8 }
|
60
|
-
Then { result.transaction_id == 123 }
|
61
|
-
Then { result.xid == 123 }
|
62
|
-
Then { result.body.empty? }
|
63
|
-
Then { result.body == '' }
|
64
|
-
Then { result.to_binary == [1, 0, 0, 8, 0, 0, 0, 123].pack('C*') }
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'with xid: 123' do
|
68
|
-
When(:result) { Pio::Hello.new(xid: 123) }
|
69
|
-
|
70
|
-
Then { result.ofp_version == 1 }
|
71
|
-
Then { result.message_type == 0 }
|
72
|
-
Then { result.message_length == 8 }
|
73
|
-
Then { result.transaction_id == 123 }
|
74
|
-
Then { result.xid == 123 }
|
75
|
-
Then { result.body.empty? }
|
76
|
-
Then { result.body == '' }
|
77
|
-
Then { result.to_binary == [1, 0, 0, 8, 0, 0, 0, 123].pack('C*') }
|
78
|
-
end
|
79
|
-
|
80
|
-
context 'with -1' do
|
81
|
-
When(:result) { Pio::Hello.new(-1) }
|
82
|
-
|
83
|
-
Then do
|
84
|
-
result ==
|
85
|
-
Failure(ArgumentError,
|
86
|
-
'Transaction ID should be an unsigned 32-bit integer.')
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'with 2**32' do
|
91
|
-
When(:result) { Pio::Hello.new(2**32) }
|
92
|
-
|
93
|
-
Then do
|
94
|
-
result ==
|
95
|
-
Failure(ArgumentError,
|
96
|
-
'Transaction ID should be an unsigned 32-bit integer.')
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'with :INVALID_ARGUMENT' do
|
101
|
-
When(:result) { Pio::Hello.new(:INVALID_ARGUMENT) }
|
102
|
-
|
103
|
-
Then { result == Failure(TypeError) }
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
data/spec/pio/lldp_spec.rb
DELETED
@@ -1,244 +0,0 @@
|
|
1
|
-
require 'pio'
|
2
|
-
|
3
|
-
describe Pio::LLDP do
|
4
|
-
Then { Pio::LLDP == Pio::Lldp }
|
5
|
-
end
|
6
|
-
|
7
|
-
describe Pio::Lldp do
|
8
|
-
describe '.new' do
|
9
|
-
context 'with :dpid and :port_number' do
|
10
|
-
Given(:lldp) do
|
11
|
-
Pio::Lldp.new(dpid: 0x192fa7b28d, port_number: 1)
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#to_binary' do
|
15
|
-
When(:result) { lldp.to_binary }
|
16
|
-
|
17
|
-
Then do
|
18
|
-
result ==
|
19
|
-
[
|
20
|
-
# Destination MAC
|
21
|
-
0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e,
|
22
|
-
# Source MAC
|
23
|
-
0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
|
24
|
-
# Ethertype
|
25
|
-
0x88, 0xcc,
|
26
|
-
# Chassis ID TLV
|
27
|
-
0x02, 0x09, 0x07, 0x00, 0x00, 0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d,
|
28
|
-
# Port ID TLV
|
29
|
-
0x04, 0x05, 0x07, 0x00, 0x00, 0x00, 0x01,
|
30
|
-
# Time to live TLV
|
31
|
-
0x06, 0x02, 0x00, 0x78,
|
32
|
-
# End of LLDPDU TLV
|
33
|
-
0x00, 0x00,
|
34
|
-
# Padding
|
35
|
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
36
|
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
37
|
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
38
|
-
].pack('C*')
|
39
|
-
end
|
40
|
-
And { result.size == 64 }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'with :dpid, :port_number and :source_mac' do
|
45
|
-
Given(:lldp) do
|
46
|
-
Pio::Lldp.new(
|
47
|
-
dpid: 0x192fa7b28d,
|
48
|
-
port_number: 1,
|
49
|
-
source_mac: '06:05:04:03:02:01'
|
50
|
-
)
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#to_binary' do
|
54
|
-
When(:result) { lldp.to_binary }
|
55
|
-
|
56
|
-
Then do
|
57
|
-
result ==
|
58
|
-
[
|
59
|
-
# Destination MAC
|
60
|
-
0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e,
|
61
|
-
# Source MAC
|
62
|
-
0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
|
63
|
-
# Ethertype
|
64
|
-
0x88, 0xcc,
|
65
|
-
# Chassis ID TLV
|
66
|
-
0x02, 0x09, 0x07, 0x00, 0x00, 0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d,
|
67
|
-
# Port ID TLV
|
68
|
-
0x04, 0x05, 0x07, 0x00, 0x00, 0x00, 0x01,
|
69
|
-
# Time to live TLV
|
70
|
-
0x06, 0x02, 0x00, 0x78,
|
71
|
-
# End of LLDPDU TLV
|
72
|
-
0x00, 0x00,
|
73
|
-
# Padding
|
74
|
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
75
|
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
76
|
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
77
|
-
].pack('C*')
|
78
|
-
end
|
79
|
-
And { result.size == 64 }
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context 'with :dpid, :port_number, :source_mac and :destination_mac' do
|
84
|
-
Given(:lldp) do
|
85
|
-
Pio::Lldp.new(
|
86
|
-
dpid: 0x192fa7b28d,
|
87
|
-
port_number: 1,
|
88
|
-
source_mac: '06:05:04:03:02:01',
|
89
|
-
destination_mac: '01:02:03:04:05:06'
|
90
|
-
)
|
91
|
-
end
|
92
|
-
|
93
|
-
describe '#to_binary' do
|
94
|
-
When(:result) { lldp.to_binary }
|
95
|
-
|
96
|
-
Then do
|
97
|
-
result ==
|
98
|
-
[
|
99
|
-
# Destination MAC
|
100
|
-
0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
|
101
|
-
# Source MAC
|
102
|
-
0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
|
103
|
-
# Ethertype
|
104
|
-
0x88, 0xcc,
|
105
|
-
# Chassis ID TLV
|
106
|
-
0x02, 0x09, 0x07, 0x00, 0x00, 0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d,
|
107
|
-
# Port ID TLV
|
108
|
-
0x04, 0x05, 0x07, 0x00, 0x00, 0x00, 0x01,
|
109
|
-
# Time to live TLV
|
110
|
-
0x06, 0x02, 0x00, 0x78,
|
111
|
-
# End of LLDPDU TLV
|
112
|
-
0x00, 0x00,
|
113
|
-
# Padding
|
114
|
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
115
|
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
116
|
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
117
|
-
].pack('C*')
|
118
|
-
end
|
119
|
-
And { result.size == 64 }
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
context '.read' do
|
125
|
-
context 'with a minimum LLDP frame' do
|
126
|
-
Given(:lldp_dump) do
|
127
|
-
[
|
128
|
-
# Destination MAC
|
129
|
-
0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e,
|
130
|
-
# Source MAC
|
131
|
-
0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d,
|
132
|
-
# Ethertype
|
133
|
-
0x88, 0xcc,
|
134
|
-
# Chassis ID TLV
|
135
|
-
0x02, 0x07, 0x04, 0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d,
|
136
|
-
# Port ID TLV
|
137
|
-
0x04, 0x0d, 0x01, 0x55, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x20,
|
138
|
-
0x74, 0x6f, 0x20, 0x53, 0x31,
|
139
|
-
# Time to live TLV
|
140
|
-
0x06, 0x02, 0x00, 0x78,
|
141
|
-
# End of LLDPDU TLV
|
142
|
-
0x00, 0x00
|
143
|
-
].pack('C*')
|
144
|
-
end
|
145
|
-
|
146
|
-
When(:lldp) { Pio::Lldp.read(lldp_dump) }
|
147
|
-
|
148
|
-
Then { lldp.destination_mac.to_s == '01:80:c2:00:00:0e' }
|
149
|
-
Then { lldp.source_mac.to_s == '00:19:2f:a7:b2:8d' }
|
150
|
-
Then { lldp.ether_type == 0x88cc }
|
151
|
-
Then { lldp.dpid == 0x192fa7b28d }
|
152
|
-
Then { lldp.dpid.class == Fixnum }
|
153
|
-
Then { lldp.chassis_id == 0x192fa7b28d }
|
154
|
-
Then { lldp.port_id == 'Uplink to S1' }
|
155
|
-
Then { lldp.port_number == 'Uplink to S1' }
|
156
|
-
Then { lldp.port_number.class == String }
|
157
|
-
Then { lldp.ttl == 120 }
|
158
|
-
Then { lldp.port_description == nil }
|
159
|
-
Then { lldp.system_name == nil }
|
160
|
-
Then { lldp.system_description == nil }
|
161
|
-
Then { lldp.system_capabilities == nil }
|
162
|
-
Then { lldp.management_address == nil }
|
163
|
-
end
|
164
|
-
|
165
|
-
context 'with a detailed LLDP frame' do
|
166
|
-
Given(:lldp_dump) do
|
167
|
-
[
|
168
|
-
# Destination MAC
|
169
|
-
0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e,
|
170
|
-
# Source MAC
|
171
|
-
0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d,
|
172
|
-
# Ethertype
|
173
|
-
0x88, 0xcc,
|
174
|
-
# Chassis ID TLV
|
175
|
-
0x02, 0x07, 0x04, 0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d,
|
176
|
-
# Port ID TLV
|
177
|
-
0x04, 0x0d, 0x01, 0x55, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x20,
|
178
|
-
0x74, 0x6f, 0x20, 0x53, 0x31,
|
179
|
-
# Time to live TLV
|
180
|
-
0x06, 0x02, 0x00, 0x78,
|
181
|
-
# Port Description
|
182
|
-
0x08, 0x17, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30,
|
183
|
-
0x30, 0x2d, 0x34, 0x38, 0x2d, 0x50, 0x6f, 0x72, 0x74, 0x20,
|
184
|
-
0x31, 0x30, 0x30, 0x31, 0x00,
|
185
|
-
# System Name
|
186
|
-
0x0a, 0x0d, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30,
|
187
|
-
0x30, 0x2d, 0x34, 0x38, 0x00,
|
188
|
-
# System Description
|
189
|
-
0x0c, 0x4c, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30,
|
190
|
-
0x30, 0x2d, 0x34, 0x38, 0x20, 0x2d, 0x20, 0x56, 0x65, 0x72,
|
191
|
-
0x73, 0x69, 0x6f, 0x6e, 0x20, 0x37, 0x2e, 0x34, 0x65, 0x2e,
|
192
|
-
0x31, 0x20, 0x28, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x20, 0x35,
|
193
|
-
0x29, 0x20, 0x62, 0x79, 0x20, 0x52, 0x65, 0x6c, 0x65, 0x61,
|
194
|
-
0x73, 0x65, 0x5f, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x20,
|
195
|
-
0x30, 0x35, 0x2f, 0x32, 0x37, 0x2f, 0x30, 0x35, 0x20, 0x30,
|
196
|
-
0x34, 0x3a, 0x35, 0x33, 0x3a, 0x31, 0x31, 0x00,
|
197
|
-
# System Capabilities
|
198
|
-
0x0e, 0x04, 0x00, 0x14, 0x00, 0x14,
|
199
|
-
# Management Address
|
200
|
-
0x10, 0x0e, 0x07, 0x06, 0x00, 0x01, 0x30, 0xf9, 0xad, 0xa0,
|
201
|
-
0x02, 0x00, 0x00, 0x03, 0xe9, 0x00,
|
202
|
-
# Organizationally Specific
|
203
|
-
0xfe, 0x07, 0x00, 0x12, 0x0f, 0x02, 0x07, 0x01, 0x00,
|
204
|
-
# End of LLDPDU TLV
|
205
|
-
0x00, 0x00
|
206
|
-
].pack('C*')
|
207
|
-
end
|
208
|
-
|
209
|
-
When(:lldp) { Pio::Lldp.read(lldp_dump) }
|
210
|
-
|
211
|
-
Then { lldp.destination_mac.to_s == '01:80:c2:00:00:0e' }
|
212
|
-
Then { lldp.source_mac.to_s == '00:19:2f:a7:b2:8d' }
|
213
|
-
Then { lldp.ether_type == 0x88cc }
|
214
|
-
Then { lldp.dpid == 0x192fa7b28d }
|
215
|
-
Then { lldp.chassis_id == 0x192fa7b28d }
|
216
|
-
Then { lldp.port_id == 'Uplink to S1' }
|
217
|
-
Then { lldp.port_number == 'Uplink to S1' }
|
218
|
-
Then { lldp.port_number.class == String }
|
219
|
-
Then { lldp.ttl == 120 }
|
220
|
-
Then { lldp.port_description == 'Summit300-48-Port 1001' }
|
221
|
-
Then { lldp.system_name == 'Summit300-48' }
|
222
|
-
Then do
|
223
|
-
lldp.system_description ==
|
224
|
-
'Summit300-48 - Version 7.4e.1 (Build 5) ' \
|
225
|
-
'by Release_Master 05/27/05 04:53:11'
|
226
|
-
end
|
227
|
-
Then { lldp.system_capabilities.system_capabilities == 20 }
|
228
|
-
Then { lldp.system_capabilities.enabled_capabilities == 20 }
|
229
|
-
Then do
|
230
|
-
lldp.management_address ==
|
231
|
-
[0x00, 0x01, 0x30, 0xf9, 0xad, 0xa0].pack('C*')
|
232
|
-
end
|
233
|
-
Then { lldp.organizationally_specific.oui == 4623 }
|
234
|
-
Then { lldp.organizationally_specific.subtype == 2 }
|
235
|
-
Then { lldp.organizationally_specific.information == "\a\x01" }
|
236
|
-
end
|
237
|
-
|
238
|
-
context 'with an invalid LLDP frame' do
|
239
|
-
When(:result) { Pio::Lldp.read('') }
|
240
|
-
|
241
|
-
Then { result == Failure(Pio::ParseError, 'End of file reached') }
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
data/spec/pio/packet_in_spec.rb
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
require 'pio/packet_in'
|
2
|
-
|
3
|
-
describe Pio::PacketIn do
|
4
|
-
Given(:data_dump) do
|
5
|
-
[
|
6
|
-
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xac, 0x5d, 0x10, 0x31,
|
7
|
-
0x37, 0x79, 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04,
|
8
|
-
0x00, 0x01, 0xac, 0x5d, 0x10, 0x31, 0x37, 0x79, 0xc0, 0xa8,
|
9
|
-
0x02, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xa8,
|
10
|
-
0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
11
|
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
12
|
-
].pack('C*')
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '.read' do
|
16
|
-
When(:result) { Pio::PacketIn.read(binary) }
|
17
|
-
|
18
|
-
context 'with a packet_in message' do
|
19
|
-
Given(:header_dump) do
|
20
|
-
[
|
21
|
-
0x01,
|
22
|
-
0x0a,
|
23
|
-
0x00, 0x4e,
|
24
|
-
0x00, 0x00, 0x00, 0x00
|
25
|
-
].pack('C*')
|
26
|
-
end
|
27
|
-
Given(:body_dump) do
|
28
|
-
[
|
29
|
-
0xff, 0xff, 0xff, 0x00,
|
30
|
-
0x00, 0x3c,
|
31
|
-
0x00, 0x01,
|
32
|
-
0x00,
|
33
|
-
0x00
|
34
|
-
].pack('C*') + data_dump
|
35
|
-
end
|
36
|
-
Given(:binary) { header_dump + body_dump }
|
37
|
-
|
38
|
-
Then { result.class == Pio::PacketIn }
|
39
|
-
Then { result.ofp_version == 0x1 }
|
40
|
-
Then { result.message_type == 0xa }
|
41
|
-
Then { result.message_length == 0x4e }
|
42
|
-
Then { result.transaction_id == 0 }
|
43
|
-
Then { result.xid == 0 }
|
44
|
-
|
45
|
-
Then { !result.body.empty? }
|
46
|
-
Then { result.buffer_id == 0xffffff00 }
|
47
|
-
Then { result.total_len == 0x3c }
|
48
|
-
Then { result.in_port == 1 }
|
49
|
-
Then { result.reason == :no_match }
|
50
|
-
Then { result.raw_data == data_dump }
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'with a Packet-In message generated with PacketIn.new' do
|
54
|
-
Given(:binary) do
|
55
|
-
Pio::PacketIn.new(
|
56
|
-
transaction_id: 0,
|
57
|
-
buffer_id: 0xffffff00,
|
58
|
-
in_port: 1,
|
59
|
-
reason: :no_match,
|
60
|
-
raw_data: data_dump
|
61
|
-
).to_binary
|
62
|
-
end
|
63
|
-
|
64
|
-
Then { result.class == Pio::PacketIn }
|
65
|
-
Then { result.ofp_version == 0x1 }
|
66
|
-
Then { result.message_type == 0xa }
|
67
|
-
Then { result.message_length == 0x4e }
|
68
|
-
Then { result.transaction_id == 0 }
|
69
|
-
Then { result.xid == 0 }
|
70
|
-
|
71
|
-
Then { !result.body.empty? }
|
72
|
-
Then { result.buffer_id == 0xffffff00 }
|
73
|
-
Then { result.total_len == 0x3c }
|
74
|
-
Then { result.in_port == 1 }
|
75
|
-
Then { result.reason == :no_match }
|
76
|
-
Then { result.raw_data == data_dump }
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'with a Hello message' do
|
80
|
-
Given(:binary) { [1, 0, 0, 8, 0, 0, 0, 0].pack('C*') }
|
81
|
-
|
82
|
-
Then do
|
83
|
-
result == Failure(Pio::ParseError,
|
84
|
-
'Invalid PacketIn message.')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe '.new' do
|
90
|
-
When(:packet_in) { Pio::PacketIn.new(user_options) }
|
91
|
-
|
92
|
-
context 'with transaction_id: option' do
|
93
|
-
When(:user_options) do
|
94
|
-
{
|
95
|
-
transaction_id: 0x123,
|
96
|
-
buffer_id: 0xffffff00,
|
97
|
-
in_port: 1,
|
98
|
-
reason: :no_match,
|
99
|
-
raw_data: data_dump
|
100
|
-
}
|
101
|
-
end
|
102
|
-
When { packet_in.datapath_id = 0xabc }
|
103
|
-
|
104
|
-
Then { packet_in.datapath_id == 0xabc }
|
105
|
-
Then { packet_in.dpid == 0xabc }
|
106
|
-
Then { packet_in.ofp_version == 1 }
|
107
|
-
Then { packet_in.message_type == 10 }
|
108
|
-
Then { packet_in.message_length == 78 }
|
109
|
-
Then { packet_in.transaction_id == 0x123 }
|
110
|
-
Then { packet_in.xid == 0x123 }
|
111
|
-
|
112
|
-
Then { !packet_in.body.empty? }
|
113
|
-
Then { packet_in.buffer_id == 0xffffff00 }
|
114
|
-
Then { packet_in.in_port == 1 }
|
115
|
-
Then { packet_in.reason == :no_match }
|
116
|
-
Then { packet_in.raw_data == data_dump }
|
117
|
-
end
|
118
|
-
|
119
|
-
context 'with xid: option' do
|
120
|
-
When(:user_options) do
|
121
|
-
{
|
122
|
-
xid: 0x123,
|
123
|
-
buffer_id: 0xffffff00,
|
124
|
-
in_port: 1,
|
125
|
-
reason: :no_match,
|
126
|
-
raw_data: data_dump
|
127
|
-
}
|
128
|
-
end
|
129
|
-
When { packet_in.dpid = 0xabc }
|
130
|
-
|
131
|
-
Then { packet_in.datapath_id == 0xabc }
|
132
|
-
Then { packet_in.dpid == 0xabc }
|
133
|
-
Then { packet_in.ofp_version == 1 }
|
134
|
-
Then { packet_in.message_type == 10 }
|
135
|
-
Then { packet_in.message_length == 78 }
|
136
|
-
Then { packet_in.transaction_id == 0x123 }
|
137
|
-
Then { packet_in.xid == 0x123 }
|
138
|
-
|
139
|
-
Then { !packet_in.body.empty? }
|
140
|
-
Then { packet_in.buffer_id == 0xffffff00 }
|
141
|
-
Then { packet_in.in_port == 1 }
|
142
|
-
Then { packet_in.reason == :no_match }
|
143
|
-
Then { packet_in.raw_data == data_dump }
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|