aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/pcapng.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 /wiretap/pcapng.c
parent33ae4cb024e36192ff7c6fa1d3d6bdcce9b25b7a (diff)
downloadwireshark-6db77b000fe58173eeed23b91b32c92c681feda2.tar.gz
wireshark-6db77b000fe58173eeed23b91b32c92c681feda2.tar.bz2
wireshark-6db77b000fe58173eeed23b91b32c92c681feda2.zip
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 'wiretap/pcapng.c')
-rw-r--r--wiretap/pcapng.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index a0be4a9eaa..6fd0a881e2 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -1109,6 +1109,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
iface_info = g_array_index(pn->interfaces, interface_info_t,
packet.interface_id);
+ wblock->packet_header->rec_type = REC_TYPE_PACKET;
wblock->packet_header->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID;
pcapng_debug3("pcapng_read_packet_block: encapsulation = %d (%s), pseudo header size = %d.",
@@ -1388,6 +1389,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
pcap_get_phdr_size(iface_info.wtap_encap, &wblock->packet_header->pseudo_header));
/* No time stamp in a simple packet block; no options, either */
+ wblock->packet_header->rec_type = REC_TYPE_PACKET;
wblock->packet_header->presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID;
wblock->packet_header->interface_id = 0;
wblock->packet_header->pkt_encap = iface_info.wtap_encap;
@@ -3552,6 +3554,12 @@ static gboolean pcapng_dump(wtap_dumper *wdh,
phdr->pkt_encap,
wtap_encap_string(phdr->pkt_encap));
+ /* We can only write packet records. */
+ if (phdr->rec_type != REC_TYPE_PACKET) {
+ *err = WTAP_ERR_REC_TYPE_UNSUPPORTED;
+ return FALSE;
+ }
+
/* Flush any hostname resolution info we may have */
pcapng_write_name_resolution_block(wdh, err);