Skip to content

Commit

Permalink
Merge branch 'release/0.27.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Sep 16, 2015
2 parents c20aa5a + 28f5f93 commit 8f34afc
Show file tree
Hide file tree
Showing 41 changed files with 526 additions and 68 deletions.
15 changes: 14 additions & 1 deletion .reek
@@ -1,2 +1,15 @@
UncommunicativeModuleName:
accept: ['Pio::Hello13', 'Pio::OpenFlow10', 'Pio::OpenFlow13', 'Pio::OpenFlow10::Port16', 'Pio::OpenFlow10::PhyPort16', 'Pio::OpenFlow10::ErrorType10', 'Pio::OpenFlow10::MatchOpenFlow10', 'Pio::OpenFlow13::Error::ErrorType13', 'Pio::OpenFlow10::Port32',]
accept: ['Pio::Hello13',
'Pio::OpenFlow10::Error::ErrorType10',
'Pio::OpenFlow10::Match10',
'Pio::OpenFlow10::MatchOpenFlow10',
'Pio::OpenFlow10::PhyPort16',
'Pio::OpenFlow10::Port16',
'Pio::OpenFlow10::Port32',
'Pio::OpenFlow13',
'Pio::OpenFlow13::Error::ErrorType13',
'Pio::OpenFlow13::Port32',
'Pio::OpenFlow10']

TooManyStatements:
enabled: false
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,11 @@
## develop (unreleased)


