summaryrefslogtreecommitdiff
path: root/wiretap/nettl.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/nettl.c
parentf65cb5f27bab6310e847f88cd763eb08bff1c93b (diff)
downloadwireshark-33bb54a9452f4be53377a185195a63194016241a.tar.gz
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/nettl.c')
-rw-r--r--wiretap/nettl.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/wiretap/nettl.c b/wiretap/nettl.c
index 83868011bf..b83c693cf7 100644
--- a/wiretap/nettl.c
+++ b/wiretap/nettl.c
@@ -295,7 +295,6 @@ int nettl_open(wtap *wth, int *err, gchar **err_info)
g_free(nettl);
return -1;
}
- wth->data_offset = FILE_HDR_SIZE;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
return 1;
@@ -309,14 +308,13 @@ static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
gboolean fddihack=FALSE;
/* Read record header. */
- *data_offset = wth->data_offset;
+ *data_offset = file_tell(wth->fh);
ret = nettl_read_rec_header(wth, wth->fh, &wth->phdr, &wth->pseudo_header,
err, err_info, &fddihack);
if (ret <= 0) {
/* Read error or EOF */
return FALSE;
}
- wth->data_offset += ret;
if (wth->phdr.caplen > WTAP_MAX_PACKET_SIZE) {
/*
@@ -351,7 +349,6 @@ static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
if (!nettl_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer),
wth->phdr.caplen, err, err_info, fddihack))
return FALSE; /* Read error */
- wth->data_offset += wth->phdr.caplen;
return TRUE;
}