How to handle 6 byte unsigned integer field in lua dissector?
Certain exchange protocols have started sending their timestamp fields as a 6 byte unsigned integer. The field data contains nanoseconds since midnight. If I promote this value to a uint64 via:
local range = buffer(offset, 6)
local value = range:uint64()
local display = "Timestamp"..value
parent:add(fields.timestamp, range, value, display)
I get:
Lua Error: [...]:370: calling 'add' on bad self (string expected, got userdata)
Is there a way to use the internal field parsers to handle 6 bytes as an integer? Do I need to write a custom function for this data?
Note: this displays the correct value but converts to a string:
Caution, I only know enough Lua to be dangerous, but can't you use a
tvbrange:uint64()
with the 6 byte range, to retrieve the value into a uint64 variable. e.g.Thanks for taking a look, I added the original script that caused the error. Your suggestion was my original line of thought.
You have a "::" on the range object, have you tried a single ":"?
I was copying from memory since this source is on a branch on my home cpu. :: was because my fingers know c++. I updated the example. Thanks.