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