Mailing List Archive

RE: How to associate a new dissector with given TC P & UDP ports
per Mark Atwood:

> The protocol I'm dissecting flows over one of a few known UDP ports,
> or over a preknown TCP port, and I cannot figure out from the
> README.developer file how to tell Ethereal to associate those TCP &
> UDP IP ports with my dissector.
>
> Explanations or pointers would be most welcome.


This functionality has been added since the README.developer was
written.

If you want to associate the ports during the startup process, when
all dissectors are registered, you need to create a function
'void proto_reg_handoff_XXX(void)'. The function should have a call
to register the ports with either TCP or UDP. The build routine will
create the register.c file to call this function during the startup.
See make-reg-dotc if you want the details.

For example to register with TCP -

void
proto_reg_handoff_MY_PROTO( void) {

dissector_add( "tcp.port", PORT_NUMBER, DISSECT_MY_PROTO);
}

Where you would substitute the actual protocol name for MY_PROTO and the
name of your dissector main function for DISSECT_MY_PROTO. And the port
number for PORT_NUMBER.

Note: 1) The void return type is on the line above the function definition.
This is required.

2) dissector_add is used for new (tvbuffer style) dissectors and
dissector_add_old is used for old (pd style) dissectors. DON'T write
a dissector using the pd style.


To do this for UDP change "tcp.port" to "udp.port".

If you want to add a port dynamically, that is a different question.

Jeff Foster
jfoste@woodward.com