Class: OSPFv2::ExternalRoute_Base
- Includes:
- Common
- Defined in:
- lib/ie/external_route.rb
Direct Known Subclasses
Constant Summary collapse
Instance Attribute Summary collapse
-
#forwarding_address ⇒ Object
readonly
Returns the value of attribute forwarding_address.
-
#metric ⇒ Object
readonly
Returns the value of attribute metric.
-
#mt_id ⇒ Object
readonly
Returns the value of attribute mt_id.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #encode ⇒ Object
-
#initialize(arg = {}) ⇒ ExternalRoute_Base
constructor
A new instance of ExternalRoute_Base.
- #parse(s) ⇒ Object
- #to_s ⇒ Object
- #to_s_ios ⇒ Object
Methods included from Common
#ivar_to_klassname, #ivars, #set, #to_hash
Constructor Details
#initialize(arg = {}) ⇒ ExternalRoute_Base
Returns a new instance of ExternalRoute_Base.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ie/external_route.rb', line 87 def initialize(arg={}) arg = arg.dup self.metric=0 self.type=:e1 self.tag=0 self.mt_id=0 if arg.is_a?(Hash) set arg elsif arg.is_a?(String) parse arg elsif arg.is_a?(self.class) parse arg.encode else raise ArgumentError, "Invalid Argument: #{arg.inspect}" end end |
Instance Attribute Details
#forwarding_address ⇒ Object (readonly)
Returns the value of attribute forwarding_address.
71 72 73 |
# File 'lib/ie/external_route.rb', line 71 def forwarding_address @forwarding_address end |
#metric ⇒ Object (readonly)
Returns the value of attribute metric.
71 72 73 |
# File 'lib/ie/external_route.rb', line 71 def metric @metric end |
#mt_id ⇒ Object (readonly)
Returns the value of attribute mt_id.
71 72 73 |
# File 'lib/ie/external_route.rb', line 71 def mt_id @mt_id end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
71 72 73 |
# File 'lib/ie/external_route.rb', line 71 def tag @tag end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
71 72 73 |
# File 'lib/ie/external_route.rb', line 71 def type @type end |
Class Method Details
.new_hash(h) ⇒ Object
182 183 184 185 186 187 188 189 |
# File 'lib/ie/external_route.rb', line 182 def ExternalRoute_Base.new_hash(h) raise unless h.is_a?(Hash) if h.has_key? :mt_metrics MtExternalRoute.new(h) else ExternalRoute.new(h) end end |
Instance Method Details
#encode ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/ie/external_route.rb', line 104 def encode external =[] external << encoded_e_id_metric external << forwarding_address.encode external << [tag].pack('N') external.join end |
#parse(s) ⇒ Object
112 113 114 115 116 |
# File 'lib/ie/external_route.rb', line 112 def parse(s) long1, long2, @tag = s.unpack('NNN') @type, @mt_id, @metric = parse_e_id_metric(long1) @forwarding_address = ForwardingAddress.new(long2) end |
#to_s ⇒ Object
118 119 120 |
# File 'lib/ie/external_route.rb', line 118 def to_s "#{type.to_s.upcase} (ID #{mt_id}) Metric: #{metric.to_i} Forwarding: #{forwarding_address.to_ip} Tag: #{tag}" end |
#to_s_ios ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/ie/external_route.rb', line 122 def to_s_ios # Metric Type: 1 (Comparable directly to link state metric) # TOS: 0 # Metric: 0 # Forward Address: 0.0.0.0 # External Route Tag: 0 #TODO: implement... end |