Have the Etherenet and PPP dissectors register themselves, and have
[obnox/wireshark/wip.git] / packet-gre.c
index e30bd9a65ffbaa81c14b6a80cd2976123e08a502..1012a5cf51f125cc306c2f0767aabfcad1c77c8c 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for the Generic Routing Encapsulation (GRE) protocol
  * Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
  *
- * $Id: packet-gre.c,v 1.24 2000/08/07 03:20:35 guy Exp $
+ * $Id: packet-gre.c,v 1.28 2000/11/19 02:00:02 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -38,7 +38,6 @@
 #include <glib.h>
 #include "packet.h"
 #include "packet-ip.h"
-#include "packet-ppp.h"
 #include "packet-ipx.h"
 
 static int proto_gre = -1;
@@ -74,6 +73,9 @@ static const value_string typevals[] = {
        { 0,        NULL  }
 };
 
+static dissector_handle_t ip_handle;
+static dissector_handle_t ppp_handle;
+
 static void
 dissect_gre(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
   
@@ -83,6 +85,8 @@ dissect_gre(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
   guint8       sre_length;
   tvbuff_t     *next_tvb;
 
+  OLD_CHECK_DISPLAY_AS_DATA(proto_gre, pd, offset, fd, tree);
+
   if (check_col(fd, COL_PROTOCOL))
     col_add_str(fd, COL_PROTOCOL, "GRE");
        
@@ -206,18 +210,17 @@ dissect_gre(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
 
     switch (type) {
       case GRE_PPP:
-       next_tvb = tvb_create_from_top(offset);
-        dissect_ppp(next_tvb, &pi, tree);
+        old_call_dissector(ppp_handle, pd, offset, fd, tree);
        break;
       case GRE_IP:
-        dissect_ip(pd, offset, fd, tree);
+        old_call_dissector(ip_handle, pd, offset, fd, tree);
         break;
       case GRE_WCCP:
         if (is_wccp2) {
           proto_tree_add_text(gre_tree, NullTVB, offset, sizeof(guint32), "WCCPv2 Data");
           offset += 4;
         }
-        dissect_ip(pd, offset, fd, tree);
+        old_call_dissector(ip_handle, pd, offset, fd, tree);
         break;
       case GRE_IPX:
        next_tvb = tvb_create_from_top(offset);
@@ -225,7 +228,7 @@ dissect_gre(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
         break;
       default:
        next_tvb = tvb_create_from_top(offset);
-       dissect_data(next_tvb, &pi, gre_tree);
+       dissect_data(next_tvb, 0, &pi, gre_tree);
        break;
     }
   }
@@ -302,4 +305,10 @@ void
 proto_reg_handoff_gre(void)
 {
        old_dissector_add("ip.proto", IP_PROTO_GRE, dissect_gre);
+
+       /*
+        * Get handles for the IP and PPP dissectors.
+        */
+       ip_handle = find_dissector("ip");
+       ppp_handle = find_dissector("ppp");
 }