Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There's probably more than 1 way to skin this cat, but you can use tonumber(). For example:

local p_foo = Proto("foo", "FOO Protocol")
local f_foo_val32_ascii = ProtoField.uint32("foo.val32_ascii", "Value 32 (ASCII)", base.DEC)

p_foo.fields = { f_foo_ascii_val, ... }
...
function p_foo.dissector(buf, pinfo, tree)
    local foo_tree = tree:add(p_foo, buf(0, -1))
    ...
    foo_tree:add(f_foo_val32_ascii, buf(offset, 4), tonumber(buf(offset, 4):string()))
    ...
end

For more information on tonumber(), refer to the Lua manual.

For more information on tvbrange:string(), refer to Section 11.8.3.18. tvbrange:string([encoding]) in the Wireshark Developer's Guide

There's probably more than 1 way to skin this cat, but you can use tonumber(). For example:

local p_foo = Proto("foo", "FOO Protocol")
local f_foo_val32_ascii = ProtoField.uint32("foo.val32_ascii", "Value 32 (ASCII)", base.DEC)

p_foo.fields = { f_foo_ascii_val, f_foo_val32_ascii, ... }
...
function p_foo.dissector(buf, pinfo, tree)
    local foo_tree = tree:add(p_foo, buf(0, -1))
    ...
    foo_tree:add(f_foo_val32_ascii, buf(offset, 4), tonumber(buf(offset, 4):string()))
    ...
end

For more information on tonumber(), refer to the Lua manual.

For more information on tvbrange:string(), refer to Section 11.8.3.18. tvbrange:string([encoding]) in the Wireshark Developer's Guide