Add a new api to allow dissection of the array payload as a whole. Bug 9307 (https...
authorMichael Mann <mmann78@netscape.net>
Mon, 21 Oct 2013 18:46:52 +0000 (18:46 -0000)
committerMichael Mann <mmann78@netscape.net>
Mon, 21 Oct 2013 18:46:52 +0000 (18:46 -0000)
From Matthieu Patou

svn path=/trunk/; revision=52743

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

index a04ebe2da69db5ed3e60cc2a06f54272b17b8d20..9127c4c1db2b316df30ca291b93cf290b9f6bf44 100644 (file)
@@ -1469,11 +1469,16 @@ dissect_ndr_ucarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
 
     return offset;
 }
-/* function to dissect a unidimensional conformant and varying array */
-int
-dissect_ndr_ucvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+
+/* function to dissect a unidimensional conformant and varying array
+ * depending on the dissection function passed as a parameter,
+ * content of the array will be dissected as a block or byte by byte
+ */
+static int
+dissect_ndr_ucvarray_core(tvbuff_t *tvb, gint offset, packet_info *pinfo,
                      proto_tree *tree, guint8 *drep,
-                     dcerpc_dissect_fnct_t *fnct)
+                     dcerpc_dissect_fnct_t *fnct_bytes,
+                     dcerpc_dissect_fnct_blk_t *fnct_block)
 {
     guint32      i;
     dcerpc_info *di;
@@ -1516,16 +1521,37 @@ dissect_ndr_ucvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
         proto_tree_add_uint(tree, hf_dcerpc_array_actual_count, tvb, di->array_actual_count_offset, conformance_size, di->array_actual_count);
 
         /* real run, dissect the elements */
-        for(i=0 ;i<di->array_actual_count; i++) {
-            old_offset = offset;
-            offset = (*fnct)(tvb, offset, pinfo, tree, drep);
-            if (offset <= old_offset)
-                THROW(ReportedBoundsError);
+        if (fnct_block) {
+                old_offset = offset;
+                offset = (*fnct_block)(tvb, offset, di->array_actual_count, pinfo, tree, drep);
+        } else {
+            for(i=0 ;i<di->array_actual_count; i++) {
+                old_offset = offset;
+                offset = (*fnct_bytes)(tvb, offset, pinfo, tree, drep);
+                if (offset <= old_offset)
+                    THROW(ReportedBoundsError);
+            }
         }
     }
 
     return offset;
 }
+
+int
+dissect_ndr_ucvarray_block(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+                     proto_tree *tree, guint8 *drep,
+                     dcerpc_dissect_fnct_blk_t *fnct)
+{
+    return dissect_ndr_ucvarray_core(tvb, offset, pinfo, tree, drep, NULL, fnct);
+}
+
+int
+dissect_ndr_ucvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+                     proto_tree *tree, guint8 *drep,
+                     dcerpc_dissect_fnct_t *fnct)
+{
+    return dissect_ndr_ucvarray_core(tvb, offset, pinfo, tree, drep, fnct, NULL);
+}
 /* function to dissect a unidimensional varying array */
 int
 dissect_ndr_uvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
index 83e230c923ad6da6b5692c3f69e63e196ffd4363..e385c7bd764a84e53ffd23cfe99d9f5e34d4a7c1 100644 (file)
@@ -229,6 +229,7 @@ int dissect_ndr_uint3264 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
                        int hfindex, guint3264 *pdata);
 
 typedef int (dcerpc_dissect_fnct_t)(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep);
+typedef int (dcerpc_dissect_fnct_blk_t)(tvbuff_t *tvb, int offset, int length, packet_info *pinfo, proto_tree *tree, guint8 *drep);
 
 typedef void (dcerpc_callback_fnct_t)(packet_info *pinfo, proto_tree *tree, proto_item *item, tvbuff_t *tvb, int start_offset, int end_offset, void *callback_args);
 
@@ -261,10 +262,16 @@ int dissect_ndr_ucarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
                         proto_tree *tree, guint8 *drep,
                         dcerpc_dissect_fnct_t *fnct);
 
-/* dissect a NDR unidimensional conformant and varying array */
+/* dissect a NDR unidimensional conformant and varying array
+ * each byte in the array is processed separately
+ */
 int dissect_ndr_ucvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
-                        proto_tree *tree, guint8 *drep,
-                        dcerpc_dissect_fnct_t *fnct);
+                         proto_tree *tree, guint8 *drep,
+                         dcerpc_dissect_fnct_t *fnct);
+
+int dissect_ndr_ucvarray_block(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+                               proto_tree *tree, guint8 *drep,
+                               dcerpc_dissect_fnct_blk_t *fnct);
 
 /* dissect a NDR unidimensional varying array */
 int dissect_ndr_uvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,