On Wed, Nov 07, 2001 at 04:30:58PM -0500, Ashok Narayanan wrote:
> On Thu, 8 Nov 2001 08:27:30 +1100, Hamish Moffatt <hamish@xxxxxxxxxxxx> wrote:
> > I concur. Do you think that looking at the IP version field
> > (as in my patch) is better than just assuming IPv4?
>
> Yeah, I guess. Gives us a 1-in-8 chance to get it right, instead of just
> blindly assuming.
My thoughts exactly. Can somebody check it in?
thanks,
Hamish
--
Hamish Moffatt VK3SB <hamish@xxxxxxxxxx> <hamish@xxxxxxxxxxxx>
Index: packet-mpls.c
===================================================================
RCS file: /cvsroot/ethereal/packet-mpls.c,v
retrieving revision 1.21
diff -u -r1.21 packet-mpls.c
--- packet-mpls.c 2001/06/18 02:17:49 1.21
+++ packet-mpls.c 2001/11/07 12:38:36
@@ -108,7 +108,8 @@
"", HFILL }},
};
-static dissector_handle_t ip_handle;
+static dissector_handle_t ipv4_handle;
+static dissector_handle_t ipv6_handle;
/*
* Given a 4-byte MPLS label starting at offset "offset", in tvbuff "tvb",
@@ -138,6 +139,7 @@
guint8 exp;
guint8 bos;
guint8 ttl;
+ guint8 ipvers;
proto_tree *mpls_tree;
proto_item *ti;
@@ -180,7 +182,13 @@
if (bos) break;
}
next_tvb = tvb_new_subset(tvb, offset, -1, -1);
- call_dissector(ip_handle, next_tvb, pinfo, tree);
+
+ ipvers = (tvb_get_guint8(tvb, offset) >> 4) & 0x0F;
+ if (ipvers == 6) {
+ call_dissector(ipv6_handle, next_tvb, pinfo, tree);
+ } else {
+ call_dissector(ipv4_handle, next_tvb, pinfo, tree);
+ }
}
void
@@ -200,9 +208,10 @@
proto_reg_handoff_mpls(void)
{
/*
- * Get a handle for the IP dissector.
+ * Get a handle for the IPv4 and IPv6 dissectors.
*/
- ip_handle = find_dissector("ip");
+ ipv4_handle = find_dissector("ip");
+ ipv6_handle = find_dissector("ipv6");
dissector_add("ethertype", ETHERTYPE_MPLS, dissect_mpls, proto_mpls);
dissector_add("ppp.protocol", PPP_MPLS_UNI, dissect_mpls, proto_mpls);