summaryrefslogtreecommitdiff
path: root/epan/proto.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-04-25 23:29:58 -0400
committerMichael Mann <mmann78@netscape.net>2017-04-26 23:46:32 +0000
commit2c921eb83c2e4a959080461777fab3397c5abac0 (patch)
treef3f71d859232bacd3e372221ee86370bd96d0f5b /epan/proto.c
parent24c93965593b535b135e1befff5cd0c32be6f28d (diff)
downloadwireshark-2c921eb83c2e4a959080461777fab3397c5abac0.tar.gz
Add proto_tree_add_item_ret_uint64
Just like proto_tree_add_item_ret_uint, but with 64-bit support Change-Id: Ie0cbfda9e63bf21e85df2d674e391a6c0abe92f7 Reviewed-on: https://code.wireshark.org/review/21355 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/epan/proto.c b/epan/proto.c
index ed1dbfab4a..766d22cb04 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -2653,6 +2653,58 @@ proto_tree_add_item_ret_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb,
}
proto_item *
+proto_tree_add_item_ret_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+ const gint start, gint length, const guint encoding, guint64 *retval)
+{
+ header_field_info *hfinfo = proto_registrar_get_nth(hfindex);
+ field_info *new_fi;
+ guint64 value;
+
+ DISSECTOR_ASSERT_HINT(hfinfo != NULL, "Not passed hfi!");
+
+ if (hfinfo->type != FT_UINT64) {
+ REPORT_DISSECTOR_BUG(wmem_strdup_printf(wmem_packet_scope(),
+ "field %s is not of type FT_UINT64", hfinfo->abbrev));
+ }
+
+ /* length validation for native number encoding caught by get_uint64_value() */
+ /* length has to be -1 or > 0 regardless of encoding */
+ if (length < -1 || length == 0)
+ REPORT_DISSECTOR_BUG(wmem_strdup_printf(wmem_packet_scope(),
+ "Invalid length %d passed to proto_tree_add_item_ret_uint",
+ length));
+
+ if (encoding & ENC_STRING) {
+ REPORT_DISSECTOR_BUG("wrong encoding");
+ }
+ /* I believe it's ok if this is called with a NULL tree */
+ /* XXX - modify if we ever support EBCDIC FT_CHAR */
+ value = get_uint64_value(tree, tvb, start, length, encoding);
+
+ if (retval) {
+ *retval = value;
+ if (hfinfo->bitmask) {
+ /* Mask out irrelevant portions */
+ *retval &= hfinfo->bitmask;
+ /* Shift bits */
+ *retval >>= hfinfo_bitshift(hfinfo);
+ }
+ }
+
+ CHECK_FOR_NULL_TREE(tree);
+
+ TRY_TO_FAKE_THIS_ITEM(tree, hfinfo->id, hfinfo);
+
+ new_fi = new_field_info(tree, hfinfo, tvb, start, length);
+
+ proto_tree_set_uint64(new_fi, value);
+
+ new_fi->flags |= (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN;
+
+ return proto_tree_add_node(tree, new_fi);
+}
+
+proto_item *
proto_tree_add_item_ret_string_and_length(proto_tree *tree, int hfindex,
tvbuff_t *tvb,
const gint start, gint length,