Skip to content

Commit

Permalink
Add PortStats::Request class.
Browse files Browse the repository at this point in the history
Refs #235
  • Loading branch information
yasuhito committed Oct 27, 2015
1 parent 7d6e310 commit 6ad83f6
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### New features
* [#250](https://github.com/trema/pio/pull/250): Add Flow Removed message parser.
* [#251](https://github.com/trema/pio/pull/251): Add Table Stats Request message generator.
* [#266](https://github.com/trema/pio/pull/266): Add Port Stats Request message generator.

### Changes
* [#265](https://github.com/trema/pio/pull/265): Rename `SetIpTos` -> `SetTos`.
Expand Down
48 changes: 48 additions & 0 deletions features/open_flow10/port_stats_request.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Feature: Pio::OpenFlow10::PortStats::Request
@open_flow10
Scenario: new(:none)
When I try to create an OpenFlow message with:
"""
Pio::OpenFlow10::PortStats::Request.new(:none)
"""
Then it should finish successfully
And the message has the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 16 |
| message_length | 20 |
| transaction_id | 0 |
| xid | 0 |
| stats_type | :port |
| port | :none |

@open_flow10
Scenario: new(:none, transaction_id: 123)
When I try to create an OpenFlow message with:
"""
Pio::OpenFlow10::PortStats::Request.new(:none, 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 |
| message_length | 20 |
| transaction_id | 123 |
| xid | 123 |
| stats_type | :port |
| port | :none |

@open_flow10
Scenario: read
When I try to parse a file named "open_flow10/port_stats_request.raw" with "PortStats::Request" class
Then it should finish successfully
And the message has the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 16 |
| message_length | 20 |
| transaction_id | 123 |
| xid | 123 |
| stats_type | :port |
| port | :none |
Binary file modified features/open_flow10/port_stats_request.raw
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/pio/open_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def self.switch_version(version)
[:Barrier, :Echo, :Features, :FlowMod, :Hello, :Match,
:PacketIn, :FlowRemoved, :PacketOut, :SendOutPort, :PortStatus,
:Stats, :FlowStats, :DescriptionStats, :AggregateStats,
:TableStats, :Error, :NiciraResubmit,
:TableStats, :PortStats, :Error, :NiciraResubmit,
:NiciraResubmitTable].each do |each|
set_message_class_name each, version
@version = version.to_s
Expand Down
1 change: 1 addition & 0 deletions lib/pio/open_flow10.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require 'pio/open_flow10/hello'
require 'pio/open_flow10/packet_in'
require 'pio/open_flow10/packet_out'
require 'pio/open_flow10/port_stats/request'
require 'pio/open_flow10/port_status'
require 'pio/open_flow10/stats_reply'
require 'pio/open_flow10/stats_request'
Expand Down
25 changes: 25 additions & 0 deletions lib/pio/open_flow10/port_stats/request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'pio/open_flow/message'

module Pio
module OpenFlow10
# Port Stats messages
class PortStats
# Port Stats Request message
class Request < OpenFlow::Message
open_flow_header version: 1,
message_type: 16,
message_length: 20

stats_type :stats_type, value: -> { :port }
uint16 :flags
port16 :port
string :padding, length: 6
hide :padding

def initialize(port, user_options = {})
super({ port: port }.merge user_options)
end
end
end
end
end
4 changes: 3 additions & 1 deletion lib/pio/open_flow10/stats_request.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'pio/open_flow10/table_stats/request'
require 'pio/open_flow10/port_stats/request'
require 'pio/open_flow/message'

module Pio
Expand All @@ -10,7 +11,8 @@ class Request
description: OpenFlow10::DescriptionStats::Request,
flow: OpenFlow10::FlowStats::Request,
aggregate: OpenFlow10::AggregateStats::Request,
table: OpenFlow10::TableStats::Request
table: OpenFlow10::TableStats::Request,
port: OpenFlow10::PortStats::Request
}

# Stats request format.
Expand Down

0 comments on commit 6ad83f6

Please sign in to comment.