xref: /netbsd-src/external/bsd/ipf/dist/lib/print_toif.c (revision b757af438b42b93f8c6571f026d8b8ef3eaf5fc9)
1 /*	$NetBSD: print_toif.c,v 1.1.1.1 2012/03/23 21:20:09 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2010 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(tag, base, fdp)
16 	char *tag;
17 	char *base;
18 	frdest_t *fdp;
19 {
20 	switch (fdp->fd_type)
21 	{
22 	case FRD_NORMAL :
23 		PRINTF("%s %s%s", tag, base + fdp->fd_name,
24 		       (fdp->fd_ptr || (long)fdp->fd_ptr == -1) ? "" : "(!)");
25 #ifdef	USE_INET6
26 		if (use_inet6 && IP6_NOTZERO(&fdp->fd_ip6.in6)) {
27 			char ipv6addr[80];
28 
29 			inet_ntop(AF_INET6, &fdp->fd_ip6, ipv6addr,
30 				  sizeof(fdp->fd_ip6));
31 			PRINTF(":%s", ipv6addr);
32 		} else
33 #endif
34 			if (fdp->fd_ip.s_addr)
35 				PRINTF(":%s", inet_ntoa(fdp->fd_ip));
36 		putchar(' ');
37 		break;
38 
39 	case FRD_DSTLIST :
40 		PRINTF("%s dstlist/%s ", tag, base + fdp->fd_name);
41 		break;
42 
43 	default :
44 		PRINTF("%s <%d>", tag, fdp->fd_type);
45 		break;
46 	}
47 }
48