pio 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +20 -18
  4. data/features/{packet_data/arp-storm.pcap → arp-storm.pcap} +0 -0
  5. data/features/arp.feature +1 -1
  6. data/features/{packet_data/arp.pcap → arp.pcap} +0 -0
  7. data/features/dhcp.feature +210 -3
  8. data/features/{packet_data/dhcp.pcap → dhcp.pcap} +0 -0
  9. data/features/icmp.feature +1 -1
  10. data/features/{packet_data/icmp.pcap → icmp.pcap} +0 -0
  11. data/features/{packet_data/lldp.detailed.pcap → lldp.detailed.pcap} +0 -0
  12. data/features/lldp.feature +5 -5
  13. data/features/{packet_data/lldp.minimal.pcap → lldp.minimal.pcap} +0 -0
  14. data/features/{packet_data → open_flow10}/aggregate_stats_reply.raw +0 -0
  15. data/features/{packet_data → open_flow10}/aggregate_stats_request.raw +0 -0
  16. data/features/{packet_data → open_flow10}/barrier_reply.raw +0 -0
  17. data/features/{packet_data → open_flow10}/barrier_request.raw +0 -0
  18. data/features/{packet_data → open_flow10}/desc_stats_reply.raw +0 -0
  19. data/features/{packet_data → open_flow10}/desc_stats_request.raw +0 -0
  20. data/features/open_flow10/echo_reply.feature +10 -10
  21. data/features/{packet_data → open_flow10}/echo_reply.raw +0 -0
  22. data/features/open_flow10/echo_request.feature +10 -10
  23. data/features/{packet_data → open_flow10}/echo_request.raw +0 -0
  24. data/features/{packet_data → open_flow10}/error.raw +0 -0
  25. data/features/open_flow10/exact_match.feature +33 -33
  26. data/features/open_flow10/features_reply.feature +71 -71
  27. data/features/{packet_data → open_flow10}/features_reply.raw +0 -0
  28. data/features/open_flow10/features_request.feature +9 -9
  29. data/features/{packet_data → open_flow10}/features_request.raw +0 -0
  30. data/features/open_flow10/flow_mod.feature +167 -167
  31. data/features/{packet_data → open_flow10}/flow_mod_add.raw +0 -0
  32. data/features/{packet_data → open_flow10}/flow_mod_delete.raw +0 -0
  33. data/features/{packet_data → open_flow10}/flow_mod_delete_strict.raw +0 -0
  34. data/features/{packet_data → open_flow10}/flow_mod_modify.raw +0 -0
  35. data/features/{packet_data → open_flow10}/flow_mod_modify_strict.raw +0 -0
  36. data/features/{packet_data → open_flow10}/flow_removed.raw +0 -0
  37. data/features/{packet_data → open_flow10}/flow_stats_reply.raw +0 -0
  38. data/features/{packet_data → open_flow10}/flow_stats_request.raw +0 -0
  39. data/features/{packet_data → open_flow10}/get_config_reply.raw +0 -0
  40. data/features/{packet_data → open_flow10}/get_config_request.raw +0 -0
  41. data/features/open_flow10/hello.feature +9 -9
  42. data/features/{packet_data → open_flow10}/hello.raw +0 -0
  43. data/features/open_flow10/packet_in.feature +4 -4
  44. data/features/{packet_data → open_flow10}/packet_in_arp_request.raw +0 -0
  45. data/features/{packet_data → open_flow10}/packet_in_cbench.raw +0 -0
  46. data/features/open_flow10/packet_out.feature +3 -3
  47. data/features/{packet_data → open_flow10}/packet_out.raw +0 -0
  48. data/features/{packet_data → open_flow10}/port_mod.raw +0 -0
  49. data/features/{packet_data → open_flow10}/port_stats_reply.raw +0 -0
  50. data/features/{packet_data → open_flow10}/port_stats_request.raw +0 -0
  51. data/features/open_flow10/port_status.feature +3 -3
  52. data/features/{packet_data → open_flow10}/port_status.raw +0 -0
  53. data/features/{packet_data → open_flow10}/queue_get_config_reply.raw +0 -0
  54. data/features/{packet_data → open_flow10}/queue_get_config_request.raw +0 -0
  55. data/features/{packet_data → open_flow10}/set_config.raw +0 -0
  56. data/features/{packet_data → open_flow10}/table_stats_reply.raw +0 -0
  57. data/features/{packet_data → open_flow10}/table_stats_request.raw +0 -0
  58. data/features/{packet_data → open_flow10}/vendor.raw +0 -0
  59. data/features/{packet_data → open_flow10}/vendor_stats_request.raw +0 -0
  60. data/features/open_flow13/echo_reply.feature +64 -61
  61. data/features/{packet_data/echo13_reply_body.raw → open_flow13/echo_reply_body.raw} +0 -0
  62. data/features/{packet_data/echo13_reply_no_body.raw → open_flow13/echo_reply_no_body.raw} +0 -0
  63. data/features/open_flow13/echo_request.feature +64 -61
  64. data/features/{packet_data/echo13_request_body.raw → open_flow13/echo_request_body.raw} +0 -0
  65. data/features/{packet_data/echo13_request_no_body.raw → open_flow13/echo_request_no_body.raw} +0 -0
  66. data/features/open_flow13/features_reply.feature +53 -0
  67. data/features/open_flow13/features_reply.raw +0 -0
  68. data/features/open_flow13/features_request.feature +89 -0
  69. data/features/open_flow13/features_request.raw +0 -0
  70. data/features/open_flow13/hello.feature +26 -23
  71. data/features/{packet_data/hello13_no_version_bitmap.raw → open_flow13/hello_no_version_bitmap.raw} +0 -0
  72. data/features/{packet_data/hello13_version_bitmap.raw → open_flow13/hello_version_bitmap.raw} +0 -0
  73. data/features/step_definitions/open_flow_steps.rb +3 -0
  74. data/features/step_definitions/packet_data_steps.rb +9 -9
  75. data/features/udp.feature +3 -3
  76. data/features/{packet_data/udp_no_payload.raw → udp_no_payload.raw} +0 -0
  77. data/features/{packet_data/udp_with_payload.raw → udp_with_payload.raw} +0 -0
  78. data/lib/pio.rb +1 -9
  79. data/lib/pio/open_flow/actions.rb +8 -8
  80. data/lib/pio/open_flow/open_flow_header.rb +10 -0
  81. data/lib/pio/open_flow10.rb +15 -0
  82. data/lib/pio/open_flow10/echo.rb +15 -0
  83. data/lib/pio/open_flow10/exact_match.rb +51 -0
  84. data/lib/pio/{features.rb → open_flow10/features.rb} +8 -7
  85. data/lib/pio/{flow_mod.rb → open_flow10/flow_mod.rb} +1 -1
  86. data/lib/pio/{hello.rb → open_flow10/hello.rb} +0 -0
  87. data/lib/pio/{match.rb → open_flow10/match.rb} +46 -43
  88. data/lib/pio/{packet_in.rb → open_flow10/packet_in.rb} +0 -0
  89. data/lib/pio/{packet_out.rb → open_flow10/packet_out.rb} +0 -0
  90. data/lib/pio/{port_status.rb → open_flow10/port_status.rb} +0 -0
  91. data/lib/pio/open_flow13.rb +12 -0
  92. data/lib/pio/{echo.rb → open_flow13/echo.rb} +9 -13
  93. data/lib/pio/open_flow13/features_reply.rb +91 -0
  94. data/lib/pio/open_flow13/features_request.rb +54 -0
  95. data/lib/pio/{hello13.rb → open_flow13/hello.rb} +4 -1
  96. data/lib/pio/{set_eth_addr.rb → set_ether_address.rb} +7 -7
  97. data/lib/pio/{set_ip_addr.rb → set_ip_address.rb} +7 -7
  98. data/lib/pio/set_ip_tos.rb +1 -1
  99. data/lib/pio/set_transport_port.rb +2 -2
  100. data/lib/pio/version.rb +1 -1
  101. data/pio.gemspec +2 -2
  102. data/spec/pio/flow_mod_spec.rb +45 -45
  103. data/spec/pio/match_spec.rb +122 -120
  104. data/spec/pio/{hello13_spec.rb → open_flow13/hello_spec.rb} +11 -11
  105. data/spec/pio/packet_out_spec.rb +19 -19
  106. data/spec/pio/set_ether_destination_address_spec.rb +28 -0
  107. data/spec/pio/set_ether_source_address_spec.rb +28 -0
  108. data/spec/pio/set_ip_destination_address_spec.rb +27 -0
  109. data/spec/pio/set_ip_source_address_spec.rb +25 -0
  110. data/spec/pio/set_transport_destination_port_spec.rb +44 -0
  111. data/spec/pio/set_transport_source_port_spec.rb +44 -0
  112. data/spec/pio/wildcards_spec.rb +23 -21
  113. metadata +179 -165
  114. data/bin/byebug +0 -16
  115. data/lib/pio/exact_match.rb +0 -51
  116. data/spec/pio/set_eth_dst_addr_spec.rb +0 -28
  117. data/spec/pio/set_eth_src_addr_spec.rb +0 -28
  118. data/spec/pio/set_ip_dst_addr_spec.rb +0 -25
  119. data/spec/pio/set_ip_src_addr_spec.rb +0 -25
  120. data/spec/pio/set_transport_dst_port_spec.rb +0 -42
  121. data/spec/pio/set_transport_src_port_spec.rb +0 -42
