aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2013-10-21 18:46:52 +0000
committerMichael Mann <mmann78@netscape.net>2013-10-21 18:46:52 +0000
commit15294a1261961d7ac2ad4316eb83b0e413effc47 (patch)
tree2df471d4fd3bda9f8d9e6f2ffbe82c697f123e87 /epan/dissectors
parent772fb97f76177a6f7ee5acb165768ed7506931ae (diff)
Add a new api to allow dissection of the array payload as a whole. Bug 9307 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9307)
From Matthieu Patou svn path=/trunk/; revision=52743
Diffstat (limited to 'epan/dissectors')
-rw-r--r--epan/dissectors/packet-dcerpc.c44
-rw-r--r--epan/dissectors/packet-dcerpc.h13
2 files changed, 45 insertions, 12 deletions
diff --git a/epan/dissectors/packet-dcerpc.c b/epan/dissectors/packet-dcerpc.c
index a04ebe2da6..9127c4c1db 100644
--- a/epan/dissectors/packet-dcerpc.c
+++ b/epan/dissectors/packet-dcerpc.c
@@ -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,
diff --git a/epan/dissectors/packet-dcerpc.h b/epan/dissectors/packet-dcerpc.h
index 83e230c923..e385c7bd76 100644
--- a/epan/dissectors/packet-dcerpc.h
+++ b/epan/dissectors/packet-dcerpc.h
@@ -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,