summaryrefslogtreecommitdiff
path: root/wiretap/mime_file.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-05-22 20:01:31 -0700
committerGuy Harris <guy@alum.mit.edu>2014-05-23 03:02:32 +0000
commitc0c480d08c175eed4524ea9e73ec86298f468cf4 (patch)
tree1234cd09094dcc8447e3fb2b13671f12aba5ae69 /wiretap/mime_file.c
parent6287efb9c05482531ea675bb5a3d23b03b5715ab (diff)
downloadwireshark-c0c480d08c175eed4524ea9e73ec86298f468cf4.tar.gz
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/mime_file.c')
-rw-r--r--wiretap/mime_file.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/wiretap/mime_file.c b/wiretap/mime_file.c
index 2a7d8be0e4..0f8934a28e 100644
--- a/wiretap/mime_file.c
+++ b/wiretap/mime_file.c
@@ -94,7 +94,7 @@ static const mime_files_t magic_files[] = {
*/
#define MAX_FILE_SIZE (16*1024*1024)
-static gboolean
+static int
mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
Buffer *buf, int *err, gchar **err_info)
{
@@ -102,7 +102,7 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
int packet_size;
if ((file_size = wtap_file_size(wth, err)) == -1)
- return FALSE;
+ return -1;
if (file_size > MAX_FILE_SIZE) {
/*
@@ -112,7 +112,7 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("mime_file: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u",
file_size, MAX_FILE_SIZE);
- return FALSE;
+ return -1;
}
packet_size = (int)file_size;
@@ -124,10 +124,12 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
phdr->ts.secs = 0;
phdr->ts.nsecs = 0;
- return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
+ if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
+ return -1;
+ return REC_TYPE_PACKET;
}
-static gboolean
+static int
mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset;
@@ -138,24 +140,24 @@ mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
/* there is only ever one packet */
if (offset != 0)
- return FALSE;
+ return -1;
*data_offset = offset;
return mime_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
}
-static gboolean
+static int
mime_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
/* there is only one packet */
if (seek_off > 0) {
*err = 0;
- return FALSE;
+ return -1;
}
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
- return FALSE;
+ return -1;
return mime_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
}