@@ -1,13 +1,13 @@
1
- require 'pio/hello13'
1
+ require 'pio/open_flow13/hello'
2
2
 
3
- describe Pio::Hello13 do
3
+ describe Pio::Hello do
4
4
  describe '.read' do
5
- When(:result) { Pio::Hello13.read(binary) }
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::Hello13 }
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::Hello13 }
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::Hello13.new }
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::Hello13.new(transaction_id: 123) }
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::Hello13.new(xid: 123) }
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::Hello13.new(xid: -1) }
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::Hello13.new(xid: 2**32) }
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::Hello13.new(invalid_keyword: :foo) }
107
+ When(:result) { Pio::Hello.new(invalid_keyword: :foo) }
108
108
 
109
109
  Then do
110
110
  result == Failure(RuntimeError, 'Unknown keyword: invalid_keyword')
@@ -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 SetEthSrcAddr action' do
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::SetEthSrcAddr.new('11:22:33:44:55:66'),
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::SetEthSrcAddr }
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 SetEthDstAddr action' do
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::SetEthDstAddr.new('11:22:33:44:55:66'),
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::SetEthDstAddr }
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 SetIpSrcAddr action' do
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::SetIpSrcAddr.new('1.2.3.4'),
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::SetIpSrcAddr }
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 SetIpDstAddr action' do
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::SetIpDstAddr.new('1.2.3.4'),
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::SetIpDstAddr }
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 SetTransportSrcPort action' do
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::SetTransportSrcPort.new(100),
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::SetTransportSrcPort }
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 SetTransportDstPort action' do
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::SetTransportDstPort.new(100),
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::SetTransportDstPort }
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
@@ -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 nw_src: 0b10101' do
26
- Given(:parameters) { { nw_src: 0b10101 } }
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 nw_src_all: true' do
32
- Given(:parameters) { { nw_src_all: true } }
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 nw_dst: 010101' do
38
- Given(:parameters) { { nw_dst: 0b10101 } }
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 nw_dst_all: true' do
44
- Given(:parameters) { { nw_dst_all: true } }
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 dl_vlan: true' do
79
+ context 'with vlan_vid: true' do
80
80
  Given(:binary) { ['00000000000000000000000000000010'].pack('B*') }
