xref: /titanic_41/usr/src/cmd/ipf/lib/common/printaps.c (revision ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright (C) 1993-2001 by Darren Reed.
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
57c478bd9Sstevel@tonic-gate  *
67c478bd9Sstevel@tonic-gate  * Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com)
77c478bd9Sstevel@tonic-gate  */
87c478bd9Sstevel@tonic-gate 
97c478bd9Sstevel@tonic-gate #include "ipf.h"
107c478bd9Sstevel@tonic-gate #include "kmem.h"
117c478bd9Sstevel@tonic-gate 
127c478bd9Sstevel@tonic-gate 
137c478bd9Sstevel@tonic-gate #if !defined(lint)
14*ab25eeb5Syz155240 static const char rcsid[] = "@(#)$Id: printaps.c,v 1.4 2004/01/08 13:34:32 darrenr Exp $";
157c478bd9Sstevel@tonic-gate #endif
167c478bd9Sstevel@tonic-gate 
177c478bd9Sstevel@tonic-gate 
printaps(aps,opts)187c478bd9Sstevel@tonic-gate void printaps(aps, opts)
197c478bd9Sstevel@tonic-gate ap_session_t *aps;
207c478bd9Sstevel@tonic-gate int opts;
217c478bd9Sstevel@tonic-gate {
227c478bd9Sstevel@tonic-gate 	ipsec_pxy_t ipsec;
237c478bd9Sstevel@tonic-gate 	ap_session_t ap;
247c478bd9Sstevel@tonic-gate 	ftpinfo_t ftp;
257c478bd9Sstevel@tonic-gate 	aproxy_t apr;
267c478bd9Sstevel@tonic-gate 	raudio_t ra;
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate 	if (kmemcpy((char *)&ap, (long)aps, sizeof(ap)))
297c478bd9Sstevel@tonic-gate 		return;
307c478bd9Sstevel@tonic-gate 	if (kmemcpy((char *)&apr, (long)ap.aps_apr, sizeof(apr)))
317c478bd9Sstevel@tonic-gate 		return;
327c478bd9Sstevel@tonic-gate 	printf("\tproxy %s/%d use %d flags %x\n", apr.apr_label,
337c478bd9Sstevel@tonic-gate 		apr.apr_p, apr.apr_ref, apr.apr_flags);
347c478bd9Sstevel@tonic-gate 	printf("\t\tproto %d flags %#x bytes ", ap.aps_p, ap.aps_flags);
357c478bd9Sstevel@tonic-gate #ifdef	USE_QUAD_T
367c478bd9Sstevel@tonic-gate 	printf("%qu pkts %qu", (unsigned long long)ap.aps_bytes,
377c478bd9Sstevel@tonic-gate 		(unsigned long long)ap.aps_pkts);
387c478bd9Sstevel@tonic-gate #else
397c478bd9Sstevel@tonic-gate 	printf("%lu pkts %lu", ap.aps_bytes, ap.aps_pkts);
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 	printf(" data %s size %d\n", ap.aps_data ? "YES" : "NO", ap.aps_psiz);
427c478bd9Sstevel@tonic-gate 	if ((ap.aps_p == IPPROTO_TCP) && (opts & OPT_VERBOSE)) {
437c478bd9Sstevel@tonic-gate 		printf("\t\tstate[%u,%u], sel[%d,%d]\n",
447c478bd9Sstevel@tonic-gate 			ap.aps_state[0], ap.aps_state[1],
457c478bd9Sstevel@tonic-gate 			ap.aps_sel[0], ap.aps_sel[1]);
467c478bd9Sstevel@tonic-gate #if (defined(NetBSD) && (NetBSD >= 199905) && (NetBSD < 1991011)) || \
477c478bd9Sstevel@tonic-gate     (__FreeBSD_version >= 300000) || defined(OpenBSD)
487c478bd9Sstevel@tonic-gate 		printf("\t\tseq: off %hd/%hd min %x/%x\n",
497c478bd9Sstevel@tonic-gate 			ap.aps_seqoff[0], ap.aps_seqoff[1],
507c478bd9Sstevel@tonic-gate 			ap.aps_seqmin[0], ap.aps_seqmin[1]);
517c478bd9Sstevel@tonic-gate 		printf("\t\tack: off %hd/%hd min %x/%x\n",
527c478bd9Sstevel@tonic-gate 			ap.aps_ackoff[0], ap.aps_ackoff[1],
537c478bd9Sstevel@tonic-gate 			ap.aps_ackmin[0], ap.aps_ackmin[1]);
547c478bd9Sstevel@tonic-gate #else
557c478bd9Sstevel@tonic-gate 		printf("\t\tseq: off %hd/%hd min %lx/%lx\n",
567c478bd9Sstevel@tonic-gate 			ap.aps_seqoff[0], ap.aps_seqoff[1],
577c478bd9Sstevel@tonic-gate 			ap.aps_seqmin[0], ap.aps_seqmin[1]);
587c478bd9Sstevel@tonic-gate 		printf("\t\tack: off %hd/%hd min %lx/%lx\n",
597c478bd9Sstevel@tonic-gate 			ap.aps_ackoff[0], ap.aps_ackoff[1],
607c478bd9Sstevel@tonic-gate 			ap.aps_ackmin[0], ap.aps_ackmin[1]);
617c478bd9Sstevel@tonic-gate #endif
627c478bd9Sstevel@tonic-gate 	}
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate 	if (!strcmp(apr.apr_label, "raudio") && ap.aps_psiz == sizeof(ra)) {
657c478bd9Sstevel@tonic-gate 		if (kmemcpy((char *)&ra, (long)ap.aps_data, sizeof(ra)))
667c478bd9Sstevel@tonic-gate 			return;
677c478bd9Sstevel@tonic-gate 		printf("\tReal Audio Proxy:\n");
687c478bd9Sstevel@tonic-gate 		printf("\t\tSeen PNA: %d\tVersion: %d\tEOS: %d\n",
697c478bd9Sstevel@tonic-gate 			ra.rap_seenpna, ra.rap_version, ra.rap_eos);
707c478bd9Sstevel@tonic-gate 		printf("\t\tMode: %#x\tSBF: %#x\n", ra.rap_mode, ra.rap_sbf);
717c478bd9Sstevel@tonic-gate 		printf("\t\tPorts:pl %hu, pr %hu, sr %hu\n",
727c478bd9Sstevel@tonic-gate 			ra.rap_plport, ra.rap_prport, ra.rap_srport);
737c478bd9Sstevel@tonic-gate 	} else if (!strcmp(apr.apr_label, "ftp") &&
747c478bd9Sstevel@tonic-gate 		   (ap.aps_psiz == sizeof(ftp))) {
757c478bd9Sstevel@tonic-gate 		if (kmemcpy((char *)&ftp, (long)ap.aps_data, sizeof(ftp)))
767c478bd9Sstevel@tonic-gate 			return;
777c478bd9Sstevel@tonic-gate 		printf("\tFTP Proxy:\n");
787c478bd9Sstevel@tonic-gate 		printf("\t\tpassok: %d\n", ftp.ftp_passok);
797c478bd9Sstevel@tonic-gate 		ftp.ftp_side[0].ftps_buf[FTP_BUFSZ - 1] = '\0';
807c478bd9Sstevel@tonic-gate 		ftp.ftp_side[1].ftps_buf[FTP_BUFSZ - 1] = '\0';
817c478bd9Sstevel@tonic-gate 		printf("\tClient:\n");
827c478bd9Sstevel@tonic-gate 		printf("\t\tseq %x (ack %x) len %d junk %d cmds %d\n",
837c478bd9Sstevel@tonic-gate 			ftp.ftp_side[0].ftps_seq[0],
847c478bd9Sstevel@tonic-gate 			ftp.ftp_side[0].ftps_seq[1],
857c478bd9Sstevel@tonic-gate 			ftp.ftp_side[0].ftps_len, ftp.ftp_side[0].ftps_junk,
867c478bd9Sstevel@tonic-gate 			ftp.ftp_side[0].ftps_cmds);
877c478bd9Sstevel@tonic-gate 		printf("\t\tbuf [");
887c478bd9Sstevel@tonic-gate 		printbuf(ftp.ftp_side[0].ftps_buf, FTP_BUFSZ, 1);
897c478bd9Sstevel@tonic-gate 		printf("]\n\tServer:\n");
907c478bd9Sstevel@tonic-gate 		printf("\t\tseq %x (ack %x) len %d junk %d cmds %d\n",
917c478bd9Sstevel@tonic-gate 			ftp.ftp_side[1].ftps_seq[0],
927c478bd9Sstevel@tonic-gate 			ftp.ftp_side[1].ftps_seq[1],
937c478bd9Sstevel@tonic-gate 			ftp.ftp_side[1].ftps_len, ftp.ftp_side[1].ftps_junk,
947c478bd9Sstevel@tonic-gate 			ftp.ftp_side[1].ftps_cmds);
957c478bd9Sstevel@tonic-gate 		printf("\t\tbuf [");
967c478bd9Sstevel@tonic-gate 		printbuf(ftp.ftp_side[1].ftps_buf, FTP_BUFSZ, 1);
977c478bd9Sstevel@tonic-gate 		printf("]\n");
987c478bd9Sstevel@tonic-gate 	} else if (!strcmp(apr.apr_label, "ipsec") &&
997c478bd9Sstevel@tonic-gate 		   (ap.aps_psiz == sizeof(ipsec))) {
1007c478bd9Sstevel@tonic-gate 		if (kmemcpy((char *)&ipsec, (long)ap.aps_data, sizeof(ipsec)))
1017c478bd9Sstevel@tonic-gate 			return;
1027c478bd9Sstevel@tonic-gate 		printf("\tIPSec Proxy:\n");
1037c478bd9Sstevel@tonic-gate 		printf("\t\tICookie %08x%08x RCookie %08x%08x %s\n",
1047c478bd9Sstevel@tonic-gate 			(u_int)ntohl(ipsec.ipsc_icookie[0]),
1057c478bd9Sstevel@tonic-gate 			(u_int)ntohl(ipsec.ipsc_icookie[1]),
1067c478bd9Sstevel@tonic-gate 			(u_int)ntohl(ipsec.ipsc_rcookie[0]),
1077c478bd9Sstevel@tonic-gate 			(u_int)ntohl(ipsec.ipsc_rcookie[1]),
1087c478bd9Sstevel@tonic-gate 			ipsec.ipsc_rckset ? "(Set)" : "(Not set)");
1097c478bd9Sstevel@tonic-gate 	}
1107c478bd9Sstevel@tonic-gate }
111