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