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

ntoh equivalent in lua wireshark

0

Hi,

I am a little new to writing a dissector using lua. So, please bare an amateur.

I am trying to implement a dissector for one of our projects. Since my host order(currently) is little Endian, I am using methods like "tree:add_le()", "tvbuf:range(offset,2):le_uint()", etc.

However, i would want to run a command, which is equivalent to "ntohl()"( method used in C/C++) at the beginning itself, which would eliminate any errors with byte ordering during dissection.

Please help.

Thanks, Spark

asked 12 Dec '16, 01:48

spark's gravatar image

spark
11115
accept rate: 0%

edited 12 Dec '16, 23:00


One Answer:

1

You should be probably just use treeitem:add_packet_field with an encoding of ENC_LITTLE_ENDIAN. If the endianness may change, use a variable for the encoding and set it appropriately (that would allow you to just set it once rather than having to remember to do it for every field).

answered 04 Jan '17, 06:42

JeffMorriss's gravatar image

JeffMorriss ♦
6.2k572
accept rate: 27%

Thanks Jeff!

(10 Jan '17, 23:05) spark