Class: OSPFv2::Network
- Defined in:
- lib/lsa/network.rb,
lib/lsa/network.rb
Constant Summary collapse
Constants inherited from Lsa
Lsa::AdvertisingRouter, Lsa::LsAge, Lsa::LsId, Lsa::MODX
Constants included from Constant
Constant::DATABASE_DESCRIPTION, Constant::HELLO, Constant::LINK_STATE_ACKNOWLEDGEMENT, Constant::LINK_STATE_REQUEST, Constant::LINK_STATE_UPDATE, Constant::V2, Constant::V3
Instance Attribute Summary collapse
-
#attached_routers ⇒ Object
Returns the value of attribute attached_routers.
-
#network_mask ⇒ Object
readonly
Returns the value of attribute network_mask.
Attributes inherited from Lsa
#advertising_router, #ls_age, #ls_id, #opaque_id, #opaque_type, #options, #sequence_number
Class Method Summary collapse
Instance Method Summary collapse
- #<<(neighbor) ⇒ Object
- #encode ⇒ Object
-
#initialize(arg = {}) ⇒ Network
constructor
A new instance of Network.
- #parse(s) ⇒ Object
-
#to_s_ios_verbose ⇒ Object
R1#show ip ospf database network .
-
#to_s_junos_verbose ⇒ Object
FIXME: should be removed and parent take care of it.
-
#to_s_verbose(*args) ⇒ Object
Network: LsAge: 34 Options: 0x22 [DC,E] LsType: network_lsa AdvertisingRouter: 192.168.1.200 LsId: 192.168.1.200 SequenceNumber: 0x80000001 LS checksum: 2dc length: 32 NetworkMask: 255.255.255.0 AttachRouter: 192.168.1.200 AttachRouter: 193.0.0.0 FIXME: when not verbose, only header is displayed and this is taken care of by parent method.
Methods inherited from Lsa
#<=>, #ack, #encode_header, #encode_request, factory, #find_lsa_from_link, #force_refresh, #header_lsa, #is_acked?, #is_opaque?, #key, #ls_type, #lsdb_link_id, #lsdb_link_id=, #maxage, #maxaged?, #method_missing, new_ntop, #refresh, #refresh2, #retransmit, #to_hash, #to_s, #to_s_ios, #to_s_junos
Methods included from Common
#ivar_to_klassname, #ivars, #set, #to_hash
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OSPFv2::Lsa
Instance Attribute Details
#attached_routers ⇒ Object
Returns the value of attribute attached_routers.
92 93 94 |
# File 'lib/lsa/network.rb', line 92 def attached_routers @attached_routers end |
#network_mask ⇒ Object (readonly)
Returns the value of attribute network_mask.
92 93 94 |
# File 'lib/lsa/network.rb', line 92 def network_mask @network_mask end |
Class Method Details
.new_hash(h) ⇒ Object
197 198 199 200 |
# File 'lib/lsa/network.rb', line 197 def self.new_hash(h) r = new(h) r end |
Instance Method Details
#<<(neighbor) ⇒ Object
113 114 115 116 |
# File 'lib/lsa/network.rb', line 113 def <<(neighbor) @attached_routers ||=[] @attached_routers << AttachRouter.new(neighbor) end |
#encode ⇒ Object
100 101 102 103 104 105 106 107 |
# File 'lib/lsa/network.rb', line 100 def encode lsa=[] @network_mask ||= NetworkMask.new @attached_routers ||=[] lsa << network_mask.encode lsa << attached_routers.collect { |x| x.encode } super lsa.join end |
#parse(s) ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/lsa/network.rb', line 118 def parse(s) network_mask, attached_routers = super(s).unpack('Na*') @network_mask = NetworkMask.new network_mask while attached_routers.size>0 self << attached_routers.slice!(0,4).unpack('N')[0] end end |
#to_s_ios_verbose ⇒ Object
R1#show ip ospf database network
OSPF Router with ID (1.1.1.1) (Process ID 1)
Net Link States (Area 0)
Routing Bit Set on this LSA
LS age: 949
Options: (No TOS-capability, DC)
LS Type: Network Links
Link State ID: 192.168.0.2 (address of Designated Router)
Advertising Router: 2.2.2.2
LS Seq Number: 8000000E
Checksum: 0xF9B3
Length: 32
Network Mask: /24
Attached Router: 2.2.2.2
Attached Router: 1.1.1.1
R1# def to_s_ios
attrs = attached_routers.collect { |ar| " Attached Router #{ar.to_ip}"}
s = []
s << super
s << "Network Mask: " + network_mask.to_s(false)
s << attached_routers.collect { |ar| " Attached Router #{ar.to_ip}"}
s.join("\n")
end
173 174 175 176 177 178 179 180 |
# File 'lib/lsa/network.rb', line 173 def to_s_ios_verbose attrs = attached_routers.collect { |ar| " Attached Router #{ar.to_ip}"} s = [] s << super s << "Network Mask: " + network_mask.to_s(false) s << attached_routers.collect { |ar| " Attached Router #{ar.to_ip}"} s.join("\n ") end |
#to_s_junos_verbose ⇒ Object
FIXME: should be removed and parent take care of it. def to_s_junos
super
end
187 188 189 190 191 192 |
# File 'lib/lsa/network.rb', line 187 def to_s_junos_verbose mask = "mask #{network_mask.to_ip}" attrs = attached_routers.collect { |ar| "attached router #{ar.to_ip}"} super + ['', mask, *attrs].join("\n ") end |
#to_s_verbose(*args) ⇒ Object
Network:
LsAge: 34
Options: 0x22 [DC,E]
LsType: network_lsa
AdvertisingRouter: 192.168.1.200
LsId: 192.168.1.200
SequenceNumber: 0x80000001
LS checksum: 2dc
length: 32
NetworkMask: 255.255.255.0
AttachRouter: 192.168.1.200
AttachRouter: 193.0.0.0
FIXME:
when not verbose, only header is displayed and this is taken care of by parent method
140 141 142 143 |
# File 'lib/lsa/network.rb', line 140 def to_s_verbose(*args) super + ['', network_mask, *attached_routers].join("\n ") end |