pio 0.15.1 → 0.15.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: 72d822a526ecc76b756781275560ac85461cb743
4
- data.tar.gz: 016ffba5c86e40a62e17baa73ad148796d3e1c9f
3
+ metadata.gz: f75df3f4f4091dda09de3b77789eea400df989dc
4
+ data.tar.gz: 1cc6ef0de733c14e84efe1fff569ed7de0943c03
5
5
  SHA512:
6
- metadata.gz: badd7676a9c52f24e3941f47b2d6d7da1a26a14a6865119434307d08219be1c34c21336b32869b5836ef2ed89317f431c5d142d51d0d84f025297eea96cc3b77
7
- data.tar.gz: 68591ec7d20cc8a5082c3742ae634e954871ec297bd7097fac3d6ebefa7af3ab439587b75b968862b973b7f396918b9d57dc0535cf1b01014627ba786a8e1071
6
+ metadata.gz: 19d72385b493052449cd2de18df8bed3a6385fb452ffc52883f6b9f781b09c9807596869920d59fce09dc812e5f9d9434be249f27389095ce650655b69e1d7e2
7
+ data.tar.gz: 6862a78e369025dc34d89086a8f10cf4fd7ca19dbdea867de0d583350cb4fd9c937f4cef1bb09117e87912d5d747ec4c5deeb8c9f5bfafccb87c155d079baaa3
data/CHANGELOG.md CHANGED
@@ -3,6 +3,11 @@
3
3
  ## develop (unreleased)
4
4
 
5
5
 
