Ethereal-dev: [Ethereal-dev] patch for packet-icmp6.c - to show a reserved field in a ICMPv6 r

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Yaniv Kaul <ykaul@xxxxxxxxxxxxxx>
Date: Mon, 28 Apr 2003 14:17:04 +0200
It checks if the reserved field equals zero, as dictated by the RFC and displays it.
Attached diff against 0.9.11:

--- packet-icmpv6.c.orig        Mon Apr 28 14:01:47 2003
+++ packet-icmpv6.c     Mon Apr 28 14:01:52 2003
@@ -147,6 +147,8 @@
    struct nd_opt_hdr nd_opt_hdr, *opt;
    int len;
    char *typename;
+    static const guint8 nd_redirect_reserved[6] = {0, 0, 0, 0, 0, 0};
+    guint8 nd_redirect_res[6];

    if (!tree)
       return;
@@ -272,6 +274,13 @@
       break;
      }
    case ND_OPT_REDIRECTED_HEADER:
+       tvb_memcpy(tvb, (guint8 *)&nd_redirect_res, offset + 2, 6);
+       if (memcmp(nd_redirect_res, nd_redirect_reserved, 6) == 0)
+          proto_tree_add_text(icmp6opt_tree, tvb,
+           offset + 2, 6, "Reserved: 0 (correct)");
+       else
+          proto_tree_add_text(icmp6opt_tree, tvb,
+           offset +2, 6, "Reserved: MUST be 0 (incorrect!)");
       proto_tree_add_text(icmp6opt_tree, tvb,
           offset + 8, (opt->nd_opt_len << 3) - 8, "Redirected packet");
       dissect_contained_icmpv6(tvb, offset + 8, pinfo, icmp6opt_tree);

--- packet-icmpv6.c.orig	Mon Apr 28 14:01:47 2003
+++ packet-icmpv6.c	Mon Apr 28 14:01:52 2003
@@ -147,6 +147,8 @@
     struct nd_opt_hdr nd_opt_hdr, *opt;
     int len;
     char *typename;
+    static const guint8 nd_redirect_reserved[6] = {0, 0, 0, 0, 0, 0};
+    guint8 nd_redirect_res[6];
 
     if (!tree)
 	return;
@@ -272,6 +274,13 @@
 	break;
       }
     case ND_OPT_REDIRECTED_HEADER:
+	tvb_memcpy(tvb, (guint8 *)&nd_redirect_res, offset + 2, 6);
+	if (memcmp(nd_redirect_res, nd_redirect_reserved, 6) == 0)
+	   proto_tree_add_text(icmp6opt_tree, tvb,
+	    offset + 2, 6, "Reserved: 0 (correct)");
+	else
+	   proto_tree_add_text(icmp6opt_tree, tvb,
+	    offset +2, 6, "Reserved: MUST be 0 (incorrect!)");	
 	proto_tree_add_text(icmp6opt_tree, tvb,
 	    offset + 8, (opt->nd_opt_len << 3) - 8, "Redirected packet");
 	dissect_contained_icmpv6(tvb, offset + 8, pinfo, icmp6opt_tree);