1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Show nd6 options and whether the packet is reached to the server or not.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-07-24 03:09:32 +00:00
parent f83a2eee05
commit 040207ea01

View file

@ -309,6 +309,7 @@ class TestSocket < Test::Unit::TestCase
Socket.udp_server_sockets(0) {|sockets| Socket.udp_server_sockets(0) {|sockets|
famlies = {} famlies = {}
sockets.each {|s| famlies[s.local_address.afamily] = s } sockets.each {|s| famlies[s.local_address.afamily] = s }
nd6 = {}
ip_addrs.reject! {|ai| ip_addrs.reject! {|ai|
s = famlies[ai.afamily] s = famlies[ai.afamily]
next true unless s next true unless s
@ -330,7 +331,9 @@ class TestSocket < Test::Unit::TestCase
ulND6_IFF_IFDISABLED = 8 ulND6_IFF_IFDISABLED = 8
in6_ondireq = ifr_name in6_ondireq = ifr_name
s.ioctl(ulSIOCGIFINFO_IN6, in6_ondireq) s.ioctl(ulSIOCGIFINFO_IN6, in6_ondireq)
next true if in6_ondireq.unpack('A16L6').last & ulND6_IFF_IFDISABLED != 0 flag = in6_ondireq.unpack('A16L6').last
next true if flag & ulND6_IFF_IFDISABLED != 0
nd6[ai] = flag
end end
when /darwin/ when /darwin/
if !ai.ipv6? if !ai.ipv6?
@ -345,7 +348,9 @@ class TestSocket < Test::Unit::TestCase
ulND6_IFF_IFDISABLED = 8 ulND6_IFF_IFDISABLED = 8
in6_ondireq = ifr_name in6_ondireq = ifr_name
s.ioctl(ulSIOCGIFINFO_IN6, in6_ondireq) s.ioctl(ulSIOCGIFINFO_IN6, in6_ondireq)
next true if in6_ondireq.unpack('A16L6').last & ulND6_IFF_IFDISABLED != 0 flag = in6_ondireq.unpack('A16L6').last
next true if (flag & ulND6_IFF_IFDISABLED) != 0
nd6[ai] = flag
in6_ifreq = [ifr_name,ai.to_sockaddr].pack('a16A*') in6_ifreq = [ifr_name,ai.to_sockaddr].pack('a16A*')
s.ioctl(ulSIOCGIFFLAGS, in6_ifreq) s.ioctl(ulSIOCGIFFLAGS, in6_ifreq)
next true if in6_ifreq.unpack('A16L1').last & ulIFF_POINTOPOINT != 0 next true if in6_ifreq.unpack('A16L1').last & ulIFF_POINTOPOINT != 0
@ -356,25 +361,30 @@ class TestSocket < Test::Unit::TestCase
end end
end end
end end
false
} }
skipped = false skipped = false
begin begin
port = sockets.first.local_address.ip_port port = sockets.first.local_address.ip_port
ping_p = false
th = Thread.new { th = Thread.new {
Socket.udp_server_loop_on(sockets) {|msg, msg_src| Socket.udp_server_loop_on(sockets) {|msg, msg_src|
break if msg == "exit" break if msg == "exit"
rmsg = Marshal.dump([msg, msg_src.remote_address, msg_src.local_address]) rmsg = Marshal.dump([msg, msg_src.remote_address, msg_src.local_address])
ping_p = true
msg_src.reply rmsg msg_src.reply rmsg
} }
} }
ip_addrs.each {|ai| ip_addrs.each {|ai|
Addrinfo.udp(ai.ip_address, port).connect {|s| Addrinfo.udp(ai.ip_address, port).connect {|s|
ping_p = false
msg1 = "<<<#{ai.inspect}>>>" msg1 = "<<<#{ai.inspect}>>>"
s.sendmsg msg1 s.sendmsg msg1
unless IO.select([s], nil, nil, 10) unless IO.select([s], nil, nil, 10)
raise "no response from #{ai.inspect}" nd6options = nd6.key?(ai) ? "nd6=%x " % nd6[ai] : ''
raise "no response from #{ai.inspect} #{nd6options}ping=#{ping_p}"
end end
msg2, addr = s.recvmsg msg2, addr = s.recvmsg
msg2, remote_address, local_address = Marshal.load(msg2) msg2, remote_address, local_address = Marshal.load(msg2)