diff --git a/features/open_flow13/nicira_send_out_port.feature b/features/open_flow13/nicira_send_out_port.feature new file mode 100644 index 00000000..8ddf50c8 --- /dev/null +++ b/features/open_flow13/nicira_send_out_port.feature @@ -0,0 +1,20 @@ +@open_flow13 +Feature: Pio::NiciraSendOutPort + + Scenario: new(:reg0) + When I try to create an OpenFlow action with: + """ + Pio::NiciraSendOutPort.new(:reg0) + """ + Then it should finish successfully + And the action has the following fields and values: + | field | value | + | action_type.to_hex | 0xffff | + | action_length | 24 | + | experimenter_id.to_hex | 0x2320 | + | experimenter_type | 15 | + | offset | 0 | + | source | :reg0 | + | max_length | 0 | + + diff --git a/lib/pio/open_flow.rb b/lib/pio/open_flow.rb index e05ba0cb..65b62649 100644 --- a/lib/pio/open_flow.rb +++ b/lib/pio/open_flow.rb @@ -21,7 +21,7 @@ def self.switch_version(version) :FlowStats, :DescriptionStats, :AggregateStats, :TableStats, :PortStats, :QueueStats, :Error, :SetArpOperation, :SetArpSenderProtocolAddress, :SetArpSenderHardwareAddress, :NiciraRegMove, :SetMetadata, - :NiciraRegLoad].each do |each| + :NiciraRegLoad, :NiciraSendOutPort].each do |each| set_message_class_name each, version @version = version.to_s end diff --git a/lib/pio/open_flow13.rb b/lib/pio/open_flow13.rb index d66eee3c..97b878ae 100644 --- a/lib/pio/open_flow13.rb +++ b/lib/pio/open_flow13.rb @@ -17,6 +17,7 @@ require 'pio/open_flow/nicira_resubmit_table' require 'pio/open_flow13/nicira_reg_load' require 'pio/open_flow13/nicira_reg_move' +require 'pio/open_flow13/nicira_send_out_port' require 'pio/open_flow13/send_out_port' require 'pio/open_flow13/set_arp_operation' require 'pio/open_flow13/set_arp_sender_hardware_address' diff --git a/lib/pio/open_flow13/nicira_send_out_port.rb b/lib/pio/open_flow13/nicira_send_out_port.rb new file mode 100644 index 00000000..dfdbdbb7 --- /dev/null +++ b/lib/pio/open_flow13/nicira_send_out_port.rb @@ -0,0 +1,38 @@ +require 'pio/open_flow/action' + +module Pio + module OpenFlow13 + # NXAST_OUTPUT_REG action + class NiciraSendOutPort < OpenFlow::Action + action_header action_type: 0xffff, action_length: 24 + uint32 :experimenter_id, value: 0x2320 + uint16 :experimenter_type, value: 15 + bit10 :offset_internal, value: 0 + bit6 :n_bits_internal + uint32 :source_internal + uint16 :max_length, value: 0 + string :zero, length: 6 + + attr_reader :source + + # rubocop:disable AbcSize + # rubocop:disable LineLength + def initialize(source) + @source = source + oxm_klass = Match.const_get(source.to_s.split('_').map(&:capitalize).join) + super(n_bits_internal: oxm_klass.new.length * 8 - 1, + source_internal: ((oxm_klass.superclass.const_get(:OXM_CLASS) << 16) | (oxm_klass.const_get(:OXM_FIELD) << 9) | oxm_klass.new.length)) + end + # rubocop:enable AbcSize + # rubocop:enable LineLength + + def offset + offset_internal + end + + def n_bits + n_bits_internal + 1 + end + end + end +end