aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/netmon.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/netmon.c
parent6287efb9c05482531ea675bb5a3d23b03b5715ab (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/netmon.c')
-rw-r--r--wiretap/netmon.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/wiretap/netmon.c b/wiretap/netmon.c
index f12bf43a87..85f3234121 100644
--- a/wiretap/netmon.c
+++ b/wiretap/netmon.c
@@ -175,9 +175,9 @@ static const int netmon_encap[] = {
#define NETMON_NET_DNS_CACHE 0xFFFE
#define NETMON_NET_NETMON_FILTER 0xFFFF
-static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
+static int netmon_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
-static gboolean netmon_seek_read(wtap *wth, gint64 seek_off,
+static int netmon_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
static gboolean netmon_read_atm_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
@@ -677,7 +677,7 @@ static process_trailer_retval netmon_process_rec_trailer(netmon_t *netmon,
}
/* Read the next packet */
-static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
+static int netmon_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
netmon_t *netmon = (netmon_t *)wth->priv;
@@ -691,7 +691,7 @@ again:
g_free(netmon->frame_table);
netmon->frame_table = NULL;
*err = 0; /* it's just an EOF, not an error */
- return FALSE;
+ return -1;
}
/* Seek to the beginning of the current record, if we're
@@ -707,7 +707,7 @@ again:
rec_offset = netmon->frame_table[netmon->current_frame];
if (file_tell(wth->fh) != rec_offset) {
if (file_seek(wth->fh, rec_offset, SEEK_SET, err) == -1)
- return FALSE;
+ return -1;
}
netmon->current_frame++;
@@ -715,11 +715,11 @@ again:
if (!netmon_process_rec_header(wth, wth->fh, &wth->phdr,
err, err_info))
- return FALSE;
+ return -1;
if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
wth->phdr.caplen, err, err_info))
- return FALSE; /* Read error */
+ return -1; /* Read error */
/*
* For version 2.1 and later, there's additional information
@@ -735,33 +735,33 @@ again:
break;
case FAILURE:
- return FALSE;
+ return -1;
}
netmon_set_pseudo_header_info(wth->phdr.pkt_encap, &wth->phdr,
wth->frame_buffer);
- return TRUE;
+ return REC_TYPE_PACKET;
}
-static gboolean
+static int
netmon_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
netmon_t *netmon = (netmon_t *)wth->priv;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
- return FALSE;
+ return -1;
if (!netmon_process_rec_header(wth, wth->random_fh, phdr,
err, err_info))
- return FALSE;
+ return -1;
/*
* Read the packet data.
*/
if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err,
err_info))
- return FALSE;
+ return -1;
/*
* For version 2.1 and later, there's additional information
@@ -776,18 +776,18 @@ netmon_seek_read(wtap *wth, gint64 seek_off,
*/
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("netmon: saw metadata in netmon_seek_read");
- return FALSE;
+ return -1;
case SUCCESS:
break;
case FAILURE:
- return FALSE;
+ return -1;
}
netmon_set_pseudo_header_info(phdr->pkt_encap, phdr, buf);
- return TRUE;
+ return REC_TYPE_PACKET;
}
static gboolean