From 433cc96e92846f4937d099f323b772d25bd1c779 Mon Sep 17 00:00:00 2001 From: Eishun Kondoh Date: Mon, 7 Nov 2016 00:28:00 +0900 Subject: [PATCH] Add support OFP_PORT_MOD --- features/open_flow10/port_mod.feature | 30 +++++++++++++++++ lib/pio/open_flow10.rb | 1 + lib/pio/open_flow10/port_mod.rb | 46 +++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 features/open_flow10/port_mod.feature create mode 100644 lib/pio/open_flow10/port_mod.rb diff --git a/features/open_flow10/port_mod.feature b/features/open_flow10/port_mod.feature new file mode 100644 index 00000000..c5b00cef --- /dev/null +++ b/features/open_flow10/port_mod.feature @@ -0,0 +1,30 @@ +@open_flow10 +Feature: FlowMod + Scenario: new + When I create an OpenFlow message with: + """ + Pio::PortMod.new( + port_no: 1, + mac_address: '11:22:33:44:55:66', + config: [], + mask: [:port_down], + advertised: [] + ) + """ + Then the message has the following fields and values: + | field | value | + | port_no | 1 | + | mac_address | 11:22:33:44:55:66 | + | config | [] | + | mask | [:port_down] | + | advertised | [] | + + Scenario: read + When I parse a file named "open_flow10/port_mod.raw" with "PortMod" class + Then the packet has the following fields and values: + | field | value | + | port_no | 1 | + | mac_address | 11:22:33:44:55:66 | + | config | [:port_down] | + | mask | [:port_down] | + | advertised | [] | diff --git a/lib/pio/open_flow10.rb b/lib/pio/open_flow10.rb index 70ad2166..245bdaad 100644 --- a/lib/pio/open_flow10.rb +++ b/lib/pio/open_flow10.rb @@ -25,6 +25,7 @@ require 'pio/open_flow10/stats_reply' require 'pio/open_flow10/stats_request' require 'pio/open_flow10/table_stats/request' +require 'pio/open_flow10/port_mod' # Actions require 'pio/open_flow/nicira_resubmit' diff --git a/lib/pio/open_flow10/port_mod.rb b/lib/pio/open_flow10/port_mod.rb new file mode 100644 index 00000000..784ce813 --- /dev/null +++ b/lib/pio/open_flow10/port_mod.rb @@ -0,0 +1,46 @@ +require 'pio/open_flow' +require 'pio/open_flow/flags' +require 'pio/type/mac_address' + +module Pio + module OpenFlow10 + # OpenFlow 1.0 Port Mod Message + class PortMod < OpenFlow::Message + open_flow_header version: 1, type: 15, length: 32 + + uint16 :port_no + mac_address :mac_address + flags_32bit :config, + [:port_down, + :no_stp, + :no_receive, + :no_receive_stp, + :no_flood, + :no_forward, + :no_packet_in] + flags_32bit :mask, + [:port_down, + :no_stp, + :no_receive, + :no_receive_stp, + :no_flood, + :no_forward, + :no_packet_in] + flags_32bit :advertised, + [:port_10mb_hd, + :port_10mb_fd, + :port_100mb_hd, + :port_100mb_fd, + :port_1gb_hd, + :port_1gb_fd, + :port_10gb_fd, + :port_copper, + :port_fiber, + :port_autoneg, + :port_pause, + :port_pause_asym] + string :_pad, length: 4 + hide :_pad + end + end +end