diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-05-22 20:01:31 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-05-23 03:02:32 +0000 |
commit | c0c480d08c175eed4524ea9e73ec86298f468cf4 (patch) | |
tree | 1234cd09094dcc8447e3fb2b13671f12aba5ae69 /wiretap/erf.c | |
parent | 6287efb9c05482531ea675bb5a3d23b03b5715ab (diff) |
Allow wtap_read() and wtap_seek_read() to return non-packet records.
This is the first step towards implementing the mechanisms requestd in
bug 8590; currently, we don't return any records other than packet
records from libwiretap, and just ignore non-packet records in the rest
of Wireshark, but this at least gets the ball rolling.
Change-Id: I34a45b54dd361f69fdad1a758d8ca4f42d67d574
Reviewed-on: https://code.wireshark.org/review/1736
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/erf.c')
-rw-r--r-- | wiretap/erf.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/wiretap/erf.c b/wiretap/erf.c index 67b7ccab1d..3513642121 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -64,11 +64,11 @@ static int erf_read_header(FILE_T fh, gchar **err_info, guint32 *bytes_read, guint32 *packet_size); -static gboolean erf_read(wtap *wth, int *err, gchar **err_info, - gint64 *data_offset); -static gboolean erf_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, - int *err, gchar **err_info); +static int erf_read(wtap *wth, int *err, gchar **err_info, + gint64 *data_offset); +static int erf_seek_read(wtap *wth, gint64 seek_off, + struct wtap_pkthdr *phdr, Buffer *buf, + int *err, gchar **err_info); static const struct { int erf_encap_value; @@ -280,7 +280,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info) } /* Read the next packet */ -static gboolean erf_read(wtap *wth, int *err, gchar **err_info, +static int erf_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { erf_header_t erf_header; @@ -292,36 +292,38 @@ static gboolean erf_read(wtap *wth, int *err, gchar **err_info, if (!erf_read_header(wth->fh, &wth->phdr, &erf_header, err, err_info, &bytes_read, &packet_size)) { - return FALSE; + return -1; } if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, packet_size, err, err_info)) - return FALSE; + return -1; } while ( erf_header.type == ERF_TYPE_PAD ); - return TRUE; + return REC_TYPE_PACKET; } -static gboolean erf_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, - int *err, gchar **err_info) +static int erf_seek_read(wtap *wth, gint64 seek_off, + struct wtap_pkthdr *phdr, Buffer *buf, + int *err, gchar **err_info) { erf_header_t erf_header; guint32 packet_size; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return FALSE; + return -1; do { if (!erf_read_header(wth->random_fh, phdr, &erf_header, err, err_info, NULL, &packet_size)) - return FALSE; + return -1; } while ( erf_header.type == ERF_TYPE_PAD ); - return wtap_read_packet_bytes(wth->random_fh, buf, packet_size, - err, err_info); + if (!wtap_read_packet_bytes(wth->random_fh, buf, packet_size, + err, err_info)) + return -1; + return REC_TYPE_PACKET; } static int erf_read_header(FILE_T fh, |