Wireshark-dev: Re: [Wireshark-dev] Check for end of packet?

From: Stephen Fisher <stephentfisher@xxxxxxxxx>
Date: Wed, 9 May 2007 14:22:29 -0700
On Wed, May 09, 2007 at 02:53:25PM -0400, Kevin A. Noll wrote:

> I'm trying to decode a packet that has TLVs at the end of it. One of 
> the possible TLVs is a "NULL" TLV, which is simply one or more bytes 
> with the zero value. However, if it's any other kind of TLV, it is 
> likely to start with a zero and then be followed by another value that 
> indicates the actual type.
> 
> How do I check for that second byte without reading past the end of 
> the packet buffer?

Check out the functions with length_remaining in their name in 
epan/tvbuff.h.  The idea is to check to make sure there is another byte 
before you try to access it.


Steve