Class: OSPFv2::MaximumReservableBandwidth_Tlv

Inherits:
Object
  • Object
show all
Includes:
Common, SubTlv
Defined in:
lib/lsa/tlv/maximum_reservable_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 = {}) ⇒ MaximumReservableBandwidth_Tlv

Returns a new instance of MaximumReservableBandwidth_Tlv.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/lsa/tlv/maximum_reservable_bandwidth.rb', line 21

def initialize(arg={})
  @tlv_type, = 7
  @max_resv_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_resv_bwObject (readonly)

Returns the value of attribute max_resv_bw.



19
20
21
# File 'lib/lsa/tlv/maximum_reservable_bandwidth.rb', line 19

def max_resv_bw
  @max_resv_bw
end

#tlv_typeObject (readonly)

Returns the value of attribute tlv_type.



19
20
21
# File 'lib/lsa/tlv/maximum_reservable_bandwidth.rb', line 19

def tlv_type
  @tlv_type
end

Instance Method Details

#__parse(s) ⇒ Object



38
39
40
41
# File 'lib/lsa/tlv/maximum_reservable_bandwidth.rb', line 38

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

#encodeObject



34
35
36
# File 'lib/lsa/tlv/maximum_reservable_bandwidth.rb', line 34

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

#to_sObject



43
44
45
# File 'lib/lsa/tlv/maximum_reservable_bandwidth.rb', line 43

def to_s
  "Maximum reservable bandwidth : #{max_resv_bw}"
end

#to_s_junos_style(ident = 0) ⇒ Object



47
48
49
# File 'lib/lsa/tlv/maximum_reservable_bandwidth.rb', line 47

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