xref: /titanic_44/usr/src/cmd/ipf/lib/common/printaps.c (revision 55553f719b521a0bb4deab6efc944cd30c1a56aa)
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 #include "kmem.h"
11 
12 
13 #if !defined(lint)
14 static const char rcsid[] = "@(#)$Id: printaps.c,v 1.4 2004/01/08 13:34:32 darrenr Exp $";
15 #endif
16 
17 
18 void printaps(aps, opts)
19 ap_session_t *aps;
20 int opts;
21 {
22 	ipsec_pxy_t ipsec;
23 	ap_session_t ap;
24 	ftpinfo_t ftp;
25 	aproxy_t apr;
26 	raudio_t ra;
27 
28 	if (kmemcpy((char *)&ap, (long)aps, sizeof(ap)))
29 		return;
30 	if (kmemcpy((char *)&apr, (long)ap.aps_apr, sizeof(apr)))
31 		return;
32 	printf("\tproxy %s/%d use %d flags %x\n", apr.apr_label,
33 		apr.apr_p, apr.apr_ref, apr.apr_flags);
34 	printf("\t\tproto %d flags %#x bytes ", ap.aps_p, ap.aps_flags);
35 #ifdef	USE_QUAD_T
36 	printf("%qu pkts %qu", (unsigned long long)ap.aps_bytes,
37 		(unsigned long long)ap.aps_pkts);
38 #else
39 	printf("%lu pkts %lu", ap.aps_bytes, ap.aps_pkts);
40 #endif
41 	printf(" data %s size %d\n", ap.aps_data ? "YES" : "NO", ap.aps_psiz);
42 	if ((ap.aps_p == IPPROTO_TCP) && (opts & OPT_VERBOSE)) {
43 		printf("\t\tstate[%u,%u], sel[%d,%d]\n",
44 			ap.aps_state[0], ap.aps_state[1],
45 			ap.aps_sel[0], ap.aps_sel[1]);
46 #if (defined(NetBSD) && (NetBSD >= 199905) && (NetBSD < 1991011)) || \
47     (__FreeBSD_version >= 300000) || defined(OpenBSD)
48 		printf("\t\tseq: off %hd/%hd min %x/%x\n",
49 			ap.aps_seqoff[0], ap.aps_seqoff[1],
50 			ap.aps_seqmin[0], ap.aps_seqmin[1]);
51 		printf("\t\tack: off %hd/%hd min %x/%x\n",
52 			ap.aps_ackoff[0], ap.aps_ackoff[1],
53 			ap.aps_ackmin[0], ap.aps_ackmin[1]);
54 #else
55 		printf("\t\tseq: off %hd/%hd min %lx/%lx\n",
56 			ap.aps_seqoff[0], ap.aps_seqoff[1],
57 			ap.aps_seqmin[0], ap.aps_seqmin[1]);
58 		printf("\t\tack: off %hd/%hd min %lx/%lx\n",
59 			ap.aps_ackoff[0], ap.aps_ackoff[1],
60 			ap.aps_ackmin[0], ap.aps_ackmin[1]);
61 #endif
62 	}
63 
64 	if (!strcmp(apr.apr_label, "raudio") && ap.aps_psiz == sizeof(ra)) {
65 		if (kmemcpy((char *)&ra, (long)ap.aps_data, sizeof(ra)))
66 			return;
67 		printf("\tReal Audio Proxy:\n");
68 		printf("\t\tSeen PNA: %d\tVersion: %d\tEOS: %d\n",
69 			ra.rap_seenpna, ra.rap_version, ra.rap_eos);
70 		printf("\t\tMode: %#x\tSBF: %#x\n", ra.rap_mode, ra.rap_sbf);
71 		printf("\t\tPorts:pl %hu, pr %hu, sr %hu\n",
72 			ra.rap_plport, ra.rap_prport, ra.rap_srport);
73 	} else if (!strcmp(apr.apr_label, "ftp") &&
74 		   (ap.aps_psiz == sizeof(ftp))) {
75 		if (kmemcpy((char *)&ftp, (long)ap.aps_data, sizeof(ftp)))
76 			return;
77 		printf("\tFTP Proxy:\n");
78 		printf("\t\tpassok: %d\n", ftp.ftp_passok);
79 		ftp.ftp_side[0].ftps_buf[FTP_BUFSZ - 1] = '\0';
80 		ftp.ftp_side[1].ftps_buf[FTP_BUFSZ - 1] = '\0';
81 		printf("\tClient:\n");
82 		printf("\t\tseq %x (ack %x) len %d junk %d cmds %d\n",
83 			ftp.ftp_side[0].ftps_seq[0],
84 			ftp.ftp_side[0].ftps_seq[1],
85 			ftp.ftp_side[0].ftps_len, ftp.ftp_side[0].ftps_junk,
86 			ftp.ftp_side[0].ftps_cmds);
87 		printf("\t\tbuf [");
88 		printbuf(ftp.ftp_side[0].ftps_buf, FTP_BUFSZ, 1);
89 		printf("]\n\tServer:\n");
90 		printf("\t\tseq %x (ack %x) len %d junk %d cmds %d\n",
91 			ftp.ftp_side[1].ftps_seq[0],
92 			ftp.ftp_side[1].ftps_seq[1],
93 			ftp.ftp_side[1].ftps_len, ftp.ftp_side[1].ftps_junk,
94 			ftp.ftp_side[1].ftps_cmds);
95 		printf("\t\tbuf [");
96 		printbuf(ftp.ftp_side[1].ftps_buf, FTP_BUFSZ, 1);
97 		printf("]\n");
98 	} else if (!strcmp(apr.apr_label, "ipsec") &&
99 		   (ap.aps_psiz == sizeof(ipsec))) {
100 		if (kmemcpy((char *)&ipsec, (long)ap.aps_data, sizeof(ipsec)))
101 			return;
102 		printf("\tIPSec Proxy:\n");
103 		printf("\t\tICookie %08x%08x RCookie %08x%08x %s\n",
104 			(u_int)ntohl(ipsec.ipsc_icookie[0]),
105 			(u_int)ntohl(ipsec.ipsc_icookie[1]),
106 			(u_int)ntohl(ipsec.ipsc_rcookie[0]),
107 			(u_int)ntohl(ipsec.ipsc_rcookie[1]),
108 			ipsec.ipsc_rckset ? "(Set)" : "(Not set)");
109 	}
110 }
111