Wireshark-dev: Re: [Wireshark-dev] Dissector callback definition

From: Stephen Fisher <steve@xxxxxxxxxxxxxxxxxx>
Date: Wed, 2 Dec 2009 11:30:41 -0700

On Dec 2, 2009, at 11:08 AM, Joshua Wright wrote:

The README.developer sample code shows the dissector callback function
as shown:

/* Code to actually dissect the packets */
static int
dissect_PROTOABBREV(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{

/* ... */

/* Return the amount of data this dissector was able to dissect */
	return tvb_length(tvb);
}

However, other source shows this function as having return type static
void.  Is it not necessary to return the number of bytes the dissector
processed any longer?

Returning the number of bytes dissected is the new and preferred method of handling dissectors. In order to have the number of bytes dissected handled, the dissector needs to be registered as a new style one such as is shown in README.developer:

PROTOABBREV_handle = new_create_dissector_handle(dissect_PROTOABBREV, proto_PROTOABBREV);


Steve