summaryrefslogtreecommitdiff
path: root/capinfos.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-05-24 11:28:30 -0700
committerGuy Harris <guy@alum.mit.edu>2014-05-24 18:31:25 +0000
commit6db77b000fe58173eeed23b91b32c92c681feda2 (patch)
tree5113821a7f5e1b43734eccf94783d37962b37712 /capinfos.c
parent33ae4cb024e36192ff7c6fa1d3d6bdcce9b25b7a (diff)
downloadwireshark-6db77b000fe58173eeed23b91b32c92c681feda2.tar.gz
Allow wtap_read() and wtap_seek_read() to return records other than packets.
Add a "record type" field to "struct wtap_pkthdr"; currently, it can be REC_TYPE_PACKET, for a record containing a packet, or REC_TYPE_FILE_TYPE_SPECIFIC, for records containing file-type-specific data. Modify code that reads packets to be able to handle non-packet records, even if that just means ignoring them. Rename some routines to indicate that they handle more than just packets. We don't yet have any libwiretap code that supplies records other than REC_TYPE_PACKET or that supporting writing records other than REC_TYPE_PACKET, or any code to support plugins for handling REC_TYPE_FILE_TYPE_SPECIFIC records; this is just the first step for bug 8590. Change-Id: Idb40b78f17c2c3aea72031bcd252abf9bc11c813 Reviewed-on: https://code.wireshark.org/review/1773 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'capinfos.c')
-rw-r--r--capinfos.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/capinfos.c b/capinfos.c
index bad557e2dd..811f5af8bd 100644
--- a/capinfos.c
+++ b/capinfos.c
@@ -853,26 +853,28 @@ process_cap_file(wtap *wth, const char *filename)
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;
- }
+ if (phdr->rec_type == REC_TYPE_PACKET) {
+ 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);
+ }
}
}