diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-06-16 00:20:00 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-06-16 00:20:00 +0000 |
commit | 8c9edf12800bc6d68894dc457e7ebaf994429da8 (patch) | |
tree | ec6efefbd4e7f8227a7b96661f721ff4ba2986c3 /wiretap/lanalyzer.c | |
parent | 3846abe34d6861c6ee0bba61fcd5baa4d213885c (diff) | |
download | wireshark-8c9edf12800bc6d68894dc457e7ebaf994429da8.tar.gz wireshark-8c9edf12800bc6d68894dc457e7ebaf994429da8.tar.bz2 wireshark-8c9edf12800bc6d68894dc457e7ebaf994429da8.zip |
Have the seek-read routines take a Buffer rather than a guint8 pointer
as the "where to put the packet data" argument.
This lets more of the libwiretap code be common between the read and
seek-read code paths, and also allows for more flexibility in the "fill
in the data" path - we can expand the buffer as needed in both cases.
svn path=/trunk/; revision=49949
Diffstat (limited to 'wiretap/lanalyzer.c')
-rw-r--r-- | wiretap/lanalyzer.c | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index 4b20363cfb..e5d6a01fa3 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -275,7 +275,7 @@ typedef struct { static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, guint8 *pd, int length, + struct wtap_pkthdr *phdr, Buffer *buf, int length, int *err, gchar **err_info); static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err); @@ -565,8 +565,6 @@ static gboolean lanalyzer_read_trace_record_header(wtap *wth, FILE_T fh, static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { - int bytes_read; - *data_offset = file_tell(wth->fh); /* Read the record header and packet descriptor */ @@ -575,27 +573,14 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, return FALSE; /* Read the packet data */ - buffer_assure_space(wth->frame_buffer, wth->phdr.caplen); - errno = WTAP_ERR_CANT_READ; - bytes_read = file_read(buffer_start_ptr(wth->frame_buffer), - wth->phdr.caplen, wth->fh); - - if (bytes_read != (int)wth->phdr.caplen) { - *err = file_error(wth->fh, err_info); - if (*err == 0) - *err = WTAP_ERR_SHORT_READ; - return FALSE; - } - - return TRUE; + return wtap_read_packet_bytes(wth->fh, wth->frame_buffer, + wth->phdr.caplen, err, err_info); } static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, guint8 *pd, int length, int *err, + struct wtap_pkthdr *phdr, Buffer *buf, int length, int *err, gchar **err_info) { - int bytes_read; - if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; @@ -607,15 +592,8 @@ static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off, /* * Read the packet data. */ - bytes_read = file_read(pd, length, wth->random_fh); - if (bytes_read != length) { - *err = file_error(wth->random_fh, err_info); - if (*err == 0) - *err = WTAP_ERR_SHORT_READ; - return FALSE; - } - - return TRUE; + return wtap_read_packet_bytes(wth->random_fh, buf, + length, err, err_info); } /*--------------------------------------------------- |