On Wed, Aug 28, 2002 at 09:36:47AM -0400, Gautham Thavva wrote:
> As my doubt is silly, I will make a fool of myself if I post
> this to the ethereal mailing list.
No, it's actually a reasonable question, so I'll forward my answer to
the ethereal-dev list.
> You have coded the Q.931 dissector and Gilbert Ramirez has
> coded the LAPD dissector. As you know, Q.931 is layer 3
> protocol and LAPD is layer 2 protocol. I fail to understand
> why the q931_handle specified in the LAPD dissector is not
> found in the Q.931 dissector.
Because that would introduce a link-time dependency between the Q.931
dissector and the LAPD and IUA dissectors, and, in general, we (or I, at
lest) prefer to have connections between dissectors established at run
time (in case, for example, we ever take an approach similar to the one
Microsoft takes in their Network Monitor sniffer and load *all*
dissectors at start-up time, i.e. make them all plugins).
If Ethereal had *no* ability to load dissectors at run time, that
wouldn't matter, but, as it does, we try to use run-time mechanisms for
connecting dissectors. (The H.323 plugin, for example, fetches the
handle for the Q.931 dissector with "find_dissector()".)
> When do you use find_dissector and create_dissector_handle?
"create_dissector_handle()" is used if no other dissector has the notion
that it calls your dissector wired into it, and your dissector is called
only through a dissector table.
If your dissector is called "directly" (i.e., through a dissector handle
for it rather than through a dissector table), you use
"register_dissector()" rather than "create_dissector_handle()" to create
the handle, and those dissectors that call it "directly" use
"find_dissector()" to find that handle.