aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/etherpeek.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-05-04 16:56:18 +0000
committerGuy Harris <guy@alum.mit.edu>2012-05-04 16:56:18 +0000
commit33bb54a9452f4be53377a185195a63194016241a (patch)
tree9308829e2105b6e51e0dc5cc0af2295d8d97a0a3 /wiretap/etherpeek.c
parentf65cb5f27bab6310e847f88cd763eb08bff1c93b (diff)
file_seek() used to be a wrapper around fseek() or gzseek(), both of
which could use lseek() and were thus expensive due to system call overhead. To avoid making a system call for every packet on a sequential read, we maintained a data_offset field in the wtap structure for sequential reads. It's now a routine that just returns information from the FILE_T data structure, so it's cheap. Use it, rather than maintaining the data_offset field. Readers for some file formats need to maintain file offset themselves; have them do so in their private data structures. svn path=/trunk/; revision=42423
Diffstat (limited to 'wiretap/etherpeek.c')
-rw-r--r--wiretap/etherpeek.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/wiretap/etherpeek.c b/wiretap/etherpeek.c
index fb5659c3fd..6f7dac635e 100644
--- a/wiretap/etherpeek.c
+++ b/wiretap/etherpeek.c
@@ -165,7 +165,6 @@ int etherpeek_open(wtap *wth, int *err, gchar **err_info)
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, err_info);
- wth->data_offset += sizeof(ep_hdr.master);
/*
* It appears that EtherHelp (a free application from WildPackets
@@ -193,7 +192,6 @@ int etherpeek_open(wtap *wth, int *err, gchar **err_info)
wtap_file_read_unknown_bytes(
&ep_hdr.secondary.v567,
sizeof(ep_hdr.secondary.v567), wth->fh, err, err_info);
- wth->data_offset += sizeof(ep_hdr.secondary.v567);
if ((0 != ep_hdr.secondary.v567.reserved[0]) ||
(0 != ep_hdr.secondary.v567.reserved[1]) ||
@@ -361,11 +359,10 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
time_t tsecs;
guint32 tusecs;
- *data_offset = wth->data_offset;
+ *data_offset = file_tell(wth->fh);
wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->fh, err,
err_info);
- wth->data_offset += sizeof(ep_pkt);
/* Extract the fields from the packet */
#if 0
@@ -412,7 +409,6 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
buffer_assure_space(wth->frame_buffer, sliceLength);
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
sliceLength, wth->fh, err, err_info);
- wth->data_offset += sliceLength;
/* fill in packet header values */
tsecs = (time_t) (timestamp/1000000);
@@ -505,11 +501,10 @@ static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info,
* the packet header, we can remember the offset of the data,
* and not have the seek_read routine read the header.
*/
- *data_offset = wth->data_offset;
+ *data_offset = file_tell(wth->fh);
wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->fh, err,
err_info);
- wth->data_offset += sizeof(ep_pkt);
/* Extract the fields from the packet */
length = pntohs(&ep_pkt[ETHERPEEK_V56_LENGTH_OFFSET]);
@@ -541,7 +536,6 @@ static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info,
buffer_assure_space(wth->frame_buffer, sliceLength);
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
sliceLength, wth->fh, err, err_info);
- wth->data_offset += sliceLength;
/* fill in packet header values */
wth->phdr.len = length;