aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debian/libwireshark0.symbols1
-rw-r--r--doc/README.dissector4
-rw-r--r--epan/proto.c52
-rw-r--r--epan/proto.h9
4 files changed, 64 insertions, 2 deletions
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols
index 82b5fa2fc8..f56dbc05bc 100644
--- a/debian/libwireshark0.symbols
+++ b/debian/libwireshark0.symbols
@@ -1159,6 +1159,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
proto_tree_add_item@Base 1.9.1
proto_tree_add_item_new@Base 1.12.0~rc1
proto_tree_add_item_new_ret_length@Base 2.1.0
+ proto_tree_add_item_ret_boolean@Base 2.3.0
proto_tree_add_item_ret_int@Base 1.99.6
proto_tree_add_item_ret_length@Base 2.1.0
proto_tree_add_item_ret_string@Base 2.1.0
diff --git a/doc/README.dissector b/doc/README.dissector
index 91fae35cd1..9f585c2b5c 100644
--- a/doc/README.dissector
+++ b/doc/README.dissector
@@ -1253,6 +1253,10 @@ protocol or field labels to the proto_tree:
*retval);
proto_item*
+ proto_tree_add_item_ret_boolean(tree, id, tvb, start, length, encoding,
+ *retval);
+
+ proto_item*
proto_tree_add_subtree(tree, tvb, start, length, idx, tree_item,
text);
diff --git a/epan/proto.c b/epan/proto.c
index 766d22cb04..5b8a08470c 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -2678,7 +2678,6 @@ proto_tree_add_item_ret_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb,
REPORT_DISSECTOR_BUG("wrong encoding");
}
/* I believe it's ok if this is called with a NULL tree */
- /* XXX - modify if we ever support EBCDIC FT_CHAR */
value = get_uint64_value(tree, tvb, start, length, encoding);
if (retval) {
@@ -2705,6 +2704,57 @@ proto_tree_add_item_ret_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb,
}
proto_item *
+proto_tree_add_item_ret_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+ const gint start, gint length,
+ const guint encoding, gboolean *retval)
+{
+ header_field_info *hfinfo = proto_registrar_get_nth(hfindex);
+ field_info *new_fi;
+ guint64 value, bitval;
+
+ DISSECTOR_ASSERT_HINT(hfinfo != NULL, "Not passed hfi!");
+
+ if (hfinfo->type != FT_BOOLEAN) {
+ REPORT_DISSECTOR_BUG(wmem_strdup_printf(wmem_packet_scope(),
+ "field %s is not of type FT_BOOLEAN", hfinfo->abbrev));
+ }
+
+ /* length validation for native number encoding caught by get_uint64_value() */
+ /* length has to be -1 or > 0 regardless of encoding */
+ if (length < -1 || length == 0)
+ REPORT_DISSECTOR_BUG(wmem_strdup_printf(wmem_packet_scope(),
+ "Invalid length %d passed to proto_tree_add_item_ret_uint",
+ length));
+
+ if (encoding & ENC_STRING) {
+ REPORT_DISSECTOR_BUG("wrong encoding");
+ }
+ /* I believe it's ok if this is called with a NULL tree */
+ value = get_uint64_value(tree, tvb, start, length, encoding);
+
+ if (retval) {
+ bitval = value;
+ if (hfinfo->bitmask) {
+ /* Mask out irrelevant portions */
+ bitval &= hfinfo->bitmask;
+ }
+ *retval = (bitval != 0);
+ }
+
+ CHECK_FOR_NULL_TREE(tree);
+
+ TRY_TO_FAKE_THIS_ITEM(tree, hfinfo->id, hfinfo);
+
+ new_fi = new_field_info(tree, hfinfo, tvb, start, length);
+
+ proto_tree_set_boolean(new_fi, value);
+
+ new_fi->flags |= (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN;
+
+ return proto_tree_add_node(tree, new_fi);
+}
+
+proto_item *
proto_tree_add_item_ret_string_and_length(proto_tree *tree, int hfindex,
tvbuff_t *tvb,
const gint start, gint length,
diff --git a/epan/proto.h b/epan/proto.h
index e46c8986d2..7306ad1d8e 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -1107,7 +1107,10 @@ 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 retrieved with these functions.
+Integers of 8, 16, 24 and 32 bits can be retrieved with the _ret_int and
+ret_uint functions; integers of 40, 48, 56, and 64 bits can be retrieved
+with the _ret_uint64 function; Boolean values of 8, 16, 24, 32, 40, 48,
+56, and 64 bits can be retrieved with the _ret_boolean function.
@param tree the tree to append this item to
@param hfindex field
@@ -1130,6 +1133,10 @@ WS_DLL_PUBLIC proto_item *
proto_tree_add_item_ret_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb,
const gint start, gint length, const guint encoding, guint64 *retval);
+WS_DLL_PUBLIC proto_item *
+proto_tree_add_item_ret_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb,
+ const gint start, gint length, const guint encoding, gboolean *retval);
+
/** Add an string item to a proto_tree, using the text label registered to
that item.