81
81
 
82
- Then { wildcards == { dl_vlan: true } }
82
+ Then { wildcards == { vlan_vid: true } }
83
83
  end
84
84
 
85
- context 'with nw_src: 010101' do
85
+ context 'with ip_source_address: 010101' do
86
86
  Given(:binary) { ['00000000000000000001010100000000'].pack('B*') }
87
87
 
88
- Then { wildcards == { nw_src: 0b10101 } }
88
+ Then { wildcards == { ip_source_address: 0b10101 } }
89
89
  end
90
90
 
91
- context 'with nw_src: 100000' do
91
+ context 'with ip_source_address: 100000' do
92
92
  Given(:binary) { ['00000000000000000010000000000000'].pack('B*') }
93
93
 
94
- Then { wildcards == { nw_src_all: true } }
94
+ Then { wildcards == { ip_source_address_all: true } }
95
95
  end
96
96
 
97
- context 'with nw_dst: 010101' do
97
+ context 'with ip_destination_address: 010101' do
98
98
  Given(:binary) { ['00000000000001010100000000000000'].pack('B*') }
99
99
 
100
- Then { wildcards == { nw_dst: 0b10101 } }
100
+ Then { wildcards == { ip_destination_address: 0b10101 } }
101
101
  end
102
102
 
103
- context 'with nw_dst: 100000' do
103
+ context 'with ip_destination_address: 100000' do
104
104
  Given(:binary) { ['00000000000010000000000000000000'].pack('B*') }
105
105
 
106
- Then { wildcards == { nw_dst_all: true } }
106
+ Then { wildcards == { ip_destination_address_all: true } }
107
107
  end
108
108
 
109
- context 'with in_port: true, nw_src: 010101, nw_tos: true' do
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 { wildcards == { in_port: true, nw_src: 0b10101, nw_tos: true } }
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