From 376b156333fe63d082d7f809f452feb65045b532 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Thu, 31 Dec 2015 15:16:23 -0500 Subject: Only use nibble logic to determine MPLS payload Bug: 11949 Change-Id: I625d80ce01918bd050889d21236aaa4cde4af8d0 Reviewed-on: https://code.wireshark.org/review/12961 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- epan/dissectors/packet-mpls.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'epan/dissectors/packet-mpls.c') diff --git a/epan/dissectors/packet-mpls.c b/epan/dissectors/packet-mpls.c index 1e67b7afae..130a688d18 100644 --- a/epan/dissectors/packet-mpls.c +++ b/epan/dissectors/packet-mpls.c @@ -458,33 +458,29 @@ dissect_mpls(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ return tvb_captured_length(tvb); /* 2) use the 1st nibble logic (see BCP 4928, RFC 4385 and 5586) */ - if (first_nibble == 4) { + switch(first_nibble) { + case 4: call_dissector(dissector_ip, next_tvb, pinfo, tree); /* IP dissector may reduce the length of the tvb. We need to do the same, so that ethernet trailer is detected. */ set_actual_length(tvb, offset+tvb_reported_length(next_tvb)); - return tvb_captured_length(tvb); - } else if (first_nibble == 6) { + break; + case 6: call_dissector(dissector_ipv6, next_tvb, pinfo, tree); /* IPv6 dissector may reduce the length of the tvb. We need to do the same, so that ethernet trailer is detected. */ set_actual_length(tvb, offset+tvb_reported_length(next_tvb)); - return tvb_captured_length(tvb); - } else if (first_nibble == 1) { + break; + case 1: call_dissector(dissector_pw_ach, next_tvb, pinfo, tree); - return tvb_captured_length(tvb); - } else if (tvb_captured_length(next_tvb) >= 14) { - guint16 etype = tvb_get_ntohs(next_tvb, 12); - if ((etype == ETHERTYPE_IP) ||(etype == ETHERTYPE_ARP) || - (etype == ETHERTYPE_ARP) ||(etype == ETHERTYPE_VLAN) || - (etype ==ETHERTYPE_IPv6)) { - /* This looks like an ethernet packet with a known ethertype. - Decode payload as Ethernet PW */ - call_dissector(dissector_pw_eth_heuristic, next_tvb, pinfo, tree); - return tvb_captured_length(tvb); - } + break; + case 0: + call_dissector(dissector_pw_eth_heuristic, next_tvb, pinfo, tree); + break; + default: + call_dissector(dissector_data, next_tvb, pinfo, tree); + break; } - call_dissector(dissector_data, next_tvb, pinfo, tree); return tvb_captured_length(tvb); } -- cgit v1.2.3