diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-10-01 07:11:49 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-10-01 07:11:49 +0000 |
commit | be2736adcf8ac583c2d56e37db9ef01f391913f9 (patch) | |
tree | defd8c4db6a77dd4d288de2b0b10f39d6c701b73 /wiretap/snoop.c | |
parent | 44bb98184df93ebb56b5dce5dbd1deb6f37d716a (diff) |
Have a pseudo-header for Ethernet packets, giving the size of the FCS -
0 means "there is no FCS in the packet data", 4 means "there is an FCS
in the packet data", -1 means "I don't know whether there's an FCS in
the packet data, guess based on the packet size".
Assume that Ethernet encapsulated inside other protocols has no FCS, by
having the "eth" dissector assume that (and not check for an Ethernet
pseudo-header).
Have "ethertype()" take an argument giving the FCS size; pass 0 when
appropriate.
Fix up Wiretap routines to set the pseudo-header. This means we no
longer use the "generic" seek-and-read routine, so get rid of it.
svn path=/trunk/; revision=8574
Diffstat (limited to 'wiretap/snoop.c')
-rw-r--r-- | wiretap/snoop.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 6be6cd406d..d8fad35dcd 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -1,6 +1,6 @@ /* snoop.c * - * $Id: snoop.c,v 1.62 2003/02/18 19:59:00 guy Exp $ + * $Id: snoop.c,v 1.63 2003/10/01 07:11:48 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -405,7 +405,9 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) * the VCI; read them and generate the pseudo-header from * them. */ - if (wth->file_encap == WTAP_ENCAP_ATM_PDUS) { + switch (wth->file_encap) { + + case WTAP_ENCAP_ATM_PDUS: if (packet_size < sizeof (struct snoop_atm_hdr)) { /* * Uh-oh, the packet isn't big enough to even @@ -427,6 +429,19 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) orig_size -= sizeof (struct snoop_atm_hdr); packet_size -= sizeof (struct snoop_atm_hdr); wth->data_offset += sizeof (struct snoop_atm_hdr); + break; + + case WTAP_ENCAP_ETHERNET: + /* + * If this is a snoop file, we assume there's no FCS in + * this frame; if this is a Shomit file, we assume there + * is. (XXX - or should we treat it a "maybe"?) + */ + if (wth->file_type == WTAP_FILE_SHOMITI) + wth->pseudo_header.eth.fcs_len = 4; + else + wth->pseudo_header.eth.fcs_len = 0; + break; } buffer_assure_space(wth->frame_buffer, packet_size); @@ -485,12 +500,27 @@ snoop_seek_read(wtap *wth, long seek_off, if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - if (wth->file_encap == WTAP_ENCAP_ATM_PDUS) { + switch (wth->file_encap) { + + case WTAP_ENCAP_ATM_PDUS: if (!snoop_read_atm_pseudoheader(wth->random_fh, pseudo_header, err)) { /* Read error */ return FALSE; } + break; + + case WTAP_ENCAP_ETHERNET: + /* + * If this is a snoop file, we assume there's no FCS in + * this frame; if this is a Shomit file, we assume there + * is. (XXX - or should we treat it a "maybe"?) + */ + if (wth->file_type == WTAP_FILE_SHOMITI) + pseudo_header->eth.fcs_len = 4; + else + pseudo_header->eth.fcs_len = 0; + break; } /* |