Class: Racket::L2::VTPSubsetAdvertisement

Inherits:
VTPGeneric show all
Defined in:
lib/racket/l2/vtp.rb

Instance Attribute Summary

Attributes inherited from RacketPart

#autofix

Instance Method Summary collapse

Methods inherited from RacketPart

#autofix?, #pretty

Constructor Details

#initialize(*args) ⇒ VTPSubsetAdvertisement

Returns a new instance of VTPSubsetAdvertisement.



79
80
81
82
83
# File 'lib/racket/l2/vtp.rb', line 79

def initialize(*args)
  @vlan_info = []
  super(*args)
  self.code = 2 
end

Instance Method Details

#add_vlan_info(status, type, id, mtu, index, name) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/racket/l2/vtp.rb', line 64

def add_vlan_info(status, type, id, mtu, index, name)
  name_length = name.length
  # zero pad name to a multiple of 4 bytes
  name = name.length % 4 == 0 ? name : name.ljust(name.length + (4 - (name.length % 4)), "\x00")
  length = 12 + name.length
  @vlan_info << [length, status, type, name_length, id, mtu, index, name]
end

#fix!Object



72
73
74
75
76
77
# File 'lib/racket/l2/vtp.rb', line 72

def fix!
  @vlan_info.each do |v|
    self.payload += v.pack("CCCCnnNa*")
  end
  super
end