This is a static, read-only archive of Wireshark Q&A. Older questions and answers from October 2017 and earlier can be found at osqa-ask.wireshark.org.
0

how to invert two bytes in lua script dissector ?

asked Oct 30 '17

updated Oct 30 '17

Hello, I'm writting a wireshark dissector using .lua script. I meet a problem with fields where most significant byte is inverted. Two cases, 16bits and 32 bits fields. In the network packet, it is present with the format : "02 80" i want to display 80 02 "14 7d 00 00" i want to display 00 00 7d 14

I tried to use the bit.bswap() function as followed :

local bit = require("bit")
...
local SAI_data = tvbuf:range(2,2):uint()
SAI_data = bit.bswap(SAI_data)

But i got an error as the bit library or bit.lua script is not installed. Is it possible to install it ? How to do that ? Or is there any other way to configure the range function to invert read bytes ?

Thank you

1 Answer

0

answered Oct 30 '17

Hi,

based on Wireshark Lua API documentation, it looks like you need to use le_uint() instead of uint().

Comments

I.e., it's not as if there's a "normal" and "inverted" byte order, there's big-endian and little-endian, and you need to fetch the data in little-endian byte order rather than big-endian byte order.

User 87485 ( Oct 30 '17 )

Hi, Thank you very much. I did not make link with little indian byte order at first time. Thanks for your help.

User 61057 ( Oct 31 '17 )

If my answer has solved your issue, please accept it by clicking on the check mark next to may answer.

User 54095 ( Oct 31 '17 )
cc-by-sa Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.