Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: [Wireshark-dev] how to check a field

From: Ed Beroset <beroset@xxxxxxxxxxxxxx>
Date: Fri, 12 Aug 2011 11:42:11 -0400
I am working on refining a dissector and need to make sure the tree I'm passed actually points to the field I intend. This code may be called either before or after the packet is dissected. To do this I'm using code like this:

if (PNODE_FINFO(tree)->hfinfo->id == hf_myproto_specialfield)
{  /* do stuff... */ }

I don't like to reach that deep into the hfinfo data structure, but it seems that the only alternative that would work would be to call proto_find_finfo(tree, hf_myproto_specialfield) but that's not really what I want and incurs a much larger runtime penalty than is really needed. Is there a better way to do this?

Ed