1*637Sml37995 /*
2*637Sml37995  * Copyright (C) 2003 by Darren Reed.
3*637Sml37995  *
4*637Sml37995  * See the IPFILTER.LICENCE file for details on licencing.
5*637Sml37995  *
6*637Sml37995  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
7*637Sml37995  * Use is subject to license terms.
8*637Sml37995  */
9*637Sml37995 
10*637Sml37995 #pragma ident	"%Z%%M%	%I%	%E% SMI"
110Sstevel@tonic-gate 
120Sstevel@tonic-gate #include "ipf.h"
130Sstevel@tonic-gate 
140Sstevel@tonic-gate char *hostname(v, ip)
150Sstevel@tonic-gate int v;
160Sstevel@tonic-gate void *ip;
170Sstevel@tonic-gate {
180Sstevel@tonic-gate #ifdef  USE_INET6
19*637Sml37995 	static char hostbuf[INET6_ADDRSTRLEN];
200Sstevel@tonic-gate #endif
210Sstevel@tonic-gate 	struct in_addr ipa;
220Sstevel@tonic-gate 
230Sstevel@tonic-gate 	if (v == 4) {
240Sstevel@tonic-gate 		ipa.s_addr = *(u_32_t *)ip;
250Sstevel@tonic-gate 		return inet_ntoa(ipa);
260Sstevel@tonic-gate 	}
270Sstevel@tonic-gate #ifdef  USE_INET6
28*637Sml37995 	(void) inet_ntop(AF_INET6, ip, hostbuf, sizeof(hostbuf));
290Sstevel@tonic-gate 	return hostbuf;
300Sstevel@tonic-gate #else
310Sstevel@tonic-gate 	return "IPv6";
320Sstevel@tonic-gate #endif
330Sstevel@tonic-gate }
34