diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-01-17 20:08:17 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-01-18 04:15:16 +0000 |
commit | 8ec153f93816a302a325e40924f4e13383ad8eaf (patch) | |
tree | 630efb01c710f8fd81c69f4c54dfd09873ec26fe | |
parent | 5fe11fb75964d8e0d87fb73d99aa5f69066b9e8f (diff) |
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 <guy@alum.mit.edu>
-rw-r--r-- | epan/dissectors/packet-atm.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-cisco-fp-mim.c | 10 | ||||
-rw-r--r-- | epan/dissectors/packet-epon.c | 8 | ||||
-rw-r--r-- | epan/dissectors/packet-eth.c | 7 | ||||
-rw-r--r-- | epan/dissectors/packet-pcap_pktdata.c | 21 |
5 files changed, 43 insertions, 8 deletions
diff --git a/epan/dissectors/packet-atm.c b/epan/dissectors/packet-atm.c index 60ce50aa47..57420f6c29 100644 --- a/epan/dissectors/packet-atm.c +++ b/epan/dissectors/packet-atm.c @@ -992,9 +992,12 @@ dissect_reassembled_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, * See RFC 2684 section 6.2 "VC Multiplexing of Bridged * Protocols". */ + struct eth_phdr eth; + proto_tree_add_item(tree, hf_atm_padding, tvb, 0, 2, ENC_NA); next_tvb = tvb_new_subset_remaining(tvb, 2); - call_dissector(eth_handle, next_tvb, pinfo, tree); + eth.fcs_len = -1; /* We don't know whether there's an FCS */ + call_dissector_with_data(eth_handle, next_tvb, pinfo, tree, ð); decoded = TRUE; } else if (octet[2] == 0x03 && /* NLPID */ diff --git a/epan/dissectors/packet-cisco-fp-mim.c b/epan/dissectors/packet-cisco-fp-mim.c index 69de9cf934..845515d935 100644 --- a/epan/dissectors/packet-cisco-fp-mim.c +++ b/epan/dissectors/packet-cisco-fp-mim.c @@ -1,4 +1,4 @@ -/* packet-mim.c +/* packet-cisco-fp-mim.c * Routines for analyzing Cisco FabricPath MiM packets * Copyright 2011, Leonard Tracy <letracy@cisco.com> * @@ -218,6 +218,7 @@ dissect_fp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ guint16 dlid = 0; const guint8 *dst_addr = NULL; gboolean dest_ig = FALSE; + struct eth_phdr eth; col_set_str( pinfo->cinfo, COL_PROTOCOL, FP_PROTO_COL_NAME ) ; col_set_str( pinfo->cinfo, COL_INFO, FP_PROTO_COL_INFO ) ; @@ -293,7 +294,12 @@ dissect_fp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ } /* call the eth dissector */ next_tvb = tvb_new_subset_remaining( tvb, FP_HEADER_SIZE) ; - call_dissector( eth_dissector, next_tvb, pinfo, tree ) ; + /* + * For now, say we don't know whether there's an FCS in the + * captured data. + */ + eth.fcs_len = -1; + call_dissector_with_data( eth_dissector, next_tvb, pinfo, tree, ð ) ; return tvb_captured_length( tvb ) ; } diff --git a/epan/dissectors/packet-epon.c b/epan/dissectors/packet-epon.c index c808534212..1ba9bcb285 100644 --- a/epan/dissectors/packet-epon.c +++ b/epan/dissectors/packet-epon.c @@ -79,6 +79,7 @@ dissect_epon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset = 0; guint dpoe_sec_byte; gboolean dpoe_encrypted = FALSE; + struct eth_phdr eth; /* Start_of_Packet delimiter (/S/) can either happen in byte 1 or byte 2, * making the captured preamble either 7 or 6 bytes in length. If the @@ -195,7 +196,12 @@ dissect_epon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, col_append_str(pinfo->cinfo, COL_INFO, " [ENCRYPTED]"); } else { next_tvb = tvb_new_subset_remaining(tvb, 6+offset); - call_dissector(eth_handle, next_tvb, pinfo, tree); + /* + * XXX - is it guaranteed whether the capture will, or won't, have + * an FCS? + */ + eth.fcs_len = -1; + call_dissector_with_data(eth_handle, next_tvb, pinfo, tree, ð); } return tvb_captured_length(tvb); diff --git a/epan/dissectors/packet-eth.c b/epan/dissectors/packet-eth.c index 48840cf522..6904849976 100644 --- a/epan/dissectors/packet-eth.c +++ b/epan/dissectors/packet-eth.c @@ -795,8 +795,9 @@ add_ethernet_trailer(packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree, /* Called for the Ethernet Wiretap encapsulation type; pass the FCS length reported to us, or, if the "assume_fcs" preference is set, pass 4. */ static int -dissect_eth_maybefcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) +dissect_eth_maybefcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { + struct eth_phdr *eth = (struct eth_phdr *)data; proto_tree *fh_tree; /* Some devices slice the packet and add their own trailer before @@ -818,9 +819,9 @@ dissect_eth_maybefcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* /* Now handle the ethernet trailer and optional FCS */ next_tvb = tvb_new_subset_remaining(tvb, tvb_captured_length(tvb) - total_trailer_length); add_ethernet_trailer(pinfo, tree, fh_tree, hf_eth_trailer, tvb, next_tvb, - eth_assume_fcs ? 4 : pinfo->pseudo_header->eth.fcs_len); + eth_assume_fcs ? 4 : eth->fcs_len); } else { - dissect_eth_common(tvb, pinfo, tree, eth_assume_fcs ? 4 : pinfo->pseudo_header->eth.fcs_len); + dissect_eth_common(tvb, pinfo, tree, eth_assume_fcs ? 4 : eth->fcs_len); } return tvb_captured_length(tvb); } 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; } |