6
+ ## 0.15.2 (2/18/2015)
7
+ ### Changes
8
+ * [#128](https://github.com/trema/pio/pull/128): Field accessors return Ruby primitives (Fixnum, Symbol, etc.).
9
+
10
+
6
11
  ## 0.15.1 (2/17/2015)
7
12
  ### Bugs fixed
8
13
  * [#127](https://github.com/trema/pio/pull/127): Make OpenFlow classes thread safe.
@@ -6,20 +6,20 @@ request.to_binary # => Features Request message in binary format.
6
6
  # The Features xid (transaction_id)
7
7
  # should be same as that of the request.
8
8
  reply = Pio::Features::Reply.new(
9
- xid: request.xid,
10
- dpid: 0x123,
11
- n_buffers: 0x100,
12
- n_tables: 0xfe,
13
- capabilities: [:flow_stats, :table_stats, :port_stats,
14
- :queue_stats, :arp_match_ip],
15
- actions: [:output, :set_vlan_vid, :set_vlan_pcp, :strip_vlan,
16
- :set_dl_src, :set_dl_dst, :set_nw_src, :set_nw_dst,
17
- :set_nw_tos, :set_tp_src, :set_tp_dst, :enqueue],
18
- ports: [{ port_no: 1,
19
- hardware_address: '11:22:33:44:55:66',
20
- name: 'port123',
21
- config: [:port_down],
22
- state: [:link_down],
23
- curr: [:port_10gb_fd, :port_copper] }]
9
+ xid: request.xid,
10
+ dpid: 0x123,
11
+ n_buffers: 0x100,
12
+ n_tables: 0xfe,
13
+ capabilities: [:flow_stats, :table_stats, :port_stats,
14
+ :queue_stats, :arp_match_ip],
15
+ actions: [:output, :set_vlan_vid, :set_vlan_pcp, :strip_vlan,
16
+ :set_dl_src, :set_dl_dst, :set_nw_src, :set_nw_dst,
17
+ :set_nw_tos, :set_tp_src, :set_tp_dst, :enqueue],
18
+ ports: [{ port_no: 1,
19
+ hardware_address: '11:22:33:44:55:66',
20
+ name: 'port123',
21
+ config: [:port_down],
22
+ state: [:link_down],
23
+ curr: [:port_10gb_fd, :port_copper] }]
24
24
  )
25
25
  reply.to_binary # => Features Reply message in binary format.
@@ -10,10 +10,10 @@ data_dump = [
10
10
  ].pack('C*')
11
11
 
12
12
  packet_in = Pio::PacketIn.new(
13
- transaction_id: 0,
14
- buffer_id: 0xffffff00,
15
- in_port: 1,
16
- reason: :no_match,
17
- data: data_dump
13
+ transaction_id: 0,
14
+ buffer_id: 0xffffff00,
15
+ in_port: 1,
16
+ reason: :no_match,
17
+ data: data_dump
18
18
  )
19
19
  packet_in.to_binary # => Packet-In message in binary format.
@@ -32,6 +32,7 @@ Feature: Pio::Features.read
32
32
  | capabilities | [:flow_stats, :table_stats, :port_stats, :arp_match_ip] |
33
33
  | actions | [:output, :set_vlan_vid, :set_vlan_pcp, :strip_vlan, :set_dl_src, :set_dl_dst, :set_nw_src, :set_nw_dst, :set_nw_tos, :set_tp_src, :set_tp_dst, :enqueue] |
34
34
  | ports.length | 3 |
35
+ | ports.first.datapath_id | 1 |
35
36
  | ports.first.port_no | 2 |
36
37
  | ports.first.mac_address | 16:7d:a4:37:ba:10 |
37
38
  | ports.first.hardware_address | 16:7d:a4:37:ba:10 |
@@ -43,6 +44,7 @@ Feature: Pio::Features.read
43
44
  | ports.first.supported | [] |
44
45
  | ports.first.peer | [] |
45
46
  | ports.last.port_no | 1 |
47
+ | ports.last.number | 1 |
46
48
  | ports.last.mac_address | 62:94:3a:f6:40:db |
47
49
  | ports.last.hardware_address | 62:94:3a:f6:40:db |
48
50
  | ports.last.name | trema1-0 |
@@ -52,3 +54,6 @@ Feature: Pio::Features.read
52
54
  | ports.last.advertised | [] |
53
55
  | ports.last.supported | [] |
54
56
  | ports.last.peer | [] |
57
+ | ports.last.up? | true |
58
+ | ports.last.down? | false |
59
+ | ports.last.local? | false |
@@ -85,7 +85,7 @@ module Pio
85
85
  private
86
86
 
87
87
  def get_tlv(tlv_type)
88
- tlv = dhcp.optional_tlvs.find do | each |
88
+ tlv = dhcp.optional_tlvs.find do |each|
89
89
  each['tlv_type'] == tlv_type
90
90
  end
91
91
  tlv['tlv_value'] if tlv
data/lib/pio/features.rb CHANGED
@@ -68,8 +68,8 @@ module Pio
68
68
  def_delegators :body, :actions
69
69
 
70
70
  def ports
71
- body.ports.map do |each|
72
- each.datapath_id = datapath_id
71
+ @format.snapshot.body.ports.map do |each|
72
+ each.instance_variable_set :@datapath_id, datapath_id
73
73
  each
74
74
  end
75
75
  end
@@ -53,7 +53,7 @@ module Pio
53
53
  private
54
54
 
55
55
  def get_tlv(tlv_type)
56
- tlv = optional_tlv.find do | each |
56
+ tlv = optional_tlv.find do |each|
57
57
  each['tlv_type'] == tlv_type
58
58
  end
59
59
  tlv['tlv_value'] if tlv
@@ -39,19 +39,22 @@ module Pio
39
39
  end
40
40
  # rubocop:enable MethodLength
41
41
 
42
+ # rubocop:disable MethodLength
42
43
  def self._define_open_flow_accessors
43
44
  proc do
44
- def_delegators :@format, :open_flow_header
45
+ def_delegators :@format, :snapshot
46
+ def_delegators :snapshot, :open_flow_header
45
47
  def_delegators :open_flow_header, :ofp_version
46
48
  def_delegators :open_flow_header, :message_type
47
49
  def_delegators :open_flow_header, :message_length
48
50
  def_delegators :open_flow_header, :transaction_id
49
51
  def_delegator :open_flow_header, :transaction_id, :xid
50
52
 
51
- def_delegators :@format, :body
52
- def_delegator :@format, :body, :user_data
53
+ def_delegators :snapshot, :body
54
+ def_delegator :snapshot, :body, :user_data
53
55
  end
54
56
  end
57
+ # rubocop:enable MethodLength
55
58
 
56
59
  def self._define_self_read
57
60
  proc do
@@ -52,28 +52,39 @@ module Pio
52
52
  port_feature :supported
53
53
  port_feature :peer
54
54
 
55
- attr_accessor :datapath_id
56
- alias_method :dpid, :datapath_id
55
+ # rubocop:disable MethodLength
56
+ def snapshot
57
+ super.tap do |ss|
58
+ def ss.datapath_id
59
+ @datapath_id || fail
60
+ end
57
61
 
58
- def number
59
- port_no
60
- end
62
+ def ss.dpid
63
+ @datapath_id || fail
64
+ end
61
65
 
62
- def mac_address
63
- hardware_address
64
- end
66
+ def ss.number
67
+ port_no
68
+ end
65
69
 
66
- def up?
67
- !down?
68
- end
70
+ def ss.mac_address
71
+ hardware_address
72
+ end
69
73
 
70
- def down?
71
- config.include?(:port_down) || state.include?(:link_down)
72
- end
74
+ def ss.up?
75
+ !down?
76
+ end
77
+
78
+ def ss.down?
79
+ config.include?(:port_down) || state.include?(:link_down)
80
+ end
73
81
 
74
- def local?
75
- port_no == PortNumber::NUMBERS[:local]
82
+ def ss.local?
83
+ port_no == PortNumber::NUMBERS[:local]
84
+ end
85
+ end
76
86
  end
87
+ # rubocop:enable MethodLength
77
88
  end
78
89
  end
79
90
  end
data/lib/pio/packet_in.rb CHANGED
@@ -91,16 +91,16 @@ module Pio
91
91
  end
92
92
 
93
93
  OpenFlow::Message.factory(PacketIn, OpenFlow::PACKET_IN) do
94
- attr_accessor :datapath_id
95
- alias_method :dpid, :datapath_id
96
- alias_method :dpid=, :datapath_id=
97
-
98
94
  def_delegators :body, :buffer_id
99
95
  def_delegators :body, :total_len
100
96
  def_delegators :body, :in_port
101
97
  def_delegators :body, :reason
102
98
  def_delegators :body, :data
103
99
 
100
+ attr_accessor :datapath_id
101
+ alias_method :dpid, :datapath_id
102
+ alias_method :dpid=, :datapath_id=
103
+
104
104
  def parsed_data
105
105
  @parsed_data ||= PacketIn::DataParser.read(data)
106
106
  end
@@ -31,10 +31,14 @@ module Pio
31
31
  end
32
32
 
33
33
  OpenFlow::Message.factory(PortStatus, OpenFlow::PORT_STATUS) do
34
- def_delegators :body, :desc
34
+ def_delegators :body, :reason
35
35
 
36
- def reason
37
- body.reason.to_s.to_sym
36
+ attr_writer :datapath_id
37
+
38
+ def desc
39
+ @desc ||= @format.body.desc.snapshot
40
+ @desc.instance_variable_set :@datapath_id, @datapath_id
41
+ @desc
38
42
  end
39
43
  end
40
44
  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.15.1'.freeze
4
+ VERSION = '0.15.2'.freeze
5
5
  end
data/pio.gemspec CHANGED
@@ -37,11 +37,11 @@ Gem::Specification.new do |gem|
37
37
  gem.add_dependency 'bindata', '~> 2.1.0'
38
38
 
39
39
  gem.add_development_dependency 'rake'
40
- gem.add_development_dependency 'bundler', '~> 1.8.0'
40
+ gem.add_development_dependency 'bundler', '~> 1.8.2'
41
41
  gem.add_development_dependency 'pry', '~> 0.10.1'
42
42
 
43
43
  # Guard
44
- gem.add_development_dependency 'guard', '~> 2.11.1'
44
+ gem.add_development_dependency 'guard', '~> 2.12.1'
45
45
  gem.add_development_dependency 'guard-bundler', '~> 2.1.0'
46
46
  gem.add_development_dependency 'guard-cucumber', '~> 1.5.3'
47
47
  gem.add_development_dependency 'guard-rspec', '~> 4.5.0'
@@ -58,11 +58,11 @@ Gem::Specification.new do |gem|
58
58
  # Test
59
59
  gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.6'
60
60
  gem.add_development_dependency 'coveralls', '~> 0.7.9'
61
- gem.add_development_dependency 'cucumber', '~> 1.3.18'
61
+ gem.add_development_dependency 'cucumber', '~> 1.3.19'
62
62
  gem.add_development_dependency 'flay', '~> 2.6.1'
63
63
  gem.add_development_dependency 'flog', '~> 4.3.2'
64
- gem.add_development_dependency 'reek', '~> 1.6.4'
64
+ gem.add_development_dependency 'reek', '~> 2.0.0'
65
65
  gem.add_development_dependency 'rspec', '~> 3.2.0'
66
- gem.add_development_dependency 'rspec-given', '~> 3.6.0'
67
- gem.add_development_dependency 'rubocop', '~> 0.28.0'
66
+ gem.add_development_dependency 'rspec-given', '~> 3.7.0'
67
+ gem.add_development_dependency 'rubocop', '~> 0.29.1'
68
68
  end
data/spec/pio/mac_spec.rb CHANGED
@@ -144,7 +144,7 @@ describe Pio::Mac do
144
144
  end
145
145
 
146
146
  context 'with reserved address' do
147
- (0x0..0xf).each do | each |
147
+ (0x0..0xf).each do |each|
148
148
  octet = format('%02x', each)
149
149
  reserved_address = "01:80:c2:00:00:#{ octet }"
150
150
 
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.15.1
4
+ version: 0.15.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-02-17 00:00:00.000000000 Z
11
+ date: 2015-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 1.8.0
47
+ version: 1.8.2
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 1.8.0
54
+ version: 1.8.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: 2.11.1
75
+ version: 2.12.1
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
- version: 2.11.1
82
+ version: 2.12.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: guard-bundler
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -254,14 +254,14 @@ dependencies:
254
254
  requirements:
255
255
  - - ~>
256
256
  - !ruby/object:Gem::Version
257
- version: 1.3.18
257
+ version: 1.3.19
258
258
  type: :development
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
262
  - - ~>
263
263
  - !ruby/object:Gem::Version
264
- version: 1.3.18
264
+ version: 1.3.19
265
265
  - !ruby/object:Gem::Dependency
266
266
  name: flay
267
267
  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.4
299
+ version: 2.0.0
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.4
306
+ version: 2.0.0
307
307
  - !ruby/object:Gem::Dependency
308
308
  name: rspec
309
309
  requirement: !ruby/object:Gem::Requirement
@@ -324,28 +324,28 @@ dependencies:
324
324
  requirements:
325
325
  - - ~>
326
326
  - !ruby/object:Gem::Version
327
- version: 3.6.0
327
+ version: 3.7.0
328
328
  type: :development
329
329
  prerelease: false
330
330
  version_requirements: !ruby/object:Gem::Requirement
331
331
  requirements:
332
332
  - - ~>
333
333
  - !ruby/object:Gem::Version
334
- version: 3.6.0
334
+ version: 3.7.0
335
335
  - !ruby/object:Gem::Dependency
336
336
  name: rubocop
337
337
  requirement: !ruby/object:Gem::Requirement
338
338
  requirements:
339
339
  - - ~>
340
340
  - !ruby/object:Gem::Version
341
- version: 0.28.0
341
+ version: 0.29.1
342
342
  type: :development
343
343
  prerelease: false
344
344
  version_requirements: !ruby/object:Gem::Requirement
345
345
  requirements:
346
346
  - - ~>
347
347
  - !ruby/object:Gem::Version
348
- version: 0.28.0
348
+ version: 0.29.1
349
349
  description: Pure ruby packet parser and generator.
350
350
  email:
351
351
  - yasuhito@gmail.com