Sync usage with man page.
[netbsd-mini2440.git] / dist / ipf / lib / printactivenat.c
blobe9866cf5bc9c97db0fa2980151da53b1adf0010b
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2002-2004 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com)
9 */
11 #include "ipf.h"
14 #if !defined(lint)
15 static const char rcsid[] = "@(#)Id: printactivenat.c,v 1.3.2.7 2006/12/12 16:13:00 darrenr Exp";
16 #endif
19 void printactivenat(nat, opts, alive, now)
20 nat_t *nat;
21 int opts, alive;
22 u_long now;
25 printf("%s", getnattype(nat, alive));
27 if (nat->nat_flags & SI_CLONE)
28 printf(" CLONE");
30 printf(" %-15s", inet_ntoa(nat->nat_inip));
32 if ((nat->nat_flags & IPN_TCPUDP) != 0)
33 printf(" %-5hu", ntohs(nat->nat_inport));
35 printf(" <- -> %-15s",inet_ntoa(nat->nat_outip));
37 if ((nat->nat_flags & IPN_TCPUDP) != 0)
38 printf(" %-5hu", ntohs(nat->nat_outport));
40 printf(" [%s", inet_ntoa(nat->nat_oip));
41 if ((nat->nat_flags & IPN_TCPUDP) != 0)
42 printf(" %hu", ntohs(nat->nat_oport));
43 printf("]");
45 if (opts & OPT_VERBOSE) {
46 printf("\n\tttl %lu use %hu sumd %s/",
47 nat->nat_age - now, nat->nat_use,
48 getsumd(nat->nat_sumd[0]));
49 printf("%s pr %u bkt %d/%d flags %x\n",
50 getsumd(nat->nat_sumd[1]), nat->nat_p,
51 nat->nat_hv[0], nat->nat_hv[1], nat->nat_flags);
52 printf("\tifp %s", getifname(nat->nat_ifps[0]));
53 printf(",%s ", getifname(nat->nat_ifps[1]));
54 #ifdef USE_QUAD_T
55 printf("bytes %qu/%qu pkts %qu/%qu",
56 (unsigned long long)nat->nat_bytes[0],
57 (unsigned long long)nat->nat_bytes[1],
58 (unsigned long long)nat->nat_pkts[0],
59 (unsigned long long)nat->nat_pkts[1]);
60 #else
61 printf("bytes %lu/%lu pkts %lu/%lu", nat->nat_bytes[0],
62 nat->nat_bytes[1], nat->nat_pkts[0], nat->nat_pkts[1]);
63 #endif
64 printf(" ipsumd %x", nat->nat_ipsumd);
67 if (opts & OPT_DEBUG) {
68 printf("\n\tnat_next %p _pnext %p _hm %p\n",
69 nat->nat_next, nat->nat_pnext, nat->nat_hm);
70 printf("\t_hnext %p/%p _phnext %p/%p\n",
71 nat->nat_hnext[0], nat->nat_hnext[1],
72 nat->nat_phnext[0], nat->nat_phnext[1]);
73 printf("\t_data %p _me %p _state %p _aps %p\n",
74 nat->nat_data, nat->nat_me, nat->nat_state, nat->nat_aps);
75 printf("\tfr %p ptr %p ifps %p/%p sync %p\n",
76 nat->nat_fr, nat->nat_ptr, nat->nat_ifps[0],
77 nat->nat_ifps[1], nat->nat_sync);
78 printf("\ttqe:pnext %p next %p ifq %p parent %p/%p\n",
79 nat->nat_tqe.tqe_pnext, nat->nat_tqe.tqe_next,
80 nat->nat_tqe.tqe_ifq, nat->nat_tqe.tqe_parent, nat);
81 printf("\ttqe:die %ld touched %ld flags %x state %d/%d\n",
82 nat->nat_tqe.tqe_die, nat->nat_tqe.tqe_touched,
83 nat->nat_tqe.tqe_flags, nat->nat_tqe.tqe_state[0],
84 nat->nat_tqe.tqe_state[1]);
86 putchar('\n');