Class: OSPFv2::MaximumBandwidth_Tlv

Inherits:
Object
  • Object
show all
Includes:
Common, SubTlv
Defined in:
lib/lsa/tlv/maximum_bandwidth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

#ivar_to_klassname, #ivars, #set, #to_hash

Methods included from SubTlv

factory

Methods included from Tlv

factory

Constructor Details

#initialize(arg = {}) ⇒ MaximumBandwidth_Tlv

Returns a new instance of MaximumBandwidth_Tlv.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/lsa/tlv/maximum_bandwidth.rb', line 23

def initialize(arg={})
  @tlv_type = 6
  @max_bw = 0

  if arg.is_a?(Hash) then
    set(arg.dup)
  elsif arg.is_a?(String)
    __parse(arg)
  else
    raise ArgumentError, "Invalid argument", caller
  end
end

Instance Attribute Details

#max_bwObject (readonly)

Returns the value of attribute max_bw.



21
22
23
# File 'lib/lsa/tlv/maximum_bandwidth.rb', line 21

def max_bw
  @max_bw
end

#tlv_typeObject (readonly)

Returns the value of attribute tlv_type.



21
22
23
# File 'lib/lsa/tlv/maximum_bandwidth.rb', line 21

def tlv_type
  @tlv_type
end

Instance Method Details

#__parse(s) ⇒ Object



40
41
42
43
# File 'lib/lsa/tlv/maximum_bandwidth.rb', line 40

def __parse(s)
  @tlv_type, _, max_bw = s.unpack('nng')
  @max_bw = (max_bw * 8).to_int
end

#encodeObject



36
37
38
# File 'lib/lsa/tlv/maximum_bandwidth.rb', line 36

def encode
  [@tlv_type, 4, @max_bw/8.0].pack('nng')
end

#to_sObject



45
46
47
# File 'lib/lsa/tlv/maximum_bandwidth.rb', line 45

def to_s
  "Maximum bandwidth : #{max_bw.to_i}"
end

#to_s_junos_style(ident = 0) ⇒ Object



49
50
51
# File 'lib/lsa/tlv/maximum_bandwidth.rb', line 49

def to_s_junos_style(ident=0)
  "  "*ident + "RtrAddr (1), length #{@length}: #{router_id.to_ip}"
end