Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Lua - Get string for a ProtoField that uses a lookup table

I'm trying to add some summary information and modify a treeitem string in a Lua dissector. I'd like to add the string of a ProtoField that is set via a valuestring table. Is there a way to get the ProtoField's current string (the currently active valuestring)? If I do a tostring(field) it dumps out internal information.

Here's some stub code:

local selectionLookup = {
   [1] = "selection 1",
   [2] = "selection 2",
   [3] = "selection 3"
local pfSelection ="Current selection",
                          "selection", ftypes.UINT8, selectionLookup)

function selectionDissector(stuff, stuff2, stuff3)
   selectionString = tostring(pfSelection) -- how do I get "selection1", etc. from pfSelection?
   return 42