Add proto_tree_add_new_bytes()

Version to add as generated field, without tvb offset, length.

Change-Id: If4c7aebcbf1b47faa483bcbd40995eff3ccb99f0
Reviewed-on: https://code.wireshark.org/review/6906
Tested-by: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
This commit is contained in:
Michal Labedzki 2015-01-06 10:46:17 +01:00
parent 722ce56cf0
commit 617c733b9f
2 changed files with 35 additions and 0 deletions

View File

@ -2437,6 +2437,28 @@ proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb,
return pi;
}
/* Add a FT_BYTES to a proto_tree */
proto_item *
proto_tree_add_new_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
gint length, const guint8 *start_ptr, gint ptr_length)
{
proto_item *pi;
header_field_info *hfinfo;
gint item_length;
PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo);
get_hfi_length(hfinfo, tvb, start, &length, &item_length);
test_length(hfinfo, tvb, start, item_length);
TRY_TO_FAKE_THIS_ITEM(tree, hfindex, hfinfo);
DISSECTOR_ASSERT_FIELD_TYPE(hfinfo, FT_BYTES);
pi = proto_tree_add_pi(tree, hfinfo, tvb, start, &length);
proto_tree_set_bytes(PNODE_FINFO(pi), start_ptr, ptr_length);
return pi;
}
/* Add a FT_BYTES to a proto_tree */
proto_item *

View File

@ -1071,6 +1071,19 @@ WS_DLL_PUBLIC proto_item *
proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
gint length, const guint8* start_ptr);
/** Add a FT_BYTES to a proto_tree.
@param tree the tree to append this item to
@param hfindex field index
@param tvb the tv buffer of the current data
@param start start of data in tvb
@param length length of data in tvb
@param start_ptr pointer to the data to display
@param ptr_length length of data in start_ptr
@return the newly created item */
WS_DLL_PUBLIC proto_item *
proto_tree_add_new_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
gint length, const guint8 *start_ptr, gint ptr_length);
/** Get and add a byte-array-based FT_* to a proto_tree.
Supported: FT_BYTES, FT_UINT_BYTES, FT_OID, FT_REL_OID, and FT_SYSTEM_ID.