xref: /freebsd/sbin/ipf/libipf/printhost.c (revision efeb8bffe34422937c7f8df836afb5b817366d16)
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
printhost(int family,u_32_t * addr)13 printhost(int family, u_32_t *addr)
14 {
15 #ifdef  USE_INET6
16 	char ipbuf[64];
17 #else
18 	struct in_addr ipa;
19 #endif
20 
21 	if ((family == -1) || !*addr)
22 		PRINTF("any");
23 	else {
24 #ifdef  USE_INET6
25 		void *ptr = addr;
26 
27 		PRINTF("%s", inet_ntop(family, ptr, ipbuf, sizeof(ipbuf)));
28 #else
29 		ipa.s_addr = *addr;
30 		PRINTF("%s", inet_ntoa(ipa));
31 #endif
32 	}
33 }
34