## 0.27.0 (9/16/2015)
### New features
* [#203](https://github.com/trema/pio/pull/203): Add new classes `Pio::OpenFlow10::DescriptionStats::Request`, `Pio::OpenFlow10::DescriptionStats::Reply`, `Pio::OpenFlow10::FlowStats::Request`, `Pio::OpenFlow10::FlowStats::Reply`, `Pio::OpenFlow10::AggregateStats::Request`, `Pio::OpenFlow10::AggregateStats::Reply`.


## 0.26.0 (9/8/2015)
### New features
* [#214](https://github.com/trema/pio/pull/214): Add new class `Pio::OpenFlow10::Error::HelloFailed`.
Expand Down
33 changes: 20 additions & 13 deletions README.md
Expand Up @@ -10,8 +10,21 @@

<a href="http://www.flickr.com/photos/mongogushi/4226014070/" title="pio pencil by mongo gushi, on Flickr"><img src="http://farm5.staticflickr.com/4022/4226014070_cdeb7c1e5d_n.jpg" width="320" height="290" alt="pio pencil"></a>

Pio is a ruby gem to easily parse and generate network packets. It
supports the following packet formats:
Pio is a ruby gem to easily parse and generate network packets.

## Features Overview

- Pure Ruby. No additional dependency on other external tools to
parse/generate packets.
- Multi-Platform. Runs on major operating systems (recent Windows,
Linux, and MacOSX).
- Clean Code. Pio is built on
[BinData](https://github.com/dmendel/bindata)'s declarative binary
format DSL so that it is easy to read and debug by human beings.

## Supported packet formats

Pio supports the following packet formats:

- [ICMP](https://relishapp.com/trema/pio/docs/pio-icmp)
- [ARP](https://relishapp.com/trema/pio/docs/pio-arp)
Expand All @@ -33,8 +46,12 @@ supports the following packet formats:
- [Exact Match](https://relishapp.com/trema/pio/docs/open-flow10/pio-exactmatch)
- [Barrier Request](https://relishapp.com/trema/pio/docs/open-flow10/pio-barrier-request)
- [Barrier Reply](https://relishapp.com/trema/pio/docs/open-flow10/pio-barrier-reply)
- [Description Stats Request](https://relishapp.com/trema/pio/docs/open-flow10/pio-descriptionstats-request)
- [Description Stats Reply](https://relishapp.com/trema/pio/docs/open-flow10/pio-descriptionstats-reply)
- [Flow Stats Request](https://relishapp.com/trema/pio/docs/open-flow10/pio-flowstats-request)
- [Flow Stats Reply](https://relishapp.com/trema/pio/docs/open-flow10/pio-flowstats-reply)
- [Aggregate Stats Request](https://relishapp.com/trema/pio/docs/open-flow10/pio-aggregatestats-request)
- [Aggregate Stats Reply](https://relishapp.com/trema/pio/docs/open-flow10/pio-aggregatestats-reply)
- OpenFlow 1.3
- [Hello](https://relishapp.com/trema/pio/docs/open-flow13/pio-hello)
- [HelloFailed](https://relishapp.com/trema/pio/docs/open-flow13/pio-error-hellofailed)
Expand All @@ -47,16 +64,6 @@ supports the following packet formats:
- [Packet Out](https://relishapp.com/trema/pio/docs/open-flow13/pio-packetout)
- [Flow Mod](https://relishapp.com/trema/pio/docs/open-flow13/pio-flowmod)

## Features Overview

- Pure Ruby. No additional dependency on other external tools to
parse/generate packets.
- Multi-Platform. Runs on major operating systems (recent Windows,
Linux, and MacOSX).
- Clean Code. Pio is built on
[BinData](https://github.com/dmendel/bindata)'s declarative binary
format DSL so that it is easy to read and debug by human beings.

## Installation

The simplest way to install Pio is to use [Bundler](http://gembundler.com/).
Expand All @@ -75,7 +82,7 @@ bundle

## Documents

- [API document generated with YARD](http://rubydoc.info/github/trema/pio/frames/file/README.md)
- [API document](https://relishapp.com/trema/pio/docs)

## Team

Expand Down
2 changes: 1 addition & 1 deletion Rakefile
@@ -1,7 +1,7 @@
require 'bundler/gem_tasks'

RELISH_PROJECT = 'trema/pio'
FLAY_THRESHOLD = 863
FLAY_THRESHOLD = 919

task default: :travis
task test: [:spec, :cucumber]
Expand Down
17 changes: 17 additions & 0 deletions features/open_flow10/aggregate_stats_reply.feature
@@ -0,0 +1,17 @@
@open_flow10
Feature: Pio::AggregateStats::Reply
Scenario: read
When I try to parse a file named "open_flow10/aggregate_stats_reply.raw" with "AggregateStats::Reply" class
Then it should finish successfully
And the message has the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 17 |
| length | 36 |
| transaction_id | 15 |
| xid | 15 |
| stats_type | :aggregate |
| flags | 0 |
| packet_count | 0 |
| byte_count | 0 |
| flow_count | 0 |
60 changes: 60 additions & 0 deletions features/open_flow10/aggregate_stats_request.feature
@@ -0,0 +1,60 @@
@open_flow10
Feature: Pio::AggregateStats::Request
Scenario: new
When I try to create an OpenFlow message with:
"""
Pio::AggregateStats::Request.new(match: Match.new(in_port: 1))
"""
Then it should finish successfully
And the message has the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 16 |
| length | 56 |
| transaction_id | 0 |
| xid | 0 |
| stats_type | :aggregate |
| match.in_port | 1 |
| match.wildcards.keys.size | 11 |
| match.wildcards.fetch(:ether_destination_address) | true |
| match.wildcards.fetch(:ether_source_address) | true |
| match.wildcards.fetch(:ether_type) | true |
| match.wildcards.fetch(:ip_destination_address_all) | true |
| match.wildcards.fetch(:ip_protocol) | true |
| match.wildcards.fetch(:ip_source_address_all) | true |
| match.wildcards.fetch(:ip_tos) | true |
| match.wildcards.fetch(:transport_destination_port) | true |
| match.wildcards.fetch(:transport_source_port) | true |
| match.wildcards.fetch(:vlan_priority) | true |
| match.wildcards.fetch(:vlan_vid) | true |
| table_id.to_hex | 0xff |
| out_port | :none |


Scenario: read
When I try to parse a file named "open_flow10/aggregate_stats_request.raw" with "AggregateStats::Request" class
Then it should finish successfully
And the message has the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 16 |
| length | 56 |
| transaction_id | 14 |
| xid | 14 |
| stats_type | :aggregate |
| match.wildcards.keys.size | 12 |
| match.wildcards.fetch(:ether_destination_address) | true |
| match.wildcards.fetch(:ether_source_address) | true |
| match.wildcards.fetch(:ether_type) | true |
| match.wildcards.fetch(:in_port) | true |
| match.wildcards.fetch(:ip_destination_address_all) | true |
| match.wildcards.fetch(:ip_protocol) | true |
| match.wildcards.fetch(:ip_source_address_all) | true |
| match.wildcards.fetch(:ip_tos) | true |
| match.wildcards.fetch(:transport_destination_port) | true |
| match.wildcards.fetch(:transport_source_port) | true |
| match.wildcards.fetch(:vlan_priority) | true |
| match.wildcards.fetch(:vlan_vid) | true |
| table_id.to_hex | 0xff |
| out_port | :none |

18 changes: 18 additions & 0 deletions features/open_flow10/description_stats_reply.feature
@@ -0,0 +1,18 @@
@open_flow10
Feature: Pio::DescriptionStats::Reply
Scenario: read
When I try to parse a file named "open_flow10/description_stats_reply.raw" with "DescriptionStats::Reply" class
Then it should finish successfully
And the message has the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 17 |
| length | 1068 |
| transaction_id | 12 |
| xid | 12 |
| stats_type | :description |
| manufacturer | Nicira, Inc. |
| hardware | |
| software | |
| serial_number | |
| datapath | |
File renamed without changes.
43 changes: 43 additions & 0 deletions features/open_flow10/description_stats_request.feature
@@ -0,0 +1,43 @@
@open_flow10
Feature: Pio::DescriptionStats::Request
Scenario: new
When I try to create an OpenFlow message with:
"""
Pio::DescriptionStats::Request.new
"""
Then it should finish successfully
And the message has the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 16 |
| length | 12 |
| transaction_id | 0 |
| xid | 0 |
| stats_type | :description |

Scenario: new(transaction_id: 123)
When I try to create an OpenFlow message with:
"""
Pio::DescriptionStats::Request.new(transaction_id: 123)
"""
Then it should finish successfully
And the message has the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 16 |
| length | 12 |
| transaction_id | 123 |
| xid | 123 |
| stats_type | :description |

Scenario: read
When I try to parse a file named "open_flow10/description_stats_request.raw" with "DescriptionStats::Request" class
Then it should finish successfully
And the message has the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 16 |
| length | 12 |
| transaction_id | 12 |
| xid | 12 |
| stats_type | :description |
File renamed without changes.
Binary file added features/open_flow10/nx_flow_mod_add.raw
Binary file not shown.
Binary file added features/open_flow10/nx_flow_mod_delete.raw
Binary file not shown.
Binary file added features/open_flow10/nx_flow_mod_delete_strict.raw
Binary file not shown.
Binary file added features/open_flow10/nx_flow_mod_modify.raw
Binary file not shown.
Binary file added features/open_flow10/nx_flow_mod_modify_strict.raw
Binary file not shown.
19 changes: 19 additions & 0 deletions features/open_flow13/stats_request.feature
@@ -0,0 +1,19 @@
Feature: Pio::StatsRequest
Background:
Given I use OpenFlow 1.3

@wip
Scenario: new
When I try to create an OpenFlow message with:
"""
Pio::StatsRequest.new(stats_type: :table)
"""
Then it should finish successfully
And the message has the following fields and values:
| field | value |
| ofp_version | 4 |
| message_type | 16 |
| message_length | 12 |
| transaction_id | 0 |
| xid | 0 |
| stats_type | :table |
42 changes: 24 additions & 18 deletions features/open_flow_read.feature
Expand Up @@ -2,21 +2,27 @@ Feature: Pio::OpenFlow.read
Scenario: OpenFlow10
Given I switch the Pio::OpenFlow version to "OpenFlow10"
Then the following each raw file should be parsed into its corresponding object using OpenFlow.read
| raw file | result object |
| open_flow10/hello.raw | Pio::OpenFlow10::Hello |
| open_flow10/hello_failed.raw | Pio::OpenFlow10::Error::HelloFailed |
| open_flow13/hello_failed.raw | Pio::OpenFlow13::Error::HelloFailed |
| open_flow10/bad_request.raw | Pio::OpenFlow10::Error::BadRequest |
| open_flow13/bad_request.raw | Pio::OpenFlow13::Error::BadRequest |
| open_flow10/echo_request.raw | Pio::OpenFlow10::Echo::Request |
| open_flow10/echo_reply.raw | Pio::OpenFlow10::Echo::Reply |
| open_flow10/features_request.raw | Pio::OpenFlow10::Features::Request |
| open_flow10/features_reply.raw | Pio::OpenFlow10::Features::Reply |
| open_flow10/packet_in.raw | Pio::OpenFlow10::PacketIn |
| open_flow10/packet_out.raw | Pio::OpenFlow10::PacketOut |
| open_flow10/flow_mod_add.raw | Pio::OpenFlow10::FlowMod |
| open_flow10/port_status.raw | Pio::OpenFlow10::PortStatus |
| open_flow10/barrier_request.raw | Pio::OpenFlow10::Barrier::Request |
| open_flow10/barrier_reply.raw | Pio::OpenFlow10::Barrier::Reply |
| open_flow10/flow_stats_request.raw | Pio::OpenFlow10::FlowStats::Request |
| open_flow10/flow_stats_reply.raw | Pio::OpenFlow10::FlowStats::Reply |
| raw file | result object |
| open_flow10/aggregate_stats_reply.raw | Pio::OpenFlow10::AggregateStats::Reply |
| open_flow10/aggregate_stats_request.raw | Pio::OpenFlow10::AggregateStats::Request |
| open_flow10/bad_request.raw | Pio::OpenFlow10::Error::BadRequest |
| open_flow10/barrier_reply.raw | Pio::OpenFlow10::Barrier::Reply |
| open_flow10/barrier_request.raw | Pio::OpenFlow10::Barrier::Request |
| open_flow10/description_stats_reply.raw | Pio::OpenFlow10::DescriptionStats::Reply |
| open_flow10/description_stats_request.raw | Pio::OpenFlow10::DescriptionStats::Request |
| open_flow10/echo_reply.raw | Pio::OpenFlow10::Echo::Reply |
| open_flow10/echo_request.raw | Pio::OpenFlow10::Echo::Request |
| open_flow10/features_reply.raw | Pio::OpenFlow10::Features::Reply |
| open_flow10/features_request.raw | Pio::OpenFlow10::Features::Request |
| open_flow10/flow_mod_add.raw | Pio::OpenFlow10::FlowMod |
| open_flow10/flow_stats_reply.raw | Pio::OpenFlow10::FlowStats::Reply |
| open_flow10/flow_stats_reply.raw | Pio::OpenFlow10::FlowStats::Reply |
| open_flow10/flow_stats_request.raw | Pio::OpenFlow10::FlowStats::Request |
| open_flow10/flow_stats_request.raw | Pio::OpenFlow10::FlowStats::Request |
| open_flow10/hello.raw | Pio::OpenFlow10::Hello |
| open_flow10/hello_failed.raw | Pio::OpenFlow10::Error::HelloFailed |
| open_flow10/packet_in.raw | Pio::OpenFlow10::PacketIn |
| open_flow10/packet_out.raw | Pio::OpenFlow10::PacketOut |
| open_flow10/port_status.raw | Pio::OpenFlow10::PortStatus |
| open_flow13/bad_request.raw | Pio::OpenFlow13::Error::BadRequest |
| open_flow13/hello_failed.raw | Pio::OpenFlow13::Error::HelloFailed |
1 change: 1 addition & 0 deletions lib/pio/arp/format.rb
Expand Up @@ -4,6 +4,7 @@
require 'pio/type/mac_address'

module Pio
# ARP parser and generator.
class Arp
# ARP parser.
class Format < BinData::Record
Expand Down
1 change: 1 addition & 0 deletions lib/pio/dhcp/ack.rb
@@ -1,6 +1,7 @@
require 'pio/dhcp/boot_reply'

module Pio
# Dhcp parser and generator.
class Dhcp
# Dhcp Ack packet generator
class Ack < BootReply
Expand Down
1 change: 1 addition & 0 deletions lib/pio/icmp/format.rb
Expand Up @@ -3,6 +3,7 @@
require 'pio/ipv4_header'

module Pio
# Icmp parser and generator.
class Icmp
# Icmp parser.
class Format < BinData::Record
Expand Down
1 change: 1 addition & 0 deletions lib/pio/lldp/chassis_id_tlv.rb
@@ -1,6 +1,7 @@
require 'bindata'

module Pio
# LLDP frame parser and generator.
class Lldp
# Chassis ID TLV
class ChassisIdTlv < BinData::Primitive
Expand Down
1 change: 1 addition & 0 deletions lib/pio/lldp/frame.rb
Expand Up @@ -7,6 +7,7 @@
require 'pio/lldp/ttl_tlv'

module Pio
# LLDP frame parser and generator.
class Lldp
# LLDP frame
class Frame < BinData::Record
Expand Down
8 changes: 4 additions & 4 deletions lib/pio/open_flow.rb
Expand Up @@ -17,8 +17,8 @@ def self.version

def self.switch_version(version)
[:Barrier, :Echo, :Features, :FlowMod, :Hello, :Match,
:PacketIn, :PacketOut, :SendOutPort, :PortStatus,
:FlowStats, :Error].each do |each|
:PacketIn, :PacketOut, :SendOutPort, :PortStatus, :Stats,
:FlowStats, :DescriptionStats, :AggregateStats, :Error].each do |each|
set_message_class_name each, version
@version = version.to_s
end
Expand All @@ -37,8 +37,8 @@ def self.read(binary)
12 => Pio::PortStatus,
13 => Pio::PacketOut,
14 => Pio::FlowMod,
16 => Pio::FlowStats::Request,
17 => Pio::FlowStats::Reply,
16 => Pio::Stats::Request,
17 => Pio::Stats::Reply,
18 => Pio::Barrier::Request,
19 => Pio::Barrier::Reply
}
Expand Down
6 changes: 6 additions & 0 deletions lib/pio/open_flow10.rb
@@ -1,5 +1,9 @@
require 'pio/open_flow10/aggregate_stats_reply.rb'
require 'pio/open_flow10/aggregate_stats_request.rb'
require 'pio/open_flow10/barrier_reply'
require 'pio/open_flow10/barrier_request'
require 'pio/open_flow10/description_stats_reply'
require 'pio/open_flow10/description_stats_request'
require 'pio/open_flow10/echo'
require 'pio/open_flow10/error'
require 'pio/open_flow10/error/bad_request'
Expand All @@ -16,3 +20,5 @@
require 'pio/open_flow10/port16'
require 'pio/open_flow10/port_status'
require 'pio/open_flow10/send_out_port'
require 'pio/open_flow10/stats_reply'
require 'pio/open_flow10/stats_request'

0 comments on commit 8f34afc

Please sign in to comment.