diff options
author | etxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-09-20 11:29:53 +0000 |
---|---|---|
committer | etxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-09-20 11:29:53 +0000 |
commit | 1133c9717fba1bb8ef55949bd25065c7572042b1 (patch) | |
tree | b6800840141b894c25c3a6266a379840b324c76d /epan/proto.c | |
parent | 68901537f75a856001d8b97d844ddd9d2d553d6b (diff) |
From Sylvain Munaut:
Add support for signed types in _proto_tree_add_bits_ret_val
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6363
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@39060 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/proto.c')
-rw-r--r-- | epan/proto.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/epan/proto.c b/epan/proto.c index 265de47d50..0a0b92f758 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -7277,6 +7277,21 @@ _proto_tree_add_bits_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb return NULL; } + /* Sign extend for signed types */ + switch(hf_field->type){ + case FT_INT8: + case FT_INT16: + case FT_INT24: + case FT_INT32: + case FT_INT64: + if (value & (G_GINT64_CONSTANT(1) << (no_of_bits-1))) + value |= (G_GINT64_CONSTANT(-1) << no_of_bits); + break; + + default: + break; + } + if(return_value){ *return_value=value; } @@ -7306,11 +7321,24 @@ _proto_tree_add_bits_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb fill_label_uint(PITEM_FINFO(pi), lbl_str); break; + case FT_INT8: + case FT_INT16: + case FT_INT24: + case FT_INT32: + pi = proto_tree_add_int(tree, hf_index, tvb, offset, length, (gint32)value); + fill_label_int(PITEM_FINFO(pi), lbl_str); + break; + case FT_UINT64: pi = proto_tree_add_uint64(tree, hf_index, tvb, offset, length, value); fill_label_uint64(PITEM_FINFO(pi), lbl_str); break; + case FT_INT64: + pi = proto_tree_add_int64(tree, hf_index, tvb, offset, length, (gint64)value); + fill_label_int64(PITEM_FINFO(pi), lbl_str); + break; + default: DISSECTOR_ASSERT_NOT_REACHED(); return NULL; |