Put the "Find Frame" and "Go To Frame" menu items under "Edit"; leave
[obnox/wireshark/wip.git] / packet-telnet.c
index 0f8d1204966f3990727db8a67b959fc528eece13..026ecc2aa99744b4f6f3dc9fafe72d66192cc566 100644 (file)
@@ -1,11 +1,11 @@
-/* packet-pop.c
+/* packet-telnet.c
  * Routines for telnet packet dissection
  * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
  *
- * $Id: packet-telnet.c,v 1.3 1999/07/07 22:51:55 gram Exp $
+ * $Id: packet-telnet.c,v 1.8 2000/01/07 22:05:41 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@unicom.net>
+ * By Gerald Combs <gerald@zing.org>
  * Copyright 1998 Gerald Combs
  *
  * Copied from packet-pop.c
 #include <string.h>
 #include <glib.h>
 #include "packet.h"
-#include "etypes.h"
+
+static int proto_telnet = -1;
+
+static gint ett_telnet = -1;
+static gint ett_telnet_subopt = -1;
 
 /* Some defines for Telnet */
 
@@ -111,8 +115,6 @@ char *options[] = {
   "TN3270E"
 };
 
-extern packet_info pi;
-
 void telnet_sub_option(proto_tree *telnet_tree, char *rr, int *i, int offset, int max_data)
 {
   proto_tree *ti, *option_tree;
@@ -141,7 +143,7 @@ void telnet_sub_option(proto_tree *telnet_tree, char *rr, int *i, int offset, in
 
   ti = proto_tree_add_text(telnet_tree, offset, subneg_len, "Suboption Begin: %s", opt);
 
-  option_tree = proto_item_add_subtree(ti, ETT_TELNET_SUBOPT);
+  option_tree = proto_item_add_subtree(ti, ett_telnet_subopt);
 
   proto_tree_add_text(option_tree, offset + 2, subneg_len - 2, "%s %s", (req ? "Send your" : "Here's my"), opt);
 
@@ -304,12 +306,13 @@ void telnet_command(proto_tree *telnet_tree, char *rr, int *i, int offset, int m
 }
 
 void
-dissect_telnet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int max_data)
+dissect_telnet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
 {
         proto_tree      *telnet_tree, *ti;
        gchar           rr[1500];
        int i1;
        int i2;
+       int max_data = pi.captured_len - offset;
 
        memset(rr, '\0', sizeof(rr));
 
@@ -331,9 +334,8 @@ dissect_telnet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, i
 
          memcpy(rr, pd + offset, max_data);
 
-         ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
-                               "Telnet Protocol");
-         telnet_tree = proto_item_add_subtree(ti, ETT_TELNET);
+         ti = proto_tree_add_item(tree, proto_telnet, offset, END_OF_FRAME, NULL);
+         telnet_tree = proto_item_add_subtree(ti, ett_telnet);
 
          i1 = i2 = i3 = 0;
 
@@ -374,8 +376,19 @@ dissect_telnet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, i
 
 }
 
-
-
-
-
-
+void
+proto_register_telnet(void)
+{
+/*        static hf_register_info hf[] = {
+                { &variable,
+                { "Name",           "telnet.abbreviation", TYPE, VALS_POINTER }},
+        };*/
+       static gint *ett[] = {
+               &ett_telnet,
+               &ett_telnet_subopt,
+       };
+
+        proto_telnet = proto_register_protocol("Telnet", "telnet");
+ /*       proto_register_field_array(proto_telnet, hf, array_length(hf));*/
+       proto_register_subtree_array(ett, array_length(ett));
+}