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