From 0bb6b214a637c548e0f486ec942e401132f7ff52 Mon Sep 17 00:00:00 2001 From: Yasuhito Takamiya Date: Sun, 25 Oct 2015 20:17:49 +0900 Subject: [PATCH] Add TableStats Request message generator. --- .../open_flow10/table_stats_request.feature | 31 +++++++++++++++++++ lib/pio/open_flow.rb | 5 +-- lib/pio/open_flow10.rb | 1 + lib/pio/open_flow10/stats_request.rb | 4 ++- lib/pio/open_flow10/table_stats/request.rb | 19 ++++++++++++ 5 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 features/open_flow10/table_stats_request.feature create mode 100644 lib/pio/open_flow10/table_stats/request.rb diff --git a/features/open_flow10/table_stats_request.feature b/features/open_flow10/table_stats_request.feature new file mode 100644 index 00000000..d1be8cea --- /dev/null +++ b/features/open_flow10/table_stats_request.feature @@ -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 | diff --git a/lib/pio/open_flow.rb b/lib/pio/open_flow.rb index 4eddc97e..12278227 100644 --- a/lib/pio/open_flow.rb +++ b/lib/pio/open_flow.rb @@ -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 diff --git a/lib/pio/open_flow10.rb b/lib/pio/open_flow10.rb index 0c3dee64..295b852e 100644 --- a/lib/pio/open_flow10.rb +++ b/lib/pio/open_flow10.rb @@ -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' diff --git a/lib/pio/open_flow10/stats_request.rb b/lib/pio/open_flow10/stats_request.rb index 33e37bb4..a47cf87f 100644 --- a/lib/pio/open_flow10/stats_request.rb +++ b/lib/pio/open_flow10/stats_request.rb @@ -1,3 +1,4 @@ +require 'pio/open_flow10/table_stats/request' require 'pio/open_flow/message' module Pio @@ -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. diff --git a/lib/pio/open_flow10/table_stats/request.rb b/lib/pio/open_flow10/table_stats/request.rb new file mode 100644 index 00000000..23056f4c --- /dev/null +++ b/lib/pio/open_flow10/table_stats/request.rb @@ -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