Moved dissect_ndr_nt_NTTIME() from packet-dcerpc-samr.c to packet-dcerpc-nt.c
[obnox/wireshark/wip.git] / packet-dcerpc-nt.c
index e25c8caf161b179e02e5346dc69f5986c922bdf4..30314bdee850b65dfff1787b393dbed898461864 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.8 2002/03/06 10:01:17 sahlberg Exp $
+ * $Id: packet-dcerpc-nt.c,v 1.12 2002/03/10 23:24:48 sahlberg Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -32,6 +32,7 @@
 #include "packet-dcerpc.h"
 #include "packet-dcerpc-nt.h"
 #include "smb.h"
+#include "packet-smb-common.h" /* for dissect_smb_64bit_time() */
 
 /*
  * This file contains helper routines that are used by the DCERPC over SMB
@@ -432,56 +433,6 @@ extern gint ett_nt_unicode_string;
   This function also looks at di->levels to see if whoever called us wanted us to append
   the name: string to any higher levels in the tree .
 */
-int
-dissect_ndr_nt_UNICODE_STRING_string (tvbuff_t *tvb, int offset, 
-                             packet_info *pinfo, proto_tree *parent_tree, 
-                             char *drep)
-{
-       proto_item *item=NULL;
-       proto_tree *tree=NULL;
-       guint32 len, off, max_len;
-       guint16 *data16;
-       char *text;
-       int old_offset=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;
-       }
-
-       if(parent_tree){
-               item = proto_tree_add_text(parent_tree, tvb, offset, 0,
-                       "unicode string");
-               tree = proto_item_add_subtree(item, ett_nt_unicode_string);
-       }
-
-        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);
-
-       offset = prs_uint16s(tvb, offset, pinfo, tree, max_len, &data16, NULL);
-       text = fake_unicode(data16, max_len);
-
-       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_len(item, offset-old_offset);
-       return offset;
-}
-
-
 int
 dissect_ndr_nt_UNICODE_STRING_str(tvbuff_t *tvb, int offset, 
                        packet_info *pinfo, proto_tree *tree, 
@@ -491,7 +442,6 @@ dissect_ndr_nt_UNICODE_STRING_str(tvbuff_t *tvb, int offset,
        guint16 *data16;
        char *text;
        int old_offset;
-       header_field_info *hfi;
        dcerpc_info *di;
 
        di=pinfo->private_data;
@@ -511,19 +461,17 @@ dissect_ndr_nt_UNICODE_STRING_str(tvbuff_t *tvb, int offset,
        offset = prs_uint16s(tvb, offset, pinfo, tree, max_len, &data16, NULL);
        text = fake_unicode(data16, max_len);
 
-       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);
+       proto_tree_add_string(tree, di->hf_index, tvb, old_offset,
+               offset-old_offset, text);
 
        if(tree){
-               proto_item_set_text(tree, "%s:%s", hfi->name, text);
+               proto_item_append_text(tree, ": %s", text);
                if(di->levels>-1){
                        tree=tree->parent;
-                       proto_item_append_text(tree, "%s:%s", hfi->name, text);
+                       proto_item_append_text(tree, ": %s", text);
                        while(di->levels>0){
                                tree=tree->parent;
-                               proto_item_append_text(tree, "%s ", text);
+                               proto_item_append_text(tree, " %s", text);
                                di->levels--;
                        }
                }
@@ -541,7 +489,7 @@ dissect_ndr_nt_UNICODE_STRING_str(tvbuff_t *tvb, int offset,
  
   the function takes one additional parameter, level
   which specifies how many additional levels up in the tree where we should
-  append "Name: string"  If unsure, specify levels as 0.
+  append the string.  If unsure, specify levels as 0.
 */
 int
 dissect_ndr_nt_UNICODE_STRING(tvbuff_t *tvb, int offset, 
@@ -552,6 +500,7 @@ dissect_ndr_nt_UNICODE_STRING(tvbuff_t *tvb, int offset,
        proto_tree *tree=NULL;
        int old_offset=offset;
        dcerpc_info *di;
+       char *name;
 
        ALIGN_TO_4_BYTES;  /* strcture starts with short, but is aligned for longs */
 
@@ -561,9 +510,10 @@ dissect_ndr_nt_UNICODE_STRING(tvbuff_t *tvb, int offset,
                return offset;
        }
 
+       name = proto_registrar_get_name(hf_index);
        if(parent_tree){
-               item = proto_tree_add_text(parent_tree, tvb, offset, 0,
-                       "");
+               item = proto_tree_add_text(parent_tree, tvb, offset, -1,
+                       "%s", name);
                tree = proto_item_add_subtree(item, ett_nt_unicode_string);
        }
 
@@ -574,7 +524,7 @@ dissect_ndr_nt_UNICODE_STRING(tvbuff_t *tvb, int offset,
        di->levels=1;
        offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
                        dissect_ndr_nt_UNICODE_STRING_str, NDR_POINTER_UNIQUE,
-                       "", hf_index, levels);
+                       name, hf_index, levels);
 
        proto_item_set_len(item, offset-old_offset);
        return offset;
@@ -582,3 +532,27 @@ dissect_ndr_nt_UNICODE_STRING(tvbuff_t *tvb, int offset,
 /* UNICODE_STRING  END */
 
 
+/* 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
+   it can handle both BIG and LITTLE endian encodings 
+ */
+int
+dissect_ndr_nt_NTTIME (tvbuff_t *tvb, int offset, 
+                       packet_info *pinfo, proto_tree *tree, 
+                       char *drep, int hf_index)
+{
+       dcerpc_info *di;
+
+       di=pinfo->private_data;
+       if(di->conformant_run){
+               /*just a run to handle conformant arrays, nothing to dissect */
+               return offset;
+       }
+
+       ALIGN_TO_4_BYTES;
+
+       offset = dissect_smb_64bit_time(tvb, pinfo, tree, offset,
+                hf_index);
+       return offset;
+}
+