xref: /netbsd-src/external/bsd/ipf/dist/lib/printhost.c (revision 6a493d6bc668897c91594964a732d38505b70cbb)
1 /*	$NetBSD: printhost.c,v 1.2 2012/07/22 14:27:36 darrenr Exp $	*/
2 
3 /*
4  * Copyright (C) 2012 by Darren Reed.
5  *
6  * See the IPFILTER.LICENCE file for details on licencing.
7  *
8  * Id: printhost.c,v 1.1.1.2 2012/07/22 13:44:40 darrenr Exp $
9  */
10 
11 #include "ipf.h"
12 
13 
14 void
15 printhost(family, addr)
16 	int	family;
17 	u_32_t	*addr;
18 {
19 #ifdef  USE_INET6
20 	char ipbuf[64];
21 #else
22 	struct in_addr ipa;
23 #endif
24 
25 	if ((family == -1) || !*addr)
26 		PRINTF("any");
27 	else {
28 		void *ptr = addr;
29 
30 #ifdef  USE_INET6
31 		PRINTF("%s", inet_ntop(family, ptr, ipbuf, sizeof(ipbuf)));
32 #else
33 		ipa.s_addr = *addr;
34 		PRINTF("%s", inet_ntoa(ipa));
35 #endif
36 	}
37 }
38