From 518570ce24319d20f6a2e357a5cd118c8e52e6c9 Mon Sep 17 00:00:00 2001 From: Yasuhito Takamiya Date: Wed, 11 Nov 2015 21:52:29 +0900 Subject: [PATCH] Add SetMetadata action --- features/open_flow13/set_metadata.feature | 14 ++++++++++++++ lib/pio/open_flow.rb | 2 +- lib/pio/open_flow13.rb | 1 + lib/pio/open_flow13/set_metadata.rb | 21 +++++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 features/open_flow13/set_metadata.feature create mode 100644 lib/pio/open_flow13/set_metadata.rb diff --git a/features/open_flow13/set_metadata.feature b/features/open_flow13/set_metadata.feature new file mode 100644 index 00000000..f7f8cad3 --- /dev/null +++ b/features/open_flow13/set_metadata.feature @@ -0,0 +1,14 @@ +@open_flow13 +Feature: Pio::SetMetadata + + Scenario: new(0x123) + When I try to create an OpenFlow action with: + """ + Pio::SetMetadata.new(0x123) + """ + Then it should finish successfully + And the action has the following fields and values: + | field | value | + | action_type | 25 | + | action_length | 16 | + | metadata.to_hex | 0x123 | diff --git a/lib/pio/open_flow.rb b/lib/pio/open_flow.rb index c303f59c..e05ba0cb 100644 --- a/lib/pio/open_flow.rb +++ b/lib/pio/open_flow.rb @@ -20,7 +20,7 @@ def self.switch_version(version) :SetSourceMacAddress, :SetDestinationMacAddress, :PortStatus, :Stats, :FlowStats, :DescriptionStats, :AggregateStats, :TableStats, :PortStats, :QueueStats, :Error, :SetArpOperation, :SetArpSenderProtocolAddress, - :SetArpSenderHardwareAddress, :NiciraRegMove, + :SetArpSenderHardwareAddress, :NiciraRegMove, :SetMetadata, :NiciraRegLoad].each do |each| set_message_class_name each, version @version = version.to_s diff --git a/lib/pio/open_flow13.rb b/lib/pio/open_flow13.rb index 8602aabf..d66eee3c 100644 --- a/lib/pio/open_flow13.rb +++ b/lib/pio/open_flow13.rb @@ -22,6 +22,7 @@ require 'pio/open_flow13/set_arp_sender_hardware_address' require 'pio/open_flow13/set_arp_sender_protocol_address' require 'pio/open_flow13/set_destination_mac_address' +require 'pio/open_flow13/set_metadata' require 'pio/open_flow13/set_source_mac_address' # Instructions diff --git a/lib/pio/open_flow13/set_metadata.rb b/lib/pio/open_flow13/set_metadata.rb new file mode 100644 index 00000000..5b30b72c --- /dev/null +++ b/lib/pio/open_flow13/set_metadata.rb @@ -0,0 +1,21 @@ +require 'pio/open_flow/action' +require 'pio/open_flow13/match' + +module Pio + module OpenFlow13 + # Set metadata + class SetMetadata < OpenFlow::Action + action_header action_type: 25, action_length: 16 + + uint16 :oxm_class, value: Match::OpenFlowBasicValue::OXM_CLASS + bit7 :oxm_field, value: Match::ArpOperation::OXM_FIELD + bit1 :oxm_hasmask, value: 0 + uint8 :oxm_length, value: 8 + uint64 :metadata + + def initialize(metadata) + super metadata: metadata + end + end + end +end