diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-02-08 16:19:12 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2018-02-09 00:29:51 +0000 |
commit | 1f5f63f8ef98bfe9c4d734674cee0df64855555d (patch) | |
tree | 133dd3563cc8d2d29dd85d4d43cd9a4636283192 /ui/text_import.c | |
parent | e4c5efafb7da2d25b7d47fe2dac3b1556c0b67b0 (diff) |
Generalize wtap_pkthdr into a structure for packet and non-packet records.
Separate the stuff that any record could have from the stuff that only
particular record types have; put the latter into a union, and put all
that into a wtap_rec structure.
Add some record-type checks as necessary.
Change-Id: Id6b3486858f826fce4b096c59231f463e44bfaa2
Reviewed-on: https://code.wireshark.org/review/25696
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/text_import.c')
-rw-r--r-- | ui/text_import.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/ui/text_import.c b/ui/text_import.c index 6a4c2e998d..6cf315fb54 100644 --- a/ui/text_import.c +++ b/ui/text_import.c @@ -504,23 +504,23 @@ write_current_packet (void) { /* Write the packet */ - struct wtap_pkthdr pkthdr; + wtap_rec rec; int err; gchar *err_info; - memset(&pkthdr, 0, sizeof(struct wtap_pkthdr)); + memset(&rec, 0, sizeof rec); - pkthdr.rec_type = REC_TYPE_PACKET; - pkthdr.ts.secs = (guint32)ts_sec; - pkthdr.ts.nsecs = ts_usec * 1000; + rec.rec_type = REC_TYPE_PACKET; + rec.ts.secs = (guint32)ts_sec; + rec.ts.nsecs = ts_usec * 1000; if (ts_fmt == NULL) { ts_usec++; } /* fake packet counter */ - pkthdr.caplen = pkthdr.len = prefix_length + curr_offset + eth_trailer_length; - pkthdr.pkt_encap = pcap_link_type; - pkthdr.pack_flags |= direction; - pkthdr.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS; + rec.rec_header.packet_header.caplen = rec.rec_header.packet_header.len = prefix_length + curr_offset + eth_trailer_length; + rec.rec_header.packet_header.pkt_encap = pcap_link_type; + rec.rec_header.packet_header.pack_flags |= direction; + rec.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS; /* XXX - report errors! */ - if (!wtap_dump(wdh, &pkthdr, packet_buf, &err, &err_info)) { + if (!wtap_dump(wdh, &rec, packet_buf, &err, &err_info)) { switch (err) { case WTAP_ERR_UNWRITABLE_REC_DATA: |