Wireshark-dev: Re: [Wireshark-dev] buffer to tvb
From: Bill Meier <wmeier@xxxxxxxxxxx>
Date: Wed, 14 Dec 2011 00:06:07 -0500
On 12/13/2011 11:37 PM, Andrew Kampjes wrote:
I've got a buffer of guint8s in a dissector that I'd like to turn
into  a tvb that I can then use as a parameter to "add_new_data_source()".
>  Is that possible/how?

Andrew.



Basically:
   [allocate and fill buffer: data_p = ....]
   my_tvb = tvb_new_real_data(data_p, data_length, data_length)
   add_new_data_source(pinfo, my_tvb, "Title");
   ....
   tvb_free(my_tvb);
   [free buffer: ]


It's possible to set a callback to free storage when the tvb is free'd.

See tvbuff.h