Ask Your Question
0

how to invert two bytes in lua script dissector ?

asked 2017-10-30 16:13:34 +0000

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-10-30 17:08:32 +0000

Pascal Quantin gravatar image

Hi,

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

edit flag offensive delete link more

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 gravatar imageGuy 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 gravatar imageNicolas ( 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 gravatar imagePascal Quantin ( 2017-10-31 16:38:10 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-10-30 16:13:34 +0000

Seen: 3,841 times

Last updated: Oct 30 '17