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