2011-04-30 22:39:25 +01:00
|
|
|
# This file implements the messages and methods for the NETLINK_ROUTE protocol
|
|
|
|
|
|
|
|
require 'netlink/nlsocket'
|
|
|
|
require 'netlink/message'
|
|
|
|
|
|
|
|
module Netlink
|
2011-05-01 09:29:02 +01:00
|
|
|
module Route
|
2011-05-03 12:41:10 +01:00
|
|
|
autoload :IFHandler, 'netlink/route/if_handler'
|
|
|
|
autoload :RTHandler, 'netlink/route/rt_handler'
|
|
|
|
|
2011-05-02 22:52:47 +01:00
|
|
|
# This class formats and receives messages using NETLINK_ROUTE protocol
|
2011-05-01 09:29:02 +01:00
|
|
|
class Socket < NLSocket
|
|
|
|
def initialize(opt={})
|
|
|
|
super(opt.merge(:protocol => Netlink::NETLINK_ROUTE))
|
|
|
|
end
|
2011-04-30 22:39:25 +01:00
|
|
|
|
2011-05-03 12:41:10 +01:00
|
|
|
# Return a Netlink::Route::IF object for manipulating interfaces
|
|
|
|
# and interface addresses
|
|
|
|
def if(reload=false)
|
|
|
|
@if = nil if reload
|
|
|
|
@if ||= Netlink::Route::IFHandler.new(self)
|
2011-05-01 09:29:02 +01:00
|
|
|
end
|
|
|
|
|
2011-05-03 12:41:10 +01:00
|
|
|
# Return a Netlink::Route::RT object for manipulating routes
|
|
|
|
def rt(reload=false)
|
|
|
|
@rt = nil if reload
|
|
|
|
@rt ||= Netlink::Route::RTHandler.new(self)
|
2011-05-01 09:29:02 +01:00
|
|
|
end
|
2011-04-30 22:39:25 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|