pio 0.14.0 → 0.15.0

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: 1fd283fac969bbd9c87f81cbca52df75e1ea0688
4
- data.tar.gz: ef718b4d71676d8d5280297e9baa886b593d5d59
3
+ metadata.gz: 160b6df4de3e742f9bc613203352993fe5f8b1b9
4
+ data.tar.gz: a35953dba3610759b5d00e111538523bafb65ac5
5
5
  SHA512:
6
- metadata.gz: dc32c4a9a1b820c3c15bc6e1e32f5ad939021e4e4ffc13e744050e2c503743d81bbec8d4a23e9a2c5a18f770e08c3118f3a1b69f1295644890df5e465c811c7c
7
- data.tar.gz: 52d1e44d687f70d594ae39e09dc82b56963bcf3e1fc1c5f5b768319d2001a4bdba43ff9968a81a70bb46b76506af9d37e0dbe61e729da6d840eb40739881ea8e
6
+ metadata.gz: b558f6a0be89346665789e8847a221791a03db8381dbcb558b6ae3c8580717d91e7f209353b92bd20f54894d1607e68a815eef68fcd34cc135d5f5a86c0e26ee
7
+ data.tar.gz: 821b6cecaa878417d2338f6e1d1a801f7f98549b721acadeb8fafd5d48dee98e6a485c5efc222381d1a41de5c2823705b4adad2d6227ca10bbd72ecc9bb6633c
data/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  ## develop (unreleased)
4
4
 
5
5
 
