xref: /titanic_52/usr/src/cmd/ipf/lib/common/hostname.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 
2 #include "ipf.h"
3 
4 char *hostname(v, ip)
5 int v;
6 void *ip;
7 {
8 #ifdef  USE_INET6
9 	static char hostbuf[MAXHOSTNAMELEN+1];
10 #endif
11 	struct in_addr ipa;
12 
13 	if (v == 4) {
14 		ipa.s_addr = *(u_32_t *)ip;
15 		return inet_ntoa(ipa);
16 	}
17 #ifdef  USE_INET6
18 	(void) inet_ntop(AF_INET6, ip, hostbuf, sizeof(hostbuf) - 1);
19 	hostbuf[MAXHOSTNAMELEN] = '\0';
20 	return hostbuf;
21 #else
22 	return "IPv6";
23 #endif
24 }
25