Sha256: bace6bd6cfa883db6f6c3df54bc9ad98130e7ac79f40dc32d7701326e94069b5

Contents?: true

Size: 621 Bytes

Versions: 1

Compression:

Stored size: 621 Bytes

Contents

require 'pio/open_flow/action'

module Pio
  module OpenFlow10
    # An action to modify the VLAN ID of a packet.
    class SetVlanVid < OpenFlow::Action
      action_header action_type: 1, action_length: 8
      uint16 :vlan_id
      string :padding, length: 2
      hide :padding

      def initialize(number)
        vlan_id = number.to_i
        unless vlan_id >= 1 && vlan_id <= 4095
          raise ArgumentError, 'VLAN ID must be between 1 and 4095 inclusive'
        end
        super(vlan_id: vlan_id)
      rescue NoMethodError
        raise TypeError, 'VLAN ID must be an Integer.'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pio-0.30.1 lib/pio/open_flow10/set_vlan_vid.rb