pio 0.11.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27d53b285f5a1953f25ee64f1e4d2049433826f1
4
- data.tar.gz: 63407621a578d12c4142b556c881921dc28d553c
3
+ metadata.gz: 0a56473e633e294a1756d819645ccee51e6440cd
4
+ data.tar.gz: 8d6d9fc9c7625281475858f76e090a9e4f1038d6
5
5
  SHA512:
6
- metadata.gz: 800d67d4ad15c762008ec915ff559a6d3c93d6908bd41d7f9a26cfbc7d11b4c90ca7eb0a15db68e772d6d05fc69e77185b895a28bcd249ebdf588fe06e42e0b0
7
- data.tar.gz: 9cad26ff854970d9b0bbb55bfbb254335300eedb621a43436c4ae64b6b38e8ebba7a07d1d0c7fbf862dc8d02b8f39ece68605045bd3310bc699ed11906ea3476
6
+ metadata.gz: 1fadec47b009cab08eb3565b864952f050aa2a82477b2e9298a760691958fc998cdcf34ddc5fdbade680b5849e9e79c6ee61b8ab452b43e803ec64c3bfda93df
7
+ data.tar.gz: 5dcb89e55d28bc69dd59325829ac1bb740bfbde2516980aa41af5f15aafb01fac17e3f6d4224503e5c18a07f05a9c38473735076192863c6bf2ddbec1b6663e3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.2 (1/29/2015)
4
+
5
+ ### Bugs fixed
6
+ * [#121](https://github.com/trema/pio/pull/121): Fix behavior of `Pio::Match#==` and `Pio::SendOutPort#==`.
7
+
8
+
3
9
  ## 0.11.1 (1/15/2015)
4
10
 
5
11
  ### New features
data/lib/pio/match.rb CHANGED
@@ -145,6 +145,7 @@ module Pio
145
145
  def_delegators :@format, :dl_vlan_pcp
146
146
  def_delegators :@format, :nw_tos
147
147
  def_delegators :@format, :to_binary_s
148
+ def_delegator :@format, :to_binary_s, :to_binary
148
149
 
149
150
  # rubocop:disable MethodLength
150
151
  # This method smells of :reek:FeatureEnvy
@@ -163,5 +164,10 @@ module Pio
163
164
  @format = MatchFormat.new({ wildcards: flags }.merge user_options)
164
165
  end
165
166
  # rubocop:enable MethodLength
167
+
168
+ def ==(other)
169
+ return false unless other
170
+ to_binary == other.to_binary
171
+ end
166
172
  end
167
173
  end
@@ -75,11 +75,11 @@ module Pio
75
75
  def self.body_type
76
76
  klass_name = name.split('::').last + 'Body'
77
77
  const_get(klass_name)
78
- klass_name.sub(/.*::/, '')
79
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
80
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
81
- .tr('-', '_')
82
- .downcase
78
+ klass_name.sub(/.*::/, '').
79
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
80
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
81
+ tr('-', '_').
82
+ downcase
83
83
  rescue NameError
84
84
  'string'
85
85
  end
@@ -71,5 +71,10 @@ module Pio
71
71
  @format = Format.new(options)
72
72
  end
73
73
  # rubocop:enable MethodLength
74
+
75
+ def ==(other)
76
+ return false unless other
77
+ to_binary == other.to_binary
78
+ end
74
79
  end
75
80
  end
data/lib/pio/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # Base module.
2
2
  module Pio
3
3
  # gem version.
4
- VERSION = '0.11.1'.freeze
4
+ VERSION = '0.11.2'.freeze
5
5
  end
data/pio.gemspec CHANGED
@@ -56,12 +56,12 @@ Gem::Specification.new do |gem|
56
56
  gem.add_development_dependency 'yard', '~> 0.8.7.6'
57
57
 
58
58
  # Test
59
- gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.5'
60
- gem.add_development_dependency 'coveralls', '~> 0.7.2'
59
+ gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.6'
60
+ gem.add_development_dependency 'coveralls', '~> 0.7.3'
61
61
  gem.add_development_dependency 'cucumber', '~> 1.3.18'
62
62
  gem.add_development_dependency 'flay', '~> 2.6.0'
63
63
  gem.add_development_dependency 'flog', '~> 4.3.1'
64
- gem.add_development_dependency 'reek', '~> 1.6.2'
64
+ gem.add_development_dependency 'reek', '~> 1.6.4'
65
65
  gem.add_development_dependency 'rspec', '~> 3.1.0'
66
66
  gem.add_development_dependency 'rspec-given', '~> 3.6.0'
67
67
  gem.add_development_dependency 'rubocop', '~> 0.28.0'
@@ -91,9 +91,10 @@ describe Pio::Match do
91
91
  end
92
92
 
93
93
  describe '.new' do
94
- context 'with in_port: 1' do
95
- When(:match) { Pio::Match.new(in_port: 1) }
94
+ When(:match) { Pio::Match.new(options) }
96
95
 
96
+ context 'with in_port: 1' do
97
+ Given(:options) { { in_port: 1 } }
97
98
  Then do
98
99
  match.wildcards.keys == [
99
100
  :dl_vlan,
@@ -121,11 +122,19 @@ describe Pio::Match do
121
122
  Then { match.nw_dst == '0.0.0.0' }
122
123
  Then { match.tp_src == 0 }
123
124
  Then { match.tp_dst == 0 }
125
+
126
+ describe '#==' do
127
+ When(:result) { match == other }
128
+
129
+ context 'with Match.new(in_port: 1)' do
130
+ Given(:other) { Pio::Match.new(in_port: 1) }
131
+ Then { result == true }
132
+ end
133
+ end
124
134
  end
125
135
 
126
136
  context "with nw_src: '192.168.1.0/24'" do
127
- When(:match) { Pio::Match.new(nw_src: '192.168.1.0/24') }
128
-
137
+ Given(:options) { { nw_src: '192.168.1.0/24' } }
129
138
  Then do
130
139
  match.wildcards.keys == [
131
140
  :in_port,
@@ -158,8 +167,7 @@ describe Pio::Match do
158
167
  end
159
168
 
160
169
  context "with nw_dst: '192.168.1.0/24'" do
161
- When(:match) { Pio::Match.new(nw_dst: '192.168.1.0/24') }
162
-
170
+ Given(:options) { { nw_dst: '192.168.1.0/24' } }
163
171
  Then do
164
172
  match.wildcards.keys == [
165
173
  :in_port,
@@ -2,20 +2,30 @@ require 'pio/send_out_port'
2
2
 
3
3
  describe Pio::SendOutPort do
4
4
  describe '.new' do
5
- When(:send_out_port) do
6
- Pio::SendOutPort.new(options)
7
- end
8
-
9
- context 'with an integer' do
10
- When(:options) { 1 }
5
+ When(:send_out_port) { Pio::SendOutPort.new(options) }
11
6
 
7
+ context 'with 1' do
8
+ Given(:options) { 1 }
12
9
  Then { send_out_port.port_number == 1 }
13
10
  Then { send_out_port.max_len == 2**16 - 1 }
11
+
12
+ describe '#==' do
13
+ When(:result) { send_out_port == other }
14
+
15
+ context 'with SendOutPort.new(1)' do
16
+ Given(:other) { Pio::SendOutPort.new(1) }
17
+ Then { result == true }
18
+ end
19
+
20
+ context 'with SendOutPort.new(2)' do
21
+ Given(:other) { Pio::SendOutPort.new(2) }
22
+ Then { result == false }
23
+ end
24
+ end
14
25
  end
15
26
 
16
27
  context 'with 0' do
17
- When(:options) { 0 }
18
-
28
+ Given(:options) { 0 }
19
29
  Then do
20
30
  send_out_port ==
21
31
  Failure(ArgumentError, 'The port_number should be > 0')
@@ -23,8 +33,7 @@ describe Pio::SendOutPort do
23
33
  end
24
34
 
25
35
  context 'with 0xff01 (OFPP_MAX + 1)' do
26
- When(:options) { 0xff01 }
27
-
36
+ Given(:options) { 0xff01 }
28
37
  Then do
29
38
  send_out_port ==
30
39
  Failure(ArgumentError, 'The port_number should be < 0xff00')
@@ -32,75 +41,63 @@ describe Pio::SendOutPort do
32
41
  end
33
42
 
34
43
  context 'with :in_port' do
35
- When(:options) { :in_port }
36
-
44
+ Given(:options) { :in_port }
37
45
  Then { send_out_port.port_number == :in_port }
38
46
  end
39
47
 
40
48
  context 'with :table' do
41
- When(:options) { :table }
42
-
49
+ Given(:options) { :table }
43
50
  Then { send_out_port.port_number == :table }
44
51
  end
45
52
 
46
53
  context 'with :normal' do
47
- When(:options) { :normal }
48
-
54
+ Given(:options) { :normal }
49
55
  Then { send_out_port.port_number == :normal }
50
56
  end
51
57
 
52
58
  context 'with :flood' do
53
- When(:options) { :flood }
54
-
59
+ Given(:options) { :flood }
55
60
  Then { send_out_port.port_number == :flood }
56
61
  end
57
62
 
58
63
  context 'with :all' do
59
- When(:options) { :all }
60
-
64
+ Given(:options) { :all }
61
65
  Then { send_out_port.port_number == :all }
62
66
  end
63
67
 
64
68
  context 'with :controller' do
65
- When(:options) { :controller }
66
-
69
+ Given(:options) { :controller }
67
70
  Then { send_out_port.port_number == :controller }
68
71
  end
69
72
 
70
73
  context 'with :controller' do
71
- When(:options) { :local }
72
-
74
+ Given(:options) { :local }
73
75
  Then { send_out_port.port_number == :local }
74
76
  end
75
77
 
76
78
  context 'with :controller' do
77
- When(:options) { :none }
78
-
79
+ Given(:options) { :none }
79
80
  Then { send_out_port.port_number == :none }
80
81
  end
81
82
 
82
83
  context 'with port_number: NUMBER option' do
83
- When(:options) { { port_number: 1 } }
84
-
84
+ Given(:options) { { port_number: 1 } }
85
85
  Then { send_out_port.port_number == 1 }
86
86
  end
87
87
 
88
88
  context 'with port_number: SYMBOL option' do
89
- When(:options) { { port_number: :flood } }
90
-
89
+ Given(:options) { { port_number: :flood } }
91
90
  Then { send_out_port.port_number == :flood }
92
91
  end
93
92
 
94
93
  context 'with port_number: and max_len: option' do
95
- When(:options) { { port_number: 1, max_len: 256 } }
96
-
94
+ Given(:options) { { port_number: 1, max_len: 256 } }
97
95
  Then { send_out_port.port_number == 1 }
98
96
  Then { send_out_port.max_len == 256 }
99
97
  end
100
98
 
101
99
  context 'with invalid max_len: (-1) option' do
102
- When(:options) { { port_number: 1, max_len: -1 } }
103
-
100
+ Given(:options) { { port_number: 1, max_len: -1 } }
104
101
  Then do
105
102
  send_out_port ==
106
103
  Failure(ArgumentError,
@@ -109,8 +106,7 @@ describe Pio::SendOutPort do
109
106
  end
110
107
 
111
108
  context 'with invalid max_len: (2**16) option' do
112
- When(:options) { { port_number: 1, max_len: 2**16 } }
113
-
109
+ Given(:options) { { port_number: 1, max_len: 2**16 } }
114
110
  Then do
115
111
  send_out_port ==
116
112
  Failure(ArgumentError,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuhito Takamiya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2015-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata
@@ -226,28 +226,28 @@ dependencies:
226
226
  requirements:
227
227
  - - ~>
228
228
  - !ruby/object:Gem::Version
229
- version: 0.4.5
229
+ version: 0.4.6
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - ~>
235
235
  - !ruby/object:Gem::Version
236
- version: 0.4.5
236
+ version: 0.4.6
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: coveralls
239
239
  requirement: !ruby/object:Gem::Requirement
240
240
  requirements:
241
241
  - - ~>
242
242
  - !ruby/object:Gem::Version
243
- version: 0.7.2
243
+ version: 0.7.3
244
244
  type: :development
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
248
  - - ~>
249
249
  - !ruby/object:Gem::Version
250
- version: 0.7.2
250
+ version: 0.7.3
251
251
  - !ruby/object:Gem::Dependency
252
252
  name: cucumber
253
253
  requirement: !ruby/object:Gem::Requirement
@@ -296,14 +296,14 @@ dependencies:
296
296
  requirements:
297
297
  - - ~>
298
298
  - !ruby/object:Gem::Version
299
- version: 1.6.2
299
+ version: 1.6.4
300
300
  type: :development
301
301
  prerelease: false
302
302
  version_requirements: !ruby/object:Gem::Requirement
303
303
  requirements:
304
304
  - - ~>
305
305
  - !ruby/object:Gem::Version
306
- version: 1.6.2
306
+ version: 1.6.4
307
307
  - !ruby/object:Gem::Dependency
308
308
  name: rspec
309
309
  requirement: !ruby/object:Gem::Requirement
@@ -583,105 +583,105 @@ required_rubygems_version: !ruby/object:Gem::Requirement
583
583
  version: '0'
584
584
  requirements: []
585
585
  rubyforge_project:
586
- rubygems_version: 2.4.5
586
+ rubygems_version: 2.4.3
587
587
  signing_key:
588
588
  specification_version: 4
589
589
  summary: Packet parser and generator.
590
590
  test_files:
591
- - spec/pio/arp/reply/options_spec.rb
592
- - spec/pio/arp/reply_spec.rb
593
- - spec/pio/arp/request/options_spec.rb
594
- - spec/pio/arp/request_spec.rb
595
- - spec/pio/arp_spec.rb
591
+ - spec/pio/set_eth_src_addr_spec.rb
592
+ - spec/pio/features/request_spec.rb
593
+ - spec/pio/features/reply_spec.rb
594
+ - spec/pio/set_vlan_vid_spec.rb
595
+ - spec/pio/set_transport_dst_port_spec.rb
596
+ - spec/pio/strip_vlan_header_spec.rb
597
+ - spec/pio/ipv4_address_spec.rb
598
+ - spec/pio/open_flow/type_spec.rb
599
+ - spec/pio/open_flow/phy_port_spec.rb
600
+ - spec/pio/enqueue_spec.rb
601
+ - spec/pio/hello_spec.rb
602
+ - spec/pio/set_ip_src_addr_spec.rb
603
+ - spec/pio/dhcp/request_spec.rb
604
+ - spec/pio/dhcp/offer_spec.rb
596
605
  - spec/pio/dhcp/ack_spec.rb
597
606
  - spec/pio/dhcp/discover_spec.rb
598
- - spec/pio/dhcp/offer_spec.rb
599
- - spec/pio/dhcp/request_spec.rb
600
- - spec/pio/dhcp_spec.rb
601
- - spec/pio/echo/reply_spec.rb
602
- - spec/pio/echo/request_spec.rb
603
- - spec/pio/enqueue_spec.rb
604
- - spec/pio/features/reply_spec.rb
605
- - spec/pio/features/request_spec.rb
607
+ - spec/pio/set_transport_src_port_spec.rb
608
+ - spec/pio/arp/request_spec.rb
609
+ - spec/pio/arp/reply/options_spec.rb
610
+ - spec/pio/arp/request/options_spec.rb
611
+ - spec/pio/arp/reply_spec.rb
606
612
  - spec/pio/flow_mod_spec.rb
607
- - spec/pio/hello_spec.rb
608
- - spec/pio/icmp/reply_spec.rb
613
+ - spec/pio/lldp/options_spec.rb
614
+ - spec/pio/set_vlan_priority_spec.rb
615
+ - spec/pio/set_ip_dst_addr_spec.rb
616
+ - spec/pio/mac_spec.rb
609
617
  - spec/pio/icmp/request_spec.rb
618
+ - spec/pio/icmp/reply_spec.rb
610
619
  - spec/pio/icmp_spec.rb
611
- - spec/pio/ipv4_address_spec.rb
612
- - spec/pio/lldp/options_spec.rb
620
+ - spec/pio/wildcards_spec.rb
621
+ - spec/pio/dhcp_spec.rb
622
+ - spec/pio/set_ip_tos_spec.rb
623
+ - spec/pio/send_out_port_spec.rb
624
+ - spec/pio/packet_in_spec.rb
613
625
  - spec/pio/lldp_spec.rb
614
- - spec/pio/mac_spec.rb
626
+ - spec/pio/arp_spec.rb
627
+ - spec/pio/echo/request_spec.rb
628
+ - spec/pio/echo/reply_spec.rb
629
+ - spec/pio/set_eth_dst_addr_spec.rb
615
630
  - spec/pio/match_spec.rb
616
- - spec/pio/open_flow/phy_port_spec.rb
617
- - spec/pio/open_flow/type_spec.rb
618
- - spec/pio/packet_in_spec.rb
619
631
  - spec/pio/packet_out_spec.rb
620
- - spec/pio/send_out_port_spec.rb
621
- - spec/pio/set_eth_dst_addr_spec.rb
622
- - spec/pio/set_eth_src_addr_spec.rb
623
- - spec/pio/set_ip_dst_addr_spec.rb
624
- - spec/pio/set_ip_src_addr_spec.rb
625
- - spec/pio/set_ip_tos_spec.rb
626
- - spec/pio/set_transport_dst_port_spec.rb
627
- - spec/pio/set_transport_src_port_spec.rb
628
- - spec/pio/set_vlan_priority_spec.rb
629
- - spec/pio/set_vlan_vid_spec.rb
630
- - spec/pio/strip_vlan_header_spec.rb
631
- - spec/pio/wildcards_spec.rb
632
632
  - spec/spec_helper.rb
633
- - features/arp_read.feature
634
- - features/dhcp_read.feature
635
- - features/echo_read.feature
636
- - features/features_read.feature
637
- - features/flow_mod_read.feature
638
633
  - features/hello_read.feature
639
- - features/icmp_read.feature
640
- - features/lldp_read.feature
641
- - features/packet_data/aggregate_stats_reply.raw
642
- - features/packet_data/aggregate_stats_request.raw
643
- - features/packet_data/arp-storm.pcap
644
- - features/packet_data/arp.pcap
645
- - features/packet_data/barrier_reply.raw
646
- - features/packet_data/barrier_request.raw
634
+ - features/support/env.rb
647
635
  - features/packet_data/desc_stats_reply.raw
648
- - features/packet_data/desc_stats_request.raw
649
636
  - features/packet_data/dhcp.pcap
650
637
  - features/packet_data/echo_reply.raw
651
- - features/packet_data/echo_request.raw
652
- - features/packet_data/error.raw
638
+ - features/packet_data/flow_mod_modify_strict.raw
639
+ - features/packet_data/flow_mod_add.raw
653
640
  - features/packet_data/features_reply.raw
641
+ - features/packet_data/packet_in.raw
642
+ - features/packet_data/aggregate_stats_reply.raw
643
+ - features/packet_data/queue_get_config_reply.raw
644
+ - features/packet_data/arp.pcap
654
645
  - features/packet_data/features_request.raw
655
- - features/packet_data/flow_mod_add.raw
656
- - features/packet_data/flow_mod_delete.raw
657
- - features/packet_data/flow_mod_delete_strict.raw
658
- - features/packet_data/flow_mod_modify.raw
659
- - features/packet_data/flow_mod_modify_strict.raw
660
- - features/packet_data/flow_removed.raw
661
- - features/packet_data/flow_stats_reply.raw
662
646
  - features/packet_data/flow_stats_request.raw
663
- - features/packet_data/get_config_reply.raw
647
+ - features/packet_data/port_stats_request.raw
648
+ - features/packet_data/flow_mod_delete_strict.raw
649
+ - features/packet_data/barrier_reply.raw
664
650
  - features/packet_data/get_config_request.raw
665
- - features/packet_data/hello.raw
666
- - features/packet_data/icmp.pcap
667
- - features/packet_data/lldp.detailed.pcap
668
- - features/packet_data/lldp.minimal.pcap
669
- - features/packet_data/packet_in.raw
670
- - features/packet_data/packet_out.raw
651
+ - features/packet_data/vendor.raw
671
652
  - features/packet_data/port_mod.raw
672
- - features/packet_data/port_stats_reply.raw
673
- - features/packet_data/port_stats_request.raw
674
- - features/packet_data/port_status.raw
675
- - features/packet_data/queue_get_config_reply.raw
676
- - features/packet_data/queue_get_config_request.raw
653
+ - features/packet_data/get_config_reply.raw
654
+ - features/packet_data/lldp.minimal.pcap
655
+ - features/packet_data/hello.raw
656
+ - features/packet_data/flow_removed.raw
677
657
  - features/packet_data/set_config.raw
658
+ - features/packet_data/port_stats_reply.raw
659
+ - features/packet_data/packet_out.raw
678
660
  - features/packet_data/table_stats_reply.raw
679
- - features/packet_data/table_stats_request.raw
680
- - features/packet_data/vendor.raw
661
+ - features/packet_data/queue_get_config_request.raw
662
+ - features/packet_data/error.raw
681
663
  - features/packet_data/vendor_stats_request.raw
682
- - features/packet_in_read.feature
683
- - features/packet_out_read.feature
684
- - features/step_definitions/packet_data_steps.rb
664
+ - features/packet_data/icmp.pcap
665
+ - features/packet_data/arp-storm.pcap
666
+ - features/packet_data/flow_stats_reply.raw
667
+ - features/packet_data/desc_stats_request.raw
668
+ - features/packet_data/barrier_request.raw
669
+ - features/packet_data/table_stats_request.raw
670
+ - features/packet_data/port_status.raw
671
+ - features/packet_data/flow_mod_modify.raw
672
+ - features/packet_data/flow_mod_delete.raw
673
+ - features/packet_data/lldp.detailed.pcap
674
+ - features/packet_data/aggregate_stats_request.raw
675
+ - features/packet_data/echo_request.raw
676
+ - features/icmp_read.feature
677
+ - features/arp_read.feature
685
678
  - features/step_definitions/pending_steps.rb
686
- - features/support/env.rb
679
+ - features/step_definitions/packet_data_steps.rb
680
+ - features/flow_mod_read.feature
681
+ - features/lldp_read.feature
682
+ - features/dhcp_read.feature
683
+ - features/features_read.feature
684
+ - features/packet_out_read.feature
685
+ - features/packet_in_read.feature
686
+ - features/echo_read.feature
687
687
  has_rdoc: