xref: /illumos-gate/usr/src/cmd/ipf/lib/printactivenat.c (revision 9164a50bf932130cbb5097a16f6986873ce0e6e5)
1 /*
2  * Copyright (C) 2002-2004 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  */
6 
7 #include "ipf.h"
8 
9 
10 #if !defined(lint)
11 static const char rcsid[] = "@(#)$Id: printactivenat.c,v 1.3.2.4 2004/05/11 16:07:32 darrenr Exp $";
12 #endif
13 
14 
15 void printactivenat(nat, opts, alive)
16 nat_t *nat;
17 int opts, alive;
18 {
19 
20 	printf("%s", getnattype(nat, alive));
21 
22 	if (nat->nat_flags & SI_CLONE)
23 		printf(" CLONE");
24 
25 	printactiveaddress(nat->nat_v, " %-15s", &nat->nat_inip6,
26 			   nat->nat_ifnames[0]);
27 
28 	if ((nat->nat_flags & IPN_TCPUDP) != 0)
29 		printf(" %-5hu", ntohs(nat->nat_inport));
30 
31 	printf(" <- -> ");
32 	printactiveaddress(nat->nat_v, "%-15s", &nat->nat_outip6,
33 			   nat->nat_ifnames[0]);
34 
35 	if ((nat->nat_flags & IPN_TCPUDP) != 0)
36 		printf(" %-5hu", ntohs(nat->nat_outport));
37 
38 	printf(" [");
39 	printactiveaddress(nat->nat_v, "%s", &nat->nat_oip6,
40 			   nat->nat_ifnames[0]);
41 
42 	if ((nat->nat_flags & IPN_TCPUDP) != 0)
43 		printf(" %hu", ntohs(nat->nat_oport));
44 	printf("]");
45 
46 	if (opts & OPT_VERBOSE) {
47 		printf("\n\tage %lu use %hu sumd %s/",
48 			nat->nat_age, nat->nat_use, 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);
65 	}
66 
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]);
85 	}
86 	putchar('\n');
87 }
88