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

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.
Hi, Thank you very much. I did not make link with little indian byte order at first time. Thanks for your help.
If my answer has solved your issue, please accept it by clicking on the check mark next to may answer.