aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/iptrace.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-08-28 01:19:45 +0000
committerGuy Harris <guy@alum.mit.edu>1999-08-28 01:19:45 +0000
commitae53260d0213cb805bcd84ee13045dd1f8a42e9c (patch)
tree3bdd6153eed5e75a235ad53a9bc3727bf40c0a57 /wiretap/iptrace.c
parentf7951bd593675a2e958e0ba7c37c93533bd6e39e (diff)
Keep in the "wtap" structure the current offset into the file being
read, and maintain it ourselves as we read through the file, rather than calling "ftell()" for every packet we read - "ftell()" may involve an "lseek()" call, which could add a noticeable CPU overhead when reading a large file. svn path=/trunk/; revision=596
Diffstat (limited to 'wiretap/iptrace.c')
-rw-r--r--wiretap/iptrace.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c
index 5b3652dc86..2d6ac59422 100644
--- a/wiretap/iptrace.c
+++ b/wiretap/iptrace.c
@@ -1,6 +1,6 @@
/* iptrace.c
*
- * $Id: iptrace.c,v 1.9 1999/08/24 03:19:34 guy Exp $
+ * $Id: iptrace.c,v 1.10 1999/08/28 01:19:43 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -39,6 +39,7 @@ int iptrace_open(wtap *wth, int *err)
char name[12];
fseek(wth->fh, 0, SEEK_SET);
+ wth->data_offset = 0;
errno = WTAP_ERR_CANT_READ;
bytes_read = fread(name, 1, 11, wth->fh);
if (bytes_read != 11) {
@@ -48,6 +49,7 @@ int iptrace_open(wtap *wth, int *err)
}
return 0;
}
+ wth->data_offset += 11;
name[11] = 0;
if (strcmp(name, "iptrace 2.0") != 0) {
return 0;
@@ -81,12 +83,13 @@ static int iptrace_read(wtap *wth, int *err)
}
return 0;
}
+ wth->data_offset += 40;
packet_size = pntohs(&header[2]) - 32;
/* Read the packet data */
buffer_assure_space(wth->frame_buffer, packet_size);
- data_offset = ftell(wth->fh);
+ data_offset = wth->data_offset;
errno = WTAP_ERR_CANT_READ;
bytes_read = fread(buffer_start_ptr(wth->frame_buffer), 1,
packet_size, wth->fh);
@@ -98,6 +101,7 @@ static int iptrace_read(wtap *wth, int *err)
*err = WTAP_ERR_SHORT_READ;
return -1;
}
+ wth->data_offset += packet_size;
wth->phdr.len = packet_size;
wth->phdr.caplen = packet_size;