xref: /titanic_41/usr/src/cmd/ipf/lib/common/printactivenat.c (revision b86efd96f8acd85ddaa930a2f0c1d664237e4aaf)
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 
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)
18 nat_t *nat;
19 int opts;
20 {
21 
22 	printf("%s", getnattype(nat->nat_ptr));
23 
24 	if (nat->nat_flags & SI_CLONE)
25 		printf(" CLONE");
26 
27 	printf(" %-15s", inet_ntoa(nat->nat_inip));
28 
29 	if ((nat->nat_flags & IPN_TCPUDP) != 0)
30 		printf(" %-5hu", ntohs(nat->nat_inport));
31 
32 	printf(" <- -> %-15s",inet_ntoa(nat->nat_outip));
33 
34 	if ((nat->nat_flags & IPN_TCPUDP) != 0)
35 		printf(" %-5hu", ntohs(nat->nat_outport));
36 
37 	printf(" [%s", inet_ntoa(nat->nat_oip));
38 	if ((nat->nat_flags & IPN_TCPUDP) != 0)
39 		printf(" %hu", ntohs(nat->nat_oport));
40 	printf("]");
41 
42 	if (opts & OPT_VERBOSE) {
43 		printf("\n\tage %lu use %hu sumd %s/",
44 			nat->nat_age, nat->nat_use, getsumd(nat->nat_sumd[0]));
45 		printf("%s pr %u bkt %d/%d flags %x\n",
46 			getsumd(nat->nat_sumd[1]), nat->nat_p,
47 			nat->nat_hv[0], nat->nat_hv[1], nat->nat_flags);
48 		printf("\tifp %s", getifname(nat->nat_ifps[0]));
49 		printf(",%s ", getifname(nat->nat_ifps[1]));
50 #ifdef	USE_QUAD_T
51 		printf("bytes %qu/%qu pkts %qu/%qu",
52 			(unsigned long long)nat->nat_bytes[0],
53 			(unsigned long long)nat->nat_bytes[1],
54 			(unsigned long long)nat->nat_pkts[0],
55 			(unsigned long long)nat->nat_pkts[1]);
56 #else
57 		printf("bytes %lu/%lu pkts %lu/%lu", nat->nat_bytes[0],
58 			nat->nat_bytes[1], nat->nat_pkts[0], nat->nat_pkts[1]);
59 #endif
60 		printf(" ipsumd %x", nat->nat_ipsumd);
61 	}
62 
63 	if (opts & OPT_DEBUG) {
64 		printf("\n\tnat_next %p _pnext %p _hm %p\n",
65 			nat->nat_next, nat->nat_pnext, nat->nat_hm);
66 		printf("\t_hnext %p/%p _phnext %p/%p\n",
67 			nat->nat_hnext[0], nat->nat_hnext[1],
68 			nat->nat_phnext[0], nat->nat_phnext[1]);
69 		printf("\t_data %p _me %p _state %p _aps %p\n",
70 			nat->nat_data, nat->nat_me, nat->nat_state, nat->nat_aps);
71 		printf("\tfr %p ptr %p ifps %p/%p sync %p\n",
72 			nat->nat_fr, nat->nat_ptr, nat->nat_ifps[0],
73 			nat->nat_ifps[1], nat->nat_sync);
74 		printf("\ttqe:pnext %p next %p ifq %p parent %p/%p\n",
75 			nat->nat_tqe.tqe_pnext, nat->nat_tqe.tqe_next,
76 			nat->nat_tqe.tqe_ifq, nat->nat_tqe.tqe_parent, nat);
77 		printf("\ttqe:die %ld touched %ld flags %x state %d/%d\n",
78 			nat->nat_tqe.tqe_die, nat->nat_tqe.tqe_touched,
79 			nat->nat_tqe.tqe_flags, nat->nat_tqe.tqe_state[0],
80 			nat->nat_tqe.tqe_state[1]);
81 	}
82 	putchar('\n');
83 }
84