Ethereal-dev: Re: [Ethereal-dev] tvbuff questions and conclusions...

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Diwakar Shetty <diwakar@xxxxxxxxxxxxxx>
Date: Tue, 13 Mar 2001 10:53:17 +0600
hi

Thanks for the reply.

Actually, I did not expect a reply becuase i thought i am asking a question
which is too much about the internals..

However there is one point which i wish to point out in your explanation
The variable used for propagation of reference-count decrement is
"tvbuffs.subset" and not "used_in"

So far as documentation is concerned, I would have appreciated if there is
some material as to how the tvbuff algorithm works. The reason is that
previously we had a "char *pd". So one could whatever he/she wanted. But now
it is encapsulated within "tvbuff". And for anybody who wishes to do something
more than just displaying data (for e.g: decompression of compressed
packets..in my case it is VJ compressed PPP packets), an idea about the
internals would really be helpful. I am attaching the code below in which i am
trying to decompress packets but need to do some tweaking of the tvbuff
routines. Hence I have added a function to the "tvbuff.c" file.

****************************** tvbuff.c **************************************

void
tvb_diwa_set_reported_length(tvbuff_t* tvb, guint reported_length)
{
        unsigned int old_len = tvb->reported_length;

        g_assert(tvb->initialized);

        /* self's length */
        tvb->reported_length = reported_length;
        tvb->length = reported_length;

        /* change parent's length */
        tvb->tvbuffs.subset.tvb->reported_length += (reported_length -
old_len);
        tvb->tvbuffs.subset.tvb->length += (reported_length - old_len);
}
****************************** end of tvbuff.c
**************************************



****************************** packet-vj.c
**************************************
void
dissect_vjc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{

        int new_len = 0, old_len = 0;
        int offset =0;
        char *pd = 0;

                pd =  tvb_get_ptr(tvb, offset, 4);

                old_len = tvb_length_remaining(tvb, offset);

                if ( (new_len = slhc_uncompress(slcomp, pd, old_len)) <= 0) {
                        printf("Error in VJ decompression\n");
                        exit(0);
                        }

                tvb_diwa_set_reported_length(tvb,new_len);

        if (!tree) {
                pinfo->captured_len += (new_len - old_len);
                pinfo->len += (new_len - old_len);
                pinfo->fd->cap_len += (new_len - old_len);

                } /* end of IF statement */

                dissect_ip(tvb,pinfo,tree);
}
****************************** end of packet-vj.c
**************************************


Gilbert Ramirez wrote:

>
> Since the tvbuff routines are responsible for reference counting and
> freeing memory when a tvbuff is no longer used, a tvbuff needs to know
> all other tvbuffs in which it is used so that it can propagate
> the reference-count decrement.
>
> --gilbert
>
> _______________________________________________
> Ethereal-dev mailing list
> Ethereal-dev@xxxxxxxxxxxx
> http://www.ethereal.com/mailman/listinfo/ethereal-dev