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, #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_default(*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.
-
#to_s_junos ⇒ Object
Network *192.168.1.200 192.168.1.200 0x80000001 98 0x22 0x2dc 32 mask 255.255.255.0 attached router 192.168.1.200 attached router 193.0.0.0.
- #to_s_junos_verbose ⇒ Object
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, #retransmit, #to_hash, #to_s_verbose
Methods included from TO_S
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
162 163 164 165 |
# File 'lib/lsa/network.rb', line 162 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_default(*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
138 139 140 141 |
# File 'lib/lsa/network.rb', line 138 def to_s_default(*args) super + ['', network_mask, *attached_routers].join("\n ") end |
#to_s_junos ⇒ Object
Network *192.168.1.200 192.168.1.200 0x80000001 98 0x22 0x2dc 32
mask 255.255.255.0
attached router 192.168.1.200
attached router 193.0.0.0
148 149 150 |
# File 'lib/lsa/network.rb', line 148 def to_s_junos super end |
#to_s_junos_verbose ⇒ Object
152 153 154 155 156 157 |
# File 'lib/lsa/network.rb', line 152 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 |