diff options
author | Tomasz Moń <desowin@gmail.com> | 2021-09-15 21:32:56 +0200 |
---|---|---|
committer | Tomasz Moń <desowin@gmail.com> | 2021-09-26 18:16:28 +0200 |
commit | 7b82110092a105eedd5209e4ed75416098161d1f (patch) | |
tree | f8393d14a485e04f9a3091f04b0cc23606aeffd9 /epan/dissectors/packet-per.c | |
parent | d87e6e58fae2c36d3834a696b9a5a4ed8cc1d21b (diff) |
USB HID: Parse bit fields with correct bit order
Implement little endian support for tvb_get_bits family of functions.
The big/little endian refers to bit numbering within an octet. In big
endian, the most significant bit is considered bit 0, while in little
endian the least significant bit is considered bit 0.
Add encoding parameters to proto tree bits format family functions.
Specify ENC_BIG_ENDIAN in all dissectors using these functions except in
USB HID that requires ENC_LITTLE_ENDIAN to work correctly.
When formatting bits values, always display most significant bit on the
leftmost position regardless of the encoding. This results in no gaps
between octets and makes the displayed value comprehensible.
Close #4478
Fix #17014
Diffstat (limited to 'epan/dissectors/packet-per.c')
-rw-r--r-- | epan/dissectors/packet-per.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/epan/dissectors/packet-per.c b/epan/dissectors/packet-per.c index a284db088c..3a5e2cdbbd 100644 --- a/epan/dissectors/packet-per.c +++ b/epan/dissectors/packet-per.c @@ -1331,10 +1331,10 @@ DEBUG_ENTRY("dissect_per_constrained_integer"); val_start = (offset)>>3; val_length = length; - val = (guint32)tvb_get_bits64(tvb,offset,num_bits, ENC_BIG_ENDIAN); + val = (guint32)tvb_get_bits64(tvb,offset,num_bits,ENC_BIG_ENDIAN); if (display_internal_per_fields){ - str = decode_bits_in_field((offset&0x07),num_bits,val); + str = decode_bits_in_field((offset&0x07),num_bits,val,ENC_BIG_ENDIAN); proto_tree_add_uint(tree, hf_per_internal_min, tvb, val_start,val_length, min); proto_tree_add_uint64(tree, hf_per_internal_range, tvb, val_start, val_length, range); proto_tree_add_uint(tree, hf_per_internal_num_bits, tvb, val_start, val_length, num_bits); @@ -2134,7 +2134,7 @@ static tvbuff_t *dissect_per_bit_string_display(tvbuff_t *tvb, guint32 offset, a value = tvb_get_bits64(out_tvb, 0, length, ENC_BIG_ENDIAN); } proto_item_append_text(actx->created_item, ", %s decimal value %" G_GINT64_MODIFIER "u", - decode_bits_in_field(0, length, value), value); + decode_bits_in_field(0, length, value, ENC_BIG_ENDIAN), value); if (named_bits) { const guint32 named_bits_bytelen = (num_named_bits + 7) / 8; proto_tree *subtree = proto_item_add_subtree(actx->created_item, ett_per_named_bits); |