THIS IS A TEST INSTANCE. Feel free to ask and answer questions, but take care to avoid triggering too many notifications.
0

how to invert two bytes in lua script dissector ?

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

updated 2017-10-30 16:13:34 +0000
This post is a wiki. Anyone with karma >750 is welcome to improve it.
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

Hi,

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

Pascal Quantin's avatar
5.8k
Pascal Quantin
answered 2017-10-30 17:08:32 +0000
edit flag offensive 0 remove flag delete link

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.

Guy Harris's avatar Guy Harris (2017-10-30 17:58:03 +0000) edit

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

Nicolas's avatar Nicolas (2017-10-31 16:04:32 +0000) edit

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

Pascal Quantin's avatar Pascal Quantin (2017-10-31 16:38:10 +0000) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer