summaryrefslogtreecommitdiff
path: root/capinfos.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 /capinfos.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 'capinfos.c')
-rw-r--r--capinfos.c87
1 files changed, 45 insertions, 42 deletions
diff --git a/capinfos.c b/capinfos.c
index bad557e2dd..a24a6ae5a2 100644
--- a/capinfos.c
+++ b/capinfos.c
@@ -803,6 +803,7 @@ static int
process_cap_file(wtap *wth, const char *filename)
{
int status = 0;
+ int rec_type;
int err;
gchar *err_info;
gint64 size;
@@ -828,51 +829,53 @@ process_cap_file(wtap *wth, const char *filename)
cf_info.encap_counts = g_new0(int,WTAP_NUM_ENCAP_TYPES);
/* Tally up data that we need to parse through the file to find */
- while (wtap_read(wth, &err, &err_info, &data_offset)) {
- phdr = wtap_phdr(wth);
- if (phdr->presence_flags & WTAP_HAS_TS) {
- prev_time = cur_time;
- cur_time = nstime_to_sec(&phdr->ts);
- if (packet == 0) {
- start_time = cur_time;
- stop_time = cur_time;
- prev_time = cur_time;
- }
- if (cur_time < prev_time) {
- order = NOT_IN_ORDER;
- }
- if (cur_time < start_time) {
- start_time = cur_time;
- }
- if (cur_time > stop_time) {
- stop_time = cur_time;
+ while ((rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1) {
+ if (rec_type == REC_TYPE_PACKET) {
+ phdr = wtap_phdr(wth);
+ if (phdr->presence_flags & WTAP_HAS_TS) {
+ prev_time = cur_time;
+ cur_time = nstime_to_sec(&phdr->ts);
+ if (packet == 0) {
+ start_time = cur_time;
+ stop_time = cur_time;
+ prev_time = cur_time;
+ }
+ if (cur_time < prev_time) {
+ order = NOT_IN_ORDER;
+ }
+ if (cur_time < start_time) {
+ start_time = cur_time;
+ }
+ if (cur_time > stop_time) {
+ stop_time = cur_time;
+ }
+ } else {
+ have_times = FALSE; /* at least one packet has no time stamp */
+ if (order != NOT_IN_ORDER)
+ order = ORDER_UNKNOWN;
}
- } else {
- have_times = FALSE; /* at least one packet has no time stamp */
- if (order != NOT_IN_ORDER)
- order = ORDER_UNKNOWN;
- }
- bytes+=phdr->len;
- packet++;
-
- /* If caplen < len for a rcd, then presumably */
- /* 'Limit packet capture length' was done for this rcd. */
- /* Keep track as to the min/max actual snapshot lengths */
- /* seen for this file. */
- if (phdr->caplen < phdr->len) {
- if (phdr->caplen < snaplen_min_inferred)
- snaplen_min_inferred = phdr->caplen;
- if (phdr->caplen > snaplen_max_inferred)
- snaplen_max_inferred = phdr->caplen;
- }
+ bytes+=phdr->len;
+ packet++;
+
+ /* If caplen < len for a rcd, then presumably */
+ /* 'Limit packet capture length' was done for this rcd. */
+ /* Keep track as to the min/max actual snapshot lengths */
+ /* seen for this file. */
+ if (phdr->caplen < phdr->len) {
+ if (phdr->caplen < snaplen_min_inferred)
+ snaplen_min_inferred = phdr->caplen;
+ if (phdr->caplen > snaplen_max_inferred)
+ snaplen_max_inferred = phdr->caplen;
+ }
- /* Per-packet encapsulation */
- if (wtap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) {
- if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
- cf_info.encap_counts[phdr->pkt_encap] += 1;
- } else {
- fprintf(stderr, "capinfos: Unknown per-packet encapsulation: %d [frame number: %d]\n", phdr->pkt_encap, packet);
+ /* Per-packet encapsulation */
+ if (wtap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) {
+ if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
+ cf_info.encap_counts[phdr->pkt_encap] += 1;
+ } else {
+ fprintf(stderr, "capinfos: Unknown per-packet encapsulation: %d [frame number: %d]\n", phdr->pkt_encap, packet);
+ }
}
}