Wireshark-dev: Re: [Wireshark-dev] Lua dissector adds trees but they have (null) in front of th
From: Richard Sharpe <realrichardsharpe@xxxxxxxxx>
Date: Sat, 20 Oct 2018 12:31:07 -0700
On Sat, Oct 20, 2018 at 12:25 PM Richard Sharpe
<realrichardsharpe@xxxxxxxxx> wrote:
>
> Hi folks,
>
> I have a small generated capture that has a three-byte header, with
> the first being a function code and the next two being the length.
>
> I handle them like this in Lua:
>
>     local t_header = tree:add(buffer, label)
>     t_header:add(f_function, buffer(offset, 1))
>     offset = offset + 1
>     t_header:add(f_length, buffer(offset, 2))
>     offset = offset + 2
>
> However, each subtree (there is another as well), appears with
> '(null)' in front of it.
>
> At first I thought maybe it was because I did not specify the length
> of the buffer, so I added this at the end:
>
>     t_header:set_len(offset - saved_offset)
>
> However, that has not fixed the problem.
>
> Does anyone know what I need to do to fix this?

Hmmm, I may have figured out what I did wrong.

I need to specify the buffer start location and length, and the
easiest thing is to treat it as a 1-byte item to start with.

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)(传说杜康是酒的发明者)