Ask Your Question

new lua dissector error

asked 2024-04-14 06:19:57 +0000

BMWE gravatar image


I'm trying to create a new dissector and has error no such field XXX method/fieldfor object type ProtoField with following code:

local globals = {}
globals.ENUM_DESCRIPTION={[0]="STOP", [1]="START"}

local delegator = Proto("DEMO", "DEMO1")
local f = delegator.fields
f.a ="zz", "k.zz", ftypes.BYTES)
f.a.b = ProtoField.uint8("ZZ", "AA", base.dec, globals.ENUM_DESCRIPTION, 0x80)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2024-04-14 13:40:16 +0000

Chuckc gravatar image

updated 2024-04-14 13:44:42 +0000

Check the Wireshark Wiki Examples dissector.lua and fpm.lua for field definition examples.
Also the Contrib Lua Plugins especially ones from @cmaynard like the Guacamole Dissector.

From the WSDG: proto.fields: proto.fields Mode: Retrieve or assign.

The ProtoField's Lua table of this dissector.

Here is a slight rewrite that creates the fields without error:

local globals = {}
globals.ENUM_DESCRIPTION={[0]="STOP", [1]="START"}

local demo_p = Proto("DEMO", "DEMO1")

local f = {
    a ="zz", "demo.k.zz", ftypes.BYTES),
    b = ProtoField.uint8("demo.ZZ", "AA", base.dec, globals.ENUM_DESCRIPTION, 0x80)

demo_p.fields = f

View -> Internals -> Supported Protocols

image description

Note to self: It can be confusing that (from WSDG), abbr, type, [valuestring], [base], [mask], [description])

and ProtoField.uint8(abbr, [name], [base], [valuestring], [mask], [description])

swap the abbr and name Argument positions.

edit flag offensive delete link more

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


Asked: 2024-04-14 06:19:57 +0000

Seen: 121 times

Last updated: Apr 14