Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add QueueStats::Request class. #267

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [#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.
* [#267](https://github.com/trema/pio/pull/267): Add Queue Stats Request message generator.

### Changes
* [#265](https://github.com/trema/pio/pull/265): Rename `SetIpTos` -> `SetTos`.
Expand Down
51 changes: 51 additions & 0 deletions features/open_flow10/queue_stats_request.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Feature: Pio::OpenFlow10::QueueStats::Request
@open_flow10
Scenario: new(port: 1, queue_id: 1)
When I try to create an OpenFlow message with:
"""
Pio::OpenFlow10::QueueStats::Request.new(port: 1, queue_id: 1)
"""
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 | :queue |
| port | 1 |
| queue_id | 1 |

@open_flow10
Scenario: new(port: 1, queue_id: 1, transaction_id: 123)
When I try to create an OpenFlow message with:
"""
Pio::OpenFlow10::QueueStats::Request.new(port: 1, queue_id: 1, 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 | :queue |
| port | 1 |
| queue_id | 1 |

@open_flow10
Scenario: read
When I try to parse a file named "open_flow10/queue_stats_request.raw" with "QueueStats::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 | :queue |
| port | :all |
| queue_id | 1 |
Binary file added features/open_flow10/queue_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, :PortStats, :Error, :NiciraResubmit,
:TableStats, :PortStats, :QueueStats, :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 @@ -21,6 +21,7 @@
require 'pio/open_flow10/packet_out'
require 'pio/open_flow10/port_stats/request'
require 'pio/open_flow10/port_status'
require 'pio/open_flow10/queue_stats/request'
require 'pio/open_flow10/stats_reply'
require 'pio/open_flow10/stats_request'
require 'pio/open_flow10/table_stats/request'
Expand Down
22 changes: 22 additions & 0 deletions lib/pio/open_flow10/queue_stats/request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'pio/open_flow/message'

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

stats_type :stats_type, value: -> { :queue }
uint16 :flags
port16 :port
string :padding, length: 2
hide :padding
uint32 :queue_id
end
end
end
end