Class: RIB::Route
- Inherits:
-
Object
- Object
- RIB::Route
- Defined in:
- lib/netutils/rib.rb
Instance Attribute Summary collapse
-
#dst ⇒ Object
readonly
Returns the value of attribute dst.
-
#interface ⇒ Object
readonly
Returns the value of attribute interface.
-
#nh ⇒ Object
readonly
Returns the value of attribute nh.
-
#prefixlen ⇒ Object
readonly
Returns the value of attribute prefixlen.
-
#proto ⇒ Object
readonly
Returns the value of attribute proto.
Instance Method Summary collapse
- #compare(other) ⇒ Object
-
#initialize(proto, dst, nh, interface) ⇒ Route
constructor
A new instance of Route.
- #tunnel? ⇒ Boolean
Constructor Details
#initialize(proto, dst, nh, interface) ⇒ Route
Returns a new instance of Route.
7 8 9 10 11 12 13 14 |
# File 'lib/netutils/rib.rb', line 7 def initialize(proto, dst, nh, interface) dst = ip_address_normalize(dst) @proto = proto @dst = dst @prefixlen = prefixlen_get(dst) @nh = nh @interface = interface end |
Instance Attribute Details
#dst ⇒ Object (readonly)
Returns the value of attribute dst.
5 6 7 |
# File 'lib/netutils/rib.rb', line 5 def dst @dst end |
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
5 6 7 |
# File 'lib/netutils/rib.rb', line 5 def interface @interface end |
#nh ⇒ Object (readonly)
Returns the value of attribute nh.
5 6 7 |
# File 'lib/netutils/rib.rb', line 5 def nh @nh end |
#prefixlen ⇒ Object (readonly)
Returns the value of attribute prefixlen.
5 6 7 |
# File 'lib/netutils/rib.rb', line 5 def prefixlen @prefixlen end |
#proto ⇒ Object (readonly)
Returns the value of attribute proto.
5 6 7 |
# File 'lib/netutils/rib.rb', line 5 def proto @proto end |
Instance Method Details
#compare(other) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/netutils/rib.rb', line 44 def compare(other) return self if ! other if defined?(PREFERRED_NEXTHOPS) PREFERRED_NEXTHOPS.each do |prefix| ir = IPAddr.new(prefix) if ir.include?(@nh) && ! ir.include?(other.nh) return self elsif ! ir.include?(@nh) && ir.include?(other.nh) return other end end end return other if @prefixlen < other.prefixlen return self end |
#tunnel? ⇒ Boolean
40 41 42 |
# File 'lib/netutils/rib.rb', line 40 def tunnel? @interface =~ /^[tT]unnel/ end |