More handler separation: e.g. RouteHandler or VlanHandler can call LinkHandler

This commit is contained in:
Brian Candler
2011-05-03 15:59:07 +01:00
parent a2735b4d4d
commit 3f4c6c7235
12 changed files with 667 additions and 498 deletions

View File

@@ -8,9 +8,17 @@ require 'netlink/route'
# The data is memoized - that is, it's downloaded from the kernel once
# and then manipulated internally.
nl = Netlink::Route::Socket.new
pp nl.if["eth0"]
pp nl.if.addrs["eth0"]
rt = Netlink::Route::Socket.new
# Find the route with the shortest prefix len (probably default route)
pp nl.rt[Socket::AF_INET].min_by { |route| route.dst_len }
puts "\nInterface eth0:"
pp rt.links["eth0"]
puts "\nAddresses on interface eth0:"
pp rt.addrs.list(:index=>"eth0").to_a
puts "\nAll routes in main routing table:"
pp rt.routes.list(:family=>Socket::AF_INET, :table=>Netlink::RT_TABLE_MAIN).to_a
puts "\nDefault route is probably:"
pp rt.routes.list(:family=>Socket::AF_INET, :table=>Netlink::RT_TABLE_MAIN).
min_by { |route| route.dst_len }