Sha256: babc7f3b813494035afcc94dd7b297adacf33b4f87922acc2dce7bcb66d696ce

Contents?: true

Size: 932 Bytes

Versions: 28

Compression:

Stored size: 932 Bytes

Contents

require 'bindata'
require 'forwardable'

module Pio
  # An action to modify the VLAN related fields of a packet.
  class SetVlan
    extend Forwardable

    # rubocop:disable MethodLength
    def self.def_format(field_name, action_type)
      str = %(
        class Format < BinData::Record
          endian :big

          uint16 :type, value: #{action_type}
          uint16 :message_length, value: 8
          uint16 :#{field_name}
          uint16 :padding
          hide :padding
        end
      )
      module_eval str
      module_eval "def_delegators :@format, :#{field_name}"
    end
    # rubocop:enable MethodLength

    def self.read(raw_data)
      set_vlan = allocate
      set_vlan.instance_variable_set :@format, const_get(:Format).read(raw_data)
      set_vlan
    end

    def_delegators :@format, :type
    def_delegators :@format, :message_length
    def_delegator :@format, :to_binary_s, :to_binary
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
pio-0.25.0 lib/pio/open_flow10/set_vlan.rb
pio-0.24.2 lib/pio/open_flow10/set_vlan.rb
pio-0.24.1 lib/pio/open_flow10/set_vlan.rb
pio-0.24.0 lib/pio/open_flow10/set_vlan.rb
pio-0.23.1 lib/pio/open_flow10/set_vlan.rb
pio-0.23.0 lib/pio/open_flow10/set_vlan.rb
pio-0.22.0 lib/pio/open_flow10/set_vlan.rb
pio-0.21.1 lib/pio/open_flow10/set_vlan.rb
pio-0.21.0 lib/pio/set_vlan.rb
pio-0.20.1 lib/pio/set_vlan.rb
pio-0.20.0 lib/pio/set_vlan.rb
pio-0.19.0 lib/pio/set_vlan.rb
pio-0.18.2 lib/pio/set_vlan.rb
pio-0.18.1 lib/pio/set_vlan.rb
pio-0.18.0 lib/pio/set_vlan.rb
pio-0.17.0 lib/pio/set_vlan.rb
pio-0.16.0 lib/pio/set_vlan.rb
pio-0.15.2 lib/pio/set_vlan.rb
pio-0.15.1 lib/pio/set_vlan.rb
pio-0.15.0 lib/pio/set_vlan.rb