From b307ffe0f990860284f6e2be4f7a8f01fa822d36 Mon Sep 17 00:00:00 2001 From: AndersBroman Date: Fri, 13 Feb 2015 09:34:16 +0100 Subject: 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 Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/proto.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'epan/proto.h') 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 -- cgit v1.2.3