pio 0.19.0 → 0.20.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 +9 -0
- data/README.md +20 -18
- data/features/{packet_data/arp-storm.pcap → arp-storm.pcap} +0 -0
- data/features/arp.feature +1 -1
- data/features/{packet_data/arp.pcap → arp.pcap} +0 -0
- data/features/dhcp.feature +210 -3
- data/features/{packet_data/dhcp.pcap → dhcp.pcap} +0 -0
- data/features/icmp.feature +1 -1
- data/features/{packet_data/icmp.pcap → icmp.pcap} +0 -0
- data/features/{packet_data/lldp.detailed.pcap → lldp.detailed.pcap} +0 -0
- data/features/lldp.feature +5 -5
- data/features/{packet_data/lldp.minimal.pcap → lldp.minimal.pcap} +0 -0
- data/features/{packet_data → open_flow10}/aggregate_stats_reply.raw +0 -0
- data/features/{packet_data → open_flow10}/aggregate_stats_request.raw +0 -0
- data/features/{packet_data → open_flow10}/barrier_reply.raw +0 -0
- data/features/{packet_data → open_flow10}/barrier_request.raw +0 -0
- data/features/{packet_data → open_flow10}/desc_stats_reply.raw +0 -0
- data/features/{packet_data → open_flow10}/desc_stats_request.raw +0 -0
- data/features/open_flow10/echo_reply.feature +10 -10
- data/features/{packet_data → open_flow10}/echo_reply.raw +0 -0
- data/features/open_flow10/echo_request.feature +10 -10
- data/features/{packet_data → open_flow10}/echo_request.raw +0 -0
- data/features/{packet_data → open_flow10}/error.raw +0 -0
- data/features/open_flow10/exact_match.feature +33 -33
- data/features/open_flow10/features_reply.feature +71 -71
- data/features/{packet_data → open_flow10}/features_reply.raw +0 -0
- data/features/open_flow10/features_request.feature +9 -9
- data/features/{packet_data → open_flow10}/features_request.raw +0 -0
- data/features/open_flow10/flow_mod.feature +167 -167
- data/features/{packet_data → open_flow10}/flow_mod_add.raw +0 -0
- data/features/{packet_data → open_flow10}/flow_mod_delete.raw +0 -0
- data/features/{packet_data → open_flow10}/flow_mod_delete_strict.raw +0 -0
- data/features/{packet_data → open_flow10}/flow_mod_modify.raw +0 -0
- data/features/{packet_data → open_flow10}/flow_mod_modify_strict.raw +0 -0
- data/features/{packet_data → open_flow10}/flow_removed.raw +0 -0
- data/features/{packet_data → open_flow10}/flow_stats_reply.raw +0 -0
- data/features/{packet_data → open_flow10}/flow_stats_request.raw +0 -0
- data/features/{packet_data → open_flow10}/get_config_reply.raw +0 -0
- data/features/{packet_data → open_flow10}/get_config_request.raw +0 -0
- data/features/open_flow10/hello.feature +9 -9
- data/features/{packet_data → open_flow10}/hello.raw +0 -0
- data/features/open_flow10/packet_in.feature +4 -4
- data/features/{packet_data → open_flow10}/packet_in_arp_request.raw +0 -0
- data/features/{packet_data → open_flow10}/packet_in_cbench.raw +0 -0
- data/features/open_flow10/packet_out.feature +3 -3
- data/features/{packet_data → open_flow10}/packet_out.raw +0 -0
- data/features/{packet_data → open_flow10}/port_mod.raw +0 -0
- data/features/{packet_data → open_flow10}/port_stats_reply.raw +0 -0
- data/features/{packet_data → open_flow10}/port_stats_request.raw +0 -0
- data/features/open_flow10/port_status.feature +3 -3
- data/features/{packet_data → open_flow10}/port_status.raw +0 -0
- data/features/{packet_data → open_flow10}/queue_get_config_reply.raw +0 -0
- data/features/{packet_data → open_flow10}/queue_get_config_request.raw +0 -0
- data/features/{packet_data → open_flow10}/set_config.raw +0 -0
- data/features/{packet_data → open_flow10}/table_stats_reply.raw +0 -0
- data/features/{packet_data → open_flow10}/table_stats_request.raw +0 -0
- data/features/{packet_data → open_flow10}/vendor.raw +0 -0
- data/features/{packet_data → open_flow10}/vendor_stats_request.raw +0 -0
- data/features/open_flow13/echo_reply.feature +64 -61
- data/features/{packet_data/echo13_reply_body.raw → open_flow13/echo_reply_body.raw} +0 -0
- data/features/{packet_data/echo13_reply_no_body.raw → open_flow13/echo_reply_no_body.raw} +0 -0
- data/features/open_flow13/echo_request.feature +64 -61
- data/features/{packet_data/echo13_request_body.raw → open_flow13/echo_request_body.raw} +0 -0
- data/features/{packet_data/echo13_request_no_body.raw → open_flow13/echo_request_no_body.raw} +0 -0
- data/features/open_flow13/features_reply.feature +53 -0
- data/features/open_flow13/features_reply.raw +0 -0
- data/features/open_flow13/features_request.feature +89 -0
- data/features/open_flow13/features_request.raw +0 -0
- data/features/open_flow13/hello.feature +26 -23
- data/features/{packet_data/hello13_no_version_bitmap.raw → open_flow13/hello_no_version_bitmap.raw} +0 -0
- data/features/{packet_data/hello13_version_bitmap.raw → open_flow13/hello_version_bitmap.raw} +0 -0
- data/features/step_definitions/open_flow_steps.rb +3 -0
- data/features/step_definitions/packet_data_steps.rb +9 -9
- data/features/udp.feature +3 -3
- data/features/{packet_data/udp_no_payload.raw → udp_no_payload.raw} +0 -0
- data/features/{packet_data/udp_with_payload.raw → udp_with_payload.raw} +0 -0
- data/lib/pio.rb +1 -9
- data/lib/pio/open_flow/actions.rb +8 -8
- data/lib/pio/open_flow/open_flow_header.rb +10 -0
- data/lib/pio/open_flow10.rb +15 -0
- data/lib/pio/open_flow10/echo.rb +15 -0
- data/lib/pio/open_flow10/exact_match.rb +51 -0
- data/lib/pio/{features.rb → open_flow10/features.rb} +8 -7
- data/lib/pio/{flow_mod.rb → open_flow10/flow_mod.rb} +1 -1
- data/lib/pio/{hello.rb → open_flow10/hello.rb} +0 -0
- data/lib/pio/{match.rb → open_flow10/match.rb} +46 -43
- data/lib/pio/{packet_in.rb → open_flow10/packet_in.rb} +0 -0
- data/lib/pio/{packet_out.rb → open_flow10/packet_out.rb} +0 -0
- data/lib/pio/{port_status.rb → open_flow10/port_status.rb} +0 -0
- data/lib/pio/open_flow13.rb +12 -0
- data/lib/pio/{echo.rb → open_flow13/echo.rb} +9 -13
- data/lib/pio/open_flow13/features_reply.rb +91 -0
- data/lib/pio/open_flow13/features_request.rb +54 -0
- data/lib/pio/{hello13.rb → open_flow13/hello.rb} +4 -1
- data/lib/pio/{set_eth_addr.rb → set_ether_address.rb} +7 -7
- data/lib/pio/{set_ip_addr.rb → set_ip_address.rb} +7 -7
- data/lib/pio/set_ip_tos.rb +1 -1
- data/lib/pio/set_transport_port.rb +2 -2
- data/lib/pio/version.rb +1 -1
- data/pio.gemspec +2 -2
- data/spec/pio/flow_mod_spec.rb +45 -45
- data/spec/pio/match_spec.rb +122 -120
- data/spec/pio/{hello13_spec.rb → open_flow13/hello_spec.rb} +11 -11
- data/spec/pio/packet_out_spec.rb +19 -19
- data/spec/pio/set_ether_destination_address_spec.rb +28 -0
- data/spec/pio/set_ether_source_address_spec.rb +28 -0
- data/spec/pio/set_ip_destination_address_spec.rb +27 -0
- data/spec/pio/set_ip_source_address_spec.rb +25 -0
- data/spec/pio/set_transport_destination_port_spec.rb +44 -0
- data/spec/pio/set_transport_source_port_spec.rb +44 -0
- data/spec/pio/wildcards_spec.rb +23 -21
- metadata +179 -165
- data/bin/byebug +0 -16
- data/lib/pio/exact_match.rb +0 -51
- data/spec/pio/set_eth_dst_addr_spec.rb +0 -28
- data/spec/pio/set_eth_src_addr_spec.rb +0 -28
- data/spec/pio/set_ip_dst_addr_spec.rb +0 -25
- data/spec/pio/set_ip_src_addr_spec.rb +0 -25
- data/spec/pio/set_transport_dst_port_spec.rb +0 -42
- data/spec/pio/set_transport_src_port_spec.rb +0 -42
@@ -1,13 +1,13 @@
|
|
1
|
-
require 'pio/
|
1
|
+
require 'pio/open_flow13/hello'
|
2
2
|
|
3
|
-
describe Pio::
|
3
|
+
describe Pio::Hello do
|
4
4
|
describe '.read' do
|
5
|
-
When(:result) { Pio::
|
5
|
+
When(:result) { Pio::Hello.read(binary) }
|
6
6
|
|
7
7
|
context 'with a hello message (no version bitmap)' do
|
8
8
|
Given(:binary) { [4, 0, 0, 8, 0, 0, 0, 0].pack('C*') }
|
9
9
|
|
10
|
-
Then { result.class == Pio::
|
10
|
+
Then { result.class == Pio::Hello }
|
11
11
|
Then { result.ofp_version == 4 }
|
12
12
|
Then { result.message_type == 0 }
|
13
13
|
Then { result.message_length == 8 }
|
@@ -21,7 +21,7 @@ describe Pio::Hello13 do
|
|
21
21
|
[4, 0, 0, 16, 0, 0, 0, 0, 0, 1, 0, 8, 0, 0, 0, 18].pack('C*')
|
22
22
|
end
|
23
23
|
|
24
|
-
Then { result.class == Pio::
|
24
|
+
Then { result.class == Pio::Hello }
|
25
25
|
Then { result.ofp_version == 4 }
|
26
26
|
Then { result.message_type == 0 }
|
27
27
|
Then { result.message_length == 16 }
|
@@ -39,7 +39,7 @@ describe Pio::Hello13 do
|
|
39
39
|
|
40
40
|
describe '.new' do
|
41
41
|
context 'with no arguments' do
|
42
|
-
When(:result) { Pio::
|
42
|
+
When(:result) { Pio::Hello.new }
|
43
43
|
|
44
44
|
Then { result.ofp_version == 4 }
|
45
45
|
Then { result.message_type == 0 }
|
@@ -54,7 +54,7 @@ describe Pio::Hello13 do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
context 'with transaction_id: 123' do
|
57
|
-
When(:result) { Pio::
|
57
|
+
When(:result) { Pio::Hello.new(transaction_id: 123) }
|
58
58
|
|
59
59
|
Then { result.ofp_version == 4 }
|
60
60
|
Then { result.message_type == 0 }
|
@@ -69,7 +69,7 @@ describe Pio::Hello13 do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
context 'with xid: 123' do
|
72
|
-
When(:result) { Pio::
|
72
|
+
When(:result) { Pio::Hello.new(xid: 123) }
|
73
73
|
|
74
74
|
Then { result.ofp_version == 4 }
|
75
75
|
Then { result.message_type == 0 }
|
@@ -84,7 +84,7 @@ describe Pio::Hello13 do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
context 'with xid: -1' do
|
87
|
-
When(:result) { Pio::
|
87
|
+
When(:result) { Pio::Hello.new(xid: -1) }
|
88
88
|
|
89
89
|
Then do
|
90
90
|
result ==
|
@@ -94,7 +94,7 @@ describe Pio::Hello13 do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
context 'with xid: 2**32' do
|
97
|
-
When(:result) { Pio::
|
97
|
+
When(:result) { Pio::Hello.new(xid: 2**32) }
|
98
98
|
|
99
99
|
Then do
|
100
100
|
result ==
|
@@ -104,7 +104,7 @@ describe Pio::Hello13 do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
context 'with invalid_keyword: :foo' do
|
107
|
-
When(:result) { Pio::
|
107
|
+
When(:result) { Pio::Hello.new(invalid_keyword: :foo) }
|
108
108
|
|
109
109
|
Then do
|
110
110
|
result == Failure(RuntimeError, 'Unknown keyword: invalid_keyword')
|
data/spec/pio/packet_out_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'pio/packet_out'
|
1
|
+
require 'pio/open_flow10/packet_out'
|
2
2
|
|
3
3
|
describe Pio::PacketOut do
|
4
4
|
Given(:header_dump) do
|
@@ -182,13 +182,13 @@ describe Pio::PacketOut do
|
|
182
182
|
Then { result.actions[0].is_a? Pio::StripVlanHeader }
|
183
183
|
end
|
184
184
|
|
185
|
-
context 'with a
|
185
|
+
context 'with a SetEtherSourceAddr action' do
|
186
186
|
When(:user_options) do
|
187
187
|
{
|
188
188
|
transaction_id: 0x16,
|
189
189
|
buffer_id: 0xffffffff,
|
190
190
|
in_port: 0xffff,
|
191
|
-
actions: Pio::
|
191
|
+
actions: Pio::SetEtherSourceAddr.new('11:22:33:44:55:66'),
|
192
192
|
raw_data: data_dump
|
193
193
|
}
|
194
194
|
end
|
@@ -196,17 +196,17 @@ describe Pio::PacketOut do
|
|
196
196
|
Then { result.message_length == 0x60 }
|
197
197
|
Then { result.actions_len == 0x10 }
|
198
198
|
Then { result.actions.length == 1 }
|
199
|
-
Then { result.actions[0].is_a? Pio::
|
199
|
+
Then { result.actions[0].is_a? Pio::SetEtherSourceAddr }
|
200
200
|
Then { result.actions[0].mac_address == '11:22:33:44:55:66' }
|
201
201
|
end
|
202
202
|
|
203
|
-
context 'with a
|
203
|
+
context 'with a SetEtherDestinationAddr action' do
|
204
204
|
When(:user_options) do
|
205
205
|
{
|
206
206
|
transaction_id: 0x16,
|
207
207
|
buffer_id: 0xffffffff,
|
208
208
|
in_port: 0xffff,
|
209
|
-
actions: Pio::
|
209
|
+
actions: Pio::SetEtherDestinationAddr.new('11:22:33:44:55:66'),
|
210
210
|
raw_data: data_dump
|
211
211
|
}
|
212
212
|
end
|
@@ -214,17 +214,17 @@ describe Pio::PacketOut do
|
|
214
214
|
Then { result.message_length == 0x60 }
|
215
215
|
Then { result.actions_len == 0x10 }
|
216
216
|
Then { result.actions.length == 1 }
|
217
|
-
Then { result.actions[0].is_a? Pio::
|
217
|
+
Then { result.actions[0].is_a? Pio::SetEtherDestinationAddr }
|
218
218
|
Then { result.actions[0].mac_address == '11:22:33:44:55:66' }
|
219
219
|
end
|
220
220
|
|
221
|
-
context 'with a
|
221
|
+
context 'with a SetIpSourceAddress action' do
|
222
222
|
When(:user_options) do
|
223
223
|
{
|
224
224
|
transaction_id: 0x16,
|
225
225
|
buffer_id: 0xffffffff,
|
226
226
|
in_port: 0xffff,
|
227
|
-
actions: Pio::
|
227
|
+
actions: Pio::SetIpSourceAddress.new('1.2.3.4'),
|
228
228
|
raw_data: data_dump
|
229
229
|
}
|
230
230
|
end
|
@@ -232,17 +232,17 @@ describe Pio::PacketOut do
|
|
232
232
|
Then { result.message_length == 0x58 }
|
233
233
|
Then { result.actions_len == 0x8 }
|
234
234
|
Then { result.actions.length == 1 }
|
235
|
-
Then { result.actions[0].is_a? Pio::
|
235
|
+
Then { result.actions[0].is_a? Pio::SetIpSourceAddress }
|
236
236
|
Then { result.actions[0].ip_address == '1.2.3.4' }
|
237
237
|
end
|
238
238
|
|
239
|
-
context 'with a
|
239
|
+
context 'with a SetIpDestinationAddress action' do
|
240
240
|
When(:user_options) do
|
241
241
|
{
|
242
242
|
transaction_id: 0x16,
|
243
243
|
buffer_id: 0xffffffff,
|
244
244
|
in_port: 0xffff,
|
245
|
-
actions: Pio::
|
245
|
+
actions: Pio::SetIpDestinationAddress.new('1.2.3.4'),
|
246
246
|
raw_data: data_dump
|
247
247
|
}
|
248
248
|
end
|
@@ -250,7 +250,7 @@ describe Pio::PacketOut do
|
|
250
250
|
Then { result.message_length == 0x58 }
|
251
251
|
Then { result.actions_len == 0x8 }
|
252
252
|
Then { result.actions.length == 1 }
|
253
|
-
Then { result.actions[0].is_a? Pio::
|
253
|
+
Then { result.actions[0].is_a? Pio::SetIpDestinationAddress }
|
254
254
|
Then { result.actions[0].ip_address == '1.2.3.4' }
|
255
255
|
end
|
256
256
|
|
@@ -272,13 +272,13 @@ describe Pio::PacketOut do
|
|
272
272
|
Then { result.actions[0].type_of_service == 32 }
|
273
273
|
end
|
274
274
|
|
275
|
-
context 'with a
|
275
|
+
context 'with a SetTransportSourcePort action' do
|
276
276
|
When(:user_options) do
|
277
277
|
{
|
278
278
|
transaction_id: 0x16,
|
279
279
|
buffer_id: 0xffffffff,
|
280
280
|
in_port: 0xffff,
|
281
|
-
actions: Pio::
|
281
|
+
actions: Pio::SetTransportSourcePort.new(100),
|
282
282
|
raw_data: data_dump
|
283
283
|
}
|
284
284
|
end
|
@@ -286,17 +286,17 @@ describe Pio::PacketOut do
|
|
286
286
|
Then { result.message_length == 0x58 }
|
287
287
|
Then { result.actions_len == 0x8 }
|
288
288
|
Then { result.actions.length == 1 }
|
289
|
-
Then { result.actions[0].is_a? Pio::
|
289
|
+
Then { result.actions[0].is_a? Pio::SetTransportSourcePort }
|
290
290
|
Then { result.actions[0].port_number == 100 }
|
291
291
|
end
|
292
292
|
|
293
|
-
context 'with a
|
293
|
+
context 'with a SetTransportDestinationPort action' do
|
294
294
|
When(:user_options) do
|
295
295
|
{
|
296
296
|
transaction_id: 0x16,
|
297
297
|
buffer_id: 0xffffffff,
|
298
298
|
in_port: 0xffff,
|
299
|
-
actions: Pio::
|
299
|
+
actions: Pio::SetTransportDestinationPort.new(100),
|
300
300
|
raw_data: data_dump
|
301
301
|
}
|
302
302
|
end
|
@@ -304,7 +304,7 @@ describe Pio::PacketOut do
|
|
304
304
|
Then { result.message_length == 0x58 }
|
305
305
|
Then { result.actions_len == 0x8 }
|
306
306
|
Then { result.actions.length == 1 }
|
307
|
-
Then { result.actions[0].is_a? Pio::
|
307
|
+
Then { result.actions[0].is_a? Pio::SetTransportDestinationPort }
|
308
308
|
Then { result.actions[0].port_number == 100 }
|
309
309
|
end
|
310
310
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'pio/set_ether_address'
|
2
|
+
|
3
|
+
describe Pio::SetEtherDestinationAddr do
|
4
|
+
describe '.new' do
|
5
|
+
Given(:set_ether_destination_address) do
|
6
|
+
Pio::SetEtherDestinationAddr.new(mac_address)
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with '11:22:33:44:55:66'" do
|
10
|
+
When(:mac_address) { '11:22:33:44:55:66' }
|
11
|
+
Then { set_ether_destination_address.mac_address == '11:22:33:44:55:66' }
|
12
|
+
|
13
|
+
describe '#to_binary' do
|
14
|
+
Then { set_ether_destination_address.to_binary.length == 16 }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with 0x112233445566' do
|
19
|
+
When(:mac_address) { 0x112233445566 }
|
20
|
+
Then { set_ether_destination_address.mac_address == '11:22:33:44:55:66' }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with Pio::Mac.new('11:22:33:44:55:66')" do
|
24
|
+
When(:mac_address) { Pio::Mac.new('11:22:33:44:55:66') }
|
25
|
+
Then { set_ether_destination_address.mac_address == '11:22:33:44:55:66' }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'pio/set_ether_address'
|
2
|
+
|
3
|
+
describe Pio::SetEtherSourceAddr do
|
4
|
+
describe '.new' do
|
5
|
+
Given(:set_ether_source_address) do
|
6
|
+
Pio::SetEtherSourceAddr.new(mac_address)
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with '11:22:33:44:55:66'" do
|
10
|
+
When(:mac_address) { '11:22:33:44:55:66' }
|
11
|
+
Then { set_ether_source_address.mac_address == '11:22:33:44:55:66' }
|
12
|
+
|
13
|
+
describe '#to_binary' do
|
14
|
+
Then { set_ether_source_address.to_binary.length == 16 }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with 0x112233445566' do
|
19
|
+
When(:mac_address) { 0x112233445566 }
|
20
|
+
Then { set_ether_source_address.mac_address == '11:22:33:44:55:66' }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with Pio::Mac.new('11:22:33:44:55:66')" do
|
24
|
+
When(:mac_address) { Pio::Mac.new('11:22:33:44:55:66') }
|
25
|
+
Then { set_ether_source_address.mac_address == '11:22:33:44:55:66' }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'pio/set_ip_address'
|
2
|
+
|
3
|
+
describe Pio::SetIpDestinationAddress do
|
4
|
+
describe '.new' do
|
5
|
+
context "with '1.2.3.4'" do
|
6
|
+
When(:set_ip_destination_addr) do
|
7
|
+
Pio::SetIpDestinationAddress.new('1.2.3.4')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#ip_address' do
|
11
|
+
Then { set_ip_destination_addr.ip_address == '1.2.3.4' }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#type' do
|
15
|
+
Then { set_ip_destination_addr.type == 7 }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#message_length' do
|
19
|
+
Then { set_ip_destination_addr.message_length == 8 }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#to_binary' do
|
23
|
+
Then { set_ip_destination_addr.to_binary.length == 8 }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'pio/set_ip_address'
|
2
|
+
|
3
|
+
describe Pio::SetIpSourceAddress do
|
4
|
+
describe '.new' do
|
5
|
+
context "with '1.2.3.4'" do
|
6
|
+
When(:set_ip_source_addr) { Pio::SetIpSourceAddress.new('1.2.3.4') }
|
7
|
+
|
8
|
+
describe '#ip_address' do
|
9
|
+
Then { set_ip_source_addr.ip_address == '1.2.3.4' }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#type' do
|
13
|
+
Then { set_ip_source_addr.type == 6 }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#message_length' do
|
17
|
+
Then { set_ip_source_addr.message_length == 8 }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#to_binary' do
|
21
|
+
Then { set_ip_source_addr.to_binary.length == 8 }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'pio/set_transport_port'
|
2
|
+
|
3
|
+
describe Pio::SetTransportDestinationPort do
|
4
|
+
describe '.new' do
|
5
|
+
When(:set_transport_destination_port) do
|
6
|
+
Pio::SetTransportDestinationPort.new(port_number)
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'with 100' do
|
10
|
+
When(:port_number) { 100 }
|
11
|
+
|
12
|
+
describe '#port_number' do
|
13
|
+
Then { set_transport_destination_port.port_number == 100 }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#type' do
|
17
|
+
Then { set_transport_destination_port.type == 10 }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#message_length' do
|
21
|
+
Then { set_transport_destination_port.message_length == 8 }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#to_binary' do
|
25
|
+
Then { set_transport_destination_port.to_binary.length == 8 }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with -1' do
|
30
|
+
When(:port_number) { -1 }
|
31
|
+
Then { set_transport_destination_port == Failure(ArgumentError) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with 2**16' do
|
35
|
+
When(:port_number) { 2**16 }
|
36
|
+
Then { set_transport_destination_port == Failure(ArgumentError) }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with :INVALID_PORT_NUMBER' do
|
40
|
+
When(:port_number) { :INVALID_PORT_NUMBER }
|
41
|
+
Then { set_transport_destination_port == Failure(TypeError) }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'pio/set_transport_port'
|
2
|
+
|
3
|
+
describe Pio::SetTransportSourcePort do
|
4
|
+
describe '.new' do
|
5
|
+
When(:set_transport_source_port) do
|
6
|
+
Pio::SetTransportSourcePort.new port_number
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'with 100' do
|
10
|
+
When(:port_number) { 100 }
|
11
|
+
|
12
|
+
describe '#port_number' do
|
13
|
+
Then { set_transport_source_port.port_number == 100 }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#type' do
|
17
|
+
Then { set_transport_source_port.type == 9 }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#message_length' do
|
21
|
+
Then { set_transport_source_port.message_length == 8 }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#to_binary' do
|
25
|
+
Then { set_transport_source_port.to_binary.length == 8 }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with -1' do
|
30
|
+
When(:port_number) { -1 }
|
31
|
+
Then { set_transport_source_port == Failure(ArgumentError) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with 2**16' do
|
35
|
+
When(:port_number) { 2**16 }
|
36
|
+
Then { set_transport_source_port == Failure(ArgumentError) }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with :INVALID_PORT_NUMBER' do
|
40
|
+
When(:port_number) { :INVALID_PORT_NUMBER }
|
41
|
+
Then { set_transport_source_port == Failure(TypeError) }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/spec/pio/wildcards_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'bindata'
|
2
|
-
require 'pio/match'
|
2
|
+
require 'pio/open_flow10/match'
|
3
3
|
|
4
4
|
describe Pio::Match::Wildcards do
|
5
5
|
# This class has wildcards field.
|
@@ -22,26 +22,26 @@ describe Pio::Match::Wildcards do
|
|
22
22
|
Then { binary == ['00000000000000000000000000000001'].pack('B*') }
|
23
23
|
end
|
24
24
|
|
25
|
-
context 'with
|
26
|
-
Given(:parameters) { {
|
25
|
+
context 'with ip_source_address: 0b10101' do
|
26
|
+
Given(:parameters) { { ip_source_address: 0b10101 } }
|
27
27
|
|
28
28
|
Then { binary == ['00000000000000000001010100000000'].pack('B*') }
|
29
29
|
end
|
30
30
|
|
31
|
-
context 'with
|
32
|
-
Given(:parameters) { {
|
31
|
+
context 'with ip_source_address_all: true' do
|
32
|
+
Given(:parameters) { { ip_source_address_all: true } }
|
33
33
|
|
34
34
|
Then { binary == ['00000000000000000010000000000000'].pack('B*') }
|
35
35
|
end
|
36
36
|
|
37
|
-
context 'with
|
38
|
-
Given(:parameters) { {
|
37
|
+
context 'with ip_destination_address: 010101' do
|
38
|
+
Given(:parameters) { { ip_destination_address: 0b10101 } }
|
39
39
|
|
40
40
|
Then { binary == ['00000000000001010100000000000000'].pack('B*') }
|
41
41
|
end
|
42
42
|
|
43
|
-
context 'with
|
44
|
-
Given(:parameters) { {
|
43
|
+
context 'with ip_destination_address_all: true' do
|
44
|
+
Given(:parameters) { { ip_destination_address_all: true } }
|
45
45
|
|
46
46
|
Then { binary == ['00000000000010000000000000000000'].pack('B*') }
|
47
47
|
end
|
@@ -76,40 +76,42 @@ describe Pio::Match::Wildcards do
|
|
76
76
|
Then { wildcards == { in_port: true } }
|
77
77
|
end
|
78
78
|
|
79
|
-
context 'with
|
79
|
+
context 'with vlan_vid: true' do
|
80
80
|
Given(:binary) { ['00000000000000000000000000000010'].pack('B*') }
|
81
81
|
|
82
|
-
Then { wildcards == {
|
82
|
+
Then { wildcards == { vlan_vid: true } }
|
83
83
|
end
|
84
84
|
|
85
|
-
context 'with
|
85
|
+
context 'with ip_source_address: 010101' do
|
86
86
|
Given(:binary) { ['00000000000000000001010100000000'].pack('B*') }
|
87
87
|
|
88
|
-
Then { wildcards == {
|
88
|
+
Then { wildcards == { ip_source_address: 0b10101 } }
|
89
89
|
end
|
90
90
|
|
91
|
-
context 'with
|
91
|
+
context 'with ip_source_address: 100000' do
|
92
92
|
Given(:binary) { ['00000000000000000010000000000000'].pack('B*') }
|
93
93
|
|
94
|
-
Then { wildcards == {
|
94
|
+
Then { wildcards == { ip_source_address_all: true } }
|
95
95
|
end
|
96
96
|
|
97
|
-
context 'with
|
97
|
+
context 'with ip_destination_address: 010101' do
|
98
98
|
Given(:binary) { ['00000000000001010100000000000000'].pack('B*') }
|
99
99
|
|
100
|
-
Then { wildcards == {
|
100
|
+
Then { wildcards == { ip_destination_address: 0b10101 } }
|
101
101
|
end
|
102
102
|
|
103
|
-
context 'with
|
103
|
+
context 'with ip_destination_address: 100000' do
|
104
104
|
Given(:binary) { ['00000000000010000000000000000000'].pack('B*') }
|
105
105
|
|
106
|
-
Then { wildcards == {
|
106
|
+
Then { wildcards == { ip_destination_address_all: true } }
|
107
107
|
end
|
108
108
|
|
109
|
-
context 'with in_port: true,
|
109
|
+
context 'with in_port: true, ip_source_address: 010101, ip_tos: true' do
|
110
110
|
Given(:binary) { ['00000000001000000001010100000001'].pack('B*') }
|
111
111
|
|
112
|
-
Then
|
112
|
+
Then do
|
113
|
+
wildcards == { in_port: true, ip_source_address: 0b10101, ip_tos: true }
|
114
|
+
end
|
113
115
|
end
|
114
116
|
end
|
115
117
|
end
|