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