Skip to content

Commit

Permalink
Add TableStats Request message generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Oct 25, 2015
1 parent 1b848fa commit 0bb6b21
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
31 changes: 31 additions & 0 deletions features/open_flow10/table_stats_request.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@open_flow10
Feature: Pio::TableStats::Request
Scenario: new
When I try to create an OpenFlow message with:
"""
Pio::TableStats::Request.new
"""
Then it should finish successfully
And the message has the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 16 |
| message_length | 12 |
| transaction_id | 0 |
| xid | 0 |
| stats_type | :table |

Scenario: new(transaction_id: 123)
When I try to create an OpenFlow message with:
"""
Pio::TableStats::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 |
| message_length | 12 |
| transaction_id | 123 |
| xid | 123 |
| stats_type | :table |
5 changes: 3 additions & 2 deletions lib/pio/open_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ def self.version

def self.switch_version(version)
[:Barrier, :Echo, :Features, :FlowMod, :Hello, :Match,
:PacketIn, :FlowRemoved, :PacketOut, :SendOutPort, :PortStatus, :Stats,
:FlowStats, :DescriptionStats, :AggregateStats, :Error].each do |each|
:PacketIn, :FlowRemoved, :PacketOut, :SendOutPort, :PortStatus,
:Stats, :FlowStats, :DescriptionStats, :AggregateStats,
:TableStats, :Error].each do |each|
set_message_class_name each, version
@version = version.to_s
end
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 @@ -22,6 +22,7 @@
require 'pio/open_flow10/port_status'
require 'pio/open_flow10/stats_reply'
require 'pio/open_flow10/stats_request'
require 'pio/open_flow10/table_stats/request'

# Actions
require 'pio/open_flow10/send_out_port'
Expand Down
4 changes: 3 additions & 1 deletion lib/pio/open_flow10/stats_request.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'pio/open_flow10/table_stats/request'
require 'pio/open_flow/message'

module Pio
Expand All @@ -8,7 +9,8 @@ class Request
TYPES = {
description: OpenFlow10::DescriptionStats::Request,
flow: OpenFlow10::FlowStats::Request,
aggregate: OpenFlow10::AggregateStats::Request
aggregate: OpenFlow10::AggregateStats::Request,
table: OpenFlow10::TableStats::Request
}

# Stats request format.
Expand Down
19 changes: 19 additions & 0 deletions lib/pio/open_flow10/table_stats/request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'pio/open_flow10/stats_type'
require 'pio/open_flow/message'

module Pio
module OpenFlow10
# OpenFlow 1.0 Table Stats messages
module TableStats
# OpenFlow 1.0 Table Stats Request message
class Request < OpenFlow::Message
open_flow_header version: 1,
message_type: 16,
message_length: 12
stats_type :stats_type, value: -> { :table }
uint16 :flags
string :body, value: ''
end
end
end
end

0 comments on commit 0bb6b21

Please sign in to comment.