Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Lua: populate a field from DissectorTable

I'm dissecting a protocol where one of fields specifies the request kind. Dissectors for request kinds are registered in a DissectorTable:

-- proto.lua
local kinds_table = DissectorTable.new("proto.request_kind", "Proto Requests", ftypes.UINT8)

-- proto_kindA.lua
local kindA = Proto("PROTO-A", "Protocol Request Kind A")
func kindA.init()
    DissectorTable.get("proto.request_kind"):set(0x55, kindA)
end

Main dissector then uses

kinds_table:try(kind, cmd:tvb(), pinfo, tree)

to render the subprotocol.

Everything is fine except the "kind" field in the protocol: it would be very useful to populate it with the name of the protocol. How do I get it from kinds_table or in some other way?

I could keep a map of kinds in the main file, thought it's error-prone: there are 6 tables for kinds, each containing ~200 entries, so I hope there is a better way to do so.

Lua: populate a field from DissectorTable

I'm dissecting a protocol where one of fields specifies the request kind. Dissectors for request kinds are registered in a DissectorTable:

-- proto.lua
local kinds_table = DissectorTable.new("proto.request_kind", "Proto Requests", ftypes.UINT8)

-- proto_kindA.lua
local kindA = Proto("PROTO-A", "Protocol Request Kind A")
func kindA.init()
    DissectorTable.get("proto.request_kind"):set(0x55, kindA)
end

Main dissector then uses

kinds_table:try(kind, cmd:tvb(), pinfo, tree)

to render the subprotocol.

Everything is fine except the "kind" field in the protocol: it would be very useful to populate it with the name of the protocol. How do I get it from kinds_table or in some other way?

I could keep a map of kinds in the main file, thought though it's error-prone: there are 6 tables for kinds, each containing ~200 entries, so I hope there is a better way to do so.