xref: /titanic_51/usr/src/cmd/ipf/lib/common/hostname.c (revision 42487ff1899d230ad6c2d55cf9573489ca5eb770)
1 /*
2  * Copyright (C) 2003 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  *
6  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
7  * Use is subject to license terms.
8  */
9 
10 #pragma ident	"%Z%%M%	%I%	%E% SMI"
11 
12 #include "ipf.h"
13 
14 char *hostname(v, ip)
15 int v;
16 void *ip;
17 {
18 #ifdef  USE_INET6
19 	static char hostbuf[INET6_ADDRSTRLEN];
20 #endif
21 	struct in_addr ipa;
22 
23 	if (v == 4) {
24 		ipa.s_addr = *(u_32_t *)ip;
25 		return inet_ntoa(ipa);
26 	}
27 #ifdef  USE_INET6
28 	(void) inet_ntop(AF_INET6, ip, hostbuf, sizeof(hostbuf));
29 	return hostbuf;
30 #else
31 	return "IPv6";
32 #endif
33 }
34