10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * Copyright (C) 1993-2001 by Darren Reed.
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing.
50Sstevel@tonic-gate *
60Sstevel@tonic-gate * Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com)
70Sstevel@tonic-gate */
80Sstevel@tonic-gate
90Sstevel@tonic-gate #include "ipf.h"
100Sstevel@tonic-gate #include "kmem.h"
110Sstevel@tonic-gate
120Sstevel@tonic-gate
130Sstevel@tonic-gate #if !defined(lint)
14*2393Syz155240 static const char rcsid[] = "@(#)$Id: printaps.c,v 1.4 2004/01/08 13:34:32 darrenr Exp $";
150Sstevel@tonic-gate #endif
160Sstevel@tonic-gate
170Sstevel@tonic-gate
printaps(aps,opts)180Sstevel@tonic-gate void printaps(aps, opts)
190Sstevel@tonic-gate ap_session_t *aps;
200Sstevel@tonic-gate int opts;
210Sstevel@tonic-gate {
220Sstevel@tonic-gate ipsec_pxy_t ipsec;
230Sstevel@tonic-gate ap_session_t ap;
240Sstevel@tonic-gate ftpinfo_t ftp;
250Sstevel@tonic-gate aproxy_t apr;
260Sstevel@tonic-gate raudio_t ra;
270Sstevel@tonic-gate
280Sstevel@tonic-gate if (kmemcpy((char *)&ap, (long)aps, sizeof(ap)))
290Sstevel@tonic-gate return;
300Sstevel@tonic-gate if (kmemcpy((char *)&apr, (long)ap.aps_apr, sizeof(apr)))
310Sstevel@tonic-gate return;
320Sstevel@tonic-gate printf("\tproxy %s/%d use %d flags %x\n", apr.apr_label,
330Sstevel@tonic-gate apr.apr_p, apr.apr_ref, apr.apr_flags);
340Sstevel@tonic-gate printf("\t\tproto %d flags %#x bytes ", ap.aps_p, ap.aps_flags);
350Sstevel@tonic-gate #ifdef USE_QUAD_T
360Sstevel@tonic-gate printf("%qu pkts %qu", (unsigned long long)ap.aps_bytes,
370Sstevel@tonic-gate (unsigned long long)ap.aps_pkts);
380Sstevel@tonic-gate #else
390Sstevel@tonic-gate printf("%lu pkts %lu", ap.aps_bytes, ap.aps_pkts);
400Sstevel@tonic-gate #endif
410Sstevel@tonic-gate printf(" data %s size %d\n", ap.aps_data ? "YES" : "NO", ap.aps_psiz);
420Sstevel@tonic-gate if ((ap.aps_p == IPPROTO_TCP) && (opts & OPT_VERBOSE)) {
430Sstevel@tonic-gate printf("\t\tstate[%u,%u], sel[%d,%d]\n",
440Sstevel@tonic-gate ap.aps_state[0], ap.aps_state[1],
450Sstevel@tonic-gate ap.aps_sel[0], ap.aps_sel[1]);
460Sstevel@tonic-gate #if (defined(NetBSD) && (NetBSD >= 199905) && (NetBSD < 1991011)) || \
470Sstevel@tonic-gate (__FreeBSD_version >= 300000) || defined(OpenBSD)
480Sstevel@tonic-gate printf("\t\tseq: off %hd/%hd min %x/%x\n",
490Sstevel@tonic-gate ap.aps_seqoff[0], ap.aps_seqoff[1],
500Sstevel@tonic-gate ap.aps_seqmin[0], ap.aps_seqmin[1]);
510Sstevel@tonic-gate printf("\t\tack: off %hd/%hd min %x/%x\n",
520Sstevel@tonic-gate ap.aps_ackoff[0], ap.aps_ackoff[1],
530Sstevel@tonic-gate ap.aps_ackmin[0], ap.aps_ackmin[1]);
540Sstevel@tonic-gate #else
550Sstevel@tonic-gate printf("\t\tseq: off %hd/%hd min %lx/%lx\n",
560Sstevel@tonic-gate ap.aps_seqoff[0], ap.aps_seqoff[1],
570Sstevel@tonic-gate ap.aps_seqmin[0], ap.aps_seqmin[1]);
580Sstevel@tonic-gate printf("\t\tack: off %hd/%hd min %lx/%lx\n",
590Sstevel@tonic-gate ap.aps_ackoff[0], ap.aps_ackoff[1],
600Sstevel@tonic-gate ap.aps_ackmin[0], ap.aps_ackmin[1]);
610Sstevel@tonic-gate #endif
620Sstevel@tonic-gate }
630Sstevel@tonic-gate
640Sstevel@tonic-gate if (!strcmp(apr.apr_label, "raudio") && ap.aps_psiz == sizeof(ra)) {
650Sstevel@tonic-gate if (kmemcpy((char *)&ra, (long)ap.aps_data, sizeof(ra)))
660Sstevel@tonic-gate return;
670Sstevel@tonic-gate printf("\tReal Audio Proxy:\n");
680Sstevel@tonic-gate printf("\t\tSeen PNA: %d\tVersion: %d\tEOS: %d\n",
690Sstevel@tonic-gate ra.rap_seenpna, ra.rap_version, ra.rap_eos);
700Sstevel@tonic-gate printf("\t\tMode: %#x\tSBF: %#x\n", ra.rap_mode, ra.rap_sbf);
710Sstevel@tonic-gate printf("\t\tPorts:pl %hu, pr %hu, sr %hu\n",
720Sstevel@tonic-gate ra.rap_plport, ra.rap_prport, ra.rap_srport);
730Sstevel@tonic-gate } else if (!strcmp(apr.apr_label, "ftp") &&
740Sstevel@tonic-gate (ap.aps_psiz == sizeof(ftp))) {
750Sstevel@tonic-gate if (kmemcpy((char *)&ftp, (long)ap.aps_data, sizeof(ftp)))
760Sstevel@tonic-gate return;
770Sstevel@tonic-gate printf("\tFTP Proxy:\n");
780Sstevel@tonic-gate printf("\t\tpassok: %d\n", ftp.ftp_passok);
790Sstevel@tonic-gate ftp.ftp_side[0].ftps_buf[FTP_BUFSZ - 1] = '\0';
800Sstevel@tonic-gate ftp.ftp_side[1].ftps_buf[FTP_BUFSZ - 1] = '\0';
810Sstevel@tonic-gate printf("\tClient:\n");
820Sstevel@tonic-gate printf("\t\tseq %x (ack %x) len %d junk %d cmds %d\n",
830Sstevel@tonic-gate ftp.ftp_side[0].ftps_seq[0],
840Sstevel@tonic-gate ftp.ftp_side[0].ftps_seq[1],
850Sstevel@tonic-gate ftp.ftp_side[0].ftps_len, ftp.ftp_side[0].ftps_junk,
860Sstevel@tonic-gate ftp.ftp_side[0].ftps_cmds);
870Sstevel@tonic-gate printf("\t\tbuf [");
880Sstevel@tonic-gate printbuf(ftp.ftp_side[0].ftps_buf, FTP_BUFSZ, 1);
890Sstevel@tonic-gate printf("]\n\tServer:\n");
900Sstevel@tonic-gate printf("\t\tseq %x (ack %x) len %d junk %d cmds %d\n",
910Sstevel@tonic-gate ftp.ftp_side[1].ftps_seq[0],
920Sstevel@tonic-gate ftp.ftp_side[1].ftps_seq[1],
930Sstevel@tonic-gate ftp.ftp_side[1].ftps_len, ftp.ftp_side[1].ftps_junk,
940Sstevel@tonic-gate ftp.ftp_side[1].ftps_cmds);
950Sstevel@tonic-gate printf("\t\tbuf [");
960Sstevel@tonic-gate printbuf(ftp.ftp_side[1].ftps_buf, FTP_BUFSZ, 1);
970Sstevel@tonic-gate printf("]\n");
980Sstevel@tonic-gate } else if (!strcmp(apr.apr_label, "ipsec") &&
990Sstevel@tonic-gate (ap.aps_psiz == sizeof(ipsec))) {
1000Sstevel@tonic-gate if (kmemcpy((char *)&ipsec, (long)ap.aps_data, sizeof(ipsec)))
1010Sstevel@tonic-gate return;
1020Sstevel@tonic-gate printf("\tIPSec Proxy:\n");
1030Sstevel@tonic-gate printf("\t\tICookie %08x%08x RCookie %08x%08x %s\n",
1040Sstevel@tonic-gate (u_int)ntohl(ipsec.ipsc_icookie[0]),
1050Sstevel@tonic-gate (u_int)ntohl(ipsec.ipsc_icookie[1]),
1060Sstevel@tonic-gate (u_int)ntohl(ipsec.ipsc_rcookie[0]),
1070Sstevel@tonic-gate (u_int)ntohl(ipsec.ipsc_rcookie[1]),
1080Sstevel@tonic-gate ipsec.ipsc_rckset ? "(Set)" : "(Not set)");
1090Sstevel@tonic-gate }
1100Sstevel@tonic-gate }
111