Wireshark-bugs: [Wireshark-bugs] [Bug 4478] New: Implement little endian support for tvb_get_bit

Date: Wed, 10 Feb 2010 00:05:59 -0800 (PST)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4478

           Summary: Implement little endian support for
                    tvb_get_bits[16|32|64]
           Product: Wireshark
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Low
         Component: Wireshark
        AssignedTo: wireshark-bugs@xxxxxxxxxxxxx
        ReportedBy: plr.vincent@xxxxxxxxx


Created an attachment (id=4285)
 --> (https://bugs.wireshark.org/bugzilla/attachment.cgi?id=4285)
For wireshark/epan/tvbuff.c, as of r31822

Build Information:
Version 1.3.3 (SVN Rev 31822 from /trunk)

Copyright 1998-2010 Gerald Combs <gerald@xxxxxxxxxxxxx> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiled with GTK+ 2.18.6, with GLib 2.22.4, with libpcap 1.0.0, with libz
1.2.3.4, without POSIX capabilities, with libpcre 7.8, without SMI, without
c-ares, without ADNS, without Lua, without Python, with GnuTLS 2.8.5, with
Gcrypt 1.4.5, with MIT Kerberos, without GeoIP, without PortAudio, without
AirPcap, with new_packet_list.

Running on Linux 2.6.32-trunk-amd64, with libpcap version 1.0.0, GnuTLS 2.8.5,
Gcrypt 1.4.5.

Built using gcc 4.4.3.

Wireshark is Open Source Software released under the GNU General Public
License.

Check the man page and http://www.wireshark.org for more information.
--
Attached patch adds support for fetching a list of bits, starting at given bit
offset and for given length (nothing new here), allowing little-endian byte
ordering (this is new).

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

And so on for bit_offsets which are not multiple of 4 (it's much less visually
obvious).

As it's my first submission to wireshark, and as it has been quite some months
since I last used C, please review for stupid constructs and bad coding style.

-- 
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.