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 --- capture_info.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'capture_info.c') diff --git a/capture_info.c b/capture_info.c index 3ef12df504..c3c232816c 100644 --- a/capture_info.c +++ b/capture_info.c @@ -232,9 +232,11 @@ gboolean capture_info_new_file(const char *new_filename) } -/* new packets arrived */ -void capture_info_new_packets(int to_read) +/* new records arrived */ +void capture_info_new_records(int to_read) { + int rec_type; + int packets_read = 0; int err; gchar *err_info; gint64 data_offset; @@ -244,25 +246,27 @@ void capture_info_new_packets(int to_read) const guchar *buf; - info_data.ui.new_packets = to_read; - /*g_warning("new packets: %u", to_read);*/ while (to_read > 0) { wtap_cleareof(info_data.wtap); - if (wtap_read(info_data.wtap, &err, &err_info, &data_offset)) { - phdr = wtap_phdr(info_data.wtap); - pseudo_header = &phdr->pseudo_header; - wtap_linktype = phdr->pkt_encap; - buf = wtap_buf_ptr(info_data.wtap); + if ((rec_type = wtap_read(info_data.wtap, &err, &err_info, &data_offset)) != -1) { + if (rec_type == REC_TYPE_PACKET) { + phdr = wtap_phdr(info_data.wtap); + pseudo_header = &phdr->pseudo_header; + wtap_linktype = phdr->pkt_encap; + buf = wtap_buf_ptr(info_data.wtap); - capture_info_packet(&info_data.counts, wtap_linktype, buf, phdr->caplen, pseudo_header); + capture_info_packet(&info_data.counts, wtap_linktype, buf, phdr->caplen, pseudo_header); + packets_read++; - /*g_warning("new packet");*/ + /*g_warning("new packet");*/ + } to_read--; } } + info_data.ui.new_packets = packets_read; capture_info_ui_update(&info_data.ui); } -- cgit v1.2.1