Class: Trema::SetVlanVid

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

Overview

An action to modify the VLAN ID of a packet.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vlan_id) ⇒ SetVlanVid

Creates an action to modify the VLAN ID of a packet. The VLAN ID is 16-bits long but the actual VID (VLAN Identifier) of the IEEE 802.1Q frame is 12-bits.

Examples:

ActionSetVlanVid.new( vlan_id )

Raises:

  • (ArgumentError)

    if vlan_id not within 1 and 4095 inclusive.

  • (TypeError)

    if vlan_id is not an Integer.



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

def initialize(vlan_id)
  unless vlan_id.is_a?(Integer)
    fail TypeError, 'VLAN ID argument must be an Integer'
  end
  unless ( vlan_id >= 1 && vlan_id <= 4095)
    fail ArgumentError, 'Valid VLAN ID values between 1 to 4095 inclusive'
  end
  @vlan_id = vlan_id
end

Instance Attribute Details

#vlan_idFixnum (readonly)



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

def vlan_id
  @vlan_id
end