Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You need to use a table then iterate through all the values. For example:

local subtype_f = Field.new("lldp.ieee.802_1.subtype")
local myproto = Proto("myproto", "My Proto")

function myproto.dissector(buf, pinfo, treeitem)
    local subtype = {subtype_f()}
    if subtype then
        for i in pairs(subtype) do
            if subtype[i].value == A_SUBTYPE then
                -- do_something
            elseif subtype[i].value == B_SUBTYPE then
                 -- do_something_else
           end
        end
    end
end

register_postdissector(myproto)

You need to use a table then iterate through all the values. For example:

local subtype_f = Field.new("lldp.ieee.802_1.subtype")
local myproto = Proto("myproto", "My Proto")

function myproto.dissector(buf, pinfo, treeitem)
    local subtype = {subtype_f()}
    if subtype then
        for i in pairs(subtype) do
            if subtype[i].value == A_SUBTYPE then
                -- do_something
            elseif subtype[i].value == B_SUBTYPE then
                 -- do_something_else
           end
        end
    end
end

register_postdissector(myproto)

And if you only want to deal with the last subtype, then of course you don't need to iterate though all subtypes, just check the last one, e.g.:

if subtype[#subtype].value == A_SUBTYPE then
    -- do_something
end