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

21
examples/add_route.rb Normal file
View File

@@ -0,0 +1,21 @@
LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift LIBDIR
require 'netlink/route'
nl = Netlink::Route::Socket.new
puts "\n*** Before adding route"
nl.routes.list(:family=>Socket::AF_INET, :table=>Netlink::RT_TABLE_MAIN) { |x| p x }
puts "\n*** After adding route"
begin
nl.routes.add(:oif=>"lo", :dst=>"1.2.3.4", :dst_len=>32, :gateway=>"127.0.0.1")
rescue Errno::EEXIST
puts "Already exists"
end
nl.routes.list(:family=>Socket::AF_INET, :table=>Netlink::RT_TABLE_MAIN) { |x| p x }
puts "\n*** After deleting route"
nl.routes.delete(:oif=>"lo", :dst=>"1.2.3.4", :dst_len=>32, :gateway=>"127.0.0.1")
nl.routes.list(:family=>Socket::AF_INET, :table=>Netlink::RT_TABLE_MAIN) { |x| p x }