Wireshark-dev: Re: [Wireshark-dev] Adding multiple ports for dissector
From: Stephen Fisher <stephentfisher@xxxxxxxxx>
Date: Wed, 29 Oct 2008 14:49:11 -0600
On Wed, Oct 29, 2008 at 01:38:24PM -0700, jdolly@xxxxxxxxx wrote:

> I have a packet dissector implemented on a single TCP Port (user 
> enterable through Preferences).
>
> I would like to add multiple ports to this dissector.
>
> Looks like I have to use "prefs_register_range_preference" function in 
> my protocol registration routine.

Yup.

> What are the other changes that need to be made to my packet dissector 
> file?

Take a look at epan/dissectors/packet-xml.c for an example.  
packet-http.c also has it, but it looks a bit more complicated.  

Basically, you're registering a range that is stored in a string, then 
you copy it with range_copy() and do a range_foreach() call to operate 
on the copy of the list of ports and have it call (in xml's case) 
range_add_xml_tcp_callback() for each port in the range list.  
range_add_xml_tcp_callback() is a one line function that does a 
dissector_add() on each tcp port it is handed.


Steve