/* * Copyright (c) 2000 Paul Herman * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: catpcap.c,v 1.6 2002/09/18 21:00:29 pherman Exp $ */ #include "tcpstat.h" #if 0 #ifdef WORDS_BIGENDIAN # define LAST_CHAR(x) ( (x) >> 8 ) # define SWAPEM(x) ( (x) ) #else # define LAST_CHAR(x) ( (x) & 0x00ff ) # define SWAPEM(x) ( (((x) << 8)&0xff00) | (((x) >> 8)&0x00ff)) #endif #endif #define SHOW_HIGH_BIT 0 /* GLOBALS */ char filterexpr[BUF_SIZ] = ""; int p_number = 1; char char_conv(char c) { if (isgraph(c)) return c; if (c == ' ') return c; if ((u_char)c > 0xa1 && SHOW_HIGH_BIT) return c; return '.'; } void proc_pcap(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { u_int length = h->caplen, i, j, k, step; u_char *r, *s; char c; r = (u_char *)p; s = (u_char *)p; step = 22; printf("%u: %lu.%.6lu, caplen %u, len %u\n", p_number++, (long unsigned int) h->ts.tv_sec, (long unsigned int) h->ts.tv_usec, h->caplen, h->len ); for (i=0; i