Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Lua ProtoField.ipv4 input data syntax

I'm writing a dissector in Lua ( and trying to use a ProtoField.ipv4 field. The problem is that the value is not from a TVB buffer (so I cannot use the usual buffer(x, y) syntax) but inside the data (maybe uncompressed or otherwise generated), and I cannot figure out the correct data syntax to use tree:add(p_addr, ipv4addr) (where ipv4addr is the IPv4 address in whatever format is required).

The error message in Wireshark is "userdata expected, got string" (or whatever syntax I try).

The original data is an IPv4 address as dotted decimal string (""), but I've also tried to use it as converted to uint32 (generated with a string.gmatch() loop), or as an array of bytes (bytes[1] = 10, bytes[2] = 1, ...). Any ideas how should I format the data so that a can add that value to the dissector tree?