aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-01-20 01:46:34 -0800
committerGuy Harris <guy@alum.mit.edu>2016-01-20 09:57:29 +0000
commiteeff506f56c0f3a2e82d0007b7e0c5836be15a33 (patch)
treed3f1260a5c9c8bd90dff67182257df2e0444a7cd
parent47648e0528f091a6c7525d9d880f85a0a5fa42d0 (diff)
Separate "Ethernet in capture file" and "Ethernet maybe with FCS" dissectors.
Have a dissector that is passed a "struct eth_phdr" pointer, indicating whether there is an FCS, there is no FCS, or there's maybe an FCS, and an "eth_maybefcs" dissector, to be called from other dissectors. The latter takes no data argument. That obviates the need for callers of the latter to fill in an "eth_phdr" structure. Note in a comment that setting the "assume an FCS" preference overrides a file format handler in Wiretap saying "we have no FCS". I seem to remember that this might be intentional. Ping-Bug: 9933 Change-Id: I600e1351d468ab31d48369edb96832d6da3e480c Reviewed-on: https://code.wireshark.org/review/13432 Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--epan/dissectors/packet-atm.c9
-rw-r--r--epan/dissectors/packet-cisco-fp-mim.c11
-rw-r--r--epan/dissectors/packet-epon.c8
-rw-r--r--epan/dissectors/packet-eth.c30
-rw-r--r--epan/dissectors/packet-tzsp.c8
5 files changed, 38 insertions, 28 deletions
diff --git a/epan/dissectors/packet-atm.c b/epan/dissectors/packet-atm.c
index 57420f6c29..7634a7586b 100644
--- a/epan/dissectors/packet-atm.c
+++ b/epan/dissectors/packet-atm.c
@@ -145,7 +145,7 @@ static dissector_handle_t fr_handle;
static dissector_handle_t llc_handle;
static dissector_handle_t sscop_handle;
static dissector_handle_t ppp_handle;
-static dissector_handle_t eth_handle;
+static dissector_handle_t eth_maybefcs_handle;
static dissector_handle_t ip_handle;
static dissector_handle_t data_handle;
@@ -992,12 +992,9 @@ 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);
- eth.fcs_len = -1; /* We don't know whether there's an FCS */
- call_dissector_with_data(eth_handle, next_tvb, pinfo, tree, &eth);
+ call_dissector(eth_maybefcs_handle, next_tvb, pinfo, tree);
decoded = TRUE;
}
else if (octet[2] == 0x03 && /* NLPID */
@@ -2018,7 +2015,7 @@ proto_reg_handoff_atm(void)
llc_handle = find_dissector("llc");
sscop_handle = find_dissector("sscop");
ppp_handle = find_dissector("ppp");
- eth_handle = find_dissector("eth");
+ eth_maybefcs_handle = find_dissector("eth_maybefcs");
ip_handle = find_dissector("ip");
data_handle = find_dissector("data");
diff --git a/epan/dissectors/packet-cisco-fp-mim.c b/epan/dissectors/packet-cisco-fp-mim.c
index 845515d935..3fcd9cbded 100644
--- a/epan/dissectors/packet-cisco-fp-mim.c
+++ b/epan/dissectors/packet-cisco-fp-mim.c
@@ -72,7 +72,7 @@ static const true_false_string ooodl_tfs = {
"Deliver in order (If DA) or Learn (If SA)"
};
-static dissector_handle_t eth_dissector ;
+static dissector_handle_t eth_maybefcs_dissector ;
#define FP_PROTO_COL_NAME "FabricPath"
@@ -218,7 +218,6 @@ 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 ) ;
@@ -295,11 +294,9 @@ 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) ;
/*
- * For now, say we don't know whether there's an FCS in the
- * captured data.
+ * For now, 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 ) ;
+ call_dissector( eth_maybefcs_dissector, next_tvb, pinfo, tree ) ;
return tvb_captured_length( tvb ) ;
}
@@ -416,7 +413,7 @@ proto_reg_handoff_fabricpath(void)
* by the Ethernet dissector. This needs more work, so we leave this
* as calling the "eth" dissector as a reminder.
*/
- eth_dissector = find_dissector( "eth" );
+ eth_maybefcs_dissector = find_dissector( "eth_maybefcs" );
prefs_initialized = TRUE;
}
}
diff --git a/epan/dissectors/packet-epon.c b/epan/dissectors/packet-epon.c
index 1ba9bcb285..7a2d04cb38 100644
--- a/epan/dissectors/packet-epon.c
+++ b/epan/dissectors/packet-epon.c
@@ -54,7 +54,7 @@ static expert_field ei_epon_dpoe_bad = EI_INIT;
static expert_field ei_epon_dpoe_encrypted_data = EI_INIT;
static expert_field ei_epon_checksum_bad = EI_INIT;
-static dissector_handle_t eth_handle;
+static dissector_handle_t eth_maybefcs_handle;
static gint ett_epon = -1;
static gint ett_epon_sec = -1;
@@ -79,7 +79,6 @@ 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
@@ -200,8 +199,7 @@ dissect_epon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *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);
+ call_dissector(eth_maybefcs_handle, next_tvb, pinfo, tree);
}
return tvb_captured_length(tvb);
@@ -297,7 +295,7 @@ proto_reg_handoff_epon(void)
epon_handle = create_dissector_handle(dissect_epon, proto_epon);
dissector_add_uint("wtap_encap", WTAP_ENCAP_EPON, epon_handle);
- eth_handle = find_dissector("eth");
+ eth_maybefcs_handle = find_dissector("eth_maybefcs");
}
/*
diff --git a/epan/dissectors/packet-eth.c b/epan/dissectors/packet-eth.c
index 6904849976..f4767c1fbd 100644
--- a/epan/dissectors/packet-eth.c
+++ b/epan/dissectors/packet-eth.c
@@ -795,7 +795,7 @@ 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)
+dissect_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
struct eth_phdr *eth = (struct eth_phdr *)data;
proto_tree *fh_tree;
@@ -808,6 +808,10 @@ dissect_eth_maybefcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
tvbuff_t *next_tvb;
guint total_trailer_length;
+ /*
+ * XXX - this overrides Wiretap saying "this packet definitely has
+ * no FCS".
+ */
total_trailer_length = eth_trailer_length + (eth_assume_fcs ? 4 : 0);
/* Dissect the tvb up to, but not including the trailer */
@@ -818,9 +822,17 @@ 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);
+ /*
+ * XXX - this overrides Wiretap saying "this packet definitely has
+ * no FCS".
+ */
add_ethernet_trailer(pinfo, tree, fh_tree, hf_eth_trailer, tvb, next_tvb,
eth_assume_fcs ? 4 : eth->fcs_len);
} else {
+ /*
+ * XXX - this overrides Wiretap saying "this packet definitely has
+ * no FCS".
+ */
dissect_eth_common(tvb, pinfo, tree, eth_assume_fcs ? 4 : eth->fcs_len);
}
return tvb_captured_length(tvb);
@@ -843,6 +855,14 @@ dissect_eth_withfcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
return tvb_captured_length(tvb);
}
+/* ...and this one's for encapsulated packets that might or might not. */
+static int
+dissect_eth_maybefcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
+{
+ dissect_eth_common(tvb, pinfo, tree, eth_assume_fcs ? 4 : -1);
+ return tvb_captured_length(tvb);
+}
+
void
proto_register_eth(void)
{
@@ -1008,7 +1028,7 @@ proto_register_eth(void)
register_dissector("eth_withoutfcs", dissect_eth_withoutfcs, proto_eth);
register_dissector("eth_withfcs", dissect_eth_withfcs, proto_eth);
- register_dissector("eth", dissect_eth_maybefcs, proto_eth);
+ register_dissector("eth_maybefcs", dissect_eth_maybefcs, proto_eth);
eth_tap = register_tap("eth");
register_conversation_table(proto_eth, TRUE, eth_conversation_packet, eth_hostlist_packet);
@@ -1018,7 +1038,7 @@ proto_register_eth(void)
void
proto_reg_handoff_eth(void)
{
- dissector_handle_t eth_maybefcs_handle, eth_withoutfcs_handle;
+ dissector_handle_t eth_handle, eth_withoutfcs_handle;
/* Get a handle for the Firewall-1 dissector. */
fw1_handle = find_dissector("fw1");
@@ -1029,8 +1049,8 @@ proto_reg_handoff_eth(void)
/* Get a handle for the generic data dissector. */
data_handle = find_dissector("data");
- eth_maybefcs_handle = find_dissector("eth");
- dissector_add_uint("wtap_encap", WTAP_ENCAP_ETHERNET, eth_maybefcs_handle);
+ eth_handle = create_dissector_handle(dissect_eth, proto_eth);
+ dissector_add_uint("wtap_encap", WTAP_ENCAP_ETHERNET, eth_handle);
eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
dissector_add_uint("ethertype", ETHERTYPE_ETHBRIDGE, eth_withoutfcs_handle);
diff --git a/epan/dissectors/packet-tzsp.c b/epan/dissectors/packet-tzsp.c
index e3f10c743d..ebbb25139f 100644
--- a/epan/dissectors/packet-tzsp.c
+++ b/epan/dissectors/packet-tzsp.c
@@ -101,7 +101,7 @@ static const value_string tzsp_encapsulation[] = {
static gint ett_tzsp = -1;
static gint ett_tag = -1;
-static dissector_handle_t eth_handle;
+static dissector_handle_t eth_maybefcs_handle;
static dissector_handle_t tr_handle;
static dissector_handle_t ppp_handle;
static dissector_handle_t fddi_handle;
@@ -289,7 +289,6 @@ dissect_tzsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
guint16 encapsulation = 0;
const char *info;
guint8 type;
- struct eth_phdr eth;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "TZSP");
col_clear(pinfo->cinfo, COL_INFO);
@@ -340,8 +339,7 @@ dissect_tzsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
switch (encapsulation) {
case TZSP_ENCAP_ETHERNET:
- eth.fcs_len = -1; /* not known */
- call_dissector_with_data(eth_handle, next_tvb, pinfo, tree, &eth);
+ call_dissector(eth_maybefcs_handle, next_tvb, pinfo, tree);
break;
case TZSP_ENCAP_TOKEN_RING:
@@ -556,7 +554,7 @@ proto_reg_handoff_tzsp(void)
dissector_add_uint("udp.port", UDP_PORT_TZSP, tzsp_handle);
/* Get the data dissector for handling various encapsulation types. */
- eth_handle = find_dissector("eth");
+ eth_maybefcs_handle = find_dissector("eth_maybefcs");
tr_handle = find_dissector("tr");
ppp_handle = find_dissector("ppp_hdlc");
fddi_handle = find_dissector("fddi");