6
+ ## 0.15.0 (2/12/2015)
7
+ ### New features
8
+ * [#126](https://github.com/trema/pio/pull/126): Add new class `Pio::PortStatus`.
9
+ * [#126](https://github.com/trema/pio/pull/126): Add new methods `Pio::Type::OpenFlow::PhyPort#up?`, `Pio::Type::OpenFlow::PhyPort#down?`, `Pio::Type::OpenFlow::PhyPort#local?`, `Pio::Type::OpenFlow::PhyPort#datapath_id` and `Pio::Type::OpenFlow::PhyPort#dpid`.
10
+ * [#126](https://github.com/trema/pio/pull/126): Add new methods `Pio::PacketIn#lldp?`.
11
+ * [#126](https://github.com/trema/pio/pull/126): Add new methods `Pio::Features::Reply#physical_ports`.
12
+
13
+
6
14
  ## 0.14.0 (2/9/2015)
7
15
  ### New features
8
16
  * [#125](https://github.com/trema/pio/pull/125): Add new accessor methods `Pio::PacketIn#datapath_id` and `Pio::PacketIn#dpid`.
data/README.md CHANGED
@@ -24,6 +24,7 @@ supports the following packet formats:
24
24
  - Packet-In
25
25
  - Packet-Out
26
26
  - Flow Mod
27
+ - Port Status
27
28
  - (…currently there are just a few formats supported but I'm sure this list will grow)
28
29
 
29
30
  ## Features Overview
@@ -384,5 +385,4 @@ and install it by running Bundler:
384
385
  ## License
385
386
 
386
387
  Pio is released under the GNU General Public License version 3.0:
387
-
388
388
  - <http://www.gnu.org/licenses/gpl.html>
@@ -0,0 +1,24 @@
1
+ Feature: Pio::PortStatus.read
2
+ Scenario: port_status.raw
3
+ Given a packet data file "port_status.raw"
4
+ When I try to parse the file with "PortStatus" class
5
+ Then it should finish successfully
6
+ And the parsed data have the following field and value:
7
+ | field | value |
8
+ | class | Pio::PortStatus |
9
+ | ofp_version | 1 |
10
+ | message_type | 12 |
11
+ | message_length | 64 |
12
+ | transaction_id | 4 |
13
+ | xid | 4 |
14
+ | reason | delete |
15
+ | desc.port_no | 65533 |
16
+ | desc.hardware_address | 01:02:03:04:05:06 |
17
+ | desc.name | foo |
18
+ | desc.config | [:no_flood] |
19
+ | desc.state | [:stp_forward, :stp_block] |
20
+ | desc.curr | [:port_10mb_hd] |
21
+ | desc.advertised | [:port_1gb_fd] |
22
+ | desc.supported | [:port_autoneg] |
23
+ | desc.peer | [:port_pause_asym] |
24
+
data/lib/pio.rb CHANGED
@@ -12,3 +12,4 @@ require 'pio/lldp'
12
12
  require 'pio/mac'
13
13
  require 'pio/packet_in'
14
14
  require 'pio/packet_out'
15
+ require 'pio/port_status'
data/lib/pio/features.rb CHANGED
@@ -65,7 +65,19 @@ module Pio
65
65
  def_delegators :body, :n_tables
66
66
  def_delegators :body, :capabilities
67
67
  def_delegators :body, :actions
68
- def_delegators :body, :ports
68
+
69
+ def ports
70
+ body.ports.map do |each|
71
+ each.datapath_id = datapath_id
72
+ each
73
+ end
74
+ end
75
+
76
+ def physical_ports
77
+ ports.select do |each|
78
+ each.port_no <= PortNumber::MAX
79
+ end
80
+ end
69
81
  end
70
82
  end
71
83
  end
@@ -53,9 +53,28 @@ module Pio
53
53
  port_feature :supported
54
54
  port_feature :peer
55
55
 
56
+ attr_accessor :datapath_id
57
+ alias_method :dpid, :datapath_id
58
+
59
+ def number
60
+ port_no
61
+ end
62
+
56
63
  def mac_address
57
64
  hardware_address
58
65
  end
66
+
67
+ def up?
68
+ !down?
69
+ end
70
+
71
+ def down?
72
+ config.include?(:port_down) || state.include?(:link_down)
73
+ end
74
+
75
+ def local?
76
+ port_no == PortNumber::NUMBERS[:local]
77
+ end
59
78
  end
60
79
  end
61
80
  end
@@ -8,6 +8,7 @@ module Pio
8
8
  FEATURES_REQUEST = 5
9
9
  FEATURES_REPLY = 6
10
10
  PACKET_IN = 10
11
+ PORT_STATUS = 12
11
12
  PACKET_OUT = 13
12
13
  FLOW_MOD = 14
13
14
  end
data/lib/pio/packet_in.rb CHANGED
@@ -69,6 +69,7 @@ module Pio
69
69
  rest :rest
70
70
  end
71
71
 
72
+ # rubocop:disable MethodLength
72
73
  def self.read(raw_data)
73
74
  ethernet_header = EthernetHeaderParser.read(raw_data)
74
75
  case ethernet_header.ether_type
@@ -76,10 +77,13 @@ module Pio
76
77
  IPv4Packet.read raw_data
77
78
  when 0x0806
78
79
  Pio::Arp.read raw_data
80
+ when 0x88cc
81
+ Pio::Lldp.read raw_data
79
82
  else
80
83
  fail 'Failed to parse packet_in data.'
81
84
  end
82
85
  end
86
+ # rubocop:enable MethodLength
83
87
  end
84
88
 
85
89
  attr_accessor :datapath_id
@@ -96,6 +100,10 @@ module Pio
96
100
  @parsed_data ||= DataParser.read(data)
97
101
  end
98
102
 
103
+ def lldp?
104
+ parsed_data.is_a? Lldp
105
+ end
106
+
99
107
  def source_mac
100
108
  parsed_data.source_mac
101
109
  end
@@ -0,0 +1,37 @@
1
+ require 'pio/open_flow'
2
+
3
+ module Pio
4
+ # OpenFlow 1.0 Port Status message
5
+ class PortStatus < OpenFlow::Message.factory(OpenFlow::Type::PORT_STATUS)
6
+ # What changed about the physical port
7
+ class Reason < BinData::Primitive
8
+ REASONS = { add: 0, delete: 1, modify: 2 }
9
+
10
+ uint8 :reason
11
+
12
+ def get
13
+ REASONS.invert.fetch(reason)
14
+ end
15
+
16
+ def set(value)
17
+ self.reason = REASONS.fetch(value)
18
+ end
19
+ end
20
+
21
+ # Message body of Packet-In.
22
+ class PortStatusBody < BinData::Record
23
+ endian :big
24
+
25
+ reason :reason
26
+ uint56 :padding
27
+ hide :padding
28
+ phy_port :desc
29
+ end
30
+
31
+ def_delegators :body, :desc
32
+
33
+ def reason
34
+ body.reason.to_s.to_sym
35
+ end
36
+ end
37
+ 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.14.0'.freeze
4
+ VERSION = '0.15.0'.freeze
5
5
  end
data/pio.gemspec CHANGED
@@ -37,7 +37,7 @@ 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.7.12'
40
+ gem.add_development_dependency 'bundler', '~> 1.8.0'
41
41
  gem.add_development_dependency 'pry', '~> 0.10.1'
42
42
 
43
43
  # Guard
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.14.0
4
+ version: 0.15.0
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-08 00:00:00.000000000 Z
11
+ date: 2015-02-12 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.7.12
47
+ version: 1.8.0
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.7.12
54
+ version: 1.8.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -435,6 +435,7 @@ files:
435
435
  - features/packet_data/vendor_stats_request.raw
436
436
  - features/packet_in_read.feature
437
437
  - features/packet_out_read.feature
438
+ - features/port_status_read.feature
438
439
  - features/step_definitions/packet_data_steps.rb
439
440
  - features/step_definitions/pending_steps.rb
440
441
  - features/support/env.rb
@@ -508,6 +509,7 @@ files:
508
509
  - lib/pio/packet_out.rb
509
510
  - lib/pio/parse_error.rb
510
511
  - lib/pio/pcap.rb
512
+ - lib/pio/port_status.rb
511
513
  - lib/pio/send_out_port.rb
512
514
  - lib/pio/set_eth_addr.rb
513
515
  - lib/pio/set_ip_addr.rb
@@ -679,6 +681,7 @@ test_files:
679
681
  - features/packet_data/echo_request.raw
680
682
  - features/exact_match.feature
681
683
  - features/icmp_read.feature
684
+ - features/port_status_read.feature
682
685
  - features/arp_read.feature
683
686
  - features/step_definitions/pending_steps.rb
684
687
  - features/step_definitions/packet_data_steps.rb