xref: /freebsd/sbin/ipf/libipf/print_toif.c (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1 
2 /*
3  * Copyright (C) 2012 by Darren Reed.
4  *
5  * See the IPFILTER.LICENCE file for details on licencing.
6  *
7  * $Id$
8  */
9 
10 #include "ipf.h"
11 
12 
13 void
14 print_toif(int family, char *tag, char *base, frdest_t *fdp)
15 {
16 	switch (fdp->fd_type)
17 	{
18 	case FRD_NORMAL :
19 		PRINTF("%s %s%s", tag, base + fdp->fd_name,
20 		       (fdp->fd_ptr || (long)fdp->fd_ptr == -1) ? "" : "(!)");
21 #ifdef	USE_INET6
22 		if (family == AF_INET6) {
23 			if (IP6_NOTZERO(&fdp->fd_ip6)) {
24 				char ipv6addr[80];
25 
26 				inet_ntop(AF_INET6, &fdp->fd_ip6, ipv6addr,
27 					  sizeof(fdp->fd_ip6));
28 				PRINTF(":%s", ipv6addr);
29 			}
30 		} else
31 #endif
32 			if (fdp->fd_ip.s_addr)
33 				PRINTF(":%s", inet_ntoa(fdp->fd_ip));
34 		putchar(' ');
35 		break;
36 
37 	case FRD_DSTLIST :
38 		PRINTF("%s dstlist/%s ", tag, base + fdp->fd_name);
39 		break;
40 
41 	default :
42 		PRINTF("%s <%d>", tag, fdp->fd_type);
43 		break;
44 	}
45 }
46