Sha256: 57b56a315bf05d6e05c2f689c78aec1d0643f53b8b7c07738d89de59c20420aa

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

require 'forwardable'

# Base module.
module Pio
  # Write metadata
  class WriteMetadata
    # OpenFlow 1.3.4 OFPIT_WRITE_METADATA instruction format
    class Format < BinData::Record
      endian :big

      uint16 :instruction_type, value: 2
      uint16 :instruction_length, value: 24
      uint32 :padding
      uint64 :metadata
      uint64 :metadata_mask
    end

    def self.read(raw_data)
      allocate.tap do |write_metadata|
        write_metadata.instance_variable_set :@format, Format.read(raw_data)
      end
    end

    extend Forwardable

    def_delegators :@format, :instruction_type
    def_delegators :@format, :instruction_length
    def_delegators :@format, :metadata
    def_delegators :@format, :metadata_mask

    def initialize(user_options)
      @options = user_options
      @format = Format.new(options)
    end

    def options
      {
        metadata: metadata_option,
        metadata_mask: metadata_mask_option
      }
    end

    def metadata_option
      @options[:metadata]
    end

    def metadata_mask_option
      @options[:metadata_mask]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pio-0.23.1 lib/pio/open_flow13/write_metadata.rb
pio-0.23.0 lib/pio/open_flow13/write_metadata.rb
pio-0.22.0 lib/pio/open_flow13/write_metadata.rb
pio-0.21.1 lib/pio/open_flow13/write_metadata.rb
pio-0.21.0 lib/pio/open_flow13/write_metadata.rb