Sha256: b091c842a96f1625dcb8f30dd9f6e1c0355aa4d4906ee09cc8cd852faccf3df2

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require 'pio/open_flow/nicira_action'
require 'pio/open_flow13/match'

module Pio
  module OpenFlow13
    # NXAST_REG_LOAD action
    class NiciraRegLoad < OpenFlow::NiciraAction
      nicira_action_header action_type: 0xffff,
                           action_length: 24,
                           subtype: 7
      bit10 :_offset, initial_value: 0
      bit6 :_n_bits
      struct :_destination do
        uint16 :oxm_class
        bit7 :oxm_field
        bit1 :oxm_hasmask, value: 0
        bit8 :oxm_length
      end
      uint64 :_value

      def initialize(value, destination, options = {})
        @destination = destination
        super(_value: value,
              _offset: options[:offset] || 0,
              _n_bits: (options[:n_bits] || oxm_length * 8) - 1,
              _destination: { oxm_class: oxm_class,
                              oxm_field: oxm_field,
                              oxm_length: oxm_length })
      end

      attr_reader :destination

      def offset
        _offset
      end

      def n_bits
        _n_bits + 1
      end

      def value
        _value
      end

      private

      def oxm_class
        destination_oxm_class.const_get(:OXM_CLASS)
      end

      def oxm_field
        destination_oxm_class.const_get(:OXM_FIELD)
      end

      def oxm_length
        destination_oxm_class.new.length
      end

      def destination_oxm_class
        Match.const_get(@destination.to_s.split('_').map(&:capitalize).join)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pio-0.30.1 lib/pio/open_flow13/nicira_reg_load.rb