xref: /netbsd-src/external/bsd/ipf/dist/lib/printhost.c (revision f44489f8dc8d71cd25a1bf30a50ca8ed13a40da3)
1 /*	$NetBSD: printhost.c,v 1.3 2014/12/20 13:15:48 prlw1 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
printhost(family,addr)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 #ifdef  USE_INET6
29 		void *ptr = addr;
30 
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