1 2 /* 3 * Copyright (C) 2012 by Darren Reed. 4 * 5 * See the IPFILTER.LICENCE file for details on licencing. 6 * 7 * Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com) 8 */ 9 10 #include "ipf.h" 11 #include "kmem.h" 12 13 14 #if !defined(lint) 15 static const char rcsid[] = "@(#)$Id$"; 16 #endif 17 18 19 void 20 printaps(ap_session_t *aps, int opts, int proto) 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 #ifdef USE_QUAD_T 35 PRINTF("\tbytes %"PRIu64" pkts %"PRIu64"", 36 (unsigned long long)ap.aps_bytes, 37 (unsigned long long)ap.aps_pkts); 38 #else 39 PRINTF("\tbytes %lu pkts %lu", ap.aps_bytes, ap.aps_pkts); 40 #endif 41 PRINTF(" data %s\n", ap.aps_data ? "YES" : "NO"); 42 if ((proto == 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 defined(__FreeBSD__) 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