aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/lanalyzer.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-06-17 21:18:47 +0000
committerGuy Harris <guy@alum.mit.edu>2013-06-17 21:18:47 +0000
commit32b95570df10da14e9662ac91974e89156221e10 (patch)
treed2de0f4835972269368035a2da153ed500a61444 /wiretap/lanalyzer.c
parent20de5f1a9a7d245887fa0e95bd9ef3dfbb8166bc (diff)
Merge "read record header" and "read packet data" routines into a single
routine, used both by read and seek-read routines. svn path=/trunk/; revision=49988
Diffstat (limited to 'wiretap/lanalyzer.c')
-rw-r--r--wiretap/lanalyzer.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index e5d6a01fa3..947d0c3da4 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -442,8 +442,8 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
#define DESCRIPTOR_LEN 32
-static gboolean lanalyzer_read_trace_record_header(wtap *wth, FILE_T fh,
- struct wtap_pkthdr *phdr, int *err, gchar **err_info)
+static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
+ struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
int bytes_read;
char LE_record_type[2];
@@ -558,7 +558,8 @@ static gboolean lanalyzer_read_trace_record_header(wtap *wth, FILE_T fh,
break;
}
- return TRUE;
+ /* Read the packet data */
+ return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
}
/* Read the next packet */
@@ -567,33 +568,26 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
{
*data_offset = file_tell(wth->fh);
- /* Read the record header and packet descriptor */
- if (!lanalyzer_read_trace_record_header(wth, wth->fh,
- &wth->phdr, err, err_info))
- return FALSE;
-
- /* Read the packet data */
- return wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
- wth->phdr.caplen, err, err_info);
+ /* Read the record */
+ return lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr,
+ wth->frame_buffer, err, err_info);
}
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf, int length, int *err,
+ struct wtap_pkthdr *phdr, Buffer *buf, int length _U_, int *err,
gchar **err_info)
{
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- /* Read the record header and packet descriptor */
- if (!lanalyzer_read_trace_record_header(wth, wth->random_fh, phdr,
- err, err_info))
+ /* Read the record */
+ if (!lanalyzer_read_trace_record(wth, wth->random_fh, phdr, buf,
+ err, err_info)) {
+ if (*err == 0)
+ *err = WTAP_ERR_SHORT_READ;
return FALSE;
-
- /*
- * Read the packet data.
- */
- return wtap_read_packet_bytes(wth->random_fh, buf,
- length, err, err_info);
+ }
+ return TRUE;
}
/*---------------------------------------------------