aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>2007-04-26 06:39:29 +0000
committeretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>2007-04-26 06:39:29 +0000
commit152667dbfa1aece1a784a896b61665d2ee8b194a (patch)
tree056e2cbe2413a66cd441208657cba4bf087c01cc
parent765d44085d6c589e368bfc681ed933f517b3b193 (diff)
Change the signature of proto_tree_add_bits() and add proto_tree_add_bits_ret_val()
which will hopefully be more acceptable. Change name of tvb_get_bits() in ansi_801 git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@21594 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--epan/dissectors/packet-ansi_801.c12
-rw-r--r--epan/proto.c15
-rw-r--r--epan/proto.h15
3 files changed, 31 insertions, 11 deletions
diff --git a/epan/dissectors/packet-ansi_801.c b/epan/dissectors/packet-ansi_801.c
index a3b0716675..c788687f9a 100644
--- a/epan/dissectors/packet-ansi_801.c
+++ b/epan/dissectors/packet-ansi_801.c
@@ -94,7 +94,7 @@ static const guint8 bit_mask[] = {
};
guint64
-tvb_get_bits(tvbuff_t *tvb, guint32 *offset_p, guint8 *bit_offset_p, guint8 num_bits)
+ansi_801_tvb_get_bits(tvbuff_t *tvb, guint32 *offset_p, guint8 *bit_offset_p, guint8 num_bits)
{
guint64 bits;
guint64 temp_octs;
@@ -1059,14 +1059,14 @@ pr_loc_response(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
if (oct & bit_mask)
{
new_offset = offset;
- temp_int = tvb_get_bits(tvb, &new_offset, &bit_offset, 18);
+ temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 18);
proto_tree_add_text(tree, tvb, offset, new_offset - offset,
"CLOCK_BIAS: (%llu)",
temp_int);
offset = new_offset;
- temp_int = tvb_get_bits(tvb, &new_offset, &bit_offset, 16);
+ temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 16);
proto_tree_add_text(tree, tvb, offset, new_offset - offset,
"CLOCK_DRIFT: (%llu)",
@@ -1144,14 +1144,14 @@ pr_loc_response(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
if (oct & bit_mask)
{
new_offset = offset;
- temp_int = tvb_get_bits(tvb, &new_offset, &bit_offset, 14);
+ temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 14);
proto_tree_add_text(tree, tvb, offset, new_offset - offset,
"HEIGHT: (%llu)",
temp_int);
offset = new_offset;
- temp_int = tvb_get_bits(tvb, &new_offset, &bit_offset, 5);
+ temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 5);
proto_tree_add_text(tree, tvb, offset, new_offset - offset,
"LOC_UNCRTNTY_V: (%llu)",
@@ -1229,7 +1229,7 @@ for_pr_gps_sat_health(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset
for (i=0; i < num_bad; i++)
{
- temp_int = tvb_get_bits(tvb, &new_offset, &bit_offset, 5);
+ temp_int = ansi_801_tvb_get_bits(tvb, &new_offset, &bit_offset, 5);
proto_tree_add_text(tree, tvb, offset, 1,
"BAD_SV_PRN_NUM: (%llu)",
diff --git a/epan/proto.c b/epan/proto.c
index e853492943..e2f0f79e9e 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -5579,6 +5579,13 @@ proto_tree_add_bitmask(proto_tree *parent_tree, tvbuff_t *tvb, int offset, int h
return item;
}
+
+proto_item *
+proto_tree_add_bits(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian)
+{
+ return proto_tree_add_bits_ret_val(tree, hf_index, tvb, bit_offset, no_of_bits, NULL, little_endian);
+
+}
/*
* This function will dissect a sequence of bits that does not need to be byte aligned the bits
* set vill be shown in the tree as ..10 10.. and the integer value returned if return_value is set.
@@ -5586,7 +5593,7 @@ proto_tree_add_bitmask(proto_tree *parent_tree, tvbuff_t *tvb, int offset, int h
*/
proto_item *
-proto_tree_add_bits(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, guint32 *return_value, gboolean little_endian)
+proto_tree_add_bits_ret_val(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, guint32 *return_value, gboolean little_endian)
{
gint offset;
guint length;
@@ -5790,12 +5797,12 @@ proto_tree_add_bits(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offs
}
}
/* 1 - 32 bits field */
-
if (hf_field->strings) {
return proto_tree_add_uint_format(tree, hf_index, tvb, offset, length, value,
- "%s: %s",
+ "%s: %s (%u)",
str,
- val_to_str(value, cVALS(hf_field->strings), "Unknown"));
+ val_to_str(value, cVALS(hf_field->strings), "Unknown "),
+ value);
}
switch(hf_field->display){
case BASE_DEC:
diff --git a/epan/proto.h b/epan/proto.h
index 8ea9bde18a..cd43deeb0d 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -1579,12 +1579,25 @@ proto_tree_add_bitmask(proto_tree *tree, tvbuff_t *tvb, int offset, int hf_hdr,
@param tvb the tv buffer of the current data
@param bit_offset start of data in tvb expressed in bits
@param no_of_bits length of data in tvb expressed in bits
+ @param little_endian big or little endian byte representation
+ @return the newly created item */
+
+extern proto_item *
+proto_tree_add_bits(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian);
+
+/** Add bitts to a proto_tree, using the text label registered to that item.
+ The item is extracted from the tvbuff handed to it.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param bit_offset start of data in tvb expressed in bits
+ @param no_of_bits length of data in tvb expressed in bits
@param return_value if a pointer is passed here the value is returned.
@param little_endian big or little endian byte representation
@return the newly created item */
extern proto_item *
-proto_tree_add_bits(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, guint32 *return_value, gboolean little_endian);
+proto_tree_add_bits_ret_val(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, guint32 *return_value, gboolean little_endian);
#ifdef __cplusplus
}