aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/iptrace.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2021-07-13 13:57:04 -0700
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-07-14 00:31:03 +0000
commit23f19e4a5d16019d67452b85f960d43063e0fd10 (patch)
tree2cccd1a9c3a15c73c8af44ab55bfe7d553f5d747 /wiretap/iptrace.c
parent9c344b207d83723eee961a36c022a36a08a4c7de (diff)
wiretap: iptrace/Sniffer/Peek classic always have packet flags.
For iptrace files, there's always a direction indication (which also means that the flags field will never be zero - "outbound" and "inbound" both have non-zero values - so the test for non-zero always succeeds, so it's not even a useful test). For Sniffer Ethernet/FDDI/synchronous serial line files, and for Peek classic files, there are always flags; they might be zero if there were no errors, but that doesn't mean that the lack of errors shouldn't be noted with a flags field. While we're at it, shuffle creating of the block next to the setting of the record type - the block and record type should match, so the two operations are doing related things.
Diffstat (limited to 'wiretap/iptrace.c')
-rw-r--r--wiretap/iptrace.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c
index 62b0f8b298..bd84ea040a 100644
--- a/wiretap/iptrace.c
+++ b/wiretap/iptrace.c
@@ -202,7 +202,6 @@ iptrace_read_rec_1_0(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
guint8 pkt_info[IPTRACE_1_0_PINFO_SIZE];
if_info info;
guint32 packet_size;
- guint32 pack_flags = 0;
gpointer result;
if (!wtap_read_bytes_or_eof(fh, header, IPTRACE_1_0_PHDR_SIZE, err,
@@ -289,19 +288,16 @@ iptrace_read_rec_1_0(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
}
rec->rec_type = REC_TYPE_PACKET;
+ rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS | WTAP_HAS_INTERFACE_ID;
rec->rec_header.packet_header.len = packet_size;
rec->rec_header.packet_header.caplen = packet_size;
rec->ts.secs = pntoh32(&header[IPTRACE_1_0_TV_SEC_OFFSET]);
rec->ts.nsecs = 0;
- rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
- pack_flags =
+ wtap_block_add_uint32_option(rec->block, OPT_PKT_FLAGS,
pkt_info[IPTRACE_1_0_TX_FLAGS_OFFSET] ?
(PACK_FLAGS_DIRECTION_OUTBOUND << PACK_FLAGS_DIRECTION_SHIFT) :
- (PACK_FLAGS_DIRECTION_INBOUND << PACK_FLAGS_DIRECTION_SHIFT);
- if (pack_flags != 0) {
- wtap_block_add_uint32_option(rec->block, OPT_PKT_FLAGS, pack_flags);
- }
+ (PACK_FLAGS_DIRECTION_INBOUND << PACK_FLAGS_DIRECTION_SHIFT));
/* Fill in the pseudo-header. */
fill_in_pseudo_header(rec->rec_header.packet_header.pkt_encap,
@@ -460,7 +456,6 @@ iptrace_read_rec_2_0(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
guint8 pkt_info[IPTRACE_2_0_PINFO_SIZE];
if_info info;
guint32 packet_size;
- guint32 pack_flags = 0;
gpointer result;
if (!wtap_read_bytes_or_eof(fh, header, IPTRACE_2_0_PHDR_SIZE, err,
@@ -565,19 +560,16 @@ iptrace_read_rec_2_0(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
}
rec->rec_type = REC_TYPE_PACKET;
+ rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS | WTAP_HAS_INTERFACE_ID;
rec->rec_header.packet_header.len = packet_size;
rec->rec_header.packet_header.caplen = packet_size;
rec->ts.secs = pntoh32(&pkt_info[IPTRACE_2_0_TV_SEC_OFFSET]);
rec->ts.nsecs = pntoh32(&pkt_info[IPTRACE_2_0_TV_NSEC_OFFSET]);
- rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
- pack_flags =
+ wtap_block_add_uint32_option(rec->block, OPT_PKT_FLAGS,
pkt_info[IPTRACE_2_0_TX_FLAGS_OFFSET] ?
(PACK_FLAGS_DIRECTION_OUTBOUND << PACK_FLAGS_DIRECTION_SHIFT) :
- (PACK_FLAGS_DIRECTION_INBOUND << PACK_FLAGS_DIRECTION_SHIFT);
- if (pack_flags != 0) {
- wtap_block_add_uint32_option(rec->block, OPT_PKT_FLAGS, pack_flags);
- }
+ (PACK_FLAGS_DIRECTION_INBOUND << PACK_FLAGS_DIRECTION_SHIFT));
/* Fill in the pseudo-header. */
fill_in_pseudo_header(rec->rec_header.packet_header.pkt_encap,