summaryrefslogtreecommitdiff
path: root/wiretap/network_instruments.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/network_instruments.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/network_instruments.c')
-rw-r--r--wiretap/network_instruments.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c
index 38abfab2cd..01ed983932 100644
--- a/wiretap/network_instruments.c
+++ b/wiretap/network_instruments.c
@@ -94,9 +94,9 @@ static void init_gmt_to_localtime_offset(void)
}
}
-static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
+static int observer_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
-static gboolean observer_seek_read(wtap *wth, gint64 seek_off,
+static int observer_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
static int read_packet_header(FILE_T fh, union wtap_pseudo_header *pseudo_header,
packet_entry_header *packet_header, int *err, gchar **err_info);
@@ -258,7 +258,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
}
/* Reads the next packet. */
-static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
+static int observer_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
int header_bytes_consumed;
@@ -273,7 +273,7 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
header_bytes_consumed = read_packet_header(wth->fh, &wth->phdr.pseudo_header, &packet_header, err,
err_info);
if (header_bytes_consumed <= 0)
- return FALSE; /* EOF or error */
+ return -1; /* EOF or error */
if (packet_header.packet_type == PACKET_TYPE_DATA_PACKET)
break;
@@ -281,32 +281,32 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
/* skip to next packet */
if (!skip_to_next_packet(wth, packet_header.offset_to_next_packet,
header_bytes_consumed, err, err_info)) {
- return FALSE; /* EOF or error */
+ return -1; /* EOF or error */
}
}
if (!process_packet_header(wth, &packet_header, &wth->phdr, err, err_info))
- return FALSE;
+ return -1;
/* read the frame data */
data_bytes_consumed = read_packet_data(wth->fh, packet_header.offset_to_frame,
header_bytes_consumed, wth->frame_buffer,
wth->phdr.caplen, err, err_info);
if (data_bytes_consumed < 0) {
- return FALSE;
+ return -1;
}
/* skip over any extra bytes following the frame data */
if (!skip_to_next_packet(wth, packet_header.offset_to_next_packet,
header_bytes_consumed + data_bytes_consumed, err, err_info)) {
- return FALSE;
+ return -1;
}
- return TRUE;
+ return REC_TYPE_PACKET;
}
/* Reads a packet at an offset. */
-static gboolean observer_seek_read(wtap *wth, gint64 seek_off,
+static int observer_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
@@ -315,25 +315,25 @@ static gboolean observer_seek_read(wtap *wth, gint64 seek_off,
int data_bytes_consumed;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
- return FALSE;
+ return -1;
/* process the packet header, including TLVs */
offset = read_packet_header(wth->random_fh, pseudo_header, &packet_header, err,
err_info);
if (offset <= 0)
- return FALSE; /* EOF or error */
+ return -1; /* EOF or error */
if (!process_packet_header(wth, &packet_header, phdr, err, err_info))
- return FALSE;
+ return -1;
/* read the frame data */
data_bytes_consumed = read_packet_data(wth->random_fh, packet_header.offset_to_frame,
offset, buf, phdr->caplen, err, err_info);
if (data_bytes_consumed < 0) {
- return FALSE;
+ return -1;
}
- return TRUE;
+ return REC_TYPE_PACKET;
}
static int