This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Endianess Issue with Lua Dissector

0

For the dissector I'm creating I have to dissect 11 bits from two bytes. The bytes in the hex dump are:

CF 81

which is the following in binary:

1100 1111 1000 0001

However, I need the bytes organized as:

81 CF

So I can get the bits as:

1000 0001 1100 1111

Where the bolded bits are the bits of interest. My attempt was to store the two bytes in a separate variable using the tvbuf:bitfield() method. Then, after extracting the 11 bits desired, adding them to the display tree with tree:add_le() method. However, I am not getting the proper value.

Thank you for your consideration!

asked 14 Dec '16, 16:03

Irfan%20Hossain's gravatar image

Irfan Hossain
116611
accept rate: 0%


One Answer:

1

Are you having trouble getting the data in the dissection tree correctly or in your local variable correctly?

If the former then you should be able to use treeitem:add_packet_field with an encoding of ENC_LITTLE_ENDIAN to tell Wireshark to flip the bytes. Of course you'd want the ProtoField to be a ftypes.UINT16 and you'd presumably want to give it a mask of 0x7FF (so Wireshark will use only the lower 11 bits in calculating the value).

answered 04 Jan '17, 06:27

JeffMorriss's gravatar image

JeffMorriss ♦
6.2k572
accept rate: 27%

Thank you for your answer! The original problem was fixed a different way due to the data organization, but this fixed another issue I had with endianess. Thanks!

(04 Jan '17, 09:13) Irfan Hossain