Obliging every capture file reader's "open()" routine to seek to the
beginning of the file before reading anything from the file is bogus - do that in the loop that tries each of the open routines, instead. (They may have to reset the seek pointer later if, for example, the capture file begins with the first packet, and the "open()" routine looks at that packet to try to guess whether the packet is in the file format in question.) Set "wth->data_offset" to 0 while you're at it, so capture file readers don't have to do that, either. svn path=/trunk/; revision=3123
This commit is contained in:
parent
9b1133892b
commit
a251addb63
|
@ -1,6 +1,6 @@
|
|||
/* ascend.c
|
||||
*
|
||||
* $Id: ascend.c,v 1.22 2000/11/19 03:47:35 guy Exp $
|
||||
* $Id: ascend.c,v 1.23 2001/03/10 06:33:57 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -209,7 +209,6 @@ int ascend_open(wtap *wth, int *err)
|
|||
fill it in. */
|
||||
wth->capture.ascend = NULL;
|
||||
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
offset = ascend_seek(wth, ASCEND_MAX_SEEK);
|
||||
if (offset == -1) {
|
||||
return 0;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* csids.c
|
||||
*
|
||||
* $Id: csids.c,v 1.5 2000/11/19 03:47:35 guy Exp $
|
||||
* $Id: csids.c,v 1.6 2001/03/10 06:33:57 guy Exp $
|
||||
*
|
||||
* Copyright (c) 2000 by Mike Hall <mlh@io.com>
|
||||
* Copyright (c) 2000 by Cisco Systems
|
||||
|
@ -71,8 +71,6 @@ int csids_open(wtap *wth, int *err)
|
|||
struct csids_header hdr;
|
||||
bytesRead=0;
|
||||
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
|
||||
/* check the file to make sure it is a csids file. */
|
||||
bytesRead = file_read( &hdr, 1, sizeof( struct csids_header), wth->fh );
|
||||
if( bytesRead != sizeof( struct csids_header) ) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Routines for opening etherpeek files
|
||||
* Copyright (c) 2001, Daniel Thompson <d.thompson@gmx.net>
|
||||
*
|
||||
* $Id: etherpeek.c,v 1.2 2001/03/09 06:34:59 guy Exp $
|
||||
* $Id: etherpeek.c,v 1.3 2001/03/10 06:33:57 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -129,9 +129,6 @@ int etherpeek_open(wtap *wth, int *err)
|
|||
* support
|
||||
*/
|
||||
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
wth->data_offset = 0;
|
||||
|
||||
g_assert(sizeof(ep_hdr.master) == ETHERPEEK_MASTER_HDR_SIZE);
|
||||
wtap_file_read_unknown_bytes(
|
||||
&ep_hdr.master, sizeof(ep_hdr.master), wth->fh, err);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* file.c
|
||||
*
|
||||
* $Id: file.c,v 1.65 2001/03/09 07:11:38 guy Exp $
|
||||
* $Id: file.c,v 1.66 2001/03/10 06:33:57 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -208,6 +208,15 @@ wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random)
|
|||
|
||||
/* Try all file types */
|
||||
for (i = 0; i < N_FILE_TYPES; i++) {
|
||||
/* Seek back to the beginning of the file; the open routine
|
||||
for the previous file type may have left the file
|
||||
position somewhere other than the beginning, and the
|
||||
open routine for this file type will probably want
|
||||
to start reading at the beginning.
|
||||
|
||||
Initialize the data offset while we're at it. */
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
wth->data_offset = 0;
|
||||
switch ((*open_routines[i])(wth, err)) {
|
||||
|
||||
case -1:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* i4btrace.c
|
||||
*
|
||||
* $Id: i4btrace.c,v 1.13 2000/11/19 03:47:35 guy Exp $
|
||||
* $Id: i4btrace.c,v 1.14 2001/03/10 06:33:57 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org>
|
||||
|
@ -56,7 +56,6 @@ int i4btrace_open(wtap *wth, int *err)
|
|||
gboolean byte_swapped = FALSE;
|
||||
|
||||
/* I4B trace files have no magic in the header... Sigh */
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(&hdr, 1, sizeof(hdr), wth->fh);
|
||||
if (bytes_read != sizeof(hdr)) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* iptrace.c
|
||||
*
|
||||
* $Id: iptrace.c,v 1.32 2000/09/21 04:41:30 gram Exp $
|
||||
* $Id: iptrace.c,v 1.33 2001/03/10 06:33:57 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -52,8 +52,6 @@ int iptrace_open(wtap *wth, int *err)
|
|||
int bytes_read;
|
||||
char name[12];
|
||||
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
wth->data_offset = 0;
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(name, 1, 11, wth->fh);
|
||||
if (bytes_read != 11) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* lanalyzer.c
|
||||
*
|
||||
* $Id: lanalyzer.c,v 1.26 2000/09/21 04:41:30 gram Exp $
|
||||
* $Id: lanalyzer.c,v 1.27 2001/03/10 06:33:57 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -61,8 +61,6 @@ int lanalyzer_open(wtap *wth, int *err)
|
|||
guint8 cr_day, cr_month, cr_year;
|
||||
struct tm tm;
|
||||
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
wth->data_offset = 0;
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(LE_record_type, 1, 2, wth->fh);
|
||||
bytes_read += file_read(LE_record_length, 1, 2, wth->fh);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libpcap.c
|
||||
*
|
||||
* $Id: libpcap.c,v 1.45 2000/12/23 08:06:15 guy Exp $
|
||||
* $Id: libpcap.c,v 1.46 2001/03/10 06:33:57 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -357,8 +357,6 @@ int libpcap_open(wtap *wth, int *err)
|
|||
int file_encap;
|
||||
|
||||
/* Read in the number that should be at the start of a "libpcap" file */
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
wth->data_offset = 0;
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(&magic, 1, sizeof magic, wth->fh);
|
||||
if (bytes_read != sizeof magic) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* netmon.c
|
||||
*
|
||||
* $Id: netmon.c,v 1.36 2001/01/25 21:47:23 guy Exp $
|
||||
* $Id: netmon.c,v 1.37 2001/03/10 06:33:57 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -131,7 +131,6 @@ int netmon_open(wtap *wth, int *err)
|
|||
|
||||
/* Read in the string that should be at the start of a Network
|
||||
* Monitor file */
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(magic, 1, sizeof magic, wth->fh);
|
||||
if (bytes_read != sizeof magic) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* nettl.c
|
||||
*
|
||||
* $Id: nettl.c,v 1.18 2000/11/17 21:00:40 gram Exp $
|
||||
* $Id: nettl.c,v 1.19 2001/03/10 06:33:57 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -81,7 +81,6 @@ int nettl_open(wtap *wth, int *err)
|
|||
int bytes_read;
|
||||
|
||||
/* Read in the string that should be at the start of a HP file */
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(magic, 1, 12, wth->fh);
|
||||
if (bytes_read != 12) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* netxray.c
|
||||
*
|
||||
* $Id: netxray.c,v 1.36 2001/02/14 09:38:10 guy Exp $
|
||||
* $Id: netxray.c,v 1.37 2001/03/10 06:33:57 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -151,8 +151,6 @@ int netxray_open(wtap *wth, int *err)
|
|||
|
||||
/* Read in the string that should be at the start of a NetXRay
|
||||
* file */
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
wth->data_offset = 0;
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(magic, 1, sizeof magic, wth->fh);
|
||||
if (bytes_read != sizeof magic) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* ngsniffer.c
|
||||
*
|
||||
* $Id: ngsniffer.c,v 1.62 2001/01/17 21:29:53 guy Exp $
|
||||
* $Id: ngsniffer.c,v 1.63 2001/03/10 06:33:57 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -348,8 +348,6 @@ int ngsniffer_open(wtap *wth, int *err)
|
|||
struct tm tm;
|
||||
|
||||
/* Read in the string that should be at the start of a Sniffer file */
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
wth->data_offset = 0;
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(magic, 1, sizeof magic, wth->fh);
|
||||
if (bytes_read != sizeof magic) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* pppdump.c
|
||||
*
|
||||
* $Id: pppdump.c,v 1.7 2000/12/09 03:02:43 gram Exp $
|
||||
* $Id: pppdump.c,v 1.8 2001/03/10 06:33:58 guy Exp $
|
||||
*
|
||||
* Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org>
|
||||
*
|
||||
|
@ -178,7 +178,6 @@ pppdump_open(wtap *wth, int *err)
|
|||
* representing the timestamp.
|
||||
*/
|
||||
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
wtap_file_read_unknown_bytes(buffer, sizeof(buffer), wth->fh, err);
|
||||
|
||||
if (buffer[0] == PPPD_RESET_TIME &&
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* radcom.c
|
||||
*
|
||||
* $Id: radcom.c,v 1.28 2000/11/17 21:00:40 gram Exp $
|
||||
* $Id: radcom.c,v 1.29 2001/03/10 06:33:58 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -86,7 +86,6 @@ int radcom_open(wtap *wth, int *err)
|
|||
char search_encap[7];
|
||||
|
||||
/* Read in the string that should be at the start of a RADCOM file */
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(magic, 1, 8, wth->fh);
|
||||
if (bytes_read != 8) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* snoop.c
|
||||
*
|
||||
* $Id: snoop.c,v 1.33 2000/11/17 21:00:40 gram Exp $
|
||||
* $Id: snoop.c,v 1.34 2001/03/10 06:33:58 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -154,8 +154,6 @@ int snoop_open(wtap *wth, int *err)
|
|||
#define NUM_SNOOP_ENCAPS (sizeof snoop_encap / sizeof snoop_encap[0])
|
||||
|
||||
/* Read in the string that should be at the start of a "snoop" file */
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
wth->data_offset = 0;
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(magic, 1, sizeof magic, wth->fh);
|
||||
if (bytes_read != sizeof magic) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* toshiba.c
|
||||
*
|
||||
* $Id: toshiba.c,v 1.14 2000/11/19 03:47:36 guy Exp $
|
||||
* $Id: toshiba.c,v 1.15 2001/03/10 06:33:58 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -182,9 +182,7 @@ static gboolean toshiba_check_file_type(wtap *wth)
|
|||
/* XXX - return -1 on I/O error and actually do something with 'err'. */
|
||||
int toshiba_open(wtap *wth, int *err)
|
||||
{
|
||||
/* Reset file position and look for Toshiba header */
|
||||
file_seek(wth->fh, 0, SEEK_SET);
|
||||
|
||||
/* Look for Toshiba header */
|
||||
if (!toshiba_check_file_type(wth)) {
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue