New upstream release.
This commit is contained in:
6
debian/changelog
vendored
6
debian/changelog
vendored
@@ -1,3 +1,9 @@
|
|||||||
|
ruby-linux-netlink (0.16-1+wheezy1) stable; urgency=medium
|
||||||
|
|
||||||
|
* New upstream release.
|
||||||
|
|
||||||
|
-- Patrick J Cherry <patch@dynamo> Tue, 26 Aug 2014 16:33:48 +0100
|
||||||
|
|
||||||
ruby-linux-netlink (0.15-1+wheezy1) stable; urgency=low
|
ruby-linux-netlink (0.15-1+wheezy1) stable; urgency=low
|
||||||
|
|
||||||
* New upstream release.
|
* New upstream release.
|
||||||
|
@@ -310,24 +310,27 @@ module Linux
|
|||||||
VLAN_FLAG_MVRP = 0x8
|
VLAN_FLAG_MVRP = 0x8
|
||||||
|
|
||||||
# from linux/if_addr.h
|
# from linux/if_addr.h
|
||||||
IFA_UNSPEC = 0
|
IFA_UNSPEC = 0
|
||||||
IFA_ADDRESS = 1
|
IFA_ADDRESS = 1
|
||||||
IFA_LOCAL = 2
|
IFA_LOCAL = 2
|
||||||
IFA_LABEL = 3
|
IFA_LABEL = 3
|
||||||
IFA_BROADCAST = 4
|
IFA_BROADCAST = 4
|
||||||
IFA_ANYCAST = 5
|
IFA_ANYCAST = 5
|
||||||
IFA_CACHEINFO = 6
|
IFA_CACHEINFO = 6
|
||||||
IFA_MULTICAST = 7
|
IFA_MULTICAST = 7
|
||||||
|
IFA_FLAGS = 8
|
||||||
|
|
||||||
IFA_F_SECONDARY = 0x01
|
IFA_F_SECONDARY = 0x01
|
||||||
IFA_F_TEMPORARY = IFA_F_SECONDARY
|
IFA_F_TEMPORARY = IFA_F_SECONDARY
|
||||||
IFA_F_NODAD = 0x02
|
IFA_F_NODAD = 0x02
|
||||||
IFA_F_OPTIMISTIC = 0x04
|
IFA_F_OPTIMISTIC = 0x04
|
||||||
IFA_F_DADFAILED = 0x08
|
IFA_F_DADFAILED = 0x08
|
||||||
IFA_F_HOMEADDRESS = 0x10
|
IFA_F_HOMEADDRESS = 0x10
|
||||||
IFA_F_DEPRECATED = 0x20
|
IFA_F_DEPRECATED = 0x20
|
||||||
IFA_F_TENTATIVE = 0x40
|
IFA_F_TENTATIVE = 0x40
|
||||||
IFA_F_PERMANENT = 0x80
|
IFA_F_PERMANENT = 0x80
|
||||||
|
IFA_F_MANAGETEMPADDR = 0x100
|
||||||
|
IFA_F_NOPREFIXROUTE = 0x200
|
||||||
|
|
||||||
# from linux/if_arp.h - selected subset
|
# from linux/if_arp.h - selected subset
|
||||||
ARPHRD_NETROM = 0
|
ARPHRD_NETROM = 0
|
||||||
|
@@ -187,7 +187,7 @@ module Netlink
|
|||||||
warn "Duplicate attribute #{name} (#{code}): #{attrs[name].inspect} -> #{val.inspect}" if attrs[name]
|
warn "Duplicate attribute #{name} (#{code}): #{attrs[name].inspect} -> #{val.inspect}" if attrs[name]
|
||||||
attrs[name] = val
|
attrs[name] = val
|
||||||
else
|
else
|
||||||
warn "Unknown attribute #{code}, in class #{self}, value #{val.inspect}"
|
warn "Unknown attribute #{code}, in class #{self}, value #{val.inspect}" if $DEBUG
|
||||||
attrs[code] = val
|
attrs[code] = val
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -58,14 +58,16 @@ module Netlink
|
|||||||
# :timeout => N (seconds, default to DEFAULT_TIMEOUT. Pass nil for no timeout)
|
# :timeout => N (seconds, default to DEFAULT_TIMEOUT. Pass nil for no timeout)
|
||||||
# :junk_handler => lambda { ... } for unexpected packets
|
# :junk_handler => lambda { ... } for unexpected packets
|
||||||
def initialize(opt)
|
def initialize(opt)
|
||||||
@socket ||= opt[:socket] || ::Socket.new(
|
@socket = opt[:socket] || ::Socket.new(
|
||||||
Socket::AF_NETLINK,
|
Socket::AF_NETLINK,
|
||||||
Socket::SOCK_DGRAM,
|
Socket::SOCK_DGRAM,
|
||||||
opt[:protocol] || (raise "Missing :protocol")
|
opt[:protocol] || (raise "Missing :protocol")
|
||||||
)
|
)
|
||||||
@socket.bind(NLSocket.sockaddr(opt)) unless opt[:socket]
|
@socket.bind(NLSocket.sockaddr(opt)) unless opt[:socket]
|
||||||
@seq = opt[:seq] || Time.now.to_i
|
@seq = opt[:seq] || Time.now.to_i
|
||||||
@pid = opt[:pid] || $$
|
|
||||||
|
@pid = @socket.getsockname.unpack(SOCKADDR_PACK)[2]
|
||||||
|
|
||||||
@timeout = opt.has_key?(:timeout) ? opt[:timeout] : DEFAULT_TIMEOUT
|
@timeout = opt.has_key?(:timeout) ? opt[:timeout] : DEFAULT_TIMEOUT
|
||||||
if opt.has_key?(:junk_handler)
|
if opt.has_key?(:junk_handler)
|
||||||
@junk_handler = opt[:junk_handler]
|
@junk_handler = opt[:junk_handler]
|
||||||
@@ -75,7 +77,7 @@ module Netlink
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Close the Netlink socket
|
# Close the Netlink socket
|
||||||
def close
|
def close
|
||||||
@socket.close
|
@socket.close
|
||||||
@@ -85,7 +87,7 @@ module Netlink
|
|||||||
def next_seq
|
def next_seq
|
||||||
@seq = (@seq + 1) & 0xffffffff
|
@seq = (@seq + 1) & 0xffffffff
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a header and send a single message over the socket.
|
# Add a header and send a single message over the socket.
|
||||||
# type:: the message type code
|
# type:: the message type code
|
||||||
# msg:: the message to send (without header)
|
# msg:: the message to send (without header)
|
||||||
@@ -203,7 +205,7 @@ module Netlink
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Receive one datagram from kernel. Validates the sender, and returns
|
# Receive one datagram from kernel. Validates the sender, and returns
|
||||||
# the raw binary message. Raises an exception on timeout or if the
|
# the raw binary message. Raises an exception on timeout or if the
|
||||||
# kernel closes the socket.
|
# kernel closes the socket.
|
||||||
|
@@ -24,6 +24,10 @@ module Netlink
|
|||||||
:pack => lambda { |val,obj| val.to_a.pack("L*") },
|
:pack => lambda { |val,obj| val.to_a.pack("L*") },
|
||||||
:unpack => lambda { |str,obj| IFACacheInfo.new(*(str.unpack("L*"))) }
|
:unpack => lambda { |str,obj| IFACacheInfo.new(*(str.unpack("L*"))) }
|
||||||
rtattr :multicast, IFA_MULTICAST, :l3addr
|
rtattr :multicast, IFA_MULTICAST, :l3addr
|
||||||
|
|
||||||
|
# TODO: is there any difference between flags and ifa_flags? The latter only
|
||||||
|
# shows up on newer kernels
|
||||||
|
rtattr :ifa_flags, IFA_FLAGS, :uint
|
||||||
end
|
end
|
||||||
|
|
||||||
module Route
|
module Route
|
||||||
|
@@ -1,10 +1,6 @@
|
|||||||
require File.join(File.dirname(__FILE__), 'test_helper')
|
require File.expand_path( File.join(File.dirname(__FILE__), 'test_helper') )
|
||||||
require 'linux/netlink/route'
|
require 'linux/netlink/route'
|
||||||
|
|
||||||
# Note: multiple sockets bound to the same PID seem to cause timeout problems.
|
|
||||||
# (Should we use different algorithm for generating the PID? PID + seq?)
|
|
||||||
$ip ||= Linux::Netlink::Route::Socket.new
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Ruby 1.8.7 appears to lack the KeyError constant.
|
# Ruby 1.8.7 appears to lack the KeyError constant.
|
||||||
#
|
#
|
||||||
@@ -15,7 +11,7 @@ end
|
|||||||
class TestAddr < Test::Unit::TestCase
|
class TestAddr < Test::Unit::TestCase
|
||||||
context "With netlink route socket" do
|
context "With netlink route socket" do
|
||||||
setup do
|
setup do
|
||||||
@ip = $ip
|
@ip = Linux::Netlink::Route::Socket.new
|
||||||
@ifname = nil
|
@ifname = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -25,12 +21,25 @@ class TestAddr < Test::Unit::TestCase
|
|||||||
rescue KeyError, IndexError
|
rescue KeyError, IndexError
|
||||||
# Do nothing
|
# Do nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ip.close
|
||||||
end
|
end
|
||||||
|
|
||||||
test "Read link type" do
|
test "Read link type" do
|
||||||
assert_equal Linux::ARPHRD_LOOPBACK, @ip.link["lo"].type
|
assert_equal Linux::ARPHRD_LOOPBACK, @ip.link["lo"].type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "Both sockets work if two are open at the same time" do
|
||||||
|
begin
|
||||||
|
@ip2 = Linux::Netlink::Route::Socket.new
|
||||||
|
|
||||||
|
assert_kind_of Enumerable, @ip.route.list
|
||||||
|
assert_kind_of Enumerable, @ip2.route.list
|
||||||
|
ensure
|
||||||
|
@ip2.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def create_test_interface(ifname = "test_#{$$}")
|
def create_test_interface(ifname = "test_#{$$}")
|
||||||
begin
|
begin
|
||||||
@ip.link.add(
|
@ip.link.add(
|
||||||
|
Reference in New Issue
Block a user