diff options
author | AndersBroman <anders.broman@ericsson.com> | 2015-02-13 09:34:16 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-03-19 16:06:18 +0000 |
commit | b307ffe0f990860284f6e2be4f7a8f01fa822d36 (patch) | |
tree | ed93209968eefe4727e3318440702ae0b8884c9e /epan/proto.h | |
parent | ef7e4c52f2daf5ce27b9d311900f7a34ea7c71a3 (diff) |
Implement proto_tree_add_item_ret_int() and proto_tree_add_item_ret_uint() which
works as proto_tree_add_item(), but also returns the value of (u)ints
of 8,16,24 and 32 bits length in a 32 bit variable. It's based on Hadriels
previous work.
Change-Id: If3b4b8588b63251f1ee9b954a202acde7c02ce86
Reviewed-on: https://code.wireshark.org/review/7230
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/proto.h')
-rw-r--r-- | epan/proto.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/epan/proto.h b/epan/proto.h index f0222e01f8..45fb0506ba 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -980,6 +980,43 @@ WS_DLL_PUBLIC proto_item * proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb, const gint start, gint length, const guint encoding); +/** Add an item to a proto_tree, using the text label registered to that item. +The item is extracted from the tvbuff handed to it, and the retrieved +value is also set to *retval so the caller gets it back for other uses. + +This function retrieves the value even if the passed-in tree param is NULL, +so that it can be used by dissectors at all times to both get the value +and set the tree item to it. + +Like other proto_tree_add functions, if there is a tree and the value cannot +be decoded from the tvbuff, then an expert info error is reported. + +This function accepts ENC_LITTLE_ENDIAN and ENC_BIG_ENDIAN for native number +encoding in the tvbuff + +The length argument must +be set to the appropriate size of the native type as in other proto_add routines. + +Integers of 8, 16, 24 and 32 bits can be retreived with these functions. + +@param tree the tree to append this item to +@param hfindex field +@param tvb the tv buffer of the current data +@param start start of data in tvb (cannot be negative) +@param length length of data in tvb (for strings can be -1 for remaining) +@param encoding data encoding (e.g, ENC_LITTLE_ENDIAN, ENC_BIG_ENDIAN, ENC_ASCII|ENC_STRING, etc.) +@param[out] retval points to a gint/guint 8/16/32/64 or gfloat/gdouble which will be set +@param[out] err gets set to 0 if no failure, else the errno code (EDOM or ERANGE) +@return the newly created item, and value is set to the decoded value +*/ +WS_DLL_PUBLIC proto_item * +proto_tree_add_item_ret_int(proto_tree *tree, int hfindex, tvbuff_t *tvb, +const gint start, gint length, const guint encoding, gint32 *retval); + +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); + /** (DEPRECATED) Add a text-only node to a proto_tree. @param tree the tree to append this item to @param tvb the tv buffer of the current data |