summaryrefslogtreecommitdiff
path: root/wiretap/lanalyzer.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/lanalyzer.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/lanalyzer.c')
-rw-r--r--wiretap/lanalyzer.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index 498855bbef..77a6887041 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -296,7 +296,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
return -1;
return 0;
}
- wth->data_offset += LA_RecordHeaderSize;
record_type = pletohs(rec_header.record_type);
record_length = pletohs(rec_header.record_length); /* make sure to do this for while() loop */
@@ -319,7 +318,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_SHORT_READ;
return -1;
}
- wth->data_offset += sizeof header_fixed;
record_length -= sizeof header_fixed;
if (record_length != 0) {
@@ -333,7 +331,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
return -1;
}
comment[record_length] = '\0';
- wth->data_offset += record_length;
wth->shb_hdr.opt_comment = comment;
}
@@ -361,7 +358,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
g_free(wth->priv);
return 0;
}
- wth->data_offset += LA_RecordHeaderSize;
record_type = pletohs(rec_header.record_type);
record_length = pletohs(rec_header.record_length);
@@ -382,7 +378,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
g_free(wth->priv);
return 0;
}
- wth->data_offset += sizeof summary;
/* Assume that the date of the creation of the trace file
* is the same date of the trace. Lanalyzer doesn't
@@ -437,7 +432,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
g_free(wth->priv);
return -1;
}
- wth->data_offset -= LA_RecordHeaderSize;
return 1;
default:
@@ -445,7 +439,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
g_free(wth->priv);
return -1;
}
- wth->data_offset += record_length;
break;
}
}
@@ -478,7 +471,6 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
}
return FALSE;
}
- wth->data_offset += 2;
bytes_read = file_read(LE_record_length, 2, wth->fh);
if (bytes_read != 2) {
*err = file_error(wth->fh, err_info);
@@ -486,7 +478,6 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
- wth->data_offset += 2;
record_type = pletohs(LE_record_type);
record_length = pletohs(LE_record_length);
@@ -523,11 +514,10 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
- wth->data_offset += DESCRIPTOR_LEN;
/* Read the packet data */
buffer_assure_space(wth->frame_buffer, packet_size);
- *data_offset = wth->data_offset;
+ *data_offset = file_tell(wth->fh);
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(buffer_start_ptr(wth->frame_buffer),
packet_size, wth->fh);
@@ -538,7 +528,6 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
- wth->data_offset += packet_size;
true_size = pletohs(&descriptor[4]);
packet_size = pletohs(&descriptor[6]);