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

Bitfield with lua endianness

0

I'm writing a dissector that must be capable of extracting numeric values from a TvbRange that spans multiple bytes, while only considering certain bits. I'm a bit concerned about chossing the right method that will also ensure the correct endianess and signedness.

From my understanding I could add a bitmask when creating the ProtoField. However this fails with "bad argument #4 to 'uint16' (must be a table)". ProtoField.uint16("abc","abc",base.DEC, 0x3000, nil, "") Any idea what is causing this? Does Wireshark apply the mask on the raw data and then start coverting to uint16?

Secondly, I would also like to have the value in an local variable. If I for instance call buf(1,2):bitfield(2,2), it will return a number, but is there some way of ensuring the correct endianess and signing? Can I maybe retrieve the values from the TreeItem?

Thanks

asked 14 Jun '16, 11:44

Luanda's gravatar image

Luanda
6112
accept rate: 0%