1ab25eeb5Syz155240 /*
2*d6c23f6fSyx160601 * Copyright (C) 2002-2004 by Darren Reed.
3ab25eeb5Syz155240 *
4ab25eeb5Syz155240 * See the IPFILTER.LICENCE file for details on licencing.
5ab25eeb5Syz155240 */
6ab25eeb5Syz155240
7f4b3ec61Sdh155122 #pragma ident "%Z%%M% %I% %E% SMI"
8f4b3ec61Sdh155122
9ab25eeb5Syz155240 #include "ipf.h"
10ab25eeb5Syz155240
11ab25eeb5Syz155240
12ab25eeb5Syz155240 #if !defined(lint)
13ab25eeb5Syz155240 static const char rcsid[] = "@(#)$Id: printactivenat.c,v 1.3.2.4 2004/05/11 16:07:32 darrenr Exp $";
14ab25eeb5Syz155240 #endif
15ab25eeb5Syz155240
16ab25eeb5Syz155240
printactivenat(nat,opts,alive)17f4b3ec61Sdh155122 void printactivenat(nat, opts, alive)
18ab25eeb5Syz155240 nat_t *nat;
19f4b3ec61Sdh155122 int opts, alive;
20ab25eeb5Syz155240 {
21ab25eeb5Syz155240
22f4b3ec61Sdh155122 printf("%s", getnattype(nat, alive));
23ab25eeb5Syz155240
24ab25eeb5Syz155240 if (nat->nat_flags & SI_CLONE)
25ab25eeb5Syz155240 printf(" CLONE");
26ab25eeb5Syz155240
27*d6c23f6fSyx160601 printactiveaddress(nat->nat_v, " %-15s", &nat->nat_inip6,
28*d6c23f6fSyx160601 nat->nat_ifnames[0]);
29ab25eeb5Syz155240
30ab25eeb5Syz155240 if ((nat->nat_flags & IPN_TCPUDP) != 0)
31ab25eeb5Syz155240 printf(" %-5hu", ntohs(nat->nat_inport));
32ab25eeb5Syz155240
33*d6c23f6fSyx160601 printf(" <- -> ");
34*d6c23f6fSyx160601 printactiveaddress(nat->nat_v, "%-15s", &nat->nat_outip6,
35*d6c23f6fSyx160601 nat->nat_ifnames[0]);
36ab25eeb5Syz155240
37ab25eeb5Syz155240 if ((nat->nat_flags & IPN_TCPUDP) != 0)
38ab25eeb5Syz155240 printf(" %-5hu", ntohs(nat->nat_outport));
39ab25eeb5Syz155240
40*d6c23f6fSyx160601 printf(" [");
41*d6c23f6fSyx160601 printactiveaddress(nat->nat_v, "%s", &nat->nat_oip6,
42*d6c23f6fSyx160601 nat->nat_ifnames[0]);
43*d6c23f6fSyx160601
44ab25eeb5Syz155240 if ((nat->nat_flags & IPN_TCPUDP) != 0)
45ab25eeb5Syz155240 printf(" %hu", ntohs(nat->nat_oport));
46ab25eeb5Syz155240 printf("]");
47ab25eeb5Syz155240
48ab25eeb5Syz155240 if (opts & OPT_VERBOSE) {
49ab25eeb5Syz155240 printf("\n\tage %lu use %hu sumd %s/",
50ab25eeb5Syz155240 nat->nat_age, nat->nat_use, getsumd(nat->nat_sumd[0]));
51ab25eeb5Syz155240 printf("%s pr %u bkt %d/%d flags %x\n",
52ab25eeb5Syz155240 getsumd(nat->nat_sumd[1]), nat->nat_p,
53ab25eeb5Syz155240 nat->nat_hv[0], nat->nat_hv[1], nat->nat_flags);
54ab25eeb5Syz155240 printf("\tifp %s", getifname(nat->nat_ifps[0]));
55ab25eeb5Syz155240 printf(",%s ", getifname(nat->nat_ifps[1]));
56ab25eeb5Syz155240 #ifdef USE_QUAD_T
57ab25eeb5Syz155240 printf("bytes %qu/%qu pkts %qu/%qu",
58ab25eeb5Syz155240 (unsigned long long)nat->nat_bytes[0],
59ab25eeb5Syz155240 (unsigned long long)nat->nat_bytes[1],
60ab25eeb5Syz155240 (unsigned long long)nat->nat_pkts[0],
61ab25eeb5Syz155240 (unsigned long long)nat->nat_pkts[1]);
62ab25eeb5Syz155240 #else
63ab25eeb5Syz155240 printf("bytes %lu/%lu pkts %lu/%lu", nat->nat_bytes[0],
64ab25eeb5Syz155240 nat->nat_bytes[1], nat->nat_pkts[0], nat->nat_pkts[1]);
65ab25eeb5Syz155240 #endif
66ab25eeb5Syz155240 printf(" ipsumd %x", nat->nat_ipsumd);
67ab25eeb5Syz155240 }
68ab25eeb5Syz155240
69ab25eeb5Syz155240 if (opts & OPT_DEBUG) {
70ab25eeb5Syz155240 printf("\n\tnat_next %p _pnext %p _hm %p\n",
71ab25eeb5Syz155240 nat->nat_next, nat->nat_pnext, nat->nat_hm);
72ab25eeb5Syz155240 printf("\t_hnext %p/%p _phnext %p/%p\n",
73ab25eeb5Syz155240 nat->nat_hnext[0], nat->nat_hnext[1],
74ab25eeb5Syz155240 nat->nat_phnext[0], nat->nat_phnext[1]);
75ab25eeb5Syz155240 printf("\t_data %p _me %p _state %p _aps %p\n",
76ab25eeb5Syz155240 nat->nat_data, nat->nat_me, nat->nat_state, nat->nat_aps);
77ab25eeb5Syz155240 printf("\tfr %p ptr %p ifps %p/%p sync %p\n",
78ab25eeb5Syz155240 nat->nat_fr, nat->nat_ptr, nat->nat_ifps[0],
79ab25eeb5Syz155240 nat->nat_ifps[1], nat->nat_sync);
80ab25eeb5Syz155240 printf("\ttqe:pnext %p next %p ifq %p parent %p/%p\n",
81ab25eeb5Syz155240 nat->nat_tqe.tqe_pnext, nat->nat_tqe.tqe_next,
82ab25eeb5Syz155240 nat->nat_tqe.tqe_ifq, nat->nat_tqe.tqe_parent, nat);
83ab25eeb5Syz155240 printf("\ttqe:die %ld touched %ld flags %x state %d/%d\n",
84ab25eeb5Syz155240 nat->nat_tqe.tqe_die, nat->nat_tqe.tqe_touched,
85ab25eeb5Syz155240 nat->nat_tqe.tqe_flags, nat->nat_tqe.tqe_state[0],
86ab25eeb5Syz155240 nat->nat_tqe.tqe_state[1]);
87ab25eeb5Syz155240 }
88ab25eeb5Syz155240 putchar('\n');
89ab25eeb5Syz155240 }
90