Ask Your Question
0

new lua dissector error

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

BMWE gravatar image

Hi,

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 = ProtoField.new("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
0

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: 11.3.5.10. proto.fields:

11.3.5.10. 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 = ProtoField.new("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)

11.3.7.1. ProtoField.new(name, abbr, type, [valuestring], [base], [mask], [description])

and

11.3.7.3. 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

Stats

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

Seen: 199 times

Last updated: Apr 14