1 /* $NetBSD: numtohost.c,v 1.2 2003/12/04 16:23:37 drochner Exp $ */
4 * numtohost - convert network number to host name.
8 #include "ntp_stdlib.h"
9 #include "lib_strbuf.h"
11 #define LOOPBACKNET 0x7f000000
12 #define LOOPBACKHOST 0x7f000001
13 #define LOOPBACKNETMASK 0xff000000
24 * This is really gross, but saves lots of hanging looking for
25 * hostnames for the radio clocks. Don't bother looking up
26 * addresses on the loopback network except for the loopback
29 if ((((ntohl(netnum
) & LOOPBACKNETMASK
) == LOOPBACKNET
)
30 && (ntohl(netnum
) != LOOPBACKHOST
))
31 || ((hp
= gethostbyaddr((char *)&netnum
, sizeof netnum
, AF_INET
))
33 return numtoa(netnum
);
37 bp
[LIB_BUFLENGTH
-1] = '\0';
38 (void) strncpy(bp
, hp
->h_name
, LIB_BUFLENGTH
-1);