From 8ec153f93816a302a325e40924f4e13383ad8eaf Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 17 Jan 2016 20:08:17 -0800 Subject: Have the "maybe an FCS" version of the Ethernet dissector take a data argument. It's called from some places other than packet-frame.c, at least one of which currently can't call anything else (the ATM dissector, for VC-multiplexed bridged frames, where you don't know whether the frames include the FCS or not), so the frame's pseudo-data doesn't necessarily have the appropriate "FCS length" value. Have it explicitly check the data argument, and explicitly pass the appropriate value to it. Ping-Bug: 9933 Change-Id: I0c75f921d25d1e2b75e476c15ff9625205036b25 Reviewed-on: https://code.wireshark.org/review/13382 Reviewed-by: Guy Harris --- epan/dissectors/packet-pcap_pktdata.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'epan/dissectors/packet-pcap_pktdata.c') diff --git a/epan/dissectors/packet-pcap_pktdata.c b/epan/dissectors/packet-pcap_pktdata.c index b15ae7d6f1..2e55eb3f54 100644 --- a/epan/dissectors/packet-pcap_pktdata.c +++ b/epan/dissectors/packet-pcap_pktdata.c @@ -257,6 +257,8 @@ dissect_pcap_pktdata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * proto_item *pseudoheader_item; proto_tree *pseudoheader_tree = NULL; proto_item *packet_item; + struct eth_phdr eth; + void *phdr; DISSECTOR_ASSERT(data); @@ -313,6 +315,7 @@ dissect_pcap_pktdata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * else pinfo->p2p_dir = P2P_DIR_UNKNOWN; offset += 4; + phdr = NULL; break; case WTAP_ENCAP_ATM_PDUS: @@ -347,11 +350,27 @@ dissect_pcap_pktdata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * next_tvb = tvb_new_subset_remaining(tvb, offset); return tvb_captured_length(tvb); } + } else { + /* + * These also require a pseudo-header, but it's not constructed + * from packet data. + */ + switch (pinfo->phdr->pkt_encap) { + + case WTAP_ENCAP_ETHERNET: + eth.fcs_len = -1; /* Unknown whether we have an FCS */ + phdr = ð + break; + + default: + phdr = NULL; + break; + } } next_tvb = tvb_new_subset_remaining(tvb, offset); - offset = dissector_try_uint_new(wtap_encap_table, pinfo->phdr->pkt_encap, next_tvb, pinfo, tree, TRUE, NULL); + offset = dissector_try_uint_new(wtap_encap_table, pinfo->phdr->pkt_encap, next_tvb, pinfo, tree, TRUE, phdr); return offset; } -- cgit v1.2.3