Class: Trema::SetVlanPriority

Inherits:
Action
  • Object
show all
Defined in:
ruby/trema/set-vlan-priority.rb

Overview

An action to modify the VLAN priority of a packet.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (SetVlanPriority) initialize(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).

Examples:

SetVlanPriority.new( 7 )

Parameters:

  • vlan_priority (Integer)

    the VLAN priority to set to.

Raises:

  • (ArgumentError)

    if vlan_priority is not within 0 and 7 inclusive.

  • (TypeError)

    if vlan_priority is not an Integer.



46
47
48
49
50
51
52
53
54
# File 'ruby/trema/set-vlan-priority.rb', line 46

def initialize(vlan_priority)
  unless vlan_priority.is_a?(Integer)
    fail TypeError, 'VLAN priority must be an unsigned 8-bit Integer'
  end
  unless ( vlan_priority >= 0 && vlan_priority <= 7)
    fail ArgumentError, 'Valid VLAN priority values are 0 to 7 inclusive'
  end
  @vlan_priority = vlan_priority
end

Instance Attribute Details

- (Fixnum) vlan_priority (readonly)

Returns the value of attribute #vlan_priority

Returns:



28
29
30
# File 'ruby/trema/set-vlan-priority.rb', line 28

def vlan_priority
  @vlan_priority
end