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