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