diff options
author | Anders Broman <anders.broman@ericsson.com> | 2010-05-02 15:37:23 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2010-05-02 15:37:23 +0000 |
commit | e87ddd657c0dcb08da204da55e141f7fc74340bd (patch) | |
tree | b30245b6d4b617c1ffc5617a614e9d4fb4666f83 /epan | |
parent | d528b62777698b0c123f1f004dd620cb864da9da (diff) | |
download | wireshark-e87ddd657c0dcb08da204da55e141f7fc74340bd.tar.gz wireshark-e87ddd657c0dcb08da204da55e141f7fc74340bd.tar.bz2 wireshark-e87ddd657c0dcb08da204da55e141f7fc74340bd.zip |
From Jakub Zawadzki:
Fix copy&paste error + add support for proto_tree_add_bits API
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4413
svn path=/trunk/; revision=32634
Diffstat (limited to 'epan')
-rw-r--r-- | epan/proto.c | 35 | ||||
-rw-r--r-- | epan/proto.h | 8 |
2 files changed, 40 insertions, 3 deletions
diff --git a/epan/proto.c b/epan/proto.c index 6d22b50150..0a5b6cc47b 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -6557,8 +6557,8 @@ proto_tree_add_bits_item(proto_tree *tree, const int hf_index, tvbuff_t *tvb, * Offset should be given in bits from the start of the tvb. */ -proto_item * -proto_tree_add_bits_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb, +static proto_item * +_proto_tree_add_bits_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, guint64 *return_value, const gboolean little_endian) { @@ -6678,7 +6678,21 @@ proto_tree_add_bits_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb, } proto_item * -proto_tree_add_bits_format_value(proto_tree *tree, const int hf_index, +proto_tree_add_bits_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb, + const gint bit_offset, const gint no_of_bits, + guint64 *return_value, const gboolean little_endian) +{ + proto_item *item; + + if ((item = _proto_tree_add_bits_ret_val(tree, hf_index, tvb, bit_offset, no_of_bits, return_value, little_endian))) { + FI_SET_FLAG(PNODE_FINFO(item), FI_BITS_OFFSET(bit_offset)); + FI_SET_FLAG(PNODE_FINFO(item), FI_BITS_SIZE(no_of_bits)); + } + return item; +} + +static proto_item * +_proto_tree_add_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, void *value_ptr, gchar *value_str) @@ -6777,6 +6791,21 @@ proto_tree_add_bits_format_value(proto_tree *tree, const int hf_index, } } +proto_item * +proto_tree_add_bits_format_value(proto_tree *tree, const int hf_index, + tvbuff_t *tvb, const gint bit_offset, + const gint no_of_bits, void *value_ptr, + gchar *value_str) +{ + proto_item *item; + + if ((item = _proto_tree_add_bits_format_value(tree, hf_index, tvb, bit_offset, no_of_bits, value_ptr, value_str))) { + FI_SET_FLAG(PNODE_FINFO(item), FI_BITS_OFFSET(bit_offset)); + FI_SET_FLAG(PNODE_FINFO(item), FI_BITS_SIZE(no_of_bits)); + } + return item; +} + #define CREATE_VALUE_STRING(dst,format,ap) \ va_start(ap,format); \ dst = ep_strdup_vprintf(format, ap); \ diff --git a/epan/proto.h b/epan/proto.h index 49394ebc08..5c5e1e76f7 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -261,6 +261,11 @@ typedef struct field_info { #define FI_LITTLE_ENDIAN 0x00000008 /** The protocol field value is in big endian */ #define FI_BIG_ENDIAN 0x00000010 +/** Field value start from nth bit (values from 0x20 - 0x100) */ +#define FI_BITS_OFFSET(n) ((n & 7) << 5) +/** Field value takes n bits (values from 0x100 - 0x4000) */ +/* if 0, it means that field takes fi->length * 8 */ +#define FI_BITS_SIZE(n) ((n & 63) << 8) /** convenience macro to get field_info.flags */ #define FI_GET_FLAG(fi, flag) ((fi) ? (fi->flags & flag) : 0) @@ -271,6 +276,9 @@ typedef struct field_info { (fi)->flags = (fi)->flags | (flag); \ } while(0) +#define FI_GET_BITS_OFFSET(fi) (FI_GET_FLAG(fi, FI_BITS_OFFSET(7)) >> 5) +#define FI_GET_BITS_SIZE(fi) (FI_GET_FLAG(fi, FI_BITS_SIZE(63)) >> 8) + /** One of these exists for the entire protocol tree. Each proto_node * in the protocol tree points to the same copy. */ typedef struct { |