preparations for autogenerated ms dcerpc interfaces
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 16 Feb 2005 11:31:56 +0000 (11:31 +0000)
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 16 Feb 2005 11:31:56 +0000 (11:31 +0000)
make it possible to prettify SIDs and control how and where their string representation should be shown in the summary line and the tree
similar to how counted_strings prettification can be controlled

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

epan/dissectors/packet-dcerpc-nt.c
epan/dissectors/packet-dcerpc-nt.h

index ab6112bf5d066f8ac5f5eb1065f1c55255234966..b55954924410ce8646517a6604af0830d7000589 100644 (file)
@@ -1,3 +1,6 @@
+/* TODO:
+    dissect_ndr_nt_SID_with_options    see comment.
+*/
 /* packet-dcerpc-nt.c
  * Routines for DCERPC over SMB packet disassembly
  * Copyright 2001-2003, Tim Potter <tpot@samba.org>
@@ -1144,7 +1147,7 @@ dissect_ndr_nt_SID(tvbuff_t *tvb, int offset, packet_info *pinfo,
 {
        dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
        dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data;
-       char *sid_str;
+       char *sid_str=NULL;
        char *name;
 
        if(di->hf_index!=-1){
@@ -1176,6 +1179,56 @@ dissect_ndr_nt_SID(tvbuff_t *tvb, int offset, packet_info *pinfo,
        return offset;
 }
 
+/* same as dissect_ndr_nt_SID() but takes the same options as counted strings
+   do to prettify the dissect pane and the COL_INFO summary line
+*/
+int
+dissect_ndr_nt_SID_with_options(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, guint32 options)
+{
+       dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
+       dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data;
+       gint levels = CB_STR_ITEM_LEVELS(options);
+       offset=dissect_ndr_nt_SID(tvb, offset, pinfo, tree, drep);
+
+       if(dcv && dcv->private_data){
+               char *s=dcv->private_data;
+               proto_item *item=(proto_item *)tree;
+
+               if ((options & CB_STR_COL_INFO)&&(!di->conformant_run)) {
+                       /* kludge, ugly,   but this is called twice for all 
+                          dcerpc interfaces due to how we chase pointers 
+                          and putting the sid twice on the summary line
+                          looks even worse.
+                          Real solution would be to block updates to col_info
+                          while we just do a conformance run,   this might
+                          have sideeffects so it needs some more thoughts first.
+                       */
+                       if (check_col(pinfo->cinfo, COL_INFO))
+                               col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", s);
+               }
+
+               /* Append string to upper-level proto_items */
+
+               if (levels > 0 && item && s && s[0]) {
+                       proto_item_append_text(item, ": %s", s);
+                       item = item->parent;
+                       levels--;
+                       if (levels > 0) {
+                               proto_item_append_text(item, ": %s", s);
+                               item = item->parent;
+                               levels--;
+                               while (levels > 0) {
+                                       proto_item_append_text(item, " %s", s);
+                                       item = item->parent;
+                                       levels--;
+                               }
+                       }
+               }
+       }
+
+       return offset;
+}
+
 static int
 dissect_ndr_nt_SID_hf_through_ptr(tvbuff_t *tvb, int offset, packet_info *pinfo, 
                   proto_tree *tree, guint8 *drep)
index 6c54a5778697a7f4acc9179b06ec11fdb3fd0a22..ab10093448593fedf3e419668e589f844c314b16 100644 (file)
@@ -128,6 +128,10 @@ dissect_ndr_nt_SID(tvbuff_t *tvb, int offset,
                   packet_info *pinfo, proto_tree *tree,
                   guint8 *drep);
 int
+dissect_ndr_nt_SID_with_options(tvbuff_t *tvb, int offset, 
+                  packet_info *pinfo, proto_tree *tree, 
+                               guint8 *drep, guint32 options);
+int
 dissect_ndr_nt_PSID(tvbuff_t *tvb, int offset,
                    packet_info *pinfo, proto_tree *parent_tree,
                    guint8 *drep);