This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

how to get/set pinfo.cols.xxx’s value in lua, and how to add a columns in pinfo?

0

and one more question, how to access the data beyon tvb. Such as I add a dissector in udp port 2222, but I need to access the data in network layer in the dissector, how to do this in Lua, or I have to use c to do this?

Best regards

asked 09 Oct '16, 04:00

cmqy's gravatar image

cmqy
6223
accept rate: 0%


One Answer:

0

If you are interested in things like the destination address, have a look at fields like pinfo.net_src or pinfo.src. You can find more of such fields at the pinfo reference.

To access individual fields, first specify the individual packet somewhere in your packet and retrieve it like this:

local myproto = Proto("myproto", "My Protocol")
local ttl_field = Field.new("ip.ttl")
function myproto.dissect(tvb, pinfo, tree)
    local ttl = ttl_field()
    -- now "ttl" contains a FieldInfo instance
end

For the available properties of the FieldInfo class instance, see the FieldInfo reference. You are likely interested in the value and range fields.

In other cases, you can just access the contents of the tvb directly.

answered 16 Oct '16, 13:50

Lekensteyn's gravatar image

Lekensteyn
2.2k3724
accept rate: 30%