Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-users: [Wireshark-users] Wide char strings in LUA dissector

From: Helge Kruse <Helge.Kruse@xxxxxxx>
Date: Sun, 27 Nov 2016 10:19:08 +0100
Hello,

I'm writing a dissector in LUA. The protocol has a packet consisting of
a wide character string. For this purpose I added an appropriate header
field to the dissector:

  local f_fsWFileName = ProtoField.new  ("WFileName", \
    "KITL.PPSH.WFileName", ftypes.UINT_STRING, nil, base.NONE)

and added it to the protocol:

  proto_ppsh.fields = { f_fsWFileName }


This results in an error:

Lua: Error during loading:
[string "C:\Users\Helge\AppData\Roaming\Wireshark\plug..."]:131: bad
argument #3 to 'new' (ProtoField_new: Invalid ProtoField field type)

This is strange, because I checked that the type UINT_STRING is defined
in "C:\Program Files\Wireshark2\init.lua":

  ftypes = {
    ....
    ["UINT_STRING"] = 27,
    ....
  }

If I replace the ftypes.UINT_STRING with 27 I get the same result.
If I replace the ftypes.UINT_STRING with 29 I get no error, but of
course the string is shown as a byte dump. So the remaining dissector
looks good. Obviously I would prefer the string for the dump.

How should I display a wide character string with LUA in Wireshark 2.2.1?

I tried the same with Wireshark 1.12.5, and get the same result. But
used the corresponding numerical value 19 for ftypes.UINT_STRING.

Regards
Helge