> Currently (ie the stable 0.8.3 version) gtk/main.c contains the following procedure
> static void
> ethereal_proto_init(void) {
> init_dissect_rpc();
> proto_init();
> init_dissect_udp();
> dfilter_init();
> #ifdef HAVE_PLUGINS
> init_plugins();
> #endif
> }
>
> Doesn't it make more sense to do all the init_dissect_protocol BEFORE
> proto_init()? In the case of UDP messages this enables new dissectors to
> register themselves in the hash using udp_hash_add (provided that this
> function is added to packet.h or something like that) and it would avoid
> adding every new protocol to packet-udp.c. Just add
> udp_hash_add(MY_PORT_NUMBER, MY_DISSECTOR) to
> proto_register_PROTOCOL!
As per my mail, we now have a two-stage registration process.
Protocols should register themselves, their fields, and their ETT
values, and do any one-time initialization - which includes initializing
any dissector tables - in their register routine.
Protocols should register themselves with parent-protocol dissector
routines in their "register handoff" routine.
All the register routines are called, and then all the "register
handoff" routines are called.
Unfortunately, unless the firewall you're behind has opened up, you
can't just check out the current CVS tree and look at "packet-dns.c" for
an example, but here's the tail of "packet-dns.c":
void
proto_register_dns(void)
{
static hf_register_info hf[] = {
...
};
static gint *ett[] = {
...
};
proto_dns = proto_register_protocol("Domain Name Service", "dns");
proto_register_field_array(proto_dns, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_dns(void)
{
dissector_add("udp.port", UDP_PORT_DNS, dissect_dns);
}
"dissect_dns()" is now a static routine.