Class: OSPFv2::LinkId_Tlv
- Defined in:
- lib/lsa/tlv/link_id.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#link_id ⇒ Object
readonly
Returns the value of attribute link_id.
-
#tlv_type ⇒ Object
readonly
Returns the value of attribute tlv_type.
Instance Method Summary collapse
- #__parse(s) ⇒ Object
- #encode ⇒ Object
-
#initialize(arg = {}) ⇒ LinkId_Tlv
constructor
A new instance of LinkId_Tlv.
- #to_s ⇒ Object
- #to_s_junos_style(ident = 0) ⇒ Object
Methods included from Common
#ivar_to_klassname, #ivars, #set, #to_hash
Methods included from SubTlv
Methods included from Tlv
Constructor Details
#initialize(arg = {}) ⇒ LinkId_Tlv
Returns a new instance of LinkId_Tlv.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lsa/tlv/link_id.rb', line 24 def initialize(arg={}) @tlv_type = 2 @link_id = LinkId.new 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
#link_id ⇒ Object (readonly)
Returns the value of attribute link_id.
20 21 22 |
# File 'lib/lsa/tlv/link_id.rb', line 20 def link_id @link_id end |
#tlv_type ⇒ Object (readonly)
Returns the value of attribute tlv_type.
20 21 22 |
# File 'lib/lsa/tlv/link_id.rb', line 20 def tlv_type @tlv_type end |
Instance Method Details
#__parse(s) ⇒ Object
41 42 43 44 |
# File 'lib/lsa/tlv/link_id.rb', line 41 def __parse(s) @tlv_type, _, link_id = s.unpack('nna*') @link_id = LinkId.new_ntoh(link_id) end |
#encode ⇒ Object
37 38 39 |
# File 'lib/lsa/tlv/link_id.rb', line 37 def encode [@tlv_type, 4, @link_id.encode].pack('nna*') end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/lsa/tlv/link_id.rb', line 46 def to_s "Link ID : " + link_id.to_ip end |
#to_s_junos_style(ident = 0) ⇒ Object
50 51 52 |
# File 'lib/lsa/tlv/link_id.rb', line 50 def to_s_junos_style(ident=0) " "*ident + "RtrAddr (1), length #{@length}: #{router_id.to_ip}" end |