Paul> Does anyone have some C source that can convert a dot-formatted
Paul> IP address into the original hostname? Essentially, this
Paul> should provide the same functionality as `nslookup` invoked in
Paul> a similar manner.
The basic idea is to use inet_aton() to parse the numeric address,
then gethostbyaddr() to look up the host name.
There is one thing you should be cautious of, though: the person
controlling the reverse DNS for any given address can supply any hostname
he wants for that address, even hostnames that don't belong to him. If
you are using reverse-lookups in any security-relevent situation (which
includes any case where hostnames are being logged rather than raw IP
numbers), then you should verify that the claimed name does actually
belong to the specified IP number, by looking up the name with
gethostbyname() and checking that the original IP address appears
somewhere in the list of addresses for that hostname.
--
Andrew.