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