Now that the IPv6 dissector has been tvbuffified, we can register it; do
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 23 Apr 2001 03:56:57 +0000 (03:56 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 23 Apr 2001 03:56:57 +0000 (03:56 +0000)
so, make it static, and call it only through a handle.

In the ICMPv6 dissector, when we dissect the invoking packet in an
ICMPv6 error or in a redirected header option, make the columns
non-writable, so the summary line for the packet shows it as an ICMPv6
packet, not as the packet included in the ICMPv6 packet.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@3361 f5534014-38df-0310-8fa8-9805f1628bb7

packet-icmpv6.c
packet-ipv6.c
packet-ipv6.h
packet-pim.c

index 0bab49bc901355aea2ce7e2c8563f9adac574b15..f4a7ada75d076d50ec2c86ce182fb1dc946cdaaf 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-icmpv6.c
  * Routines for ICMPv6 packet disassembly
  *
- * $Id: packet-icmpv6.c,v 1.39 2001/04/23 03:37:31 guy Exp $
+ * $Id: packet-icmpv6.c,v 1.40 2001/04/23 03:56:57 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -79,6 +79,8 @@ static gint ett_nodeinfo_node6 = -1;
 static gint ett_nodeinfo_nodebitmap = -1;
 static gint ett_nodeinfo_nodedns = -1;
 
+static dissector_handle_t ipv6_handle;
+
 static const value_string names_nodeinfo_qtype[] = {
     { NI_QTYPE_NOOP,           "NOOP" },
     { NI_QTYPE_SUPTYPES,       "Supported query types" },
@@ -217,9 +219,17 @@ again:
        proto_tree_add_text(icmp6opt_tree, tvb,
            offset + 8, (opt->nd_opt_len << 3) - 8, "Redirected packet");
        /* tiny sanity check */
-       if ((tvb_get_guint8(tvb, offset + 8) & 0xf0) == 0x60)
-           dissect_ipv6(tvb_new_subset(tvb, offset + 8, -1, -1), pinfo, icmp6opt_tree);
-       else
+       if ((tvb_get_guint8(tvb, offset + 8) & 0xf0) == 0x60) {
+           /* The redirected packet is an IPv6 datagram; dissect it.
+
+              Set the columns non-writable, so that the packet list
+              shows this as an ICMPv6 packet, not as the type of packet
+              for which the ICMPv6 packet was generated. */
+           col_set_writable(pinfo->fd, FALSE);
+
+           call_dissector(ipv6_handle, tvb_new_subset(tvb, offset + 8, -1, -1),
+               pinfo, icmp6opt_tree);
+       } else
            dissect_data(tvb_new_subset(tvb, offset + 8, -1, -1), 0, pinfo, icmp6opt_tree);
        break;
     case ND_OPT_MTU:
@@ -1037,7 +1047,14 @@ dissect_icmpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        case ICMP6_TIME_EXCEEDED:
            /* tiny sanity check */
            if ((tvb_get_guint8(tvb, offset + sizeof(*dp)) & 0xf0) == 0x60) {
-               dissect_ipv6(next_tvb, pinfo, icmp6_tree);
+               /* The invoking packet is an IPv6 datagram; dissect it.
+
+                  Set the columns non-writable, so that the packet list
+                  shows this as an ICMPv6 packet, not as the type of packet
+                  for which the ICMPv6 packet was generated. */
+               col_set_writable(pinfo->fd, FALSE);
+
+               call_dissector(ipv6_handle, next_tvb, pinfo, icmp6_tree);
            } else {
                dissect_data(next_tvb, 0, pinfo, icmp6_tree);
            }
@@ -1048,7 +1065,14 @@ dissect_icmpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                "MTU: %u", pntohl(&dp->icmp6_mtu));
            /* tiny sanity check */
            if ((tvb_get_guint8(tvb, offset + sizeof(*dp)) & 0xf0) == 0x60) {
-               dissect_ipv6(next_tvb, pinfo, icmp6_tree);
+               /* The invoking packet is an IPv6 datagram; dissect it.
+
+                  Set the columns non-writable, so that the packet list
+                  shows this as an ICMPv6 packet, not as the type of packet
+                  for which the ICMPv6 packet was generated. */
+               col_set_writable(pinfo->fd, FALSE);
+
+               call_dissector(ipv6_handle, next_tvb, pinfo, icmp6_tree);
            } else {
                dissect_data(next_tvb, 0, pinfo, icmp6_tree);
            }
@@ -1059,7 +1083,14 @@ dissect_icmpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                "Problem pointer: 0x%04x", pntohl(&dp->icmp6_pptr));
            /* tiny sanity check */
            if ((tvb_get_guint8(tvb, offset + sizeof(*dp)) & 0xf0) == 0x60) {
-               dissect_ipv6(next_tvb, pinfo, icmp6_tree);
+               /* The invoking packet is an IPv6 datagram; dissect it.
+
+                  Set the columns non-writable, so that the packet list
+                  shows this as an ICMPv6 packet, not as the type of packet
+                  for which the ICMPv6 packet was generated. */
+               col_set_writable(pinfo->fd, FALSE);
+
+               call_dissector(ipv6_handle, next_tvb, pinfo, icmp6_tree);
            } else {
                dissect_data(next_tvb, 0, pinfo, icmp6_tree);
            }
