Ethereal-dev: Re: [Ethereal-dev] Van Jacobson dissector.

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

From: Irfan Khan <ikhan@xxxxxxxxxxxx>
Date: Wed, 19 Dec 2001 10:30:15 -0700

What data is it reading?  Is there another way to provide it?
"tvb_orig()" is a bit ugly....

I agree, very very ugly indeed.

The VJ dissector needs to replace the compressed tcp/ip header with the decompressed version of it. It is nasty to modify the original tvbuff; the path of least resistance is to build a new tvbuff with the decompressed header. After the header decompression both the compressed and the decompressed tvbuffs are displayed in separate frames. In the VJ dissector I don't have the bytes preceding the ppp payload which can potentially be 1-2 bytes for the ppp protocol field to many depending on what ppp is running over (pppoe comes to mind). The requirement therefore is to have a means to copy all bytes preceding the tvbuff passed in.

tvb_orig is pretty much the same as offset_from_real_beginning with the exception that it returns the pointer to the original tvbuff, in addition to the byte offset from the beginning. This allows me to use tvbuff access functions to copy the bytes preceding the VJ tvbuff. Other methods to achieve the same got uglier and uglier.

I tried to minimize the ugliness by having tvb_orig's prototype in tvbuff.h defined inside #ifdef's where the assumption is that the ifdef is turned on in packet-vj.c only. tvb_orig can potentially be accessed by other protocols by defining tvb_orig as an extern in those dissectors. At that point all I can do is throw up my hands.