Subject: UDP and ICMP unreach
To: NetBSD Users <netbsd-users@NetBSD.org>
From: Jorgen Lundman <lundman@lundman.net>
List: netbsd-users
Date: 02/10/2005 16:09:55
If I open a standard UDP socket in nonblocking mode, and use sendto() to send 
packets around the place, but I would like to somehow detect the situation where 
the remote host send ICMP unreachable.

Looking at traceroute, it appears to use a RAW socket and build the UDP packets 
itself. Supposedly, I can also open just a RAW listening socket and weed out 
those packets I am interested in (?).

I am under the impression that if I call connect() on my UDP socket, I should 
also receive EHOSTUNREACH, but the man-page also specify that I will only 
receive packets from said host, which is not so handy if I use my UDP socket to 
send to multiple destinations.

I have, unsuccessfully, attempted to trace the route in the kernel sources 
between ip_icmp.c, to udp_usrreq.c's notify() function but I am unsure where my 
async error code goes amiss.

I do notice that Windows 2000 will give me error 10054 in this situation, is 
there anything reasonable one can do to enable such detection? setsockopt() ?

Any reply is appreciated,

Lund

-- 
Jorgen Lundman       | <lundman@lundman.net>
Unix Administrator   | +81 (0)3 -5456-2687 ext 1017 (work)
Shibuya-ku, Tokyo    | +81 (0)90-5578-8500          (cell)
Japan                | +81 (0)3 -3375-1767          (home)