Wireshark-dev: Re: [Wireshark-dev] Browse field in the preferences
Date: Wed, 5 Aug 2009 14:52:27 +0200
Hello Aurelien,
Perhaps you can use the "Follow TCP/UDP stream" feature then save the result.
Regarding your idea about having a file setting inside the preferences it should be possible, but I do not know how to use it properly.
Here are some sources I use in my dissector templates to let the users change the tcp/udp ports range for a specific protocol.
The template is not complete but I hope it can help. I also think it can be greatly improved but it works as expected.
#define VRU201_DEFAULT_RANGE "5000" /* Ports TCP comma separated */
static range_t *global_vru201_tcp_range = NULL;
static range_t *vru201_tcp_range = NULL;
static void reinit_vru201(void);
static void range_delete_vru201_tcp(guint32);
static void range_add_vru201_tcp(guint32);
/*--- proto_register_vru201 ----------------------------------------------*/
void proto_register_vru201(void)
  /* prefs */
  module_t* vru201_module;
  /* List of fields */
  static hf_register_info hf[] = {
  #include "packet-vru201-hfarr.c"
  /* List of subtrees */
  static gint *ett[] = {
  #include "packet-vru201-ettarr.c"
  /* Register protocol */
  proto_vru201 = proto_register_protocol(PNAME, PSNAME, PFNAME);
  /* Prefs VRU201 */
  vru201_module = prefs_register_protocol(proto_vru201, reinit_vru201);
  range_convert_str(&global_vru201_tcp_range, VRU201_DEFAULT_RANGE, 65535);
  vru201_tcp_range = range_empty();
  prefs_register_range_preference(vru201_module, "tcp.port", "TCP Ports",
        "TCP Ports range",
        &global_vru201_tcp_range, 65535);
  /* Register fields and subtrees */
  proto_register_field_array(proto_vru201, hf, array_length(hf));
  proto_register_subtree_array(ett, array_length(ett));
/* Register the protocol if the ports list has changed */
static void reinit_vru201(void) {
 range_foreach(vru201_tcp_range, range_delete_vru201_tcp);
 vru201_tcp_range = range_copy(global_vru201_tcp_range);
 range_foreach(vru201_tcp_range, range_add_vru201_tcp);
/* Wrapper to remove a port from the dissector */
static void range_delete_vru201_tcp(guint32 port) {
 dissector_delete("tcp.port", port, vru201_handle);
/* Wrapper to add a port to the dissector */
static void range_add_vru201_tcp(guint32 port) {
 dissector_add("tcp.port", port, vru201_handle);
/*--- proto_reg_handoff_vru201 -------------------------------------------*/
void proto_reg_handoff_vru201(void) {
 static gboolean inited = FALSE;
 if( !inited ) {
  vru201_handle = create_dissector_handle(dissect_vru201, proto_vru201);
  inited = TRUE;

France Telecom R&D