4 * numtohost - convert network number to host name.
9 #ifdef HAVE_NETINET_IN_H
10 #include <netinet/in.h> /* ntohl */
14 #include "ntp_stdlib.h"
15 #include "lib_strbuf.h"
17 #define LOOPBACKNET 0x7f000000
18 #define LOOPBACKHOST 0x7f000001
19 #define LOOPBACKNETMASK 0xff000000
30 * This is really gross, but saves lots of hanging looking for
31 * hostnames for the radio clocks. Don't bother looking up
32 * addresses on the loopback network except for the loopback
35 if ((((ntohl(netnum
) & LOOPBACKNETMASK
) == LOOPBACKNET
)
36 && (ntohl(netnum
) != LOOPBACKHOST
))
37 || ((hp
= gethostbyaddr((char *)&netnum
, sizeof netnum
, AF_INET
))
39 return numtoa(netnum
);
43 bp
[LIB_BUFLENGTH
-1] = '\0';
44 (void) strncpy(bp
, hp
->h_name
, LIB_BUFLENGTH
-1);