From c0c480d08c175eed4524ea9e73ec86298f468cf4 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 22 May 2014 20:01:31 -0700 Subject: 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 --- wiretap/pppdump.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'wiretap/pppdump.c') diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index 6ba142485b..319ada0feb 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -95,9 +95,9 @@ typedef enum { DIRECTION_RECV } direction_enum; -static gboolean pppdump_read(wtap *wth, int *err, gchar **err_info, +static int pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off, +static int pppdump_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); /* @@ -327,7 +327,7 @@ pppdump_set_phdr(struct wtap_pkthdr *phdr, int num_bytes, } /* Find the next packet and parse it; called from wtap_read(). */ -static gboolean +static int pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { int num_bytes; @@ -344,7 +344,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) pid = g_new(pkt_id, 1); if (!pid) { *err = errno; /* assume a malloc failed and set "errno" */ - return FALSE; + return -1; } pid->offset = 0; } else @@ -357,7 +357,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) pid, 0)) { if (pid != NULL) g_free(pid); - return FALSE; + return -1; } if (pid != NULL) @@ -374,7 +374,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) wth->phdr.ts.nsecs = state->tenths * 100000000; pppdump_set_phdr(&wth->phdr, num_bytes, direction); - return TRUE; + return REC_TYPE_PACKET; } /* Returns number of bytes copied for record, -1 if failure. @@ -715,7 +715,7 @@ done: /* Used to read packets in random-access fashion */ -static gboolean +static int pppdump_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, @@ -736,11 +736,11 @@ pppdump_seek_read(wtap *wth, if (!pid) { *err = WTAP_ERR_BAD_FILE; /* XXX - better error? */ *err_info = g_strdup("pppdump: PID not found for record"); - return FALSE; + return -1; } if (file_seek(wth->random_fh, pid->offset, SEEK_SET, err) == -1) - return FALSE; + return -1; init_state(state->seek_state); state->seek_state->offset = pid->offset; @@ -763,13 +763,13 @@ pppdump_seek_read(wtap *wth, do { if (!collate(state->seek_state, wth->random_fh, err, err_info, pd, &num_bytes, &direction, NULL, num_bytes_to_skip)) - return FALSE; + return -1; num_bytes_to_skip = 0; } while (direction != pid->dir); pppdump_set_phdr(phdr, num_bytes, pid->dir); - return TRUE; + return REC_TYPE_PACKET; } static void -- cgit v1.2.1