Rename the routines that handle dissector tables with unsigned integer
[obnox/wireshark/wip.git] / plugins / docsis / packet-dsarsp.c
index 17bb066c8b0fd587a64b1f288bbb83217c190841..ec9745bb5588777f1fa864d38ae7f91ec83ba0c2 100644 (file)
@@ -2,10 +2,10 @@
  * Routines for Dynamic Service Addition Response dissection
  * Copyright 2002, Anand V. Narwani <anand[AT]narwani.org>
  *
- * $Id: packet-dsarsp.c,v 1.5 2003/05/28 14:52:52 gerald Exp $
+ * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
 # include "config.h"
 #endif
 
-#include "plugins/plugin_api.h"
-#include "plugins/plugin_api_defs.h"
-#include "moduleinfo.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <gmodule.h>
-
 #include <epan/packet.h>
 
 /* Initialize the protocol and registered fields */
 static int proto_docsis_dsarsp = -1;
-static int hf_docsis_dsarsp = -1;
 static int hf_docsis_dsarsp_tranid = -1;
 static int hf_docsis_dsarsp_response = -1;
 static dissector_handle_t docsis_tlv_handle;
@@ -58,29 +47,22 @@ dissect_dsarsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
 {
 
   proto_item *it;
-  proto_tree *dsarsp_tree;
+  proto_tree *dsarsp_tree = NULL;
   guint16 transid;
-  guint16 tlv_data_len;
   guint8 response;
   tvbuff_t *next_tvb;
 
   transid = tvb_get_ntohs (tvb, 0);
   response = tvb_get_guint8 (tvb, 2);
-  tlv_data_len = tvb_length_remaining (tvb, 3);
 
-  if (check_col (pinfo->cinfo, COL_INFO))
-    {
-      col_clear (pinfo->cinfo, COL_INFO);
-      col_add_fstr (pinfo->cinfo, COL_INFO,
-                   "Dynamic Service Add Response ID = %u (%s)", transid,
-                   val_to_str (response, docsis_conf_code, "%s"));
-    }
+  col_add_fstr (pinfo->cinfo, COL_INFO,
+           "Dynamic Service Add Response ID = %u (%s)", transid,
+           val_to_str (response, docsis_conf_code, "%d"));
 
   if (tree)
     {
       it =
-       proto_tree_add_protocol_format (tree, proto_docsis_dsarsp, tvb, 0,
-                                       tvb_length_remaining (tvb, 0),
+       proto_tree_add_protocol_format (tree, proto_docsis_dsarsp, tvb, 0, -1,
                                        "DSA Response");
       dsarsp_tree = proto_item_add_subtree (it, ett_docsis_dsarsp);
       proto_tree_add_item (dsarsp_tree, hf_docsis_dsarsp_tranid, tvb, 0, 2,
@@ -88,10 +70,10 @@ dissect_dsarsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
       proto_tree_add_item (dsarsp_tree, hf_docsis_dsarsp_response, tvb, 2, 1,
                           FALSE);
 
-      /* Call dissector for Appendix C TLV's */
-      next_tvb = tvb_new_subset (tvb, 3, tlv_data_len, tlv_data_len);
-      call_dissector (docsis_tlv_handle, next_tvb, pinfo, dsarsp_tree);
     }
+    /* Call dissector for Appendix C TLV's */
+    next_tvb = tvb_new_subset_remaining (tvb, 3);
+    call_dissector (docsis_tlv_handle, next_tvb, pinfo, dsarsp_tree);
 
 
 
@@ -100,7 +82,7 @@ dissect_dsarsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
 
 
 
-/* Register the protocol with Ethereal */
+/* Register the protocol with Wireshark */
 
 /* this format is require because a script is used to build the C function
    that calls all the protocol registration.
@@ -113,20 +95,15 @@ proto_register_docsis_dsarsp (void)
 
 /* Setup list of header fields  See Section 1.6.1 for details*/
   static hf_register_info hf[] = {
-    {&hf_docsis_dsarsp,
-     {"Dynamic Service Add Request", "docsis.dsarsp",
-      FT_BYTES, BASE_HEX, NULL, 0x0,
-      "Dynamic Service Add Request", HFILL}
-     },
     {&hf_docsis_dsarsp_tranid,
-     {"Transaction Id", "docsis.dsarsp.tranid",
+     {"Transaction Id", "docsis_dsarsp.tranid",
       FT_UINT16, BASE_DEC, NULL, 0x0,
       "Service Identifier", HFILL}
      },
     {&hf_docsis_dsarsp_response,
-     {"Confirmation Code", "docsis.dsarsp.confcode",
+     {"Confirmation Code", "docsis_dsarsp.confcode",
       FT_UINT8, BASE_DEC, VALS (docsis_conf_code), 0x0,
-      "Confirmation Code", HFILL}
+      NULL, HFILL}
      },
   };
 
@@ -159,6 +136,6 @@ proto_reg_handoff_docsis_dsarsp (void)
 
   docsis_dsarsp_handle = find_dissector ("docsis_dsarsp");
   docsis_tlv_handle = find_dissector ("docsis_tlv");
-  dissector_add ("docsis_mgmt", 0x10, docsis_dsarsp_handle);
+  dissector_add_uint ("docsis_mgmt", 0x10, docsis_dsarsp_handle);
 
 }