Little tuning of proto_tree_add_bytes_with_length

Change name from proto_tree_add_new_bytes to
proto_tree_add_bytes_with_length and other tweaks
pointed by Peter Wu.

Change-Id: I6058c28a74a154e2882e4eb04558bedcede6f508
Reviewed-on: https://code.wireshark.org/review/7039
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
This commit is contained in:
Michal Labedzki 2015-02-09 08:56:28 +01:00
parent 4359cb8478
commit 707522396c
5 changed files with 36 additions and 27 deletions

View File

@ -934,6 +934,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
proto_tree_add_bytes_format@Base 1.9.1 proto_tree_add_bytes_format@Base 1.9.1
proto_tree_add_bytes_format_value@Base 1.9.1 proto_tree_add_bytes_format_value@Base 1.9.1
proto_tree_add_bytes_item@Base 1.12.0~rc1 proto_tree_add_bytes_item@Base 1.12.0~rc1
proto_tree_add_bytes_with_bytes@Base 1.99.3
proto_tree_add_debug_text@Base 1.9.1 proto_tree_add_debug_text@Base 1.9.1
proto_tree_add_double@Base 1.9.1 proto_tree_add_double@Base 1.9.1
proto_tree_add_double_format@Base 1.9.1 proto_tree_add_double_format@Base 1.9.1
@ -969,7 +970,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
proto_tree_add_ipxnet_format_value@Base 1.9.1 proto_tree_add_ipxnet_format_value@Base 1.9.1
proto_tree_add_item@Base 1.9.1 proto_tree_add_item@Base 1.9.1
proto_tree_add_item_new@Base 1.12.0~rc1 proto_tree_add_item_new@Base 1.12.0~rc1
proto_tree_add_new_bytes@Base 1.99.3
proto_tree_add_none_format@Base 1.9.1 proto_tree_add_none_format@Base 1.9.1
proto_tree_add_protocol_format@Base 1.9.1 proto_tree_add_protocol_format@Base 1.9.1
proto_tree_add_string@Base 1.9.1 proto_tree_add_string@Base 1.9.1

View File

@ -1129,6 +1129,9 @@ protocol or field labels to the proto_tree:
proto_tree_add_bytes_format_value(tree, id, tvb, start, length, proto_tree_add_bytes_format_value(tree, id, tvb, start, length,
start_ptr, format, ...); start_ptr, format, ...);
proto_item *
proto_tree_add_bytes_with_length(tree, id, tvb, start, tvb_length, start_ptr, ptr_length);
proto_item * proto_item *
proto_tree_add_time(tree, id, tvb, start, length, value_ptr); proto_tree_add_time(tree, id, tvb, start, length, value_ptr);
@ -1583,6 +1586,11 @@ any more.
For proto_tree_add_bytes(), the 'value_ptr' argument is a pointer to a For proto_tree_add_bytes(), the 'value_ptr' argument is a pointer to a
sequence of bytes. sequence of bytes.
proto_tree_add_bytes_with_length() is similar to proto_tree_add_bytes,
except that the length is not derived from the tvb length. Instead,
the displayed data size is controlled by 'ptr_length'.
For proto_tree_add_bytes_format() and proto_tree_add_bytes_format_value(), the For proto_tree_add_bytes_format() and proto_tree_add_bytes_format_value(), the
'value_ptr' argument is a pointer to a sequence of bytes or NULL if the bytes 'value_ptr' argument is a pointer to a sequence of bytes or NULL if the bytes
should be taken from the given TVB using the given offset and length. should be taken from the given TVB using the given offset and length.

View File

@ -1663,7 +1663,7 @@ dissect_handle_uint(proto_tree *tree, packet_info *pinfo, gint hf,
if (local_uuid.size == 2) if (local_uuid.size == 2)
sub_item = proto_tree_add_uint(sub_tree, hf_btatt_uuid16, tvb, 0, 0, local_uuid.bt_uuid); sub_item = proto_tree_add_uint(sub_tree, hf_btatt_uuid16, tvb, 0, 0, local_uuid.bt_uuid);
else else
sub_item = proto_tree_add_new_bytes(sub_tree, hf_btatt_uuid128, tvb, 0, 0, local_uuid.data, 16); sub_item = proto_tree_add_bytes_with_length(sub_tree, hf_btatt_uuid128, tvb, 0, 0, local_uuid.data, 16);
PROTO_ITEM_SET_GENERATED(sub_item); PROTO_ITEM_SET_GENERATED(sub_item);

View File

@ -2441,29 +2441,6 @@ proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb,
return pi; 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 */ /* Add a FT_BYTES to a proto_tree */
proto_item * proto_item *
proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
@ -2487,6 +2464,29 @@ proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
return pi; return pi;
} }
/* Add a FT_BYTES to a proto_tree */
proto_item *
proto_tree_add_bytes_with_length(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
gint tvb_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, &tvb_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, &tvb_length);
proto_tree_set_bytes(PNODE_FINFO(pi), start_ptr, ptr_length);
return pi;
}
proto_item * proto_item *
proto_tree_add_bytes_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb, proto_tree_add_bytes_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
gint start, gint length, gint start, gint length,

View File

@ -1071,7 +1071,8 @@ WS_DLL_PUBLIC proto_item *
proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
gint length, const guint8* start_ptr); gint length, const guint8* start_ptr);
/** Add a FT_BYTES to a proto_tree. /** Add a FT_BYTES to a proto_tree like proto_tree_add_bytes,
but used when the tvb data length does not match the bytes length.
@param tree the tree to append this item to @param tree the tree to append this item to
@param hfindex field index @param hfindex field index
@param tvb the tv buffer of the current data @param tvb the tv buffer of the current data
@ -1081,7 +1082,7 @@ proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
@param ptr_length length of data in start_ptr @param ptr_length length of data in start_ptr
@return the newly created item */ @return the newly created item */
WS_DLL_PUBLIC proto_item * WS_DLL_PUBLIC proto_item *
proto_tree_add_new_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, proto_tree_add_bytes_with_length(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
gint length, const guint8 *start_ptr, gint ptr_length); gint length, const guint8 *start_ptr, gint ptr_length);
/** Get and add a byte-array-based FT_* to a proto_tree. /** Get and add a byte-array-based FT_* to a proto_tree.