https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4478
--- Comment #3 from Chris Maynard <christopher.maynard@xxxxxxxxx> 2010-12-23 07:36:40 PST ---
(In reply to comment #0)
> I believe the best to do to describe the implementation is to provide examples,
> focusing on tvb_get_bits32:
> - file data
> 0x12 0x34 0x56 0x78 0x9A
> - bit_offset, no_of_bits = result // comment
> 0, 32 = 0x78563412 // regular conversion of 4 first bytes
> 4, 24 = 0x7856342 // 4 (=bit_offset) MSbs of 1st byte are stripped
> 4, 32 = 0xA7856342 // 4 (=32 - (bit_offset + no_of_bits)) LSbs of 5th byte
> are added to result
These examples don't make sense to me. First, let's start with the current BE
bit order for tvb_get_bits32:
- file data
0x12 0x34 0x56 0x78 0x9A
- bit_offset, no_of_bits = result // comment
0, 32 = 0x12345678 // regular conversion of 4 first bytes
4, 24 = 0x00234567 // Take 24 bits, skipping the 1st 4 bits of the 1st byte
4, 32 = 0x23456789 // Take 32 bits, skipping the 1st 4 bits of the 1st byte
Now comes the LE results ... but this can be confusing because are we talking
about LE byte ordering or LE bit ordering? If it's LE byte ordering, then we
have this:
- file data
0x12 0x34 0x56 0x78 0x9A
- bit_offset, no_of_bits = result // comment
0, 32 = 0x78563412 // regular conversion of 4 first bytes
4, 24 = 0x00674523 // Take 24 bits, skipping the 1st 4 bits of the 1st byte
4, 32 = 0x89674523 // Take 32 bits, skipping the 1st 4 bits of the 1st byte
... and if it's LE bit ordering, then it's this:
- file data
0x12 0x34 0x56 0x78 0x9A
- bit_offset, no_of_bits = result // comment
0, 32 = 0x1E6A2C48 // regular conversion of 4 first bytes
4, 24 = 0x00E6A2C4 // Take 24 bits, skipping the 1st 4 bits of the 1st byte
4, 32 = 0x91E6A2C4 // Take 32 bits, skipping the 1st 4 bits of the 1st byte
If it's LE bit ordering, then we would even need a tvb_get_bits8_le() function
... or change the existing tvb_get_bits8() call to accept a little_endian
argument like its tvb_get_bits16() and tvb_get_bits32() counterparts. Here's a
quick illustration of why, using 3-bits as an example:
3-bits BE LE
000 0 0
001 1 4
010 2 2
011 3 6
100 4 1
101 5 5
110 6 3
111 7 7
--
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.