@@ -1272,4 +1303,9 @@ void
 proto_reg_handoff_icmpv6(void)
 {
   dissector_add("ip.proto", IP_PROTO_ICMPV6, dissect_icmpv6, proto_icmpv6);
+
+  /*
+   * Get a handle for the IPv6 dissector.
+   */
+  ipv6_handle = find_dissector("ipv6");
 }
index e2be7afceb5bb88d16152ee6375eb23877ad7c1b..7ece3f69f8c9cc9bf58b8bdfbde78f035d052477 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-ipv6.c
  * Routines for IPv6 packet disassembly 
  *
- * $Id: packet-ipv6.c,v 1.55 2001/04/23 03:37:31 guy Exp $
+ * $Id: packet-ipv6.c,v 1.56 2001/04/23 03:56:57 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -611,7 +611,7 @@ dissect_dstopts(tvbuff_t *tvb, int offset, proto_tree *tree) {
     return dissect_opts(tvb, offset, tree, "Destination Option");
 }
 
-void
+static void
 dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
   proto_tree *ipv6_tree;
   proto_item *ti;
@@ -923,15 +923,17 @@ proto_register_ipv6(void)
   proto_ipv6 = proto_register_protocol("Internet Protocol Version 6", "IPv6", "ipv6");
   proto_register_field_array(proto_ipv6, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
+
+  register_dissector("ipv6", dissect_ipv6, proto_ipv6);
 }
 
 void
 proto_reg_handoff_ipv6(void)
 {
-       dissector_add("ethertype", ETHERTYPE_IPv6, dissect_ipv6, proto_ipv6);
-       dissector_add("ppp.protocol", PPP_IPV6, dissect_ipv6, proto_ipv6);
-       dissector_add("ip.proto", IP_PROTO_IPV6, dissect_ipv6, proto_ipv6);
-       dissector_add("null.type", BSD_AF_INET6_BSD, dissect_ipv6, proto_ipv6);
-       dissector_add("null.type", BSD_AF_INET6_FREEBSD, dissect_ipv6, proto_ipv6);
-       dissector_add("ip.proto", IP_PROTO_NONE, dissect_ipv6_none, proto_ipv6);
+  dissector_add("ethertype", ETHERTYPE_IPv6, dissect_ipv6, proto_ipv6);
+  dissector_add("ppp.protocol", PPP_IPV6, dissect_ipv6, proto_ipv6);
+  dissector_add("ip.proto", IP_PROTO_IPV6, dissect_ipv6, proto_ipv6);
+  dissector_add("null.type", BSD_AF_INET6_BSD, dissect_ipv6, proto_ipv6);
+  dissector_add("null.type", BSD_AF_INET6_FREEBSD, dissect_ipv6, proto_ipv6);
+  dissector_add("ip.proto", IP_PROTO_NONE, dissect_ipv6_none, proto_ipv6);
 }
index adb91b595c264d0f7f22246ecbb0d6ecac40003f..cfa03a8368833d94fb4505d86deb99c193221c7f 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-ipv6.h
  * Definitions for IPv6 packet disassembly 
  *
- * $Id: packet-ipv6.h,v 1.20 2001/04/23 03:37:31 guy Exp $
+ * $Id: packet-ipv6.h,v 1.21 2001/04/23 03:56:57 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -30,8 +30,6 @@
 
 #include "ipv6-utils.h"
 
-void dissect_ipv6(tvbuff_t *, packet_info *, proto_tree *);
-
 #define INET6_ADDRSTRLEN       46
 
 /*
index 95ed0654c84a256a5a197178b9475497c9e88525..3e778e735d68291d46244896015bebafd383f031 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for PIM disassembly
  * (c) Copyright Jun-ichiro itojun Hagino <itojun@itojun.org>
  *
- * $Id: packet-pim.c,v 1.25 2001/04/23 03:37:31 guy Exp $
+ * $Id: packet-pim.c,v 1.26 2001/04/23 03:56:57 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -45,7 +45,6 @@
 
 #include "packet.h"
 #include "packet-ip.h"
-#include "packet-ipv6.h"
 #include "in_cksum.h"
 
 #define PIM_TYPE(x)    ((x) & 0x0f)
@@ -63,6 +62,7 @@ static int hf_pim_cksum = -1;
 static gint ett_pim = -1;
 
 static dissector_handle_t ip_handle;
+static dissector_handle_t ipv6_handle;
 
 /*
  * Address family values.
@@ -379,9 +379,9 @@ dissect_pim(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
                    break;
            case 6:     /* IPv6 */
 #if 0
-                   dissect_ipv6(next_tvb, pinfo, tree);
+                   call_dissector(ipv6_handle, next_tvb, pinfo, tree);
 #else
-                   dissect_ipv6(next_tvb, pinfo, pimopt_tree);
+                   call_dissector(ipv6_handle, next_tvb, pinfo, pimopt_tree);
 #endif
                    break;
            default:
@@ -666,7 +666,8 @@ proto_reg_handoff_pim(void)
     dissector_add("ip.proto", IP_PROTO_PIM, dissect_pim, proto_pim);
 
     /*
-     * Get a handle for the IP dissector.
+     * Get handles for the IPv4 and IPv6 dissectors.
      */
     ip_handle = find_dissector("ip");
+    ipv6_handle = find_dissector("ipv6");
 }