Add proto_tree_add_item_ret_uint64
authorMichael Mann <mmann78@netscape.net>
Wed, 26 Apr 2017 03:29:58 +0000 (23:29 -0400)
committerMichael Mann <mmann78@netscape.net>
Wed, 26 Apr 2017 23:46:32 +0000 (23:46 +0000)
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>
debian/libwireshark0.symbols
doc/README.dissector
epan/proto.c
epan/proto.h

index 36a704b6779a6014c6c7e6253f6cc2614b6fb33e..82b5fa2fc8794d2b84415d654ec78bcd57313baa 100644 (file)
@@ -1164,6 +1164,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
  proto_tree_add_item_ret_string@Base 2.1.0
  proto_tree_add_item_ret_string_and_length@Base 2.1.0
  proto_tree_add_item_ret_uint@Base 1.99.6
+ proto_tree_add_item_ret_uint64@Base 2.3.0
  proto_tree_add_none_format@Base 1.9.1
  proto_tree_add_protocol_format@Base 1.9.1
  proto_tree_add_split_bits_item_ret_val@Base 2.3.0
index 1f327a99954f3bf915064727978572e2648e46b7..91fae35cd1c840cd569e25e4656e2c9ed8e88cd0 100644 (file)
@@ -1248,6 +1248,10 @@ protocol or field labels to the proto_tree:
     proto_tree_add_item_ret_uint(tree, id, tvb, start, length, encoding,
         *retval);
 
+    proto_item*
+    proto_tree_add_item_ret_uint64(tree, id, tvb, start, length, encoding,
+        *retval);
+
     proto_item*
     proto_tree_add_subtree(tree, tvb, start, length, idx, tree_item,
         text);
index ed1dbfab4a30f321b45b69eff901745d4747a29d..766d22cb0492f596b5e6351c3f8c40128b1e46a7 100644 (file)
@@ -2652,6 +2652,58 @@ proto_tree_add_item_ret_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb,
        return proto_tree_add_node(tree, new_fi);
 }
 
+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,
index 982ae22fc7852d20b1916fee05208c8da5539ee0..e46c8986d2e3490aad2ca981f52e62c43199b4d7 100644 (file)
@@ -1126,6 +1126,10 @@ WS_DLL_PUBLIC proto_item *
 proto_tree_add_item_ret_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb,
     const gint start, gint length, const guint encoding, guint32 *retval);
 
+WS_DLL_PUBLIC 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);
+
 /** Add an string item to a proto_tree, using the text label registered to
 that item.