summaryrefslogtreecommitdiff
path: root/wiretap/btsnoop.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/btsnoop.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/btsnoop.c')
-rw-r--r--wiretap/btsnoop.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c
index a8e6d80e73..c9397d556b 100644
--- a/wiretap/btsnoop.c
+++ b/wiretap/btsnoop.c
@@ -98,7 +98,6 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info)
return -1;
return 0;
}
- wth->data_offset += sizeof magic;
if (memcmp(magic, btsnoop_magic, sizeof btsnoop_magic) != 0) {
return 0;
@@ -113,7 +112,6 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info)
return -1;
return 0;
}
- wth->data_offset += sizeof hdr;
/*
* Make sure it's a version we support.
@@ -169,7 +167,7 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
/* As the send/receive flag is stored in the middle of the capture header
but needs to go in the pseudo header for wiretap, the header needs to be reread
in the seek_read function*/
- *data_offset = wth->data_offset;
+ *data_offset = file_tell(wth->fh);
/* Read record header. */
errno = WTAP_ERR_CANT_READ;
@@ -180,7 +178,6 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
- wth->data_offset += sizeof hdr;
packet_size = g_ntohl(hdr.incl_len);
orig_size = g_ntohl(hdr.orig_len);
@@ -201,7 +198,6 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
packet_size, err, err_info)) {
return FALSE; /* Read error */
}
- wth->data_offset += packet_size;
ts = GINT64_FROM_BE(hdr.ts_usec);
ts -= KUnixTimeBase;