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