Include <string.h> to get "strcmp()" declared.
[obnox/wireshark/wip.git] / packet-dcerpc-epm.c
index c3b5dcd87ad8d41594c5047d3862f92f35458ac7..45b0d418f3c708dcf85dc84ec73533d4301bb80a 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for dcerpc endpoint mapper dissection
  * Copyright 2001, Todd Sabin <tas@webspan.net>
  *
- * $Id: packet-dcerpc-epm.c,v 1.16 2002/10/23 00:48:33 guy Exp $
+ * $Id: packet-dcerpc-epm.c,v 1.21 2003/08/04 02:49:03 tpot Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -124,19 +124,17 @@ epm_dissect_ept_lookup_rqst (tvbuff_t *tvb, int offset,
 
     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
                              epm_dissect_pointer_UUID, NDR_POINTER_PTR,
-                             "Object:", hf_epm_object, 0);
+                             "Object:", hf_epm_object);
 
     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
                              epm_dissect_pointer_IF_ID, NDR_POINTER_PTR,
-                             "Interface:", hf_epm_if_id, 0);
+                             "Interface:", hf_epm_if_id);
 
     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
                                  hf_epm_ver_opt, NULL);
-    if (tree) {
-        proto_tree_add_bytes (tree, hf_epm_hnd, tvb, offset, 20,
-                              tvb_get_ptr (tvb, offset, 20));
-    }
-    offset += 20;
+
+    offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
+                                  hf_epm_hnd, NULL);
 
     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
                                  hf_epm_max_ents, NULL);
@@ -155,7 +153,7 @@ epm_dissect_ept_entry_t(tvbuff_t *tvb, int offset,
     guint32 len;
     gint strlen;
     dcerpc_info *di;
-    char *str;
+    const char *str;
     
     di=pinfo->private_data;
     if(di->conformant_run){
@@ -172,13 +170,13 @@ epm_dissect_ept_entry_t(tvbuff_t *tvb, int offset,
 
     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
                              epm_dissect_tower, NDR_POINTER_PTR,
-                             "Tower pointer:", -1, 1);
+                             "Tower pointer:", -1);
 
     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
                                  hf_epm_ann_offset, NULL);
     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
                                  hf_epm_ann_len, &len);
-    str=(char *)tvb_get_ptr(tvb, offset, -1);
+    str=(const char *)tvb_get_ptr(tvb, offset, -1);
     strlen=len;
     strlen=MIN(strlen,tvb_length_remaining(tvb, offset));
     proto_tree_add_item(tree, hf_epm_annotation, tvb, offset, len, TRUE);
@@ -222,7 +220,7 @@ epm_dissect_ept_lookup_resp (tvbuff_t *tvb, int offset,
 
     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
                              epm_dissect_ept_entry_t_array, NDR_POINTER_REF,
-                             "Entries:", -1, 1);
+                             "Entries:", -1);
 
     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
                                  hf_epm_rc, NULL);
@@ -411,7 +409,7 @@ epm_dissect_tower_pointer (tvbuff_t *tvb, int offset,
 {
     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
                              epm_dissect_tower, NDR_POINTER_PTR,
-                             "Tower pointer:", -1, 1);
+                             "Tower pointer:", -1);
     return offset;
 }
 static int
@@ -446,7 +444,7 @@ epm_dissect_ept_map_rqst (tvbuff_t *tvb, int offset,
     /* [in, ptr] twr_p_t map_tower */
     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
                              epm_dissect_tower, NDR_POINTER_PTR,
-                             "Tower pointer:", -1, 1);
+                             "Tower pointer:", -1);
 
     /* [in, out] ept_lookup_handle_t *entry_handle */
     offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
@@ -475,7 +473,7 @@ epm_dissect_ept_map_resp (tvbuff_t *tvb, int offset,
     /* [out, length_is(*num_towers), size_is(max_towers), ptr] twr_p_t towers[] */
     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
                              epm_dissect_tower_array, NDR_POINTER_REF,
-                             "Tower array:", -1, 1);
+                             "Tower array:", -1);
 
     /* [out] error_status_t *status */
     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
@@ -509,7 +507,7 @@ epm_dissect_ept_insert_rqst (tvbuff_t *tvb, int offset,
 
     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
                              epm_dissect_ept_entry_t_ucarray, NDR_POINTER_REF,
-                             "Entries:", -1, 1);
+                             "Entries:", -1);
 
     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
                                  hf_epm_replace, NULL);
@@ -545,7 +543,7 @@ epm_dissect_ept_delete_rqst (tvbuff_t *tvb, int offset,
 
     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
                              epm_dissect_ept_entry_t_ucarray, NDR_POINTER_REF,
-                             "Entries:", -1, 1);
+                             "Entries:", -1);
 
     return offset;
 }
@@ -565,6 +563,33 @@ epm_dissect_ept_delete_resp (tvbuff_t *tvb, int offset,
 }
 
 
+
+static int
+epm_dissect_ept_lookup_handle_free_rqst (tvbuff_t *tvb, int offset,
+                             packet_info *pinfo, proto_tree *tree,
+                             char *drep)
+{
+    offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
+                                  hf_epm_hnd, NULL);
+
+    return offset;
+}
+
+static int
+epm_dissect_ept_lookup_handle_free_resp (tvbuff_t *tvb, int offset,
+                             packet_info *pinfo, proto_tree *tree,
+                             char *drep)
+{
+    offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
+                                  hf_epm_hnd, NULL);
+
+    offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
+                                 hf_epm_rc, NULL);
+
+    return offset;
+}
+
+
 static dcerpc_sub_dissector epm_dissectors[] = {
     { 0, "Insert", 
        epm_dissect_ept_insert_rqst,
@@ -578,30 +603,21 @@ static dcerpc_sub_dissector epm_dissectors[] = {
     { 3, "Map",
        epm_dissect_ept_map_rqst,
        epm_dissect_ept_map_resp },
-    { 4, "ept_lookup_handle_free", NULL, NULL },
-    { 5, "ept_inq_object", NULL, NULL },
-    { 6, "ept_mgmt_delete", NULL, NULL },
+    { 4, "LookupHandleFree",
+       epm_dissect_ept_lookup_handle_free_rqst,
+       epm_dissect_ept_lookup_handle_free_resp },
+    { 5, "InqObject", NULL, NULL },
+    { 6, "MgmtDelete", NULL, NULL },
     { 0, NULL, NULL, NULL }
 };
 
-static const value_string epm_opnum_vals[] = {
-       { 0, "Insert" },
-       { 1, "Delete" },
-       { 2, "Lookup" },
-       { 3, "Map" },
-       { 4, "lookup_handle_free" },
-       { 5, "inq_object" },
-       { 6, "mgmt_delete" },
-       { 0, NULL }
-};
-
 void
 proto_register_epm (void)
 {
        static hf_register_info hf[] = {
         { &hf_epm_opnum,
          { "Operation", "epm.opnum", FT_UINT16, BASE_DEC,
-           VALS(epm_opnum_vals), 0x0, "Operation", HFILL }},
+           NULL, 0x0, "Operation", HFILL }},
         { &hf_epm_inquiry_type,
           { "Inquiry type", "epm.inq_type", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
         { &hf_epm_object,