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>
This commit is contained in:
Guy Harris 2016-01-17 20:08:17 -08:00
parent 5fe11fb759
commit 8ec153f938
5 changed files with 43 additions and 8 deletions

View File

@ -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, &eth);
decoded = TRUE;
}
else if (octet[2] == 0x03 && /* NLPID */

View File

@ -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, &eth ) ;
return tvb_captured_length( tvb ) ;
}

View File

@ -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, &eth);
}
return tvb_captured_length(tvb);

View File

@ -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);
}

View File

@ -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 = &eth;
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;
}