Wireshark-dev: Re: [Wireshark-dev] tvb_composite
From: Jeff Morriss <jeff.morriss.ws@xxxxxxxxx>
Date: Thu, 07 Apr 2011 16:27:19 -0400
Yosi Saggi wrote:
I have gone through the composite function once more and found the
problem I had with it.
In "tvb_composite_append" function at the end there is a use of
"add_to_used_in_list" function.
This is used also in "tvb_composite_prepend" function.
My issue with the " tvb_composite_append" function was that the first
buffer in the composed_tvb->used_in->data was the last buffer I have
added
To the composed buffer.
As I mentioned the "add_to_used_in_list" function does the following:

static void
add_to_used_in_list(tvbuff_t *tvb, tvbuff_t *used_in)
{
	tvb->used_in = g_slist_prepend(tvb->used_in, used_in);
	tvb_increment_usage_count(tvb, 1);
}

As you can see both for appending and prepending we are using "
g_slist_prepend" which is incorrect. Once I have changed the function
into:

static void
add_to_used_in_list_append(tvbuff_t *tvb, tvbuff_t *used_in)
{
	tvb->used_in = g_slist_append(tvb->used_in, used_in);
	tvb_increment_usage_count(tvb, 1);
}

I can now get my composed buffer in " (tvbuff_t*) composed_tvb
->used_in->data ". I'm not sure this is the way it was ment to be used,
but it works for me. The result is a composed buffer out of the chunked
buffers I have mentioned previously, The functions just need to be fixed
to the appropriate use:
Append - g_slist_append
Prepend - g_slist_prepend

Any comments will be welcomed

Sorry, just getting back to this...

That's all true, but why do you need to be using 'used_in'? I would think you should only be using the tvb_* functions in which case the order of used_in won't matter. (Of course this assumes the accessor functions work for composites.)