Sha256: 87022cf59557eedcf56541b211c9ad6d97efde30f8d0aeabbbbedf129aa87561

Contents?: true

Size: 906 Bytes

Versions: 6

Compression:

Stored size: 906 Bytes

Contents

require 'bindata'

module Pio
  # Actions not yet implemented.
  class UnsupportedAction < BinData::Record
    endian :big

    uint16 :action_type
    uint16 :action_length
  end

  # Actions list of actions-apply instruction.
  class Actions < BinData::Primitive
    mandatory_parameter :length

    endian :big

    string :binary, read_length: :length

    def set(value)
      self.binary = [value].flatten.map(&:to_binary).join
    end

    # rubocop:disable MethodLength
    def get
      actions = []
      tmp = binary
      while tmp.length > 0
        action = case BinData::Uint16be.read(tmp)
                 when 0
                   SendOutPort.read(tmp)
                 else
                   UnsupportedAction.read(tmp)
                 end
        tmp = tmp[action.action_length..-1]
        actions << action
      end
      actions
    end
    # rubocop:enable MethodLength
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pio-0.25.0 lib/pio/open_flow13/actions.rb
pio-0.24.2 lib/pio/open_flow13/actions.rb
pio-0.24.1 lib/pio/open_flow13/actions.rb
pio-0.24.0 lib/pio/open_flow13/actions.rb
pio-0.23.1 lib/pio/open_flow13/actions.rb
pio-0.23.0 lib/pio/open_flow13/actions.rb