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