aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/lanalyzer.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-02-26 10:20:40 +0000
committerGuy Harris <guy@alum.mit.edu>2012-02-26 10:20:40 +0000
commit83bf13e1e609e3fa3a935876e707aecfda4635de (patch)
tree603ee4399ff394ab426b33b350c1303441b5a78c /wiretap/lanalyzer.c
parent30b86b78178e111747eaf605925cce289483b98d (diff)
For LANalyzer files, make the "File type name" be the file comment.
Display the file comment in the Summary dialog. svn path=/trunk/; revision=41188
Diffstat (limited to 'wiretap/lanalyzer.c')
-rw-r--r--wiretap/lanalyzer.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index d762f386c0..75331c665b 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -278,6 +278,8 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
LA_RecordHeader rec_header;
+ char header_fixed[2];
+ char *comment;
char summary[210];
guint16 board_type, mxslc;
guint16 record_type, record_length;
@@ -302,6 +304,39 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
return 0;
}
+ /* Read the major and minor version numbers */
+ if (record_length < 2) {
+ /* Not enough room for the major and minor version numbers. */
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup_printf("lanalyzer: trace header record length %u < 2",
+ record_length);
+ return -1;
+ }
+ bytes_read = file_read(&header_fixed, sizeof header_fixed, wth->fh);
+ if (bytes_read != sizeof header_fixed) {
+ *err = file_error(wth->fh, err_info);
+ if (*err == 0)
+ *err = WTAP_ERR_SHORT_READ;
+ return -1;
+ }
+ wth->data_offset += sizeof header_fixed;
+ record_length -= sizeof header_fixed;
+
+ if (record_length != 0) {
+ /* Read the rest of the record as a comment. */
+ comment = g_malloc(record_length + 1);
+ bytes_read = file_read(comment, record_length, wth->fh);
+ if (bytes_read != record_length) {
+ *err = file_error(wth->fh, err_info);
+ if (*err == 0)
+ *err = WTAP_ERR_SHORT_READ;
+ return -1;
+ }
+ comment[record_length] = '\0';
+ wth->data_offset += record_length;
+ wth->shb_hdr.opt_comment = comment;
+ }
+
/* If we made it this far, then the file is a LANAlyzer file.
* Let's get some info from it. Note that we get wth->snapshot_length
* from a record later in the file. */
@@ -315,11 +350,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
/* Read records until we find the start of packets */
while (1) {
- if (file_seek(wth->fh, record_length, SEEK_CUR, err) == -1) {
- g_free(wth->priv);
- return -1;
- }
- wth->data_offset += record_length;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&rec_header, LA_RecordHeaderSize, wth->fh);
if (bytes_read != LA_RecordHeaderSize) {
@@ -382,7 +412,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
mxslc = pletohs(&summary[30]);
wth->snapshot_length = mxslc;
- record_length = 0; /* to fake the next iteration of while() */
board_type = pletohs(&summary[188]);
switch (board_type) {
case BOARD_325:
@@ -412,7 +441,12 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
return 1;
default:
- ; /* no action */
+ if (file_seek(wth->fh, record_length, SEEK_CUR, err) == -1) {
+ g_free(wth->priv);
+ return -1;
+ }
+ wth->data_offset += record_length;
+ break;
}
}
}