Wireshark-dev: Re: [Wireshark-dev] basic question
From: Ed Beroset <beroset@xxxxxxxxxxxxxx>
Date: Mon, 29 Mar 2010 11:10:59 -0400 (EDT)
>But what if I just wanted to make this dissector available as "decode 
>as" and not by the port it broadcasts on..??
[...]
>Just wanted to see what the best thing to do is here. I was just simply 
>going to pick a port that it would never be on...such as 11111.

You don't want to do that unless port 11111 was actually assigned by IANA.  Instead, what you can do is assign it to port 0 and then do this:

void proto_reg_handoff_myproto(void)
{
  static gboolean initialized = FALSE;
  static dissector_handle_t myproto_handle;
  static guint myproto_port;

  if (!initialized) {
    myproto_handle = new_create_dissector_handle(dissect_myproto, proto_myproto);
    dissector_add_handle("tcp.port", myproto_handle);
    initialized = TRUE;
  } else {
    if (myproto_port != 0) {
      dissector_delete("tcp.port", myproto_port, myproto_handle);
    }
  }
  if (global_myproto_port != 0) {
    dissector_add("tcp.port", global_myproto_port, myproto_handle);
  }
  myproto_port = global_myproto_port;
}

Then within your proto_register_myproto(void) function, do this:

  myproto_module = prefs_register_protocol(proto_myproto, NULL);
  prefs_register_uint_preference(myproto_module, "tcp.port", 
				  "My Protocol port",
                                  "My Protocol port", 
				  10, 
				  &global_myproto_port);

That way, the "myproto" dissector will be available as a "decode as" choice but not falsely claim a port it doesn't really own.

Ed