From 2fed18defb3bd6c967025098b7d0c482c2967222 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 16 Nov 2002 20:20:30 +0000 Subject: [PATCH] AIX's tcpdump has the same annoying habit as AIX's iptrace of putting 3 bytes of padding in front of FDDI frames; strip it off. svn path=/trunk/; revision=6647 --- wiretap/libpcap.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index eb33f061d7..8381348e3c 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -1,6 +1,6 @@ /* libpcap.c * - * $Id: libpcap.c,v 1.83 2002/10/22 09:11:13 guy Exp $ + * $Id: libpcap.c,v 1.84 2002/11/16 20:20:30 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -843,6 +843,7 @@ static gboolean libpcap_read(wtap *wth, int *err, long *data_offset) guint packet_size; guint orig_size; int bytes_read; + char fddi_padding[3]; bytes_read = libpcap_read_header(wth, err, &hdr, FALSE); if (bytes_read == -1) { @@ -856,6 +857,28 @@ static gboolean libpcap_read(wtap *wth, int *err, long *data_offset) packet_size = hdr.hdr.incl_len; orig_size = hdr.hdr.orig_len; + /* + * AIX appears to put 3 bytes of padding in front of FDDI + * frames; strip that crap off. + */ + if (wth->file_type == WTAP_FILE_PCAP_AIX && + (wth->file_encap == WTAP_ENCAP_FDDI || + wth->file_encap == WTAP_ENCAP_FDDI_BITSWAPPED)) { + /* + * The packet size is really a record size and includes + * the padding. + */ + packet_size -= 3; + orig_size -= 3; + wth->data_offset += 3; + + /* + * Read the padding. + */ + if (!libpcap_read_rec_data(wth->fh, fddi_padding, 3, err)) + return FALSE; /* Read error */ + } + *data_offset = wth->data_offset; /*