2 * Copyright (C) 2003 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
7 * Use is subject to license terms.
10 #pragma ident "%Z%%M% %I% %E% SMI"
18 static char hostbuf
[MAXHOSTNAMELEN
+1];
24 ipa
.s_addr
= *(u_32_t
*)ip
;
25 if (ipa
.s_addr
== htonl(0xfedcba98))
26 return "test.host.dots";
29 if ((opts
& OPT_NORESOLVE
) == 0) {
31 hp
= gethostbyaddr(ip
, 4, AF_INET
);
32 if (hp
!= NULL
&& hp
->h_name
!= NULL
&&
33 *hp
->h_name
!= '\0') {
34 strncpy(hostbuf
, hp
->h_name
, sizeof(hostbuf
));
35 hostbuf
[sizeof(hostbuf
) - 1] = '\0';
39 np
= getnetbyaddr(ipa
.s_addr
, AF_INET
);
40 if (np
!= NULL
&& np
->n_name
!= NULL
&&
41 *np
->n_name
!= '\0') {
42 strncpy(hostbuf
, np
->n_name
, sizeof(hostbuf
));
43 hostbuf
[sizeof(hostbuf
) - 1] = '\0';
50 return inet_ntoa(ipa
);
53 (void) inet_ntop(AF_INET6
, ip
, hostbuf
, sizeof(hostbuf
) - 1);
54 hostbuf
[MAXHOSTNAMELEN
] = '\0';