aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/iptrace.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/iptrace.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/iptrace.c')
-rw-r--r--wiretap/iptrace.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c
index 3b6c7739e2..1dca53675d 100644
--- a/wiretap/iptrace.c
+++ b/wiretap/iptrace.c
@@ -65,7 +65,6 @@ int iptrace_open(wtap *wth, int *err, gchar **err_info)
return -1;
return 0;
}
- wth->data_offset += 11;
name[11] = 0;
if (strcmp(name, "iptrace 1.0") == 0) {
@@ -134,14 +133,13 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
guint8 fddi_padding[3];
/* Read the descriptor data */
- *data_offset = wth->data_offset;
+ *data_offset = file_tell(wth->fh);
ret = iptrace_read_rec_header(wth->fh, header, IPTRACE_1_0_PHDR_SIZE,
err, err_info);
if (ret <= 0) {
/* Read error or EOF */
return FALSE;
}
- wth->data_offset += IPTRACE_1_0_PHDR_SIZE;
/*
* Byte 28 of the frame header appears to be a BSD-style IFT_xxx
@@ -185,7 +183,6 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
return FALSE;
}
packet_size -= 3;
- wth->data_offset += 3;
/*
* Read the padding.
@@ -210,7 +207,6 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
if (!iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err,
err_info))
return FALSE; /* Read error */
- wth->data_offset += packet_size;
wth->phdr.presence_flags = WTAP_HAS_TS;
wth->phdr.len = packet_size;
@@ -349,14 +345,13 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
guint8 fddi_padding[3];
/* Read the descriptor data */
- *data_offset = wth->data_offset;
+ *data_offset = file_tell(wth->fh);
ret = iptrace_read_rec_header(wth->fh, header, IPTRACE_2_0_PHDR_SIZE,
err, err_info);
if (ret <= 0) {
/* Read error or EOF */
return FALSE;
}
- wth->data_offset += IPTRACE_2_0_PHDR_SIZE;
/*
* Byte 28 of the frame header appears to be a BSD-style IFT_xxx
@@ -400,7 +395,6 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
return FALSE;
}
packet_size -= 3;
- wth->data_offset += 3;
/*
* Read the padding.
@@ -425,7 +419,6 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
if (!iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err,
err_info))
return FALSE; /* Read error */
- wth->data_offset += packet_size;
wth->phdr.presence_flags = WTAP_HAS_TS;
wth->phdr.len = packet_size;