Sha256: ce60d6502e4bf5923521ce0219d2e8f6107d39b5da9eb3e627638123972f9021

Contents?: true

Size: 965 Bytes

Versions: 14

Compression:

Stored size: 965 Bytes

Contents

require 'bindata'
require 'forwardable'
require 'pio/open_flow13/actions'

module Pio
  # An instruction to apply a list of actions to a packet in-order.
  class Apply
    # OpenFlow 1.3.4 OFPIT_APPLY_ACTIONS instruction format.
    class Format < BinData::Record
      endian :big

      uint16 :instruction_type, value: 4
      uint16 :instruction_length,
             initial_value: -> { 8 + actions.binary.length }
      string :padding, length: 4
      actions :actions, length: -> { instruction_length - 8 }
    end

    def self.read(raw_data)
      allocate.tap do |apply|
        apply.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, :actions
    def_delegators :@format, :to_binary_s

    def initialize(actions = [])
      @format = Format.new(actions: actions)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pio-0.30.0 lib/pio/open_flow13/apply.rb
pio-0.29.0 lib/pio/open_flow13/apply.rb
pio-0.28.1 lib/pio/open_flow13/apply.rb
pio-0.28.0 lib/pio/open_flow13/apply.rb
pio-0.27.2 lib/pio/open_flow13/apply.rb
pio-0.27.1 lib/pio/open_flow13/apply.rb
pio-0.27.0 lib/pio/open_flow13/apply.rb
pio-0.26.0 lib/pio/open_flow13/apply.rb
pio-0.25.0 lib/pio/open_flow13/apply.rb
pio-0.24.2 lib/pio/open_flow13/apply.rb
pio-0.24.1 lib/pio/open_flow13/apply.rb
pio-0.24.0 lib/pio/open_flow13/apply.rb
pio-0.23.1 lib/pio/open_flow13/apply.rb
pio-0.23.0 lib/pio/open_flow13/apply.rb