Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Maybe you can use a preference to set the mask and dynamically apply it using the method I suggested in a recent discussion on the Wireshark developers mailing list? Here's a link to the beginning of that thread: For convenience or in case that link is ever dead, the sample function I provided, relevant to that discussion, was as follows:

local function dissect_RuPortId_F(tree, buffer)

    local t = {}
    local mask = 2^my_protocol.prefs.ru_port_id_width - 1
    local val =, 2):uint(), mask)

    for i = 15, 0, -1 do
        if, i), 1) == 1 then
            table.insert(t, (, i), 1) == 1 and '1') or '0')
            table.insert(t, '.')

        if (i % 4) == 0 then
            table.insert(t, ' ')

    tree:add(RuPortId_F, buffer(4, 2)):set_text(table.concat(t) .. " = Ru Port ID: " .. val)
end -- dissect_RuPortId_F()

With only some minor changes, it should be relatively easy to apply that function to your protocol, assuming this solution works for you.

If there are only a couple of different applicable masks that are dependent upon the version of your protocol, then you might just want to introduce a version preference and then use the mask that's applicable to that particular version. You'll still need to dynamically apply the mask though, that is unless you use different fields for the different versions, each with its own applicable mask, which is also another possible option.