Move the STRING dissector to packet-dcerpc-nt.c and add one more parameter
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 11 Mar 2002 00:15:20 +0000 (00:15 +0000)
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 11 Mar 2002 00:15:20 +0000 (00:15 +0000)
to make it more similar to the UNICODE_STRING dissector.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4920 f5534014-38df-0310-8fa8-9805f1628bb7

packet-dcerpc-nt.c
packet-dcerpc-nt.h
packet-dcerpc-samr.c

index 30314bdee850b65dfff1787b393dbed898461864..6c931e45c1f7b5f08720e665f0b0511454f0edd7 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for DCERPC over SMB packet disassembly
  * Copyright 2001, Tim Potter <tpot@samba.org>
  *
- * $Id: packet-dcerpc-nt.c,v 1.12 2002/03/10 23:24:48 sahlberg Exp $
+ * $Id: packet-dcerpc-nt.c,v 1.13 2002/03/11 00:15:20 sahlberg Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -531,6 +531,89 @@ dissect_ndr_nt_UNICODE_STRING(tvbuff_t *tvb, int offset,
 }
 /* UNICODE_STRING  END */
 
+/* functions to dissect a STRING structure, common to many 
+   NT services
+   struct {
+     short len;
+     short size;
+     [size_is(size), length_is(len), ptr] char *string;
+   } STRING;
+*/
+int
+dissect_ndr_nt_STRING_string (tvbuff_t *tvb, int offset, 
+                             packet_info *pinfo, proto_tree *tree, 
+                             char *drep)
+{
+       guint32 len, off, max_len;
+       guint8 *text;
+       int old_offset;
+       header_field_info *hfi;
+       dcerpc_info *di;
+
+       di=pinfo->private_data;
+       if(di->conformant_run){
+               /*just a run to handle conformant arrays, nothing to dissect */
+               return offset;
+       }
+
+        offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
+                                     hf_nt_str_len, &len);
+        offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
+                                     hf_nt_str_off, &off);
+        offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
+                                     hf_nt_str_max_len, &max_len);
+
+       old_offset=offset;
+       offset = prs_uint8s(tvb, offset, pinfo, tree, max_len, &text, NULL);
+
+       hfi = proto_registrar_get_nth(di->hf_index);
+       proto_tree_add_string_format(tree, di->hf_index, 
+               tvb, old_offset, offset-old_offset,
+               text, "%s: %s", hfi->name, text);
+
+       if(tree){
+               proto_item_set_text(tree, "%s: %s", hfi->name, text);
+               proto_item_set_text(tree->parent, "%s: %s", hfi->name, text);
+       }
+       return offset;
+}
+
+int
+dissect_ndr_nt_STRING (tvbuff_t *tvb, int offset, 
+                             packet_info *pinfo, proto_tree *parent_tree, 
+                             char *drep, int hf_index, int levels)
+{
+       proto_item *item=NULL;
+       proto_tree *tree=NULL;
+       int old_offset=offset;
+       dcerpc_info *di;
+
+       ALIGN_TO_4_BYTES;  /* strcture starts with short, but is aligned for longs */
+
+       di=pinfo->private_data;
+       if(di->conformant_run){
+               /*just a run to handle conformant arrays, nothing to dissect */
+               return offset;
+       }
+
+       if(parent_tree){
+               item = proto_tree_add_text(parent_tree, tvb, offset, 0,
+                       "string");
+               tree = proto_item_add_subtree(item, ett_nt_unicode_string);
+       }
+
+        offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
+                                     hf_nt_string_length, NULL);
+        offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
+                                     hf_nt_string_size, NULL);
+        offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
+                       dissect_ndr_nt_STRING_string, NDR_POINTER_UNIQUE,
+                       "", hf_index, levels);
+
+       proto_item_set_len(item, offset-old_offset);
+       return offset;
+}
+
 
 /* This function is used to dissect a DCERPC encoded 64 bit time value.
    XXX it should be fixed both here and in dissect_smb_64bit_time so
index e25445a4ea53d7238ce086aeb4b0d91c81641acf..f72568eb9296436008222c2162bed1d8bcb0f3df 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for DCERPC over SMB packet disassembly
  * Copyright 2001, Tim Potter <tpot@samba.org>
  *
- * $Id: packet-dcerpc-nt.h,v 1.9 2002/03/11 00:00:15 sahlberg Exp $
+ * $Id: packet-dcerpc-nt.h,v 1.10 2002/03/11 00:15:20 sahlberg Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -84,6 +84,14 @@ int
 dissect_ndr_nt_UNICODE_STRING(tvbuff_t *tvb, int offset, 
                        packet_info *pinfo, proto_tree *parent_tree, 
                        char *drep, int hf_index, int levels);
+int
+dissect_ndr_nt_STRING_string (tvbuff_t *tvb, int offset, 
+                             packet_info *pinfo, proto_tree *tree, 
+                             char *drep);
+int
+dissect_ndr_nt_STRING (tvbuff_t *tvb, int offset, 
+                        packet_info *pinfo, proto_tree *parent_tree, 
+                       char *drep, int hf_index, int levels);
 int 
 dissect_ndr_nt_acct_ctrl(tvbuff_t *tvb, int offset, packet_info *pinfo, 
                        proto_tree *parent_tree, char *drep);
index 405a5e97d6a434ba9d80e8f0ccd1739e1077a61e..24cb2b14b1fc6ea42a14fc2fb1ba0a92686e95fb 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright 2001, Tim Potter <tpot@samba.org>
  *   2002 Added all command dissectors  Ronnie Sahlberg
  *
- * $Id: packet-dcerpc-samr.c,v 1.22 2002/03/11 00:00:15 sahlberg Exp $
+ * $Id: packet-dcerpc-samr.c,v 1.23 2002/03/11 00:15:20 sahlberg Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -190,89 +190,6 @@ static e_uuid_t uuid_dcerpc_samr = {
 static guint16 ver_dcerpc_samr = 1;
 
 
-/* functions to dissect a STRING structure, common to many 
-   NT services
-   struct {
-     short len;
-     short size;
-     [size_is(size), length_is(len), ptr] char *string;
-   } STRING;
-*/
-
-static int
-dissect_ndr_nt_STRING_string (tvbuff_t *tvb, int offset, 
-                             packet_info *pinfo, proto_tree *tree, 
-                             char *drep)
-{
-       guint32 len, off, max_len;
-       guint8 *text;
-       int old_offset;
-       char *name;
-       dcerpc_info *di;
-
-       di=pinfo->private_data;
-       if(di->conformant_run){
-               /*just a run to handle conformant arrays, nothing to dissect */
-               return offset;
-       }
-
-        offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
-                                     hf_nt_str_len, &len);
-        offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
-                                     hf_nt_str_off, &off);
-        offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
-                                     hf_nt_str_max_len, &max_len);
-
-       old_offset=offset;
-       offset = prs_uint8s(tvb, offset, pinfo, tree, max_len, &text, NULL);
-
-       name = proto_registrar_get_name(di->hf_index);
-       proto_tree_add_string(tree, di->hf_index, tvb, old_offset,
-               offset-old_offset, text);
-
-       if(tree){
-               proto_item_set_text(tree, "%s: %s", name, text);
-               proto_item_set_text(tree->parent, "%s: %s", name, text);
-       }
-       return offset;
-}
-
-int
-dissect_ndr_nt_STRING (tvbuff_t *tvb, int offset, 
-                             packet_info *pinfo, proto_tree *parent_tree, 
-                             char *drep, int hf_index)
-{
-       proto_item *item=NULL;
-       proto_tree *tree=NULL;
-       int old_offset=offset;
-       char *name;
-       dcerpc_info *di;
-
-       di=pinfo->private_data;
-       if(di->conformant_run){
-               /*just a run to handle conformant arrays, nothing to dissect */
-               return offset;
-       }
-
-       name = proto_registrar_get_name(di->hf_index);
-       if(parent_tree){
-               item = proto_tree_add_text(parent_tree, tvb, offset, -1,
-                       "%s", name);
-               tree = proto_item_add_subtree(item, ett_nt_unicode_string);
-       }
-
-        offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
-                                     hf_nt_string_length, NULL);
-        offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
-                                     hf_nt_string_size, NULL);
-        offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
-                       dissect_ndr_nt_STRING_string, NDR_POINTER_PTR,
-                       name, hf_index, 0);
-
-       proto_item_set_len(item, offset-old_offset);
-       return offset;
-}
-
 static int
 samr_dissect_SID(tvbuff_t *tvb, int offset, 
                        packet_info *pinfo, proto_tree *tree, 
@@ -456,7 +373,7 @@ samr_dissect_pointer_STRING(tvbuff_t *tvb, int offset,
        }
 
        offset = dissect_ndr_nt_STRING(tvb, offset, pinfo, tree, drep,
-                       di->hf_index);
+                       di->hf_index, 0);
        return offset;
 }
 
@@ -743,9 +660,9 @@ samr_dissect_ASCII_DISPINFO(tvbuff_t *tvb, int offset,
                        hf_samr_rid, NULL);
        offset = dissect_ndr_nt_acct_ctrl(tvb, offset, pinfo, tree, drep);
        offset = dissect_ndr_nt_STRING(tvb, offset, pinfo, tree, drep,
-                       hf_samr_acct_name);
+                       hf_samr_acct_name, 0);
        offset = dissect_ndr_nt_STRING(tvb, offset, pinfo, tree, drep,
-                       hf_samr_acct_desc);
+                       hf_samr_acct_desc,0 );
 
        proto_item_set_len(item, offset-old_offset);
        return offset;
@@ -865,7 +782,7 @@ samr_dissect_get_display_enumeration_index_rqst(tvbuff_t *tvb, int offset,
         offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
                                      hf_samr_level, NULL);
        offset = dissect_ndr_nt_STRING(tvb, offset, pinfo, tree, drep,
-                       hf_samr_acct_name);
+                       hf_samr_acct_name, 0);
        return offset;
 }