Sha256: 57070a83a1401c3e8157dd9fd765ad12a87c9098cea00477864cb1632bd3bd96

Contents?: true

Size: 1.88 KB

Versions: 13

Compression:

Stored size: 1.88 KB

Contents

#
# Copyright (C) 2008-2012 NEC Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#


require "trema/action"


module Trema
  #
  # An action to modify the VLAN priority of a packet.
  #
  class SetVlanPriority < Action
    # @return [Fixnum] the value of attribute {#vlan_priority}
    attr_reader :vlan_priority


    #
    # Creates an action to modify the VLAN priority of a
    # packet. Priority bits can be used to prioritize different
    # classes of traffic. Valid values are between 0 (lowest) and 7
    # (highest).
    #
    # @example
    #   SetVlanPriority.new( 7 )
    #
    # @param [Integer] vlan_priority
    #   the VLAN priority to set to.
    #
    # @raise [ArgumentError] if vlan_priority is not within 0 and 7 inclusive.
    # @raise [TypeError] if vlan_priority is not an Integer.
    #
    def initialize vlan_priority
      unless vlan_priority.is_a?( Integer )
        raise TypeError, "VLAN priority must be an unsigned 8-bit Integer"
      end
      unless ( vlan_priority >= 0 and vlan_priority <= 7 )
        raise ArgumentError, "Valid VLAN priority values are 0 to 7 inclusive"
      end
      @vlan_priority = vlan_priority
    end
  end


  ActionSetVlanPcp = SetVlanPriority
end


### Local variables:
### mode: Ruby
### coding: utf-8-unix
### indent-tabs-mode: nil
### End:

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
trema-0.3.9 ruby/trema/set-vlan-priority.rb
trema-0.3.8 ruby/trema/set-vlan-priority.rb
trema-0.3.7 ruby/trema/set-vlan-priority.rb
trema-0.3.6 ruby/trema/set-vlan-priority.rb
trema-0.3.5 ruby/trema/set-vlan-priority.rb
trema-0.3.4 ruby/trema/set-vlan-priority.rb
trema-0.3.3 ruby/trema/set-vlan-priority.rb
trema-0.3.2 ruby/trema/set-vlan-priority.rb
trema-0.3.1 ruby/trema/set-vlan-priority.rb
trema-0.3.0 ruby/trema/set-vlan-priority.rb
trema-0.2.8 ruby/trema/set-vlan-priority.rb
trema-0.2.7 ruby/trema/set-vlan-priority.rb
trema-0.2.6 ruby/trema/set-vlan-priority.rb