Added two new arguments to epan_init() and proto_init() to
[obnox/wireshark/wip.git] / packet-data.c
index 0d197ed002b3065214ace87d505f3c1ad92016f2..46da3a1c6b8f308a1bd05f93e8726f4da7e25e22 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for raw data (default case)
  * Gilbert Ramirez <gram@xiexie.org>
  *
- * $Id: packet-data.c,v 1.17 2000/05/11 22:04:15 gram Exp $
+ * $Id: packet-data.c,v 1.21 2001/01/03 06:55:27 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -40,8 +40,9 @@
  */
 int proto_data = -1;
 
+/* Remove this once all dissectors are converted to use tvbuffs */
 void
-dissect_data(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+old_dissect_data(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
 {
        if (IS_DATA_IN_FRAME(offset) && tree) {
                proto_tree_add_protocol_format(tree, proto_data, NullTVB, offset,
@@ -50,17 +51,19 @@ dissect_data(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
        }
 }
 
-/* This will become dissect_data() once all dissectors are converted to use tvbuffs */
 void
-dissect_data_tvb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+dissect_data(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
 {
        int bytes;
 
        if (tree) {
-               bytes = tvb_length(tvb);
-               proto_tree_add_protocol_format(tree, proto_data, tvb, 0,
-                       bytes, "Data (%d byte%s)", bytes,
-                       plurality(bytes, "", "s"));
+               bytes = tvb_length_remaining(tvb, offset);
+               if (bytes > 0) {
+                       proto_tree_add_protocol_format(tree, proto_data, tvb,
+                               offset,
+                               bytes, "Data (%d byte%s)", bytes,
+                               plurality(bytes, "", "s"));
+               }
        }
 }
 
@@ -68,6 +71,15 @@ void
 proto_register_data(void)
 {
        proto_data = proto_register_protocol (
-               /* name */      "Data",
-               /* abbrev */    "data" );
+               "Data",         /* name */
+               "Data",         /* short name */
+               "data"          /* abbrev */
+               );
+
+       /*
+        * "Data" is used to dissect something whose normal dissector
+        * is disabled, so it cannot itself be disabled.
+        */
+       proto_set_cant_disable(proto_data);
+
 }