Add proto_tree_add_bitmask_with_flags.

It's proto_tree_add_bitmask with the ability to control the data appended to header.

Change-Id: Icce97437ba7cfc9158ec204a837da8db8138424a
Reviewed-on: https://code.wireshark.org/review/5533
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2014-11-29 15:58:56 -05:00
parent 75cdf9201e
commit e172ebb3b4
4 changed files with 53 additions and 0 deletions

View File

@ -935,6 +935,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
proto_tracking_interesting_fields@Base 1.9.1
proto_tree_add_ascii_7bits_item@Base 1.12.0~rc1
proto_tree_add_bitmask@Base 1.9.1
proto_tree_add_bitmask_with_flags@1.99.1
proto_tree_add_bitmask_len@Base 1.9.1
proto_tree_add_bitmask_text@Base 1.9.1
proto_tree_add_bits_item@Base 1.9.1

View File

@ -7603,6 +7603,30 @@ proto_tree_add_bitmask(proto_tree *parent_tree, tvbuff_t *tvb,
return item;
}
/* The same as proto_tree_add_bitmask(), but uses user-supplied flags to determine
* what data is appended to the header.
*/
proto_item *
proto_tree_add_bitmask_with_flags(proto_tree *parent_tree, tvbuff_t *tvb, const guint offset,
const int hf_hdr, const gint ett, const int **fields, const guint encoding, const int flags)
{
proto_item *item = NULL;
header_field_info *hf;
int len;
PROTO_REGISTRAR_GET_NTH(hf_hdr,hf);
DISSECTOR_ASSERT(IS_FT_INT(hf->type) || IS_FT_UINT(hf->type));
len = ftype_length(hf->type);
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_hdr, tvb, offset, len, encoding);
proto_item_add_bitmask_tree(item, tvb, offset, len, ett, fields, encoding,
flags, FALSE);
}
return item;
}
/* The same as proto_tree_add_bitmask(), but using a caller-supplied length.
* This is intended to support bitmask fields whose lengths can vary, perhaps
* as the underlying standard evolves over time.

View File

@ -2184,6 +2184,32 @@ WS_DLL_PUBLIC proto_item *
proto_tree_add_bitmask(proto_tree *tree, tvbuff_t *tvb, const guint offset,
const int hf_hdr, const gint ett, const int **fields, const guint encoding);
/** This function will dissect a sequence of bytes that describe a bitmask.
* This has "filterable" bitmask header functionality of proto_tree_add_bitmask
* with the ability to control what data is appended to the header like
* proto_tree_add_bitmask_text
@param tree the tree to append this item to
@param tvb the tv buffer of the current data
@param offset start of data in tvb
@param hf_hdr an 8/16/24/32 bit integer that describes the bitmask to be dissected.
This field will form an expansion under which the individual fields of the
bitmask is dissected and displayed.
This field must be of the type FT_[U]INT{8|16|24|32}.
@param ett subtree index
@param fields an array of pointers to int that lists all the fields of the
bitmask. These fields can be either of the type FT_BOOLEAN for flags
or another integer of the same type/size as hf_hdr with a mask specified.
This array is terminated by a NULL entry.
FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
FT_integer fields that have a value_string attached will have the
matched string displayed on the expansion line.
@param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
@param flags bitmask field using BMT_NO_* flags to determine behavior
@return the newly created item */
WS_DLL_PUBLIC proto_item *
proto_tree_add_bitmask_with_flags(proto_tree *tree, tvbuff_t *tvb, const guint offset,
const int hf_hdr, const gint ett, const int **fields, const guint encoding, const int flags);
/** This function will dissect a sequence of bytes that describe a bitmask.
@param tree the tree to append this item to
@param tvb the tv buffer of the current data

View File

@ -214,6 +214,7 @@ my @findAllFunctionList =
proto_tree_add_bits_item
proto_tree_add_bits_ret_val
proto_tree_add_bitmask
proto_tree_add_bitmask_with_flags
tvb_get_bits
tvb_get_bits16
tvb_get_bits24
@ -317,6 +318,7 @@ while (my $fileName = $ARGV[0]) {
# Find and replace: alters <fcn_name>() encoding arg in $fileContents
$found += fix_encoding_args(1, $searchReplaceFalseTrueHRef, "proto_tree_add_bits_(?:item|ret_val)", \$fileContents, $fileName);
$found += fix_encoding_args(1, $searchReplaceFalseTrueHRef, "proto_tree_add_bitmask", \$fileContents, $fileName);
$found += fix_encoding_args(1, $searchReplaceFalseTrueHRef, "proto_tree_add_bitmask_with_flags", \$fileContents, $fileName);
$found += fix_encoding_args(1, $searchReplaceFalseTrueHRef, "tvb_get_bits(?:16|24|32|64)?", \$fileContents, $fileName);
$found += fix_encoding_args(1, $searchReplaceFalseTrueHRef, "tvb_get_(?:ephemeral_)?unicode_string[z]?", \$fileContents, $fileName);