diff options
Diffstat (limited to 'epan/dissectors')
278 files changed, 913 insertions, 2563 deletions
diff --git a/epan/dissectors/asn1/c1222/packet-c1222-template.c b/epan/dissectors/asn1/c1222/packet-c1222-template.c index bf4269dc5f..c177ca6b18 100644 --- a/epan/dissectors/asn1/c1222/packet-c1222-template.c +++ b/epan/dissectors/asn1/c1222/packet-c1222-template.c @@ -1418,7 +1418,7 @@ proto_reg_handoff_c1222(void) if( !initialized ) { c1222_handle = create_dissector_handle(dissect_c1222, proto_c1222); c1222_udp_handle = create_dissector_handle(dissect_c1222_common, proto_c1222); - dissector_add_uint("tcp.port", global_c1222_port, c1222_handle); + dissector_add_uint_with_preference("tcp.port", C1222_PORT, c1222_handle); dissector_add_uint("udp.port", global_c1222_port, c1222_udp_handle); initialized = TRUE; } diff --git a/epan/dissectors/asn1/cmp/packet-cmp-template.c b/epan/dissectors/asn1/cmp/packet-cmp-template.c index 0446c6040c..68bd35d568 100644 --- a/epan/dissectors/asn1/cmp/packet-cmp-template.c +++ b/epan/dissectors/asn1/cmp/packet-cmp-template.c @@ -50,7 +50,6 @@ void proto_register_cmp(void); /* desegmentation of CMP over TCP */ static gboolean cmp_desegment = TRUE; -static guint cmp_alternate_tcp_port = 0; static guint cmp_alternate_http_port = 0; static guint cmp_alternate_tcp_style_http_port = 0; @@ -345,12 +344,6 @@ void proto_register_cmp(void) { "To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &cmp_desegment); - prefs_register_uint_preference(cmp_module, "tcp_alternate_port", - "Alternate TCP port", - "Decode this TCP port\'s traffic as CMP. Set to \"0\" to disable.", - 10, - &cmp_alternate_tcp_port); - prefs_register_uint_preference(cmp_module, "http_alternate_port", "Alternate HTTP port", "Decode this TCP port\'s traffic as CMP-over-HTTP. Set to \"0\" to disable. " @@ -373,7 +366,6 @@ void proto_reg_handoff_cmp(void) { static dissector_handle_t cmp_http_handle; static dissector_handle_t cmp_tcp_style_http_handle; static dissector_handle_t cmp_tcp_handle; - static guint cmp_alternate_tcp_port_prev = 0; static guint cmp_alternate_http_port_prev = 0; static guint cmp_alternate_tcp_style_http_port_prev = 0; @@ -387,7 +379,7 @@ void proto_reg_handoff_cmp(void) { dissector_add_string("media_type", "application/x-pkixcmp-poll", cmp_tcp_style_http_handle); cmp_tcp_handle = create_dissector_handle(dissect_cmp_tcp, proto_cmp); - dissector_add_uint("tcp.port", TCP_PORT_CMP, cmp_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_CMP, cmp_tcp_handle); oid_add_from_string("Cryptlib-presence-check","1.3.6.1.4.1.3029.3.1.1"); oid_add_from_string("Cryptlib-PKIBoot","1.3.6.1.4.1.3029.3.1.2"); @@ -401,20 +393,10 @@ void proto_reg_handoff_cmp(void) { inited = TRUE; } - /* change alternate TCP port if changed in the preferences */ - if (cmp_alternate_tcp_port != cmp_alternate_tcp_port_prev) { - if (cmp_alternate_tcp_port_prev != 0) - dissector_delete_uint("tcp.port", cmp_alternate_tcp_port_prev, cmp_tcp_handle); - if (cmp_alternate_tcp_port != 0) - dissector_add_uint("tcp.port", cmp_alternate_tcp_port, cmp_tcp_handle); - cmp_alternate_tcp_port_prev = cmp_alternate_tcp_port; - } - /* change alternate HTTP port if changed in the preferences */ if (cmp_alternate_http_port != cmp_alternate_http_port_prev) { if (cmp_alternate_http_port_prev != 0) { - dissector_delete_uint("tcp.port", cmp_alternate_http_port_prev, NULL); - dissector_delete_uint("http.port", cmp_alternate_http_port_prev, NULL); + http_tcp_dissector_delete(cmp_alternate_http_port_prev); } if (cmp_alternate_http_port != 0) http_tcp_dissector_add( cmp_alternate_http_port, cmp_http_handle); @@ -424,8 +406,7 @@ void proto_reg_handoff_cmp(void) { /* change alternate TCP-style-HTTP port if changed in the preferences */ if (cmp_alternate_tcp_style_http_port != cmp_alternate_tcp_style_http_port_prev) { if (cmp_alternate_tcp_style_http_port_prev != 0) { - dissector_delete_uint("tcp.port", cmp_alternate_tcp_style_http_port_prev, NULL); - dissector_delete_uint("http.port", cmp_alternate_tcp_style_http_port_prev, NULL); + http_tcp_dissector_delete(cmp_alternate_tcp_style_http_port_prev); } if (cmp_alternate_tcp_style_http_port != 0) http_tcp_dissector_add( cmp_alternate_tcp_style_http_port, cmp_tcp_style_http_handle); diff --git a/epan/dissectors/asn1/h245/packet-h245-template.c b/epan/dissectors/asn1/h245/packet-h245-template.c index d4da1cc117..ce66688a6b 100644 --- a/epan/dissectors/asn1/h245/packet-h245-template.c +++ b/epan/dissectors/asn1/h245/packet-h245-template.c @@ -610,7 +610,7 @@ void proto_reg_handoff_h245(void) { amr_handle = find_dissector("amr_if2_nb"); - dissector_add_for_decode_as("tcp.port", h245_handle); + dissector_add_for_decode_as_with_preference("tcp.port", h245_handle); dissector_add_for_decode_as("udp.port", MultimediaSystemControlMessage_handle); } diff --git a/epan/dissectors/asn1/h248/packet-h248-template.c b/epan/dissectors/asn1/h248/packet-h248-template.c index d4c18e4dcc..abe81546fb 100644 --- a/epan/dissectors/asn1/h248/packet-h248-template.c +++ b/epan/dissectors/asn1/h248/packet-h248-template.c @@ -837,7 +837,7 @@ void gcp_analyze_msg(proto_tree* gcp_tree, packet_info* pinfo, tvbuff_t* gcp_tvb static gboolean keep_persistent_data = FALSE; static guint global_udp_port = 2945; -static guint global_tcp_port = 2945; +#define H248_TCP_PORT 2945 static gboolean h248_desegment = TRUE; @@ -2383,11 +2383,6 @@ void proto_register_h248(void) { "Port to be decoded as h248", 10, &global_udp_port); - prefs_register_uint_preference(h248_module, "tcp_port", - "TCP port", - "Port to be decoded as h248", - 10, - &global_tcp_port); prefs_register_bool_preference(h248_module, "desegment", "Desegment H.248 over TCP", "Desegment H.248 messages that span more TCP segments", @@ -2406,31 +2401,23 @@ void proto_reg_handoff_h248(void) { static gboolean initialized = FALSE; static guint32 udp_port; - static guint32 tcp_port; if (!initialized) { dissector_add_uint("mtp3.service_indicator", MTP_SI_GCP, h248_handle); h248_term_handle = find_dissector_add_dependency("h248term", proto_h248); + dissector_add_uint_with_preference("tcp.port", H248_TCP_PORT, h248_tpkt_handle); initialized = TRUE; } else { if (udp_port != 0) dissector_delete_uint("udp.port", udp_port, h248_handle); - - if (tcp_port != 0) - dissector_delete_uint("tcp.port", tcp_port, h248_tpkt_handle); } udp_port = global_udp_port; - tcp_port = global_tcp_port; if (udp_port != 0) { dissector_add_uint("udp.port", udp_port, h248_handle); } - if (tcp_port != 0) { - dissector_add_uint("tcp.port", tcp_port, h248_tpkt_handle); - } - ss7pc_address_type = address_type_get_by_name("AT_SS7PC"); exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_7); } diff --git a/epan/dissectors/asn1/h501/packet-h501-template.c b/epan/dissectors/asn1/h501/packet-h501-template.c index a995701c96..ab7538d1d5 100644 --- a/epan/dissectors/asn1/h501/packet-h501-template.c +++ b/epan/dissectors/asn1/h501/packet-h501-template.c @@ -51,8 +51,8 @@ static int ett_h501 = -1; static dissector_handle_t h501_pdu_handle; /* Preferences */ +#define H501_TCP_PORT 2099 static guint h501_udp_port = 2099; -static guint h501_tcp_port = 2099; static gboolean h501_desegment_tcp = TRUE; void proto_reg_handoff_h501(void); @@ -116,10 +116,6 @@ void proto_register_h501(void) { "UDP port", "Port to be decoded as h501", 10, &h501_udp_port); - prefs_register_uint_preference(h501_module, "tcp.port", - "TCP port", - "Port to be decoded as h501", - 10, &h501_tcp_port); prefs_register_bool_preference(h501_module, "desegment", "Desegment H.501 over TCP", "Desegment H.501 messages that span more TCP segments", @@ -134,22 +130,19 @@ void proto_reg_handoff_h501(void) static dissector_handle_t h501_udp_handle; static dissector_handle_t h501_tcp_handle; static guint saved_h501_udp_port; - static guint saved_h501_tcp_port; if (!h501_prefs_initialized) { h501_udp_handle = create_dissector_handle(dissect_h501_udp, proto_h501); h501_tcp_handle = create_dissector_handle(dissect_h501_tcp, proto_h501); + dissector_add_uint_with_preference("tcp.port", H501_TCP_PORT, h501_tcp_handle); h501_prefs_initialized = TRUE; } else { dissector_delete_uint("udp.port", saved_h501_udp_port, h501_udp_handle); - dissector_delete_uint("tcp.port", saved_h501_tcp_port, h501_tcp_handle); } /* Set our port number for future use */ saved_h501_udp_port = h501_udp_port; dissector_add_uint("udp.port", saved_h501_udp_port, h501_udp_handle); - saved_h501_tcp_port = h501_tcp_port; - dissector_add_uint("tcp.port", saved_h501_tcp_port, h501_tcp_handle); } diff --git a/epan/dissectors/asn1/idmp/packet-idmp-template.c b/epan/dissectors/asn1/idmp/packet-idmp-template.c index c54a9e7294..41b65229f6 100644 --- a/epan/dissectors/asn1/idmp/packet-idmp-template.c +++ b/epan/dissectors/asn1/idmp/packet-idmp-template.c @@ -47,13 +47,11 @@ void proto_register_idmp(void); void proto_reg_handoff_idm(void); -static void prefs_register_idmp(void); /* forward declaration for use in preferences registration */ void register_idmp_protocol_info(const char *oid, const ros_info_t *rinfo, int proto _U_, const char *name); static gboolean idmp_desegment = TRUE; -static guint global_idmp_tcp_port = 1102; /* made up for now */ +#define IDMP_TCP_PORT 1102 /* made up for now - not IANA registered */ static gboolean idmp_reassemble = TRUE; -static guint tcp_port = 0; static dissector_handle_t idmp_handle = NULL; static proto_tree *top_tree = NULL; @@ -343,7 +341,7 @@ void proto_register_idmp(void) /* Register our configuration options for IDMP, particularly our port */ - idmp_module = prefs_register_protocol_subtree("OSI/X.500", proto_idmp, prefs_register_idmp); + idmp_module = prefs_register_protocol_subtree("OSI/X.500", proto_idmp, NULL); prefs_register_bool_preference(idmp_module, "desegment_idmp_messages", "Reassemble IDMP messages spanning multiple TCP segments", @@ -357,33 +355,10 @@ void proto_register_idmp(void) " To use this option, you must also enable" " \"Allow subdissectors to reassemble TCP streams\"" " in the TCP protocol settings.", &idmp_reassemble); - - prefs_register_uint_preference(idmp_module, "tcp.port", "IDMP TCP Port", - "Set the port for Internet Directly Mapped Protocol requests/responses", - 10, &global_idmp_tcp_port); - } /*--- proto_reg_handoff_idm --- */ void proto_reg_handoff_idm(void) { - -} - - -static void -prefs_register_idmp(void) -{ - - /* de-register the old port */ - /* port 102 is registered by TPKT - don't undo this! */ - if(idmp_handle) - dissector_delete_uint("tcp.port", tcp_port, idmp_handle); - - /* Set our port number for future use */ - tcp_port = global_idmp_tcp_port; - - if((tcp_port > 0) && idmp_handle) - dissector_add_uint("tcp.port", global_idmp_tcp_port, idmp_handle); - + dissector_add_uint_with_preference("tcp.port", IDMP_TCP_PORT, idmp_handle); } diff --git a/epan/dissectors/asn1/ilp/packet-ilp-template.c b/epan/dissectors/asn1/ilp/packet-ilp-template.c index 0f6cff3ca6..6b0f2aca8a 100644 --- a/epan/dissectors/asn1/ilp/packet-ilp-template.c +++ b/epan/dissectors/asn1/ilp/packet-ilp-template.c @@ -50,7 +50,7 @@ static dissector_handle_t ilp_handle; /* IANA Registered Ports * oma-ilp 7276/tcp OMA Internal Location */ -static guint gbl_ilp_port = 7276; +#define ILP_TCP_PORT 7276 /* Initialize the protocol and registered fields */ static int proto_ilp = -1; @@ -123,21 +123,13 @@ void proto_register_ilp(void) { proto_register_field_array(proto_ilp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - ilp_module = prefs_register_protocol(proto_ilp,proto_reg_handoff_ilp); + ilp_module = prefs_register_protocol(proto_ilp, NULL); prefs_register_bool_preference(ilp_module, "desegment_ilp_messages", "Reassemble ILP messages spanning multiple TCP segments", "Whether the ILP dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &ilp_desegment); - - /* Register a configuration option for port */ - prefs_register_uint_preference(ilp_module, "tcp.port", - "ILP TCP Port", - "Set the TCP port for ILP messages(IANA registered port is 7276)", - 10, - &gbl_ilp_port); - } @@ -145,18 +137,9 @@ void proto_register_ilp(void) { void proto_reg_handoff_ilp(void) { - static gboolean initialized = FALSE; - static guint local_ilp_port; - - if (!initialized) { - dissector_add_string("media_type","application/oma-supl-ilp", ilp_handle); - rrlp_handle = find_dissector_add_dependency("rrlp", proto_ilp); - lpp_handle = find_dissector_add_dependency("lpp", proto_ilp); - initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", local_ilp_port, ilp_handle); - } - - local_ilp_port = gbl_ilp_port; - dissector_add_uint("tcp.port", gbl_ilp_port, ilp_handle); + dissector_add_string("media_type","application/oma-supl-ilp", ilp_handle); + rrlp_handle = find_dissector_add_dependency("rrlp", proto_ilp); + lpp_handle = find_dissector_add_dependency("lpp", proto_ilp); + + dissector_add_uint_with_preference("tcp.port", ILP_TCP_PORT, ilp_handle); } diff --git a/epan/dissectors/asn1/kerberos/packet-kerberos-template.c b/epan/dissectors/asn1/kerberos/packet-kerberos-template.c index 91158f13aa..7a8a4ab335 100644 --- a/epan/dissectors/asn1/kerberos/packet-kerberos-template.c +++ b/epan/dissectors/asn1/kerberos/packet-kerberos-template.c @@ -2339,7 +2339,7 @@ proto_reg_handoff_kerberos(void) proto_kerberos); dissector_add_uint("udp.port", UDP_PORT_KERBEROS, kerberos_handle_udp); - dissector_add_uint("tcp.port", TCP_PORT_KERBEROS, kerberos_handle_tcp); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_KERBEROS, kerberos_handle_tcp); register_dcerpc_auth_subdissector(DCE_C_AUTHN_LEVEL_CONNECT, DCE_C_RPC_AUTHN_PROTOCOL_GSS_KERBEROS, diff --git a/epan/dissectors/asn1/ldap/packet-ldap-template.c b/epan/dissectors/asn1/ldap/packet-ldap-template.c index 785d2321a4..d65c7c6ca3 100644 --- a/epan/dissectors/asn1/ldap/packet-ldap-template.c +++ b/epan/dissectors/asn1/ldap/packet-ldap-template.c @@ -216,16 +216,13 @@ static gchar *attr_type = NULL; static gboolean is_binary_attr_type = FALSE; static gboolean ldap_found_in_frame = FALSE; -#define TCP_PORT_LDAP 389 +#define TCP_PORT_RANGE_LDAP "389,3268" /* 3268 is Windows 2000 Global Catalog */ #define TCP_PORT_LDAPS 636 #define UDP_PORT_CLDAP 389 -#define TCP_PORT_GLOBALCAT_LDAP 3268 /* Windows 2000 Global Catalog */ /* desegmentation of LDAP */ static gboolean ldap_desegment = TRUE; -static guint global_ldap_tcp_port = TCP_PORT_LDAP; static guint global_ldaps_tcp_port = TCP_PORT_LDAPS; -static guint tcp_port = 0; static guint ssl_port = 0; static dissector_handle_t gssapi_handle; @@ -2203,10 +2200,6 @@ void proto_register_ldap(void) { " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &ldap_desegment); - prefs_register_uint_preference(ldap_module, "tcp.port", "LDAP TCP Port", - "Set the port for LDAP operations", - 10, &global_ldap_tcp_port); - prefs_register_uint_preference(ldap_module, "ssl.port", "LDAPS TCP Port", "Set the port for LDAP operations over SSL", 10, &global_ldaps_tcp_port); @@ -2252,8 +2245,6 @@ proto_reg_handoff_ldap(void) { dissector_handle_t cldap_handle; - dissector_add_uint("tcp.port", TCP_PORT_GLOBALCAT_LDAP, ldap_handle); - cldap_handle = create_dissector_handle(dissect_mscldap, proto_cldap); dissector_add_uint("udp.port", UDP_PORT_CLDAP, cldap_handle); @@ -2321,25 +2312,12 @@ proto_reg_handoff_ldap(void) #include "packet-ldap-dis-tab.c" - + dissector_add_uint_range_with_preference("tcp.port", TCP_PORT_RANGE_LDAP, ldap_handle); } static void prefs_register_ldap(void) { - - if(tcp_port != global_ldap_tcp_port) { - if(tcp_port) - dissector_delete_uint("tcp.port", tcp_port, ldap_handle); - - /* Set our port number for future use */ - tcp_port = global_ldap_tcp_port; - - if(tcp_port) - dissector_add_uint("tcp.port", tcp_port, ldap_handle); - - } - if(ssl_port != global_ldaps_tcp_port) { if(ssl_port) ssl_dissector_delete(ssl_port, ldap_handle); diff --git a/epan/dissectors/asn1/sabp/packet-sabp-template.c b/epan/dissectors/asn1/sabp/packet-sabp-template.c index a05cc45865..5f68453dbd 100644 --- a/epan/dissectors/asn1/sabp/packet-sabp-template.c +++ b/epan/dissectors/asn1/sabp/packet-sabp-template.c @@ -73,6 +73,8 @@ static guint32 ProtocolIE_ID; static guint32 ProtocolExtensionID; static guint8 sms_encoding; +#define SABP_PORT 3452 + /* desegmentation of sabp over TCP */ static gboolean gbl_sabp_desegment = TRUE; @@ -286,8 +288,8 @@ void proto_register_sabp(void) { void proto_reg_handoff_sabp(void) { - dissector_add_uint("udp.port", 3452, sabp_handle); - dissector_add_uint("tcp.port", 3452, sabp_tcp_handle); + dissector_add_uint("udp.port", SABP_PORT, sabp_handle); + dissector_add_uint_with_preference("tcp.port", SABP_PORT, sabp_tcp_handle); dissector_add_uint("sctp.ppi", SABP_PAYLOAD_PROTOCOL_ID, sabp_handle); #include "packet-sabp-dis-tab.c" diff --git a/epan/dissectors/asn1/smrse/packet-smrse-template.c b/epan/dissectors/asn1/smrse/packet-smrse-template.c index 0903045ea7..ff9db2b7d1 100644 --- a/epan/dissectors/asn1/smrse/packet-smrse-template.c +++ b/epan/dissectors/asn1/smrse/packet-smrse-template.c @@ -33,7 +33,7 @@ #define PSNAME "SMRSE" #define PFNAME "smrse" -#define TCP_PORT_SMRSE 4321 +#define TCP_PORT_SMRSE 4321 /* Not IANA registered */ void proto_register_smrse(void); void proto_reg_handoff_smrse(void); @@ -178,6 +178,6 @@ void proto_reg_handoff_smrse(void) { dissector_handle_t smrse_handle; smrse_handle = create_dissector_handle(dissect_smrse, proto_smrse); - dissector_add_uint("tcp.port",TCP_PORT_SMRSE, smrse_handle); + dissector_add_uint_with_preference("tcp.port",TCP_PORT_SMRSE, smrse_handle); } diff --git a/epan/dissectors/asn1/snmp/packet-snmp-template.c b/epan/dissectors/asn1/snmp/packet-snmp-template.c index 44cc3819c0..a10b26415d 100644 --- a/epan/dissectors/asn1/snmp/packet-snmp-template.c +++ b/epan/dissectors/asn1/snmp/packet-snmp-template.c @@ -2588,7 +2588,10 @@ void proto_reg_handoff_snmp(void) { dissector_add_uint("hpext.dxsap", HPEXT_SNMP, snmp_handle); snmp_tcp_handle = create_dissector_handle(dissect_snmp_tcp, proto_snmp); - dissector_add_uint("tcp.port", TCP_PORT_SNMP, snmp_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_SNMP, snmp_tcp_handle); + /* Since "regular" SNMP port and "trap" SNMP port use the same handler, + the "trap" port doesn't really need a separate preference. Just register + normally */ dissector_add_uint("tcp.port", TCP_PORT_SNMP_TRAP, snmp_tcp_handle); data_handle = find_dissector("data"); @@ -2631,7 +2634,7 @@ proto_reg_handoff_smux(void) dissector_handle_t smux_handle; smux_handle = create_dissector_handle(dissect_smux, proto_smux); - dissector_add_uint("tcp.port", TCP_PORT_SMUX, smux_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_SMUX, smux_handle); } /* diff --git a/epan/dissectors/asn1/t38/packet-t38-template.c b/epan/dissectors/asn1/t38/packet-t38-template.c index 7f718414f9..51f41b93e9 100644 --- a/epan/dissectors/asn1/t38/packet-t38-template.c +++ b/epan/dissectors/asn1/t38/packet-t38-template.c @@ -727,7 +727,7 @@ proto_register_t38(void) t38_tap = register_tap("t38"); - t38_module = prefs_register_protocol(proto_t38, proto_reg_handoff_t38); + t38_module = prefs_register_protocol(proto_t38, NULL); prefs_register_bool_preference(t38_module, "use_pre_corrigendum_asn1_specification", "Use the Pre-Corrigendum ASN.1 specification", "Whether the T.38 dissector should decode using the Pre-Corrigendum T.38 " @@ -739,7 +739,6 @@ proto_register_t38(void) "be dissected as RTP packet or T.38 packet. If enabled there is a risk that T.38 UDPTL " "packets with sequence number higher than 32767 may be dissected as RTP.", &dissect_possible_rtpv2_packets_as_rtp); - prefs_register_obsolete_preference(t38_module, "tcp.port"); prefs_register_obsolete_preference(t38_module, "udp.port"); prefs_register_bool_preference(t38_module, "reassembly", "Reassemble T.38 PDUs over TPKT over TCP", @@ -764,16 +763,11 @@ proto_register_t38(void) void proto_reg_handoff_t38(void) { - static gboolean t38_prefs_initialized = FALSE; - - if (!t38_prefs_initialized) { - t38_udp_handle=create_dissector_handle(dissect_t38_udp, proto_t38); - t38_tcp_handle=create_dissector_handle(dissect_t38_tcp, proto_t38); - t38_tcp_pdu_handle=create_dissector_handle(dissect_t38_tcp_pdu, proto_t38); - rtp_handle = find_dissector_add_dependency("rtp", proto_t38); - t30_hdlc_handle = find_dissector_add_dependency("t30.hdlc""rtp", proto_t38); - data_handle = find_dissector("data"); - t38_prefs_initialized = TRUE; - } + t38_udp_handle=create_dissector_handle(dissect_t38_udp, proto_t38); + t38_tcp_handle=create_dissector_handle(dissect_t38_tcp, proto_t38); + t38_tcp_pdu_handle=create_dissector_handle(dissect_t38_tcp_pdu, proto_t38); + rtp_handle = find_dissector_add_dependency("rtp", proto_t38); + t30_hdlc_handle = find_dissector_add_dependency("t30.hdlc""rtp", proto_t38); + data_handle = find_dissector("data"); } diff --git a/epan/dissectors/asn1/ulp/packet-ulp-template.c b/epan/dissectors/asn1/ulp/packet-ulp-template.c index 6a8ab185fc..4861779d73 100644 --- a/epan/dissectors/asn1/ulp/packet-ulp-template.c +++ b/epan/dissectors/asn1/ulp/packet-ulp-template.c @@ -51,8 +51,8 @@ static dissector_handle_t lpp_handle; * oma-ulp 7275/tcp OMA UserPlane Location * oma-ulp 7275/udp OMA UserPlane Location */ -static guint gbl_ulp_tcp_port = 7275; -static guint gbl_ulp_udp_port = 7275; +#define ULP_PORT 7275 +static guint gbl_ulp_udp_port = ULP_PORT; /* Initialize the protocol and registered fields */ static int proto_ulp = -1; @@ -428,11 +428,6 @@ void proto_register_ulp(void) { &ulp_desegment); /* Register a configuration option for port */ - prefs_register_uint_preference(ulp_module, "tcp.port", - "ULP TCP Port", - "Set the TCP port for ULP messages (IANA registered port is 7275)", - 10, - &gbl_ulp_tcp_port); prefs_register_uint_preference(ulp_module, "udp.port", "ULP UDP Port", "Set the UDP port for ULP messages (IANA registered port is 7275)", @@ -448,7 +443,7 @@ proto_reg_handoff_ulp(void) { static gboolean initialized = FALSE; static dissector_handle_t ulp_udp_handle; - static guint local_ulp_tcp_port, local_ulp_udp_port; + static guint local_ulp_udp_port; if (!initialized) { dissector_add_string("media_type","application/oma-supl-ulp", ulp_tcp_handle); @@ -456,14 +451,12 @@ proto_reg_handoff_ulp(void) ulp_udp_handle = create_dissector_handle(dissect_ULP_PDU_PDU, proto_ulp); rrlp_handle = find_dissector_add_dependency("rrlp", proto_ulp); lpp_handle = find_dissector_add_dependency("lpp", proto_ulp); + dissector_add_uint_with_preference("tcp.port", ULP_PORT, ulp_tcp_handle); initialized = TRUE; } else { - dissector_delete_uint("tcp.port", local_ulp_tcp_port, ulp_tcp_handle); dissector_delete_uint("udp.port", local_ulp_udp_port, ulp_udp_handle); } - local_ulp_tcp_port = gbl_ulp_tcp_port; - dissector_add_uint("tcp.port", gbl_ulp_tcp_port, ulp_tcp_handle); local_ulp_udp_port = gbl_ulp_udp_port; dissector_add_uint("udp.port", gbl_ulp_udp_port, ulp_udp_handle); } diff --git a/epan/dissectors/packet-3com-njack.c b/epan/dissectors/packet-3com-njack.c index e46f18c27f..b51673c356 100644 --- a/epan/dissectors/packet-3com-njack.c +++ b/epan/dissectors/packet-3com-njack.c @@ -785,9 +785,9 @@ proto_reg_handoff_njack(void) njack_handle = create_dissector_handle(dissect_njack_static, proto_njack); dissector_add_uint("udp.port", PORT_NJACK_PC, njack_handle); - /* dissector_add_uint("tcp.port", PORT_NJACK_PC, njack_handle); */ + /* dissector_add_uint_with_preference("tcp.port", PORT_NJACK_PC, njack_handle); */ dissector_add_uint("udp.port", PORT_NJACK_SWITCH, njack_handle); - /* dissector_add_uint("tcp.port", PORT_NJACK_SWITCH, njack_handle); */ + /* dissector_add_uint_with_preference("tcp.port", PORT_NJACK_SWITCH, njack_handle); */ heur_dissector_add("udp", dissect_njack_heur, "NJACK over UDP", "njack_udp", proto_njack, HEURISTIC_ENABLE); heur_dissector_add("tcp", dissect_njack_heur, "NJACK over TCP", "njack_tcp", proto_njack, HEURISTIC_DISABLE); diff --git a/epan/dissectors/packet-9p.c b/epan/dissectors/packet-9p.c index d2b1439761..efc73994e0 100644 --- a/epan/dissectors/packet-9p.c +++ b/epan/dissectors/packet-9p.c @@ -2735,7 +2735,7 @@ void proto_reg_handoff_9P(void) ninep_handle = create_dissector_handle(dissect_9P, proto_9P); - dissector_add_uint("tcp.port", NINEPORT, ninep_handle); + dissector_add_uint_with_preference("tcp.port", NINEPORT, ninep_handle); } diff --git a/epan/dissectors/packet-acap.c b/epan/dissectors/packet-acap.c index 2d83675145..209220c1a1 100644 --- a/epan/dissectors/packet-acap.c +++ b/epan/dissectors/packet-acap.c @@ -228,7 +228,7 @@ proto_register_acap(void) void proto_reg_handoff_acap(void) { - dissector_add_uint("tcp.port", TCP_PORT_ACAP, acap_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_ACAP, acap_handle); } /* diff --git a/epan/dissectors/packet-adb.c b/epan/dissectors/packet-adb.c index 9829b191ce..c1a85f399f 100644 --- a/epan/dissectors/packet-adb.c +++ b/epan/dissectors/packet-adb.c @@ -900,7 +900,7 @@ proto_reg_handoff_adb(void) { adb_service_handle = find_dissector_add_dependency("adb_service", proto_adb); - dissector_add_for_decode_as("tcp.port", adb_handle); + dissector_add_for_decode_as_with_preference("tcp.port", adb_handle); dissector_add_for_decode_as("usb.device", adb_handle); dissector_add_for_decode_as("usb.product", adb_handle); dissector_add_for_decode_as("usb.protocol", adb_handle); diff --git a/epan/dissectors/packet-adb_cs.c b/epan/dissectors/packet-adb_cs.c index 910906264f..b5f93ec293 100644 --- a/epan/dissectors/packet-adb_cs.c +++ b/epan/dissectors/packet-adb_cs.c @@ -437,7 +437,7 @@ proto_reg_handoff_adb_cs(void) { adb_service_handle = find_dissector_add_dependency("adb_service", proto_adb_cs); - dissector_add_for_decode_as("tcp.port", adb_cs_handle); + dissector_add_for_decode_as_with_preference("tcp.port", adb_cs_handle); } /* diff --git a/epan/dissectors/packet-agentx.c b/epan/dissectors/packet-agentx.c index db4473f5ae..671b3ec5cd 100644 --- a/epan/dissectors/packet-agentx.c +++ b/epan/dissectors/packet-agentx.c @@ -26,12 +26,11 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> #include <epan/to_str.h> #include "packet-tcp.h" -static guint global_agentx_tcp_port = 705; +#define AGENTX_TCP_PORT 705 void proto_register_agentx(void); void proto_reg_handoff_agentx(void); @@ -1111,42 +1110,21 @@ proto_register_agentx(void) &ett_flags, }; - - module_t *agentx_module; - - proto_agentx = proto_register_protocol("AgentX", - "AgentX", "agentx"); + proto_agentx = proto_register_protocol("AgentX", "AgentX", "agentx"); proto_register_field_array(proto_agentx, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - agentx_module = prefs_register_protocol(proto_agentx, proto_reg_handoff_agentx); - - prefs_register_uint_preference(agentx_module, "tcp.agentx_port", - "AgentX listener TCP Port", - "Set the TCP port for AgentX" - "(if other than the default of 705)", - 10, &global_agentx_tcp_port); } /* The registration hand-off routine */ void proto_reg_handoff_agentx(void) { - static gboolean agentx_prefs_initialized = FALSE; - static dissector_handle_t agentx_handle; - static guint agentx_tcp_port; + dissector_handle_t agentx_handle; - if(!agentx_prefs_initialized) { - agentx_handle = create_dissector_handle(dissect_agentx, proto_agentx); - agentx_prefs_initialized = TRUE; - } - else { - dissector_delete_uint("tcp.port", agentx_tcp_port, agentx_handle); - } + agentx_handle = create_dissector_handle(dissect_agentx, proto_agentx); - agentx_tcp_port = global_agentx_tcp_port; - dissector_add_uint("tcp.port", agentx_tcp_port, agentx_handle); + dissector_add_uint_with_preference("tcp.port", AGENTX_TCP_PORT, agentx_handle); } /* diff --git a/epan/dissectors/packet-aim-oft.c b/epan/dissectors/packet-aim-oft.c index a3e4dc8c63..55671c85b4 100644 --- a/epan/dissectors/packet-aim-oft.c +++ b/epan/dissectors/packet-aim-oft.c @@ -98,7 +98,7 @@ proto_reg_handoff_aim_oft(void) /* FIXME aim_handle = create_dissector_handle(dissect_aim, proto_aim); - dissector_add_uint("tcp.port", TCP_PORT_AIM, aim_handle);*/ + dissector_add_uint_with_preference("tcp.port", TCP_PORT_AIM, aim_handle);*/ } /* diff --git a/epan/dissectors/packet-aim.c b/epan/dissectors/packet-aim.c index 44fc8dc4e0..ada3b719a5 100644 --- a/epan/dissectors/packet-aim.c +++ b/epan/dissectors/packet-aim.c @@ -1736,7 +1736,7 @@ proto_register_aim(void) void proto_reg_handoff_aim(void) { - dissector_add_uint("tcp.port", TCP_PORT_AIM, aim_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_AIM, aim_handle); ssl_dissector_add(0, aim_handle); /* Heuristics disabled by default, it is really weak... */ heur_dissector_add("ssl", dissect_aim_ssl_heur, "AIM over SSL", "aim_ssl", proto_aim, HEURISTIC_DISABLE); diff --git a/epan/dissectors/packet-ajp13.c b/epan/dissectors/packet-ajp13.c index cea01c369b..921bf87d27 100644 --- a/epan/dissectors/packet-ajp13.c +++ b/epan/dissectors/packet-ajp13.c @@ -32,6 +32,7 @@ void proto_register_ajp13(void); void proto_reg_handoff_ajp13(void); +#define AJP13_TCP_PORT 8009 /* Not IANA registered */ /* IMPORTANT IMPLEMENTATION NOTES * @@ -1118,7 +1119,7 @@ proto_reg_handoff_ajp13(void) { dissector_handle_t ajp13_handle; ajp13_handle = create_dissector_handle(dissect_ajp13, proto_ajp13); - dissector_add_uint("tcp.port", 8009, ajp13_handle); + dissector_add_uint_with_preference("tcp.port", AJP13_TCP_PORT, ajp13_handle); } /* diff --git a/epan/dissectors/packet-alljoyn.c b/epan/dissectors/packet-alljoyn.c index 6dcaf18dd0..19fdf407ca 100644 --- a/epan/dissectors/packet-alljoyn.c +++ b/epan/dissectors/packet-alljoyn.c @@ -28,8 +28,8 @@ void proto_register_AllJoyn(void); void proto_reg_handoff_AllJoyn(void); -static const int name_server_port = 9956; -static const int message_port = 9955; +#define ALLJOYN_NAME_SERVER_PORT 9956 /* IANA lists only UDP as being registered (dissector also uses TCP port) */ +#define ALLJOYN_MESSAGE_PORT 9955 /* DBus limits array length to 2^26. AllJoyn limits it to 2^17 */ #define MAX_ARRAY_LEN 131072 @@ -3034,21 +3034,16 @@ proto_reg_handoff_AllJoyn(void) if(!initialized) { alljoyn_handle_ns = create_dissector_handle(dissect_AllJoyn_name_server, proto_AllJoyn_ns); alljoyn_handle_ardp = create_dissector_handle(dissect_AllJoyn_ardp, proto_AllJoyn_ardp); - } else { - dissector_delete_uint("udp.port", name_server_port, alljoyn_handle_ns); - dissector_delete_uint("tcp.port", name_server_port, alljoyn_handle_ns); - - dissector_delete_uint("udp.port", message_port, alljoyn_handle_ardp); - dissector_delete_uint("tcp.port", message_port, alljoyn_handle_ardp); + dissector_add_uint_with_preference("tcp.port", ALLJOYN_NAME_SERVER_PORT, alljoyn_handle_ns); + dissector_add_uint_with_preference("tcp.port", ALLJOYN_MESSAGE_PORT, alljoyn_handle_ardp); + initialized = TRUE; } - dissector_add_uint("udp.port", name_server_port, alljoyn_handle_ns); - dissector_add_uint("tcp.port", name_server_port, alljoyn_handle_ns); + dissector_add_uint("udp.port", ALLJOYN_NAME_SERVER_PORT, alljoyn_handle_ns); /* The ARDP dissector will directly call the AllJoyn message dissector if needed. * This includes the case where there is no ARDP data. */ - dissector_add_uint("udp.port", message_port, alljoyn_handle_ardp); - dissector_add_uint("tcp.port", message_port, alljoyn_handle_ardp); + dissector_add_uint("udp.port", ALLJOYN_MESSAGE_PORT, alljoyn_handle_ardp); } /* diff --git a/epan/dissectors/packet-amqp.c b/epan/dissectors/packet-amqp.c index 41fbc8afc7..3d321d838d 100644 --- a/epan/dissectors/packet-amqp.c +++ b/epan/dissectors/packet-amqp.c @@ -53,7 +53,7 @@ void proto_register_amqp(void); void proto_reg_handoff_amqp(void); /* Generic data */ -static guint amqp_port = 5672; +#define AMQP_PORT 5672 static guint amqps_port = 5671; /* AMQP over TLS/SSL */ /* Generic defines */ @@ -13977,11 +13977,7 @@ proto_register_amqp(void) expert_register_field_array(expert_amqp, ei, array_length(ei)); amqp_module = prefs_register_protocol(proto_amqp, proto_reg_handoff_amqp); - prefs_register_uint_preference(amqp_module, "tcp.port", - "AMQP listening TCP Port", - "Set the TCP port for AMQP" - "(if other than the default of 5672)", - 10, &amqp_port); + prefs_register_uint_preference(amqp_module, "ssl.port", "AMQPS listening TCP Port", "Set the TCP port for AMQP over TLS/SSL" @@ -13993,30 +13989,21 @@ void proto_reg_handoff_amqp(void) { static dissector_handle_t amqp_tcp_handle; - static guint old_amqp_port = 0; static guint old_amqps_port = 0; + static gboolean initialize = FALSE; amqp_tcp_handle = find_dissector("amqp"); - /* Register TCP port for dissection */ - if (old_amqp_port != 0 && old_amqp_port != amqp_port){ - dissector_delete_uint("tcp.port", old_amqp_port, amqp_tcp_handle); - } - - if (amqp_port != 0 && old_amqp_port != amqp_port) { - old_amqp_port = amqp_port; - dissector_add_uint("tcp.port", amqp_port, amqp_tcp_handle); + if (!initialize) { + /* Register TCP port for dissection */ + dissector_add_uint_with_preference("tcp.port", AMQP_PORT, amqp_tcp_handle); + initialize = TRUE; } /* Register for TLS/SSL payload dissection */ if (old_amqps_port != 0 && old_amqps_port != amqps_port){ ssl_dissector_delete(old_amqps_port, amqp_tcp_handle); } - - if (amqps_port != 0 && old_amqps_port != amqps_port) { - old_amqps_port = amqps_port; - ssl_dissector_add(amqps_port, amqp_tcp_handle); - } } /* diff --git a/epan/dissectors/packet-ancp.c b/epan/dissectors/packet-ancp.c index a28e775cd0..4204656fc5 100644 --- a/epan/dissectors/packet-ancp.c +++ b/epan/dissectors/packet-ancp.c @@ -929,7 +929,7 @@ proto_reg_handoff_ancp(void) dissector_handle_t ancp_handle; ancp_handle = create_dissector_handle(dissect_ancp, proto_ancp); - dissector_add_uint("tcp.port", ANCP_PORT, ancp_handle); + dissector_add_uint_with_preference("tcp.port", ANCP_PORT, ancp_handle); stats_tree_register("ancp", "ancp", "ANCP", 0, ancp_stats_tree_packet, ancp_stats_tree_init, NULL); } diff --git a/epan/dissectors/packet-aol.c b/epan/dissectors/packet-aol.c index c5f3072181..1415ba5199 100644 --- a/epan/dissectors/packet-aol.c +++ b/epan/dissectors/packet-aol.c @@ -396,10 +396,10 @@ void proto_register_aol(void) { * Initialize the dissector. */ void proto_reg_handoff_aol(void) { - static dissector_handle_t aol_handle; + dissector_handle_t aol_handle; aol_handle = create_dissector_handle(dissect_aol,proto_aol); - dissector_add_uint("tcp.port",AOL_PORT,aol_handle); + dissector_add_uint_with_preference("tcp.port",AOL_PORT,aol_handle); } /* vi:set ts=4: */ diff --git a/epan/dissectors/packet-asap.c b/epan/dissectors/packet-asap.c index fa860996a1..170a1e1db6 100644 --- a/epan/dissectors/packet-asap.c +++ b/epan/dissectors/packet-asap.c @@ -924,7 +924,7 @@ proto_reg_handoff_asap(void) asap_handle = create_dissector_handle(dissect_asap, proto_asap); dissector_add_uint("sctp.ppi", ASAP_PAYLOAD_PROTOCOL_ID, asap_handle); dissector_add_uint("udp.port", ASAP_UDP_PORT, asap_handle); - dissector_add_uint("tcp.port", ASAP_TCP_PORT, asap_handle); + dissector_add_uint_with_preference("tcp.port", ASAP_TCP_PORT, asap_handle); dissector_add_uint("sctp.port", ASAP_SCTP_PORT, asap_handle); } diff --git a/epan/dissectors/packet-assa_r3.c b/epan/dissectors/packet-assa_r3.c index 778b879089..70bcdb73a0 100644 --- a/epan/dissectors/packet-assa_r3.c +++ b/epan/dissectors/packet-assa_r3.c @@ -28,6 +28,7 @@ #include <epan/packet.h> #include <epan/expert.h> +#include <epan/range.h> #include <epan/crc16-tvb.h> #include "packet-tcp.h" @@ -1030,6 +1031,8 @@ typedef enum userType_e; +#define ASSA_R3_PORT_RANGE "2571,8023" /* Neither are IANA registered */ + /* * Wireshark ID of the R3 protocol */ @@ -10103,8 +10106,8 @@ void proto_register_r3 (void) void proto_reg_handoff_r3 (void) { dissector_handle_t r3_handle = find_dissector ("r3"); - dissector_add_uint ("tcp.port", 2571, r3_handle); - dissector_add_uint ("tcp.port", 8023, r3_handle); + + dissector_add_uint_range_with_preference("tcp.port", ASSA_R3_PORT_RANGE, r3_handle); } /* diff --git a/epan/dissectors/packet-atmtcp.c b/epan/dissectors/packet-atmtcp.c index f143af42c1..7e556d7c09 100644 --- a/epan/dissectors/packet-atmtcp.c +++ b/epan/dissectors/packet-atmtcp.c @@ -29,7 +29,6 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> void proto_register_atmtcp(void); void proto_reg_handoff_atmtcp(void); @@ -39,7 +38,7 @@ static int hf_atmtcp_vpi = -1; static int hf_atmtcp_vci = -1; static int hf_atmtcp_length = -1; -static guint global_atmtcp_tcp_port = 2812; +#define ATMTCP_TCP_PORT 2812 static gint ett_atmtcp = -1; @@ -104,9 +103,6 @@ dissect_atmtcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ void proto_register_atmtcp(void) { - module_t *atmtcp_module; - - static hf_register_info hf[] = { { &hf_atmtcp_vpi, { "VPI", "atmtcp.vpi", FT_UINT16, BASE_DEC, NULL, 0x0, @@ -132,33 +128,17 @@ proto_register_atmtcp(void) proto_register_field_array(proto_atmtcp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - - atmtcp_module = prefs_register_protocol(proto_atmtcp, proto_reg_handoff_atmtcp); - - prefs_register_uint_preference(atmtcp_module, "tcp.port", "ATMTCP TCP Port", - "ATMTCP TCP port if other than the default", - 10, &global_atmtcp_tcp_port); } void proto_reg_handoff_atmtcp(void) { - static gboolean initialized = FALSE; - static dissector_handle_t atmtcp_handle; - static int current_port; - - if (!initialized) { - atmtcp_handle = create_dissector_handle(dissect_atmtcp, proto_atmtcp); - initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", current_port, atmtcp_handle); - } + dissector_handle_t atmtcp_handle; - current_port = global_atmtcp_tcp_port; + atmtcp_handle = create_dissector_handle(dissect_atmtcp, proto_atmtcp); - dissector_add_uint("tcp.port", current_port, atmtcp_handle); + dissector_add_uint_with_preference("tcp.port", ATMTCP_TCP_PORT, atmtcp_handle); } /* diff --git a/epan/dissectors/packet-ax4000.c b/epan/dissectors/packet-ax4000.c index fda623a2c6..6855a35a0d 100644 --- a/epan/dissectors/packet-ax4000.c +++ b/epan/dissectors/packet-ax4000.c @@ -166,7 +166,7 @@ proto_reg_handoff_ax4000(void) ax4000_handle = create_dissector_handle(dissect_ax4000, proto_ax4000); dissector_add_uint("ip.proto", IP_PROTO_AX4000, ax4000_handle); - dissector_add_uint("tcp.port", AX4000_TCP_PORT, ax4000_handle); + dissector_add_uint_with_preference("tcp.port", AX4000_TCP_PORT, ax4000_handle); dissector_add_uint("udp.port", AX4000_UDP_PORT, ax4000_handle); } diff --git a/epan/dissectors/packet-banana.c b/epan/dissectors/packet-banana.c index 081881dbce..f1ce7d04e8 100644 --- a/epan/dissectors/packet-banana.c +++ b/epan/dissectors/packet-banana.c @@ -29,7 +29,6 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> #include <epan/expert.h> void proto_register_banana(void); @@ -120,9 +119,6 @@ static const value_string pb_vals[] = { #define MAX_ELEMENT_INT_LEN 4 #define MAX_ELEMENT_VAL_LEN 8 -static range_t *global_banana_tcp_range = NULL; -static range_t *banana_tcp_range = NULL; - /* Dissect the packets */ static int @@ -256,14 +252,6 @@ dissect_banana(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ return tvb_reported_length(tvb); } -static void -banana_prefs(void) { - dissector_delete_uint_range("tcp.port", banana_tcp_range, banana_handle); - g_free(banana_tcp_range); - banana_tcp_range = range_copy(global_banana_tcp_range); - dissector_add_uint_range("tcp.port", banana_tcp_range, banana_handle); -} - /* Register the protocol with Wireshark */ void @@ -312,7 +300,6 @@ proto_register_banana(void) } }; - module_t *banana_module; expert_module_t* expert_banana; /* Setup protocol subtree array */ @@ -337,17 +324,13 @@ proto_register_banana(void) proto_register_subtree_array(ett, array_length(ett)); expert_banana = expert_register_protocol(proto_banana); expert_register_field_array(expert_banana, ei, array_length(ei)); - - /* Initialize dissector preferences */ - banana_module = prefs_register_protocol(proto_banana, banana_prefs); - banana_tcp_range = range_empty(); - prefs_register_range_preference(banana_module, "tcp.port", "TCP Ports", "Banana TCP Port range", &global_banana_tcp_range, 65535); } void proto_reg_handoff_banana(void) { banana_handle = create_dissector_handle(dissect_banana, proto_banana); + dissector_add_uint_range_with_preference("tcp.port", "", banana_handle); } /* diff --git a/epan/dissectors/packet-beep.c b/epan/dissectors/packet-beep.c index 56bd7883fa..11a2daa53a 100644 --- a/epan/dissectors/packet-beep.c +++ b/epan/dissectors/packet-beep.c @@ -32,6 +32,7 @@ #include <stdlib.h> #include <epan/packet.h> #include <epan/prefs.h> +#include <epan/prefs-int.h> #include <epan/conversation.h> #include <epan/expert.h> #include <epan/proto_data.h> @@ -39,7 +40,7 @@ #include <wsutil/ws_printf.h> /* ws_debug_printf */ #endif -#define TCP_PORT_BEEP 10288 +#define TCP_PORT_BEEP 10288 /* Don't think this is IANA registered */ void proto_register_beep(void); void proto_reg_handoff_beep(void); @@ -889,6 +890,14 @@ dissect_beep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ return tvb_captured_length(tvb); } +static void +apply_beep_prefs(void) +{ + /* Beep uses the port preference to determine client/server */ + pref_t *beep_port = prefs_find_preference(prefs_find_module("beep"), "tcp.port"); + global_beep_tcp_port = *beep_port->varp.uint; +} + /* Register all the bits needed with the filtering engine */ void @@ -987,12 +996,7 @@ proto_register_beep(void) /* Register our configuration options for BEEP, particularly our port */ - beep_module = prefs_register_protocol(proto_beep, proto_reg_handoff_beep); - - prefs_register_uint_preference(beep_module, "tcp.port", "BEEP TCP Port", - "Set the port for BEEP messages (if other" - " than the default of 10288)", - 10, &global_beep_tcp_port); + beep_module = prefs_register_protocol(proto_beep, apply_beep_prefs); prefs_register_bool_preference(beep_module, "strict_header_terminator", "BEEP Header Requires CRLF", @@ -1005,28 +1009,11 @@ proto_register_beep(void) void proto_reg_handoff_beep(void) { - static gboolean beep_prefs_initialized = FALSE; - static dissector_handle_t beep_handle; - static guint beep_tcp_port; - - if (!beep_prefs_initialized) { - - beep_handle = create_dissector_handle(dissect_beep, proto_beep); - - beep_prefs_initialized = TRUE; - - } - else { - - dissector_delete_uint("tcp.port", beep_tcp_port, beep_handle); - - } - - /* Set our port number for future use */ + dissector_handle_t beep_handle; - beep_tcp_port = global_beep_tcp_port; + beep_handle = create_dissector_handle(dissect_beep, proto_beep); - dissector_add_uint("tcp.port", global_beep_tcp_port, beep_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_BEEP, beep_handle); } diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c index 10f39b7b04..7647068f20 100644 --- a/epan/dissectors/packet-ber.c +++ b/epan/dissectors/packet-ber.c @@ -4607,7 +4607,7 @@ proto_reg_handoff_ber(void) /* allow the dissection of BER/DER carried over a TCP transport by using "Decode As..." */ - dissector_add_for_decode_as("tcp.port", ber_handle); + dissector_add_for_decode_as_with_preference("tcp.port", ber_handle); ber_update_oids(); } diff --git a/epan/dissectors/packet-bfcp.c b/epan/dissectors/packet-bfcp.c index f8874c3716..c4ea596970 100644 --- a/epan/dissectors/packet-bfcp.c +++ b/epan/dissectors/packet-bfcp.c @@ -692,8 +692,7 @@ void proto_register_bfcp(void) bfcp_handle = register_dissector("bfcp", dissect_bfcp, proto_bfcp); - bfcp_module = prefs_register_protocol(proto_bfcp, - proto_reg_handoff_bfcp); + bfcp_module = prefs_register_protocol(proto_bfcp, NULL); prefs_register_obsolete_preference(bfcp_module, "enable"); @@ -707,20 +706,14 @@ void proto_register_bfcp(void) void proto_reg_handoff_bfcp(void) { - static gboolean prefs_initialized = FALSE; - /* "Decode As" is always available; * Heuristic dissection in disabled by default since * the heuristic is quite weak. */ - if (!prefs_initialized) - { - heur_dissector_add("tcp", dissect_bfcp_heur, "BFCP over TCP", "bfcp_tcp", proto_bfcp, HEURISTIC_DISABLE); - heur_dissector_add("udp", dissect_bfcp_heur, "BFCP over UDP", "bfcp_udp", proto_bfcp, HEURISTIC_DISABLE); - dissector_add_for_decode_as("tcp.port", bfcp_handle); - dissector_add_for_decode_as("udp.port", bfcp_handle); - prefs_initialized = TRUE; - } + heur_dissector_add("tcp", dissect_bfcp_heur, "BFCP over TCP", "bfcp_tcp", proto_bfcp, HEURISTIC_DISABLE); + heur_dissector_add("udp", dissect_bfcp_heur, "BFCP over UDP", "bfcp_udp", proto_bfcp, HEURISTIC_DISABLE); + dissector_add_for_decode_as_with_preference("tcp.port", bfcp_handle); + dissector_add_for_decode_as("udp.port", bfcp_handle); } /* diff --git a/epan/dissectors/packet-bgp.c b/epan/dissectors/packet-bgp.c index 0efa4149da..c33d6cbbee 100644 --- a/epan/dissectors/packet-bgp.c +++ b/epan/dissectors/packet-bgp.c @@ -9537,7 +9537,7 @@ proto_register_bgp(void) void proto_reg_handoff_bgp(void) { - dissector_add_uint("tcp.port", BGP_TCP_PORT, bgp_handle); + dissector_add_uint_with_preference("tcp.port", BGP_TCP_PORT, bgp_handle); } /* * Editor modelines - http://www.wireshark.org/tools/modelines.html diff --git a/epan/dissectors/packet-bitcoin.c b/epan/dissectors/packet-bitcoin.c index a7a779e5f8..fa621ad8b1 100644 --- a/epan/dissectors/packet-bitcoin.c +++ b/epan/dissectors/packet-bitcoin.c @@ -1878,7 +1878,7 @@ proto_reg_handoff_bitcoin(void) { dissector_handle_t command_handle; - dissector_add_for_decode_as("tcp.port", bitcoin_handle); + dissector_add_for_decode_as_with_preference("tcp.port", bitcoin_handle); heur_dissector_add( "tcp", dissect_bitcoin_heur, "Bitcoin over TCP", "bitcoin_tcp", hfi_bitcoin->id, HEURISTIC_ENABLE); diff --git a/epan/dissectors/packet-bittorrent.c b/epan/dissectors/packet-bittorrent.c index b070b44325..461067d3fa 100644 --- a/epan/dissectors/packet-bittorrent.c +++ b/epan/dissectors/packet-bittorrent.c @@ -42,6 +42,8 @@ void proto_reg_handoff_bittorrent(void); * http://bitconjurer.org/BitTorrent/protocol.html */ +#define DEFAULT_TCP_PORT_RANGE "6881-6889" /* Not IANA registered */ + #define BITTORRENT_MESSAGE_CHOKE 0 #define BITTORRENT_MESSAGE_UNCHOKE 1 #define BITTORRENT_MESSAGE_INTERESTED 2 @@ -697,17 +699,8 @@ proto_reg_handoff_bittorrent(void) bencode_handle = find_dissector_add_dependency("bencode", proto_bittorrent); dissector_handle = find_dissector("bittorrent.tcp"); -#if 0 - dissector_add_uint("tcp.port", 6881, dissector_handle); - dissector_add_uint("tcp.port", 6882, dissector_handle); - dissector_add_uint("tcp.port", 6883, dissector_handle); - dissector_add_uint("tcp.port", 6884, dissector_handle); - dissector_add_uint("tcp.port", 6885, dissector_handle); - dissector_add_uint("tcp.port", 6886, dissector_handle); - dissector_add_uint("tcp.port", 6887, dissector_handle); - dissector_add_uint("tcp.port", 6888, dissector_handle); - dissector_add_uint("tcp.port", 6889, dissector_handle); -#endif + dissector_add_uint_range_with_preference("tcp.port", DEFAULT_TCP_PORT_RANGE, dissector_handle); + heur_dissector_add("tcp", test_bittorrent_packet, "BitTorrent over TCP", "bittorrent_tcp", proto_bittorrent, HEURISTIC_ENABLE); } diff --git a/epan/dissectors/packet-bmp.c b/epan/dissectors/packet-bmp.c index da484e1a83..b46fef542f 100644 --- a/epan/dissectors/packet-bmp.c +++ b/epan/dissectors/packet-bmp.c @@ -810,7 +810,7 @@ proto_reg_handoff_bmp(void) static dissector_handle_t bmp_handle; bmp_handle = create_dissector_handle(dissect_bmp, proto_bmp); - dissector_add_for_decode_as("tcp.port", bmp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", bmp_handle); dissector_bgp = find_dissector_add_dependency("bgp", proto_bmp); } /* diff --git a/epan/dissectors/packet-bzr.c b/epan/dissectors/packet-bzr.c index e1ddb62971..d426927351 100644 --- a/epan/dissectors/packet-bzr.c +++ b/epan/dissectors/packet-bzr.c @@ -324,7 +324,7 @@ proto_reg_handoff_bzr(void) bencode_handle = find_dissector_add_dependency("bencode", proto_bzr); bzr_handle = find_dissector("bzr"); - dissector_add_uint("tcp.port", TCP_PORT_BZR, bzr_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_BZR, bzr_handle); } /* diff --git a/epan/dissectors/packet-c1222.c b/epan/dissectors/packet-c1222.c index a1873c07e3..a68da36555 100644 --- a/epan/dissectors/packet-c1222.c +++ b/epan/dissectors/packet-c1222.c @@ -2058,7 +2058,7 @@ proto_reg_handoff_c1222(void) if( !initialized ) { c1222_handle = create_dissector_handle(dissect_c1222, proto_c1222); c1222_udp_handle = create_dissector_handle(dissect_c1222_common, proto_c1222); - dissector_add_uint("tcp.port", global_c1222_port, c1222_handle); + dissector_add_uint_with_preference("tcp.port", C1222_PORT, c1222_handle); dissector_add_uint("udp.port", global_c1222_port, c1222_udp_handle); initialized = TRUE; } diff --git a/epan/dissectors/packet-cast.c b/epan/dissectors/packet-cast.c index 9875e33a04..3b91fa1101 100644 --- a/epan/dissectors/packet-cast.c +++ b/epan/dissectors/packet-cast.c @@ -29,7 +29,7 @@ #include "packet-tcp.h" -#define TCP_PORT_CAST 4224 +#define TCP_PORT_CAST 4224 /* Not IANA registered */ void proto_register_cast(void); void proto_reg_handoff_cast(void); @@ -1709,7 +1709,7 @@ proto_reg_handoff_cast(void) dissector_handle_t cast_handle; cast_handle = create_dissector_handle(dissect_cast, proto_cast); - dissector_add_uint("tcp.port", TCP_PORT_CAST, cast_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_CAST, cast_handle); } /* diff --git a/epan/dissectors/packet-chargen.c b/epan/dissectors/packet-chargen.c index 2fc0ec3ecb..c800655a7a 100644 --- a/epan/dissectors/packet-chargen.c +++ b/epan/dissectors/packet-chargen.c @@ -94,7 +94,7 @@ proto_reg_handoff_chargen(void) chargen_handle = create_dissector_handle(dissect_chargen, proto_chargen); dissector_add_uint("udp.port", CHARGEN_PORT_UDP, chargen_handle); - dissector_add_uint("tcp.port", CHARGEN_PORT_TCP, chargen_handle); + dissector_add_uint_with_preference("tcp.port", CHARGEN_PORT_TCP, chargen_handle); } /* diff --git a/epan/dissectors/packet-cigi.c b/epan/dissectors/packet-cigi.c index 04be38b945..1a23ce0b2c 100644 --- a/epan/dissectors/packet-cigi.c +++ b/epan/dissectors/packet-cigi.c @@ -12041,7 +12041,7 @@ proto_reg_handoff_cigi(void) cigi_handle = create_dissector_handle(dissect_cigi, proto_cigi); dissector_add_for_decode_as("udp.port", cigi_handle); - dissector_add_for_decode_as("tcp.port", cigi_handle); + dissector_add_for_decode_as_with_preference("tcp.port", cigi_handle); heur_dissector_add("udp", dissect_cigi_heur, "CIGI over UDP", "cigi_udp", proto_cigi, HEURISTIC_ENABLE); inited = TRUE; diff --git a/epan/dissectors/packet-cimd.c b/epan/dissectors/packet-cimd.c index e7cb3244ea..3216b3bc56 100644 --- a/epan/dissectors/packet-cimd.c +++ b/epan/dissectors/packet-cimd.c @@ -1168,7 +1168,7 @@ proto_reg_handoff_cimd(void) * Also register as one that can be selected by a TCP port number. */ cimd_handle = create_dissector_handle(dissect_cimd, proto_cimd); - dissector_add_for_decode_as("tcp.port", cimd_handle); + dissector_add_for_decode_as_with_preference("tcp.port", cimd_handle); } /* diff --git a/epan/dissectors/packet-classicstun.c b/epan/dissectors/packet-classicstun.c index 5ac04c6528..23f1c532ae 100644 --- a/epan/dissectors/packet-classicstun.c +++ b/epan/dissectors/packet-classicstun.c @@ -704,7 +704,7 @@ proto_reg_handoff_classicstun(void) classicstun_handle = find_dissector("classicstun"); - dissector_add_uint("tcp.port", TCP_PORT_STUN, classicstun_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_STUN, classicstun_handle); dissector_add_uint("udp.port", UDP_PORT_STUN, classicstun_handle); #endif heur_dissector_add("udp", dissect_classicstun_heur, "Classic STUN over UDP", "classicstun_udp", proto_classicstun, HEURISTIC_ENABLE); diff --git a/epan/dissectors/packet-cmp.c b/epan/dissectors/packet-cmp.c index 8e0bc7b492..800cdea1e9 100644 --- a/epan/dissectors/packet-cmp.c +++ b/epan/dissectors/packet-cmp.c @@ -58,7 +58,6 @@ void proto_register_cmp(void); /* desegmentation of CMP over TCP */ static gboolean cmp_desegment = TRUE; -static guint cmp_alternate_tcp_port = 0; static guint cmp_alternate_http_port = 0; static guint cmp_alternate_tcp_style_http_port = 0; @@ -235,7 +234,7 @@ static int hf_cmp_PKIFailureInfo_systemFailure = -1; static int hf_cmp_PKIFailureInfo_duplicateCertReq = -1; /*--- End of included file: packet-cmp-hf.c ---*/ -#line 68 "./asn1/cmp/packet-cmp-template.c" +#line 67 "./asn1/cmp/packet-cmp-template.c" /* Initialize the subtree pointers */ static gint ett_cmp = -1; @@ -291,7 +290,7 @@ static gint ett_cmp_PollRepContent = -1; static gint ett_cmp_PollRepContent_item = -1; /*--- End of included file: packet-cmp-ett.c ---*/ -#line 72 "./asn1/cmp/packet-cmp-template.c" +#line 71 "./asn1/cmp/packet-cmp-template.c" /*--- Included file: packet-cmp-fn.c ---*/ #line 1 "./asn1/cmp/packet-cmp-fn.c" @@ -1483,7 +1482,7 @@ static int dissect_SuppLangTagsValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _ /*--- End of included file: packet-cmp-fn.c ---*/ -#line 73 "./asn1/cmp/packet-cmp-template.c" +#line 72 "./asn1/cmp/packet-cmp-template.c" static int dissect_cmp_pdu(tvbuff_t *tvb, proto_tree *tree, asn1_ctx_t *actx) @@ -2368,7 +2367,7 @@ void proto_register_cmp(void) { NULL, HFILL }}, /*--- End of included file: packet-cmp-hfarr.c ---*/ -#line 325 "./asn1/cmp/packet-cmp-template.c" +#line 324 "./asn1/cmp/packet-cmp-template.c" }; /* List of subtrees */ @@ -2426,7 +2425,7 @@ void proto_register_cmp(void) { &ett_cmp_PollRepContent_item, /*--- End of included file: packet-cmp-ettarr.c ---*/ -#line 331 "./asn1/cmp/packet-cmp-template.c" +#line 330 "./asn1/cmp/packet-cmp-template.c" }; module_t *cmp_module; @@ -2444,12 +2443,6 @@ void proto_register_cmp(void) { "To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &cmp_desegment); - prefs_register_uint_preference(cmp_module, "tcp_alternate_port", - "Alternate TCP port", - "Decode this TCP port\'s traffic as CMP. Set to \"0\" to disable.", - 10, - &cmp_alternate_tcp_port); - prefs_register_uint_preference(cmp_module, "http_alternate_port", "Alternate HTTP port", "Decode this TCP port\'s traffic as CMP-over-HTTP. Set to \"0\" to disable. " @@ -2472,7 +2465,6 @@ void proto_reg_handoff_cmp(void) { static dissector_handle_t cmp_http_handle; static dissector_handle_t cmp_tcp_style_http_handle; static dissector_handle_t cmp_tcp_handle; - static guint cmp_alternate_tcp_port_prev = 0; static guint cmp_alternate_http_port_prev = 0; static guint cmp_alternate_tcp_style_http_port_prev = 0; @@ -2486,7 +2478,7 @@ void proto_reg_handoff_cmp(void) { dissector_add_string("media_type", "application/x-pkixcmp-poll", cmp_tcp_style_http_handle); cmp_tcp_handle = create_dissector_handle(dissect_cmp_tcp, proto_cmp); - dissector_add_uint("tcp.port", TCP_PORT_CMP, cmp_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_CMP, cmp_tcp_handle); oid_add_from_string("Cryptlib-presence-check","1.3.6.1.4.1.3029.3.1.1"); oid_add_from_string("Cryptlib-PKIBoot","1.3.6.1.4.1.3029.3.1.2"); @@ -2518,24 +2510,14 @@ void proto_reg_handoff_cmp(void) { /*--- End of included file: packet-cmp-dis-tab.c ---*/ -#line 401 "./asn1/cmp/packet-cmp-template.c" +#line 393 "./asn1/cmp/packet-cmp-template.c" inited = TRUE; } - /* change alternate TCP port if changed in the preferences */ - if (cmp_alternate_tcp_port != cmp_alternate_tcp_port_prev) { - if (cmp_alternate_tcp_port_prev != 0) - dissector_delete_uint("tcp.port", cmp_alternate_tcp_port_prev, cmp_tcp_handle); - if (cmp_alternate_tcp_port != 0) - dissector_add_uint("tcp.port", cmp_alternate_tcp_port, cmp_tcp_handle); - cmp_alternate_tcp_port_prev = cmp_alternate_tcp_port; - } - /* change alternate HTTP port if changed in the preferences */ if (cmp_alternate_http_port != cmp_alternate_http_port_prev) { if (cmp_alternate_http_port_prev != 0) { - dissector_delete_uint("tcp.port", cmp_alternate_http_port_prev, NULL); - dissector_delete_uint("http.port", cmp_alternate_http_port_prev, NULL); + http_tcp_dissector_delete(cmp_alternate_http_port_prev); } if (cmp_alternate_http_port != 0) http_tcp_dissector_add( cmp_alternate_http_port, cmp_http_handle); @@ -2545,8 +2527,7 @@ void proto_reg_handoff_cmp(void) { /* change alternate TCP-style-HTTP port if changed in the preferences */ if (cmp_alternate_tcp_style_http_port != cmp_alternate_tcp_style_http_port_prev) { if (cmp_alternate_tcp_style_http_port_prev != 0) { - dissector_delete_uint("tcp.port", cmp_alternate_tcp_style_http_port_prev, NULL); - dissector_delete_uint("http.port", cmp_alternate_tcp_style_http_port_prev, NULL); + http_tcp_dissector_delete(cmp_alternate_tcp_style_http_port_prev); } if (cmp_alternate_tcp_style_http_port != 0) http_tcp_dissector_add( cmp_alternate_tcp_style_http_port, cmp_tcp_style_http_handle); diff --git a/epan/dissectors/packet-cmpp.c b/epan/dissectors/packet-cmpp.c index 125ea82727..a82090c550 100644 --- a/epan/dissectors/packet-cmpp.c +++ b/epan/dissectors/packet-cmpp.c @@ -30,10 +30,7 @@ #define CMPP_DELIVER_REPORT_LEN 71 /* These are not registered with IANA */ -#define CMPP_SP_LONG_PORT 7890 -#define CMPP_SP_SHORT_PORT 7900 -#define CMPP_ISMG_LONG_PORT 7930 -#define CMPP_ISMG_SHORT_PORT 9168 +#define CMPP_PORT_RANGE "7890,7900,7930,9168" void proto_register_cmpp(void); void proto_reg_handoff_cmpp(void); @@ -977,10 +974,7 @@ proto_reg_handoff_cmpp(void) dissector_handle_t cmpp_handle; cmpp_handle = create_dissector_handle(dissect_cmpp, proto_cmpp); - dissector_add_uint("tcp.port", CMPP_SP_LONG_PORT, cmpp_handle); - dissector_add_uint("tcp.port", CMPP_SP_SHORT_PORT, cmpp_handle); - dissector_add_uint("tcp.port", CMPP_ISMG_LONG_PORT, cmpp_handle); - dissector_add_uint("tcp.port", CMPP_ISMG_SHORT_PORT, cmpp_handle); + dissector_add_uint_range_with_preference("tcp.port", CMPP_PORT_RANGE, cmpp_handle); } /* diff --git a/epan/dissectors/packet-coap.c b/epan/dissectors/packet-coap.c index 663637046b..639f06c5e1 100644 --- a/epan/dissectors/packet-coap.c +++ b/epan/dissectors/packet-coap.c @@ -90,7 +90,7 @@ static expert_field ei_coap_invalid_option_number = EI_INIT; static expert_field ei_coap_invalid_option_range = EI_INIT; static expert_field ei_coap_option_length_bad = EI_INIT; -/* CoAP's IANA-assigned port number */ +/* CoAP's IANA-assigned port (UDP only) number */ #define DEFAULT_COAP_PORT 5683 /* indicators whether those are to be showed or not */ @@ -1274,15 +1274,14 @@ proto_reg_handoff_coap(void) if (!coap_prefs_initialized) { coap_handle = find_dissector("coap"); media_type_dissector_table = find_dissector_table("media_type"); + dissector_add_uint_with_preference("tcp.port", DEFAULT_COAP_PORT, coap_handle); coap_prefs_initialized = TRUE; } else { dissector_delete_uint("udp.port", coap_port_number, coap_handle); - dissector_delete_uint("tcp.port", coap_port_number, coap_handle); } coap_port_number = global_coap_port_number; dissector_add_uint("udp.port", coap_port_number, coap_handle); - dissector_add_uint("tcp.port", coap_port_number, coap_handle); } /* diff --git a/epan/dissectors/packet-cops.c b/epan/dissectors/packet-cops.c index 68226ef780..280027d796 100644 --- a/epan/dissectors/packet-cops.c +++ b/epan/dissectors/packet-cops.c @@ -72,9 +72,6 @@ void proto_register_cops(void); -/* Preference: Variable to hold the tcp port preference */ -static guint global_cops_tcp_port = TCP_PORT_COPS; - /* Preference: desegmentation of COPS */ static gboolean cops_desegment = TRUE; @@ -2814,8 +2811,7 @@ void proto_register_cops(void) expert_module_t* expert_cops; /* Register the protocol name and description */ - proto_cops = proto_register_protocol("Common Open Policy Service", - "COPS", "cops"); + proto_cops = proto_register_protocol("Common Open Policy Service", "COPS", "cops"); /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_cops, hf, array_length(hf)); @@ -2827,11 +2823,7 @@ void proto_register_cops(void) register_dissector("cops", dissect_cops, proto_cops); /* Register our configuration options for cops */ - cops_module = prefs_register_protocol(proto_cops, proto_reg_handoff_cops); - prefs_register_uint_preference(cops_module,"tcp.cops_port", - "COPS TCP Port", - "Set the TCP port for COPS messages", - 10,&global_cops_tcp_port); + cops_module = prefs_register_protocol(proto_cops, NULL); prefs_register_bool_preference(cops_module, "desegment", "Reassemble COPS messages spanning multiple TCP segments", "Whether the COPS dissector should reassemble messages spanning multiple TCP segments." @@ -2853,21 +2845,15 @@ void proto_register_cops(void) void proto_reg_handoff_cops(void) { - static gboolean cops_prefs_initialized = FALSE; - static dissector_handle_t cops_handle; - static guint cops_tcp_port; - - if (!cops_prefs_initialized) { - cops_handle = find_dissector("cops"); - dissector_add_uint("tcp.port", TCP_PORT_PKTCABLE_COPS, cops_handle); - dissector_add_uint("tcp.port", TCP_PORT_PKTCABLE_MM_COPS, cops_handle); - cops_prefs_initialized = TRUE; - } else { - dissector_delete_uint("tcp.port",cops_tcp_port,cops_handle); - } - cops_tcp_port = global_cops_tcp_port; + dissector_handle_t cops_handle; + + cops_handle = find_dissector("cops"); + /* These could use a separate "preference name" (to avoid collision), + but they are IANA registered and users could still use Decode As */ + dissector_add_uint("tcp.port", TCP_PORT_PKTCABLE_COPS, cops_handle); + dissector_add_uint("tcp.port", TCP_PORT_PKTCABLE_MM_COPS, cops_handle); - dissector_add_uint("tcp.port", cops_tcp_port, cops_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_COPS, cops_handle); } diff --git a/epan/dissectors/packet-couchbase.c b/epan/dissectors/packet-couchbase.c index 99483f9d18..c93ea0f3d6 100644 --- a/epan/dissectors/packet-couchbase.c +++ b/epan/dissectors/packet-couchbase.c @@ -623,10 +623,6 @@ static const int * subdoc_flags[] = { static dissector_handle_t couchbase_tcp_handle; static dissector_handle_t json_handle; -/* couchbase ports */ -static range_t *couchbase_tcp_port_range; - - /* desegmentation of COUCHBASE payload */ static gboolean couchbase_desegment_body = TRUE; @@ -1883,9 +1879,6 @@ proto_register_couchbase(void) expert_couchbase = expert_register_protocol(proto_couchbase); expert_register_field_array(expert_couchbase, ei, array_length(ei)); - /* Set default port range */ - range_convert_str(&couchbase_tcp_port_range, COUCHBASE_DEFAULT_PORT, MAX_TCP_PORT); - /* Register our configuration options */ couchbase_module = prefs_register_protocol(proto_couchbase, NULL); @@ -1896,31 +1889,15 @@ proto_register_couchbase(void) " To use this option, you must also enable \"Allow subdissectors" " to reassemble TCP streams\" in the TCP protocol settings.", &couchbase_desegment_body); - - prefs_register_range_preference(couchbase_module, "tcp.ports", "Couchbase TCP ports", - "TCP ports to be decoded as Couchbase (default is " - COUCHBASE_DEFAULT_PORT ")", - &couchbase_tcp_port_range, MAX_TCP_PORT); } /* Register the tcp couchbase dissector. */ void proto_reg_handoff_couchbase(void) { - static range_t *tcp_port_range; - static gboolean initialized = FALSE; - - if (initialized == FALSE) { - couchbase_tcp_handle = create_dissector_handle(dissect_couchbase_tcp, proto_couchbase); - initialized = TRUE; - } - else { - dissector_delete_uint_range("tcp.port", tcp_port_range, couchbase_tcp_handle); - g_free(tcp_port_range); - } + couchbase_tcp_handle = create_dissector_handle(dissect_couchbase_tcp, proto_couchbase); - tcp_port_range = range_copy(couchbase_tcp_port_range); - dissector_add_uint_range("tcp.port", tcp_port_range, couchbase_tcp_handle); + dissector_add_uint_range_with_preference("tcp.port", COUCHBASE_DEFAULT_PORT, couchbase_tcp_handle); json_handle = find_dissector_add_dependency("json", proto_couchbase); } diff --git a/epan/dissectors/packet-cp2179.c b/epan/dissectors/packet-cp2179.c index 5cf6be4c1c..f43e5a6075 100644 --- a/epan/dissectors/packet-cp2179.c +++ b/epan/dissectors/packet-cp2179.c @@ -120,7 +120,6 @@ void proto_register_cp2179(void); #define SBO_OPERATE_REPLY_LEN 9 #define SBO_SELECT_REPLY_LEN 10 -#define PORT_CP2179 0 static gboolean cp2179_telnet_clean = TRUE; @@ -206,8 +205,6 @@ typedef struct { static int proto_cp2179 = -1; -static guint global_cp2179_tcp_port = PORT_CP2179; /* Port 0 (by default), adjustable by user prefs */ - /* Initialize the subtree pointers */ static gint ett_cp2179 = -1; static gint ett_cp2179_header = -1; @@ -1362,13 +1359,7 @@ proto_register_cp2179(void) proto_register_subtree_array(ett, array_length(ett)); /* Register required preferences for CP2179 Encapsulated-over-TCP decoding */ - cp2179_module = prefs_register_protocol(proto_cp2179, proto_reg_handoff_cp2179); - - /* Default TCP Port, allows for "user" port either than 0. */ - prefs_register_uint_preference(cp2179_module, "tcp.port", "CP 2179 Protocol Port", - "Set the TCP port for CP 2179 Protocol packets (if other" - " than the default of 0)", - 10, &global_cp2179_tcp_port); + cp2179_module = prefs_register_protocol(proto_cp2179, NULL); /* Telnet protocol IAC (0xFF) processing; defaults to TRUE to allow Telnet Encapsulated Data */ prefs_register_bool_preference(cp2179_module, "telnetclean", @@ -1383,19 +1374,7 @@ proto_register_cp2179(void) void proto_reg_handoff_cp2179(void) { - static int cp2179_prefs_initialized = FALSE; - static unsigned int cp2179_port; - - if (!cp2179_prefs_initialized){ - cp2179_prefs_initialized = TRUE; - } - else { - dissector_delete_uint("tcp.port", cp2179_port, cp2179_handle); - } - - cp2179_port = global_cp2179_tcp_port; - - dissector_add_uint("tcp.port", cp2179_port, cp2179_handle); + dissector_add_for_decode_as_with_preference("tcp.port", cp2179_handle); dissector_add_for_decode_as("rtacser.data", cp2179_handle); } diff --git a/epan/dissectors/packet-cql.c b/epan/dissectors/packet-cql.c index ea3c5143a9..760801b721 100644 --- a/epan/dissectors/packet-cql.c +++ b/epan/dissectors/packet-cql.c @@ -32,7 +32,7 @@ #include <epan/expert.h> -#define CQL_DEFAULT_PORT 9042 +#define CQL_DEFAULT_PORT 9042 /* Not IANA registered */ void proto_reg_handoff_cql(void); @@ -931,7 +931,7 @@ proto_reg_handoff_cql(void) static dissector_handle_t cql_handle; cql_handle = create_dissector_handle(dissect_cql_tcp, proto_cql); - dissector_add_uint("tcp.port", CQL_DEFAULT_PORT, cql_handle); + dissector_add_uint_with_preference("tcp.port", CQL_DEFAULT_PORT, cql_handle); } diff --git a/epan/dissectors/packet-ctdb.c b/epan/dissectors/packet-ctdb.c index f13efabda6..f3f561e87e 100644 --- a/epan/dissectors/packet-ctdb.c +++ b/epan/dissectors/packet-ctdb.c @@ -1241,7 +1241,7 @@ proto_reg_handoff_ctdb(void) dissector_handle_t ctdb_handle; ctdb_handle = create_dissector_handle(dissect_ctdb, proto_ctdb); - dissector_add_for_decode_as("tcp.port", ctdb_handle); + dissector_add_for_decode_as_with_preference("tcp.port", ctdb_handle); heur_dissector_add("tcp", dissect_ctdb, "Cluster TDB over TCP", "ctdb_tcp", proto_ctdb, HEURISTIC_ENABLE); } diff --git a/epan/dissectors/packet-daytime.c b/epan/dissectors/packet-daytime.c index ac77d244ac..a0b73df852 100644 --- a/epan/dissectors/packet-daytime.c +++ b/epan/dissectors/packet-daytime.c @@ -106,7 +106,7 @@ void proto_reg_handoff_daytime(void) { dissector_add_uint("udp.port", DAYTIME_PORT, daytime_handle); - dissector_add_uint("tcp.port", DAYTIME_PORT, daytime_handle); + dissector_add_uint_with_preference("tcp.port", DAYTIME_PORT, daytime_handle); } /* diff --git a/epan/dissectors/packet-db-lsp.c b/epan/dissectors/packet-db-lsp.c index 85b19e612d..cab92beb7a 100644 --- a/epan/dissectors/packet-db-lsp.c +++ b/epan/dissectors/packet-db-lsp.c @@ -271,7 +271,7 @@ proto_reg_handoff_db_lsp (void) db_lsp_tcp_handle = find_dissector ("db-lsp.tcp"); db_lsp_udp_handle = find_dissector ("db-lsp.udp"); - dissector_add_uint ("tcp.port", DB_LSP_PORT, db_lsp_tcp_handle); + dissector_add_uint_with_preference("tcp.port", DB_LSP_PORT, db_lsp_tcp_handle); dissector_add_uint ("udp.port", DB_LSP_PORT, db_lsp_udp_handle); } diff --git a/epan/dissectors/packet-dbus.c b/epan/dissectors/packet-dbus.c index 36bf9e4ed0..bc084e3b6e 100644 --- a/epan/dissectors/packet-dbus.c +++ b/epan/dissectors/packet-dbus.c @@ -716,7 +716,7 @@ void proto_reg_handoff_dbus(void) { dissector_add_uint("wtap_encap", WTAP_ENCAP_DBUS, dbus_handle); - dissector_add_for_decode_as("tcp.port", dbus_handle_tcp); + dissector_add_for_decode_as_with_preference("tcp.port", dbus_handle_tcp); } /* diff --git a/epan/dissectors/packet-dcm.c b/epan/dissectors/packet-dcm.c index 587d36e9c3..d38ebe11e1 100644 --- a/epan/dissectors/packet-dcm.c +++ b/epan/dissectors/packet-dcm.c @@ -239,9 +239,6 @@ void proto_reg_handoff_dcm(void); #define MAX_BUF_LEN 1024 /* Used for string allocations */ -static range_t *global_dcm_tcp_range = NULL; -static range_t *global_dcm_tcp_range_backup = NULL; /* needed to deregister */ - static gboolean global_dcm_export_header = TRUE; static guint global_dcm_export_minsize = 4096; /* Filter small objects in export */ @@ -7071,25 +7068,6 @@ dissect_dcm_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 off return offset; /* return the number of processed bytes */ } -static void -dcm_apply_settings(void) -{ - /* deregister first */ - dissector_delete_uint_range("tcp.port", global_dcm_tcp_range_backup, dcm_handle); - g_free(global_dcm_tcp_range_backup); - - /* Register 'static' tcp port range specified in properties - Statically defined ports take precedence over a heuristic one, - I.e., if an foreign protocol claims a port, where dicom is running on - We would never be called, by just having the heuristic registration - */ - - dissector_add_uint_range("tcp.port", global_dcm_tcp_range, dcm_handle); - - /* remember settings for next time */ - global_dcm_tcp_range_backup = range_copy(global_dcm_tcp_range); -} - /* Register the protocol with Wireshark */ void @@ -7295,12 +7273,7 @@ proto_register_dcm(void) /* Allow other dissectors to find this one by name. */ dcm_handle = register_dissector("dicom", dissect_dcm_static, proto_dcm); - dcm_module = prefs_register_protocol(proto_dcm, dcm_apply_settings); - - range_convert_str(&global_dcm_tcp_range, DICOM_DEFAULT_RANGE, 65535); - global_dcm_tcp_range_backup = range_empty(); - prefs_register_range_preference(dcm_module, "tcp.port", - "DICOM Ports", "DICOM Ports range", &global_dcm_tcp_range, 65535); + dcm_module = prefs_register_protocol(proto_dcm, NULL); prefs_register_obsolete_preference(dcm_module, "heuristic"); @@ -7352,8 +7325,12 @@ proto_register_dcm(void) void proto_reg_handoff_dcm(void) { - - dcm_apply_settings(); /* Register static ports */ + /* Register 'static' tcp port range specified in properties + Statically defined ports take precedence over a heuristic one, + I.e., if an foreign protocol claims a port, where dicom is running on + We would never be called, by just having the heuristic registration + */ + dissector_add_uint_range_with_preference("tcp.port", DICOM_DEFAULT_RANGE, dcm_handle); heur_dissector_add("tcp", dissect_dcm_heuristic, "DICOM over TCP", "dicom_tcp", proto_dcm, HEURISTIC_DISABLE); } diff --git a/epan/dissectors/packet-dhcp-failover.c b/epan/dissectors/packet-dhcp-failover.c index 1146df9c59..7321dd92fa 100644 --- a/epan/dissectors/packet-dhcp-failover.c +++ b/epan/dissectors/packet-dhcp-failover.c @@ -44,13 +44,11 @@ #include "packet-arp.h" #include "packet-tcp.h" -#define TCP_PORT_DHCPFO 519 +#define TCP_PORT_DHCPFO 519 /* Not IANA registered */ void proto_register_dhcpfo(void); void proto_reg_handoff_dhcpfo(void); -static guint tcp_port_pref = TCP_PORT_DHCPFO; - /* desegmentation of DHCP failover over TCP */ static gboolean dhcpfo_desegment = TRUE; @@ -1132,8 +1130,7 @@ proto_register_dhcpfo(void) expert_module_t* expert_dhcpfo; /* Register the protocol name and description */ - proto_dhcpfo = proto_register_protocol("DHCP Failover", "DHCPFO", - "dhcpfo"); + proto_dhcpfo = proto_register_protocol("DHCP Failover", "DHCPFO", "dhcpfo"); /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_dhcpfo, hf, array_length(hf)); @@ -1141,10 +1138,8 @@ proto_register_dhcpfo(void) expert_dhcpfo = expert_register_protocol(proto_dhcpfo); expert_register_field_array(expert_dhcpfo, ei, array_length(ei)); - dhcpfo_module = prefs_register_protocol(proto_dhcpfo, proto_reg_handoff_dhcpfo); - prefs_register_uint_preference(dhcpfo_module, "tcp_port", - "DHCP failover TCP Port", "Set the port for DHCP failover communications", - 10, &tcp_port_pref); + dhcpfo_module = prefs_register_protocol(proto_dhcpfo, NULL); + prefs_register_bool_preference(dhcpfo_module, "desegment", "Reassemble DHCP failover messages spanning multiple TCP segments", "Whether the DHCP failover dissector should reassemble messages spanning multiple TCP segments." @@ -1155,18 +1150,10 @@ proto_register_dhcpfo(void) void proto_reg_handoff_dhcpfo(void) { - static gboolean initialized = FALSE; - static dissector_handle_t dhcpfo_handle; - static guint saved_tcp_port; + dissector_handle_t dhcpfo_handle; - if (!initialized) { - dhcpfo_handle = create_dissector_handle(dissect_dhcpfo, proto_dhcpfo); - initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", saved_tcp_port, dhcpfo_handle); - } - dissector_add_uint("tcp.port", tcp_port_pref, dhcpfo_handle); - saved_tcp_port = tcp_port_pref; + dhcpfo_handle = create_dissector_handle(dissect_dhcpfo, proto_dhcpfo); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_DHCPFO, dhcpfo_handle); } /* diff --git a/epan/dissectors/packet-dhcpv6.c b/epan/dissectors/packet-dhcpv6.c index 8b7950dc08..703689f5b4 100644 --- a/epan/dissectors/packet-dhcpv6.c +++ b/epan/dissectors/packet-dhcpv6.c @@ -2464,7 +2464,7 @@ proto_reg_handoff_dhcpv6(void) dhcpv6_bulkquery_handle = create_dissector_handle(dissect_dhcpv6_bulk_leasequery, proto_dhcpv6_bulk_leasequery); - dissector_add_uint("tcp.port", UDP_PORT_DHCPV6_UPSTREAM, dhcpv6_bulkquery_handle); + dissector_add_uint_with_preference("tcp.port", UDP_PORT_DHCPV6_UPSTREAM, dhcpv6_bulkquery_handle); } /* diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c index 77b949d89c..161bc93c23 100644 --- a/epan/dissectors/packet-diameter.c +++ b/epan/dissectors/packet-diameter.c @@ -302,7 +302,6 @@ static int diameter_tap = -1; static dissector_handle_t diameter_udp_handle; static dissector_handle_t diameter_tcp_handle; static dissector_handle_t diameter_sctp_handle; -static range_t *global_diameter_tcp_port_range; static range_t *global_diameter_sctp_port_range; static range_t *global_diameter_udp_port_range; /* This is used for TCP and SCTP */ @@ -2334,7 +2333,6 @@ proto_register_diameter(void) diameter_expr_result_vnd_table = register_dissector_table("diameter.vnd_exp_res", "DIAMETER Experimental-Result-Code", proto_diameter, FT_UINT32, BASE_DEC); /* Set default TCP ports */ - range_convert_str(&global_diameter_tcp_port_range, DEFAULT_DIAMETER_PORT_RANGE, MAX_UDP_PORT); range_convert_str(&global_diameter_sctp_port_range, DEFAULT_DIAMETER_PORT_RANGE, MAX_SCTP_PORT); range_convert_str(&global_diameter_udp_port_range, "", MAX_UDP_PORT); @@ -2342,11 +2340,6 @@ proto_register_diameter(void) diameter_module = prefs_register_protocol(proto_diameter, proto_reg_handoff_diameter); - prefs_register_range_preference(diameter_module, "tcp.ports", "Diameter TCP ports", - "TCP ports to be decoded as Diameter (default: " - DEFAULT_DIAMETER_PORT_RANGE ")", - &global_diameter_tcp_port_range, MAX_UDP_PORT); - prefs_register_range_preference(diameter_module, "sctp.ports", "Diameter SCTP Ports", "SCTP ports to be decoded as Diameter (default: " @@ -2369,7 +2362,6 @@ proto_register_diameter(void) * them as obsolete rather than just illegal. */ prefs_register_obsolete_preference(diameter_module, "version"); - prefs_register_obsolete_preference(diameter_module, "tcp.port"); prefs_register_obsolete_preference(diameter_module, "sctp.port"); prefs_register_obsolete_preference(diameter_module, "command_in_header"); prefs_register_obsolete_preference(diameter_module, "dictionary.name"); @@ -2388,7 +2380,6 @@ void proto_reg_handoff_diameter(void) { static gboolean Initialized=FALSE; - static range_t *diameter_tcp_port_range; static range_t *diameter_sctp_port_range; static range_t *diameter_udp_port_range; @@ -2435,19 +2426,16 @@ proto_reg_handoff_diameter(void) Initialized=TRUE; } else { - dissector_delete_uint_range("tcp.port", diameter_tcp_port_range, diameter_tcp_handle); dissector_delete_uint_range("sctp.port", diameter_sctp_port_range, diameter_sctp_handle); dissector_delete_uint_range("udp.port", diameter_udp_port_range, diameter_udp_handle); - g_free(diameter_tcp_port_range); g_free(diameter_sctp_port_range); g_free(diameter_udp_port_range); } /* set port for future deletes */ - diameter_tcp_port_range = range_copy(global_diameter_tcp_port_range); diameter_sctp_port_range = range_copy(global_diameter_sctp_port_range); diameter_udp_port_range = range_copy(global_diameter_udp_port_range); - dissector_add_uint_range("tcp.port", diameter_tcp_port_range, diameter_tcp_handle); + dissector_add_uint_range_with_preference("tcp.port", DEFAULT_DIAMETER_PORT_RANGE, diameter_tcp_handle); dissector_add_uint_range("sctp.port", diameter_sctp_port_range, diameter_sctp_handle); dissector_add_uint_range("udp.port", diameter_udp_port_range, diameter_udp_handle); diff --git a/epan/dissectors/packet-distcc.c b/epan/dissectors/packet-distcc.c index 97c184c581..44a1ca936b 100644 --- a/epan/dissectors/packet-distcc.c +++ b/epan/dissectors/packet-distcc.c @@ -53,8 +53,6 @@ static gboolean distcc_desegment = TRUE; #define TCP_PORT_DISTCC 3632 -static guint glb_distcc_tcp_port = TCP_PORT_DISTCC; - void proto_register_distcc(void); extern void proto_reg_handoff_distcc(void); @@ -366,13 +364,8 @@ proto_register_distcc(void) expert_distcc = expert_register_protocol(proto_distcc); expert_register_field_array(expert_distcc, ei, array_length(ei)); - distcc_module = prefs_register_protocol(proto_distcc, - proto_reg_handoff_distcc); - prefs_register_uint_preference(distcc_module, "tcp.port", - "DISTCC TCP Port", - "Set the TCP port for DISTCC messages", - 10, - &glb_distcc_tcp_port); + distcc_module = prefs_register_protocol(proto_distcc, NULL); + prefs_register_bool_preference(distcc_module, "desegment_distcc_over_tcp", "Reassemble DISTCC-over-TCP messages\nspanning multiple TCP segments", "Whether the DISTCC dissector should reassemble messages spanning multiple TCP segments." @@ -383,28 +376,10 @@ proto_register_distcc(void) void proto_reg_handoff_distcc(void) { - static gboolean registered_dissector = FALSE; - static int distcc_tcp_port; - static dissector_handle_t distcc_handle; - - if (!registered_dissector) { - /* - * We haven't registered the dissector yet; get a handle - * for it. - */ - distcc_handle = create_dissector_handle(dissect_distcc, - proto_distcc); - registered_dissector = TRUE; - } else { - /* - * We've registered the dissector with a TCP port number - * of "distcc_tcp_port"; we might be changing the TCP port - * number, so remove that registration. - */ - dissector_delete_uint("tcp.port", distcc_tcp_port, distcc_handle); - } - distcc_tcp_port = glb_distcc_tcp_port; - dissector_add_uint("tcp.port", distcc_tcp_port, distcc_handle); + dissector_handle_t distcc_handle; + + distcc_handle = create_dissector_handle(dissect_distcc, proto_distcc); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_DISTCC, distcc_handle); } /* diff --git a/epan/dissectors/packet-dji-uav.c b/epan/dissectors/packet-dji-uav.c index dc7b81e6a5..d055d39455 100644 --- a/epan/dissectors/packet-dji-uav.c +++ b/epan/dissectors/packet-dji-uav.c @@ -90,7 +90,7 @@ static int hf_djiuav_response_time = -1; #define PROTO_SHORT_NAME "DJIUAV" #define PROTO_LONG_NAME "DJI UAV Drone Control Protocol" -#define PORT_DJIUAV 2001 +#define PORT_DJIUAV 2001 /* Not IANA registered */ static const value_string djiuav_pdu_type[] = { { 0x20, "Set Time" }, @@ -386,9 +386,8 @@ proto_reg_handoff_djiuav(void) { dissector_handle_t djiuav_handle; - djiuav_handle = create_dissector_handle(dissect_djiuav_static, proto_djiuav); - dissector_add_uint("tcp.port", PORT_DJIUAV, djiuav_handle); + dissector_add_uint_with_preference("tcp.port", PORT_DJIUAV, djiuav_handle); } /* diff --git a/epan/dissectors/packet-dlm3.c b/epan/dissectors/packet-dlm3.c index f6e52423a4..5cd633d67a 100644 --- a/epan/dissectors/packet-dlm3.c +++ b/epan/dissectors/packet-dlm3.c @@ -50,7 +50,7 @@ -#define TCP_PORT_DLM3 21064 +#define TCP_PORT_DLM3 21064 /* Not IANA registered */ #define SCTP_PORT_DLM3 TCP_PORT_DLM3 #define DLM3_MAJOR_VERSION 0x00030000 @@ -351,7 +351,6 @@ static gint ett_dlm3_rl_name = -1; /* configurable parameters */ -static guint dlm3_tcp_port = TCP_PORT_DLM3; static guint dlm3_sctp_port = SCTP_PORT_DLM3; /* @@ -1552,11 +1551,6 @@ proto_register_dlm3(void) dlm3_module = prefs_register_protocol(proto_dlm3, proto_reg_handoff_dlm3); - prefs_register_uint_preference(dlm3_module, "tcp.port", - "DLM3 TCP Port", - "Set the TCP port for Distributed Lock Manager", - 10, - &dlm3_tcp_port); prefs_register_uint_preference(dlm3_module, "sctp.port", "DLM3 SCTP Port", "Set the SCTP port for Distributed Lock Manager", @@ -1570,7 +1564,6 @@ proto_reg_handoff_dlm3(void) { static gboolean dissector_registered = FALSE; - static guint tcp_port; static guint sctp_port; static dissector_handle_t dlm3_tcp_handle; @@ -1579,15 +1572,13 @@ proto_reg_handoff_dlm3(void) if (!dissector_registered) { dlm3_sctp_handle = create_dissector_handle(dissect_dlm3, proto_dlm3); dlm3_tcp_handle = create_dissector_handle(dissect_dlm3, proto_dlm3); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_DLM3, dlm3_tcp_handle); dissector_registered = TRUE; } else { - dissector_delete_uint("tcp.port", tcp_port, dlm3_tcp_handle); dissector_delete_uint("sctp.port", sctp_port, dlm3_sctp_handle); } - tcp_port = dlm3_tcp_port; sctp_port = dlm3_sctp_port; - dissector_add_uint("tcp.port", tcp_port, dlm3_tcp_handle); dissector_add_uint("sctp.port", sctp_port, dlm3_sctp_handle); } diff --git a/epan/dissectors/packet-dlsw.c b/epan/dissectors/packet-dlsw.c index 070b21354f..daf2896193 100644 --- a/epan/dissectors/packet-dlsw.c +++ b/epan/dissectors/packet-dlsw.c @@ -689,7 +689,7 @@ proto_reg_handoff_dlsw(void) dissector_add_uint("udp.port", UDP_PORT_DLSW, dlsw_udp_handle); dlsw_tcp_handle = create_dissector_handle(dissect_dlsw_tcp, proto_dlsw); - dissector_add_uint("tcp.port", TCP_PORT_DLSW, dlsw_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_DLSW, dlsw_tcp_handle); } /* diff --git a/epan/dissectors/packet-dnp.c b/epan/dissectors/packet-dnp.c index 07aaac91ad..18461f31a0 100644 --- a/epan/dissectors/packet-dnp.c +++ b/epan/dissectors/packet-dnp.c @@ -4599,7 +4599,7 @@ proto_reg_handoff_dnp3(void) dnp3_tcp_handle = create_dissector_handle(dissect_dnp3_tcp, proto_dnp3); dnp3_udp_handle = create_dissector_handle(dissect_dnp3_udp, proto_dnp3); - dissector_add_uint("tcp.port", TCP_PORT_DNP, dnp3_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_DNP, dnp3_tcp_handle); dissector_add_uint("udp.port", UDP_PORT_DNP, dnp3_udp_handle); dissector_add_for_decode_as("rtacser.data", dnp3_udp_handle); } diff --git a/epan/dissectors/packet-dns.c b/epan/dissectors/packet-dns.c index a41460da5d..7916fc6db9 100644 --- a/epan/dissectors/packet-dns.c +++ b/epan/dissectors/packet-dns.c @@ -421,7 +421,6 @@ static dissector_table_t dns_tsig_dissector_table=NULL; static dissector_handle_t dns_handle; -static range_t *global_dns_tcp_port_range; static range_t *global_dns_udp_port_range; /* desegmentation of DNS over TCP */ @@ -448,9 +447,9 @@ typedef struct _dns_conv_info_t { /* Ports used for DNS. */ #define DEFAULT_DNS_PORT_RANGE "53" +#define DEFAULT_DNS_TCP_PORT_RANGE "53,5353" /* Includes mDNS */ #define SCTP_PORT_DNS 53 #define UDP_PORT_MDNS 5353 -#define TCP_PORT_MDNS 5353 #define UDP_PORT_LLMNR 5355 #define TCP_PORT_DNS_TLS 853 #define UDP_PORT_DNS_DTLS 853 @@ -4079,7 +4078,6 @@ static int dns_stats_tree_packet(stats_tree* st, packet_info* pinfo _U_, epan_di void proto_reg_handoff_dns(void) { - static range_t *dns_tcp_port_range; static range_t *dns_udp_port_range; static gboolean Initialized = FALSE; @@ -4091,7 +4089,6 @@ proto_reg_handoff_dns(void) mdns_udp_handle = create_dissector_handle(dissect_mdns_udp, proto_mdns); llmnr_udp_handle = create_dissector_handle(dissect_llmnr_udp, proto_llmnr); dissector_add_uint("udp.port", UDP_PORT_MDNS, mdns_udp_handle); - dissector_add_uint("tcp.port", TCP_PORT_MDNS, dns_handle); dissector_add_uint("udp.port", UDP_PORT_LLMNR, llmnr_udp_handle); dissector_add_uint("sctp.port", SCTP_PORT_DNS, dns_handle); #if 0 @@ -4102,18 +4099,15 @@ proto_reg_handoff_dns(void) ntlmssp_handle = find_dissector_add_dependency("ntlmssp", proto_dns); ssl_dissector_add(TCP_PORT_DNS_TLS, dns_handle); dtls_dissector_add(UDP_PORT_DNS_DTLS, dns_handle); + dissector_add_uint_range_with_preference("tcp.port", DEFAULT_DNS_TCP_PORT_RANGE, dns_handle); Initialized = TRUE; } else { - dissector_delete_uint_range("tcp.port", dns_tcp_port_range, dns_handle); dissector_delete_uint_range("udp.port", dns_udp_port_range, dns_handle); - g_free(dns_tcp_port_range); g_free(dns_udp_port_range); } - dns_tcp_port_range = range_copy(global_dns_tcp_port_range); dns_udp_port_range = range_copy(global_dns_udp_port_range); - dissector_add_uint_range("tcp.port", dns_tcp_port_range, dns_handle); dissector_add_uint_range("udp.port", dns_udp_port_range, dns_handle); } @@ -5578,16 +5572,10 @@ proto_register_dns(void) expert_register_field_array(expert_dns, ei, array_length(ei)); /* Set default ports */ - range_convert_str(&global_dns_tcp_port_range, DEFAULT_DNS_PORT_RANGE, MAX_TCP_PORT); range_convert_str(&global_dns_udp_port_range, DEFAULT_DNS_PORT_RANGE, MAX_UDP_PORT); dns_module = prefs_register_protocol(proto_dns, proto_reg_handoff_dns); - prefs_register_range_preference(dns_module, "tcp.ports", "DNS TCP ports", - "TCP ports to be decoded as DNS (default: " - DEFAULT_DNS_PORT_RANGE ")", - &global_dns_tcp_port_range, MAX_TCP_PORT); - prefs_register_range_preference(dns_module, "udp.ports", "DNS UDP ports", "UDP ports to be decoded as DNS (default: " DEFAULT_DNS_PORT_RANGE ")", diff --git a/epan/dissectors/packet-dof.c b/epan/dissectors/packet-dof.c index ea63f9a60d..3e7f20d90d 100644 --- a/epan/dissectors/packet-dof.c +++ b/epan/dissectors/packet-dof.c @@ -10594,7 +10594,7 @@ static void dof_tun_handoff(void) tcp_handle = create_dissector_handle(dissect_tunnel_tcp, proto_2012_1_tunnel); - dissector_add_uint("tcp.port", DOF_TUN_NON_SEC_TCP_PORT, tcp_handle); + dissector_add_uint_with_preference("tcp.port", DOF_TUN_NON_SEC_TCP_PORT, tcp_handle); } /* Main DOF Registration Support */ @@ -11050,7 +11050,7 @@ static void dof_handoff(void) undissected_data_handle = find_dissector("data"); - dissector_add_uint("tcp.port", DOF_P2P_NEG_SEC_TCP_PORT, tcp_handle); + dissector_add_uint_with_preference("tcp.port", DOF_P2P_NEG_SEC_TCP_PORT, tcp_handle); dissector_add_uint("udp.port", DOF_P2P_NEG_SEC_UDP_PORT, dof_udp_handle); dissector_add_uint("udp.port", DOF_MCAST_NEG_SEC_UDP_PORT, dof_udp_handle); } diff --git a/epan/dissectors/packet-dsi.c b/epan/dissectors/packet-dsi.c index a682c3ec78..d760125bbb 100644 --- a/epan/dissectors/packet-dsi.c +++ b/epan/dissectors/packet-dsi.c @@ -117,7 +117,7 @@ static gboolean dsi_desegment = TRUE; static dissector_handle_t afp_handle; static dissector_handle_t afp_server_status_handle; -#define TCP_PORT_DSI 548 +#define TCP_PORT_DSI 548 /* Not IANA registered */ #define DSI_BLOCKSIZ 16 @@ -478,7 +478,7 @@ proto_reg_handoff_dsi(void) dissector_handle_t dsi_handle; dsi_handle = create_dissector_handle(dissect_dsi, proto_dsi); - dissector_add_uint("tcp.port", TCP_PORT_DSI, dsi_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_DSI, dsi_handle); afp_handle = find_dissector_add_dependency("afp", proto_dsi); afp_server_status_handle = find_dissector_add_dependency("afp_server_status", proto_dsi); diff --git a/epan/dissectors/packet-dtcp-ip.c b/epan/dissectors/packet-dtcp-ip.c index 0c2cc2df9b..3fa6407cb8 100644 --- a/epan/dissectors/packet-dtcp-ip.c +++ b/epan/dissectors/packet-dtcp-ip.c @@ -41,12 +41,9 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> static int proto_dtcp_ip = -1; -static guint pref_tcp_port = 0; - void proto_register_dtcp_ip(void); void proto_reg_handoff_dtcp_ip(void); @@ -285,38 +282,21 @@ proto_register_dtcp_ip(void) &ett_dtcp_ip_ake_procedure }; - module_t *dtcp_ip_module; - proto_dtcp_ip = proto_register_protocol( "Digital Transmission Content Protection over IP", "DTCP-IP", "dtcp-ip"); proto_register_field_array(proto_dtcp_ip, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - dtcp_ip_module = prefs_register_protocol( - proto_dtcp_ip, proto_reg_handoff_dtcp_ip); - prefs_register_uint_preference(dtcp_ip_module, "tcp.port", - "TCP port", "TCP port number for DTCP-IP", 10, &pref_tcp_port); } void proto_reg_handoff_dtcp_ip(void) { - static gboolean initialized = FALSE; - static dissector_handle_t dtcp_ip_handle = NULL; - static guint current_tcp_port = 0; - - if (!initialized) { - dtcp_ip_handle = - create_dissector_handle(dissect_dtcp_ip, proto_dtcp_ip); - initialized = TRUE; - } - else - dissector_delete_uint("tcp.port", current_tcp_port, dtcp_ip_handle); + dissector_handle_t dtcp_ip_handle; - current_tcp_port = pref_tcp_port; - dissector_add_uint("tcp.port", current_tcp_port, dtcp_ip_handle); + dtcp_ip_handle = create_dissector_handle(dissect_dtcp_ip, proto_dtcp_ip); + dissector_add_for_decode_as_with_preference("tcp.port", dtcp_ip_handle); } /* diff --git a/epan/dissectors/packet-dtn.c b/epan/dissectors/packet-dtn.c index b3ef00583b..d1ce3e002f 100644 --- a/epan/dissectors/packet-dtn.c +++ b/epan/dissectors/packet-dtn.c @@ -289,8 +289,8 @@ static expert_field ei_tcp_convergence_ack_length = EI_INIT; static dissector_handle_t bundle_handle; -static guint bundle_tcp_port = 4556; -static guint bundle_udp_port = 4556; +#define BUNDLE_PORT 4556 +static guint bundle_udp_port = BUNDLE_PORT; typedef struct dictionary_data { int bundle_header_dict_length; @@ -3058,12 +3058,6 @@ proto_register_bundle(void) proto_tcp_conv = proto_register_protocol ("DTN TCP Convergence Layer Protocol", "TCPCL", "tcpcl"); - prefs_register_uint_preference(bundle_module, "tcp.port", - "Bundle Protocol TCP Port", - "TCP Port to Accept Bundle Protocol Connections", - 10, - &bundle_tcp_port); - prefs_register_uint_preference(bundle_module, "udp.port", "Bundle Protocol UDP Port", "UDP Port to Accept Bundle Protocol Connections", @@ -3088,22 +3082,19 @@ void proto_reg_handoff_bundle(void) { static dissector_handle_t tcpcl_handle; - static guint tcp_port; static guint udp_port; static int Initialized = FALSE; if (!Initialized) { tcpcl_handle = create_dissector_handle(dissect_tcpcl, proto_bundle); + dissector_add_uint_with_preference("tcp.port", BUNDLE_PORT, tcpcl_handle); Initialized = TRUE; } else { - dissector_delete_uint("tcp.port", tcp_port, tcpcl_handle); dissector_delete_uint("udp.port", udp_port, bundle_handle); } - tcp_port = bundle_tcp_port; udp_port = bundle_udp_port; - dissector_add_uint("tcp.port", tcp_port, tcpcl_handle); dissector_add_uint("udp.port", udp_port, bundle_handle); } diff --git a/epan/dissectors/packet-dtpt.c b/epan/dissectors/packet-dtpt.c index 37bd2718f9..0d45350f96 100644 --- a/epan/dissectors/packet-dtpt.c +++ b/epan/dissectors/packet-dtpt.c @@ -136,7 +136,7 @@ static dissector_handle_t dtpt_conversation_handle; /* Server port */ -static unsigned int gbl_dtptServerPort=5721; +#define TCP_SERVER_PORT 5721 static const value_string names_message_type[] = { #define LookupBeginRequest 9 @@ -1166,7 +1166,6 @@ proto_register_dtpt(void) &ett_dtpt_blobraw, &ett_dtpt_blob, }; - module_t *dtpt_module; e_guid_t guid_svcid_inet_hostaddrbyname = {0x0002A803, 0x0000, 0x0000, {0xC0,0,0,0,0,0,0,0x46}}; e_guid_t guid_svcid_inet_hostaddrbyinetstring = {0x0002A801, 0x0000, 0x0000, {0xC0,0,0,0,0,0,0,0x46}}; guids_add_guid(&guid_svcid_inet_hostaddrbyname, "SVCID_INET_HOSTADDRBYNAME"); @@ -1176,38 +1175,19 @@ proto_register_dtpt(void) "DTPT", "dtpt"); proto_register_field_array(proto_dtpt, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - /* Register a configuration option for port */ - dtpt_module = prefs_register_protocol(proto_dtpt, - proto_reg_handoff_dtpt); - prefs_register_uint_preference(dtpt_module, "tcp.port", - "DTPT Server TCP Port", - "Set the TDP port for the DTPT Server", - 10, &gbl_dtptServerPort); } void proto_reg_handoff_dtpt(void) { - static dissector_handle_t dtpt_handle; - static gboolean Initialized=FALSE; - static int ServerPort; - - if (!Initialized) { - dtpt_handle = create_dissector_handle(dissect_dtpt, proto_dtpt); - dtpt_conversation_handle = create_dissector_handle(dissect_dtpt_conversation, proto_dtpt); -/** dtpt_data_handle = create_dissector_handle(dissect_dtpt_data, proto_dtpt); **/ - - Initialized=TRUE; - } else { - dissector_delete_uint("tcp.port", ServerPort, dtpt_handle); - } + dissector_handle_t dtpt_handle; - /* set port for future deletes */ - ServerPort=gbl_dtptServerPort; + dtpt_handle = create_dissector_handle(dissect_dtpt, proto_dtpt); + dtpt_conversation_handle = create_dissector_handle(dissect_dtpt_conversation, proto_dtpt); +/** dtpt_data_handle = create_dissector_handle(dissect_dtpt_data, proto_dtpt); **/ - dissector_add_uint("tcp.port", gbl_dtptServerPort, dtpt_handle); + dissector_add_uint_with_preference("tcp.port", TCP_SERVER_PORT, dtpt_handle); } /* diff --git a/epan/dissectors/packet-echo.c b/epan/dissectors/packet-echo.c index b52bacf674..a6aa6bb59e 100644 --- a/epan/dissectors/packet-echo.c +++ b/epan/dissectors/packet-echo.c @@ -115,7 +115,7 @@ void proto_reg_handoff_echo(void) echo_handle = create_dissector_handle(dissect_echo, proto_echo); dissector_add_uint("udp.port", ECHO_PORT, echo_handle); - dissector_add_uint("tcp.port", ECHO_PORT, echo_handle); + dissector_add_uint_with_preference("tcp.port", ECHO_PORT, echo_handle); } diff --git a/epan/dissectors/packet-ecmp.c b/epan/dissectors/packet-ecmp.c index bf9994dd48..9352c81f47 100644 --- a/epan/dissectors/packet-ecmp.c +++ b/epan/dissectors/packet-ecmp.c @@ -37,6 +37,7 @@ #include "packet-mbtcp.h" #define PROTO_TAG_ECMP "ECMP" +#define ECMP_TCP_PORT 6160 void proto_reg_handoff_ecmp(void); void proto_register_ecmp (void); @@ -3573,7 +3574,7 @@ void proto_reg_handoff_ecmp(void) /* Cyclic frames are over UDP and non-cyclic are over TCP */ dissector_add_uint("udp.port", global_ecmp_port, ecmp_udp_handle); - dissector_add_uint("tcp.port", global_ecmp_port, ecmp_tcp_handle); + dissector_add_uint_with_preference("tcp.port", ECMP_TCP_PORT, ecmp_tcp_handle); initialized = TRUE; } diff --git a/epan/dissectors/packet-edonkey.c b/epan/dissectors/packet-edonkey.c index 94499b2408..332e24bc85 100644 --- a/epan/dissectors/packet-edonkey.c +++ b/epan/dissectors/packet-edonkey.c @@ -182,6 +182,7 @@ static gint ett_emule_sourceOBFU = -1; static expert_field ei_kademlia_tag_type = EI_INIT; static expert_field ei_kademlia_search_expression_type = EI_INIT; +#define EDONKEY_TCP_PORT_RANGE "4661-4663" /* Not IANA registered */ /* desegmentation of eDonkey over TCP */ static gboolean edonkey_desegment = TRUE; @@ -3406,9 +3407,7 @@ void proto_reg_handoff_edonkey(void) { edonkey_tcp_handle = create_dissector_handle(dissect_edonkey_tcp, proto_edonkey); edonkey_udp_handle = create_dissector_handle(dissect_edonkey_udp, proto_edonkey); - dissector_add_uint("tcp.port", 4661, edonkey_tcp_handle); - dissector_add_uint("tcp.port", 4662, edonkey_tcp_handle); - dissector_add_uint("tcp.port", 4663, edonkey_tcp_handle); + dissector_add_uint_range_with_preference("tcp.port", EDONKEY_TCP_PORT_RANGE, edonkey_tcp_handle); dissector_add_uint("udp.port", 4665, edonkey_udp_handle); dissector_add_uint("udp.port", 4672, edonkey_udp_handle); diff --git a/epan/dissectors/packet-elasticsearch.c b/epan/dissectors/packet-elasticsearch.c index 119e14e77c..461ebdac7c 100644 --- a/epan/dissectors/packet-elasticsearch.c +++ b/epan/dissectors/packet-elasticsearch.c @@ -27,7 +27,7 @@ #include "packet-tcp.h" #define ELASTICSEARCH_DISCOVERY_PORT 54328 -#define ELASTICSEARCH_BINARY_PORT 9300 +#define ELASTICSEARCH_BINARY_PORT 9300 /* Not IANA registered */ #define IPv4_ADDRESS_LENGTH 4 #define ELASTICSEARCH_STATUS_FLAG_RESPONSE 1 /* 001 */ @@ -728,7 +728,7 @@ void proto_reg_handoff_elasticsearch(void) { elasticsearch_zen_handle = create_dissector_handle(dissect_elasticsearch_zen_ping, proto_elasticsearch); dissector_add_uint("udp.port", ELASTICSEARCH_DISCOVERY_PORT, elasticsearch_zen_handle); - dissector_add_uint("tcp.port", ELASTICSEARCH_BINARY_PORT, elasticsearch_handle_binary); + dissector_add_uint_with_preference("tcp.port", ELASTICSEARCH_BINARY_PORT, elasticsearch_handle_binary); } diff --git a/epan/dissectors/packet-elcom.c b/epan/dissectors/packet-elcom.c index a3179125a8..02e891bcc4 100644 --- a/epan/dissectors/packet-elcom.c +++ b/epan/dissectors/packet-elcom.c @@ -30,7 +30,7 @@ #include <epan/packet.h> -#define TCP_PORT_ELCOM 5997 +#define TCP_PORT_ELCOM 5997 /* Not IANA registered */ /* Application level: */ #define A_CONRQ 0x04 @@ -761,7 +761,7 @@ proto_reg_handoff_elcom(void) dissector_handle_t elcom_handle; elcom_handle = create_dissector_handle(dissect_elcom, proto_elcom); - dissector_add_uint("tcp.port", TCP_PORT_ELCOM, elcom_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_ELCOM, elcom_handle); } /* diff --git a/epan/dissectors/packet-enip.c b/epan/dissectors/packet-enip.c index a20b7798d5..02620e67e4 100644 --- a/epan/dissectors/packet-enip.c +++ b/epan/dissectors/packet-enip.c @@ -4411,7 +4411,7 @@ proto_reg_handoff_enip(void) /* Register for EtherNet/IP, using TCP */ enip_tcp_handle = find_dissector("enip"); - dissector_add_uint("tcp.port", ENIP_ENCAP_PORT, enip_tcp_handle); + dissector_add_uint_with_preference("tcp.port", ENIP_ENCAP_PORT, enip_tcp_handle); /* Register for EtherNet/IP, using UDP */ enip_udp_handle = create_dissector_handle(dissect_enip_udp, proto_enip); diff --git a/epan/dissectors/packet-enttec.c b/epan/dissectors/packet-enttec.c index 48a4561bb7..4b55e6b085 100644 --- a/epan/dissectors/packet-enttec.c +++ b/epan/dissectors/packet-enttec.c @@ -37,7 +37,7 @@ /* Define UDP/TCP ports for ENTTEC */ #define UDP_PORT_ENTTEC 0x0D05 -#define TCP_PORT_ENTTEC 0x0D05 +#define TCP_PORT_ENTTEC 0x0D05 /* Not IANA registered */ #define ENTTEC_HEAD_ESPR 0x45535052 @@ -108,7 +108,6 @@ static int ett_enttec = -1; */ static guint global_udp_port_enttec = UDP_PORT_ENTTEC; -static guint global_tcp_port_enttec = TCP_PORT_ENTTEC; static gint global_disp_chan_val_type = 0; static gint global_disp_col_count = 16; @@ -552,11 +551,6 @@ proto_register_enttec(void) "The UDP port on which ENTTEC packets will be sent", 10,&global_udp_port_enttec); - prefs_register_uint_preference(enttec_module, "tcp_port", - "ENTTEC TCP Port", - "The TCP port on which ENTTEC packets will be sent", - 10,&global_tcp_port_enttec); - prefs_register_enum_preference(enttec_module, "dmx_disp_chan_val_type", "DMX Display channel value type", "The way DMX values are displayed", @@ -582,22 +576,19 @@ proto_reg_handoff_enttec(void) { static gboolean enttec_initialized = FALSE; static dissector_handle_t enttec_udp_handle, enttec_tcp_handle; static guint udp_port_enttec; - static guint tcp_port_enttec; if(!enttec_initialized) { enttec_udp_handle = create_dissector_handle(dissect_enttec_udp,proto_enttec); enttec_tcp_handle = create_dissector_handle(dissect_enttec_tcp,proto_enttec); + dissector_add_uint_with_preference("tcp.port",TCP_PORT_ENTTEC,enttec_tcp_handle); enttec_initialized = TRUE; } else { dissector_delete_uint("udp.port",udp_port_enttec,enttec_udp_handle); - dissector_delete_uint("tcp.port",tcp_port_enttec,enttec_tcp_handle); } udp_port_enttec = global_udp_port_enttec; - tcp_port_enttec = global_tcp_port_enttec; dissector_add_uint("udp.port",global_udp_port_enttec,enttec_udp_handle); - dissector_add_uint("tcp.port",global_tcp_port_enttec,enttec_tcp_handle); } /* diff --git a/epan/dissectors/packet-epmd.c b/epan/dissectors/packet-epmd.c index 996987db11..d72067a8a7 100644 --- a/epan/dissectors/packet-epmd.c +++ b/epan/dissectors/packet-epmd.c @@ -418,7 +418,7 @@ proto_reg_handoff_epmd(void) { epmd_handle = find_dissector("epmd"); edp_handle = find_dissector("erldp"); - dissector_add_uint("tcp.port", EPMD_PORT, epmd_handle); + dissector_add_uint_with_preference("tcp.port", EPMD_PORT, epmd_handle); } /* diff --git a/epan/dissectors/packet-erldp.c b/epan/dissectors/packet-erldp.c index d87fbda41b..720d136113 100644 --- a/epan/dissectors/packet-erldp.c +++ b/epan/dissectors/packet-erldp.c @@ -683,7 +683,7 @@ void proto_register_erldp(void) { /*--- proto_reg_handoff_erldp -------------------------------------------*/ void proto_reg_handoff_erldp(void) { - dissector_add_for_decode_as("tcp.port", erldp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", erldp_handle); } /* diff --git a/epan/dissectors/packet-etch.c b/epan/dissectors/packet-etch.c index 76c380b83c..148d828ab8 100644 --- a/epan/dissectors/packet-etch.c +++ b/epan/dissectors/packet-etch.c @@ -136,7 +136,6 @@ static dissector_handle_t etch_handle; */ static const char *gbl_keytab_folder = ""; -static guint gbl_etch_port = 0; static char *gbl_current_keytab_folder = NULL; static int gbl_pdu_counter; @@ -946,8 +945,7 @@ void proto_register_etch(void) register_init_routine(&etch_dissector_init); - etch_module = prefs_register_protocol(proto_etch, - proto_reg_handoff_etch); + etch_module = prefs_register_protocol(proto_etch, proto_reg_handoff_etch); prefs_register_directory_preference(etch_module, "file", "Apache Etch symbol folder", @@ -955,34 +953,21 @@ void proto_register_etch(void) "(generated by the Apache Etch compiler) " "ending with .ewh here", &gbl_keytab_folder); - prefs_register_uint_preference(etch_module, "tcp.port", - "Etch TCP Port", - "Etch TCP port", - 10, - &gbl_etch_port); } void proto_reg_handoff_etch(void) { static gboolean etch_prefs_initialized = FALSE; - static guint old_etch_port = 0; /* create dissector handle only once */ if(!etch_prefs_initialized) { /* add heuristic dissector for tcp */ heur_dissector_add("tcp", dissect_etch, "Etch over TCP", "etch_tcp", proto_etch, HEURISTIC_ENABLE); + dissector_add_for_decode_as_with_preference("tcp.port", etch_handle); etch_prefs_initialized = TRUE; } - if(old_etch_port != 0 && old_etch_port != gbl_etch_port){ - dissector_delete_uint("tcp.port", old_etch_port, etch_handle); - } - - if(gbl_etch_port != 0 && old_etch_port != gbl_etch_port) { - dissector_add_uint("tcp.port", gbl_etch_port, etch_handle); - } - old_etch_port = gbl_etch_port; /* read config folder files, if filename has changed * (while protecting strcmp() from NULLs) diff --git a/epan/dissectors/packet-exec.c b/epan/dissectors/packet-exec.c index da8b7dafa5..78c2297dfd 100644 --- a/epan/dissectors/packet-exec.c +++ b/epan/dissectors/packet-exec.c @@ -408,7 +408,7 @@ proto_reg_handoff_exec(void) dissector_handle_t exec_handle; exec_handle = create_dissector_handle(dissect_exec, proto_exec); - dissector_add_uint("tcp.port", EXEC_PORT, exec_handle); + dissector_add_uint_with_preference("tcp.port", EXEC_PORT, exec_handle); } /* diff --git a/epan/dissectors/packet-fcgi.c b/epan/dissectors/packet-fcgi.c index 6b9b16c800..b076770b63 100644 --- a/epan/dissectors/packet-fcgi.c +++ b/epan/dissectors/packet-fcgi.c @@ -24,7 +24,6 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> #include "packet-tcp.h" void proto_register_fcgi(void); @@ -32,8 +31,6 @@ void proto_reg_handoff_fcgi(void); static int proto_fcgi = -1; -static guint tcp_port = 0; - static int hf_fcgi_version = -1; static int hf_fcgi_type = -1; static int hf_fcgi_id = -1; @@ -382,43 +379,19 @@ proto_register_fcgi(void) &ett_fcgi_end_request, &ett_fcgi_params }; - module_t *fcgi_module; proto_fcgi = proto_register_protocol("FastCGI", "FCGI", "fcgi"); proto_register_field_array(proto_fcgi, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - fcgi_module = prefs_register_protocol(proto_fcgi, proto_reg_handoff_fcgi); - - prefs_register_uint_preference(fcgi_module, - "tcp.port", - "TCP port for FCGI", - "Set the TCP port for FastCGI traffic", - 10, - &tcp_port); - fcgi_handle = register_dissector("fcgi", dissect_fcgi, proto_fcgi); } void proto_reg_handoff_fcgi(void) { - static gboolean initialized = FALSE; - static guint saved_tcp_port; - - if (!initialized) { - dissector_add_for_decode_as("tcp.port", fcgi_handle); - initialized = TRUE; - } else if (saved_tcp_port != 0) { - dissector_delete_uint("tcp.port", saved_tcp_port, fcgi_handle); - } - - if (tcp_port != 0) { - dissector_add_uint("tcp.port", tcp_port, fcgi_handle); - } - - saved_tcp_port = tcp_port; + dissector_add_for_decode_as_with_preference("tcp.port", fcgi_handle); } /* diff --git a/epan/dissectors/packet-fcip.c b/epan/dissectors/packet-fcip.c index 4772a8c051..587f955644 100644 --- a/epan/dissectors/packet-fcip.c +++ b/epan/dissectors/packet-fcip.c @@ -651,7 +651,7 @@ proto_reg_handoff_fcip (void) heur_dissector_add("tcp", dissect_fcip_heur, "FCIP over TCP", "fcip_tcp", proto_fcip, HEURISTIC_ENABLE); fcip_handle = create_dissector_handle(dissect_fcip_handle, proto_fcip); - dissector_add_for_decode_as("tcp.port", fcip_handle); + dissector_add_for_decode_as_with_preference("tcp.port", fcip_handle); fc_handle = find_dissector_add_dependency("fc", proto_fcip); } diff --git a/epan/dissectors/packet-ff.c b/epan/dissectors/packet-ff.c index 4e950abacd..496b8ce65e 100644 --- a/epan/dissectors/packet-ff.c +++ b/epan/dissectors/packet-ff.c @@ -15298,7 +15298,7 @@ proto_reg_handoff_ff(void) * - Client / Server */ dissector_add_uint("udp.port", UDP_PORT_FF_FMS, ff_udp_handle); - dissector_add_uint("tcp.port", TCP_PORT_FF_FMS, ff_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_FF_FMS, ff_tcp_handle); /* * 4.8.4.2. Use diff --git a/epan/dissectors/packet-finger.c b/epan/dissectors/packet-finger.c index c3e8a493b6..adbfa59727 100644 --- a/epan/dissectors/packet-finger.c +++ b/epan/dissectors/packet-finger.c @@ -202,7 +202,7 @@ proto_reg_handoff_finger(void) static dissector_handle_t finger_handle; finger_handle = create_dissector_handle(dissect_finger, proto_finger); - dissector_add_uint("tcp.port", FINGER_PORT, finger_handle); + dissector_add_uint_with_preference("tcp.port", FINGER_PORT, finger_handle); } /* diff --git a/epan/dissectors/packet-fix.c b/epan/dissectors/packet-fix.c index 749b264b3a..db797395cc 100644 --- a/epan/dissectors/packet-fix.c +++ b/epan/dissectors/packet-fix.c @@ -70,9 +70,6 @@ static int hf_fix_field_tag = -1; static dissector_handle_t fix_handle; -static range_t *global_fix_tcp_range = NULL; -static range_t *fix_tcp_range = NULL; - /* 8=FIX */ #define MARKER_TAG "8=FIX" #define MARKER_LEN 5 @@ -460,15 +457,6 @@ dissect_fix_heur_ssl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * return TRUE; } -/* Register the protocol with Wireshark */ -static void fix_prefs(void) -{ - dissector_delete_uint_range("tcp.port", fix_tcp_range, fix_handle); - g_free(fix_tcp_range); - fix_tcp_range = range_copy(global_fix_tcp_range); - dissector_add_uint_range("tcp.port", fix_tcp_range, fix_handle); -} - /* this format is require because a script is used to build the C function that calls all the protocol registration. */ @@ -519,8 +507,7 @@ proto_register_fix(void) register_init_routine(&dissect_fix_init); /* Register the protocol name and description */ - proto_fix = proto_register_protocol("Financial Information eXchange Protocol", - "FIX", "fix"); + proto_fix = proto_register_protocol("Financial Information eXchange Protocol", "FIX", "fix"); /* Allow dissector to find be found by name. */ fix_handle = register_dissector("fix", dissect_fix, proto_fix); @@ -531,17 +518,13 @@ proto_register_fix(void) expert_fix = expert_register_protocol(proto_fix); expert_register_field_array(expert_fix, ei, array_length(ei)); - fix_module = prefs_register_protocol(proto_fix, fix_prefs); + fix_module = prefs_register_protocol(proto_fix, NULL); prefs_register_bool_preference(fix_module, "desegment", "Reassemble FIX messages spanning multiple TCP segments", "Whether the FIX dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable" " \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &fix_desegment); - - prefs_register_range_preference(fix_module, "tcp.port", "TCP Ports", "TCP Ports range", &global_fix_tcp_range, 65535); - - fix_tcp_range = range_empty(); } @@ -551,8 +534,7 @@ proto_reg_handoff_fix(void) /* Let the tcp dissector know that we're interested in traffic */ heur_dissector_add("tcp", dissect_fix_heur, "FIX over TCP", "fix_tcp", proto_fix, HEURISTIC_ENABLE); heur_dissector_add("ssl", dissect_fix_heur_ssl, "FIX over SSL", "fix_ssl", proto_fix, HEURISTIC_ENABLE); - /* Register a fix handle to "tcp.port" to be able to do 'decode-as' */ - dissector_add_for_decode_as("tcp.port", fix_handle); + dissector_add_uint_range_with_preference("tcp.port", "", fix_handle); } /* diff --git a/epan/dissectors/packet-forces.c b/epan/dissectors/packet-forces.c index e9f129050a..fcadd6a0f5 100644 --- a/epan/dissectors/packet-forces.c +++ b/epan/dissectors/packet-forces.c @@ -145,7 +145,6 @@ static int hf_forces_unknown_tlv = -1; #define TCP_UDP_TML_FOCES_MESSAGE_OFFSET_TCP 2 /*TCP+UDP TML*/ -static guint forces_alternate_tcp_port = 0; static guint forces_alternate_udp_port = 0; /*SCTP TML*/ static guint forces_alternate_sctp_high_prio_channel_port = 0; @@ -833,11 +832,6 @@ proto_register_forces(void) forces_module = prefs_register_protocol(proto_forces,proto_reg_handoff_forces); - prefs_register_uint_preference(forces_module, "tcp_alternate_port", - "TCP port", - "Decode packets on this TCP port as ForCES", - 10, &forces_alternate_tcp_port); - prefs_register_uint_preference(forces_module, "udp_alternate_port", "UDP port", "Decode packets on this UDP port as ForCES", @@ -864,7 +858,6 @@ proto_reg_handoff_forces(void) { static gboolean inited = FALSE; - static guint alternate_tcp_port = 0; /* 3000 */ static guint alternate_udp_port = 0; static guint alternate_sctp_high_prio_channel_port = 0; /* 6700 */ static guint alternate_sctp_med_prio_channel_port = 0; @@ -876,15 +869,12 @@ proto_reg_handoff_forces(void) forces_handle_tcp = create_dissector_handle(dissect_forces_tcp, proto_forces); forces_handle = create_dissector_handle(dissect_forces_not_tcp, proto_forces); ip_handle = find_dissector_add_dependency("ip", proto_forces); + /* Register TCP port for dissection */ + dissector_add_for_decode_as_with_preference("tcp.port", forces_handle_tcp); + inited = TRUE; } - /* Register TCP port for dissection */ - if ((alternate_tcp_port != 0) && (alternate_tcp_port != forces_alternate_tcp_port)) - dissector_delete_uint("tcp.port", alternate_tcp_port, forces_handle_tcp); - if ((forces_alternate_tcp_port != 0) && (alternate_tcp_port != forces_alternate_tcp_port)) - dissector_add_uint("tcp.port", forces_alternate_tcp_port, forces_handle_tcp); - alternate_tcp_port = forces_alternate_tcp_port; /* Register UDP port for dissection */ if ((alternate_udp_port != 0) && (alternate_udp_port != forces_alternate_udp_port)) diff --git a/epan/dissectors/packet-ftp.c b/epan/dissectors/packet-ftp.c index caa9c3147d..93f7b289de 100644 --- a/epan/dissectors/packet-ftp.c +++ b/epan/dissectors/packet-ftp.c @@ -1047,9 +1047,9 @@ proto_reg_handoff_ftp(void) dissector_handle_t ftp_handle; ftpdata_handle = find_dissector("ftp-data"); - dissector_add_uint("tcp.port", TCP_PORT_FTPDATA, ftpdata_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_FTPDATA, ftpdata_handle); ftp_handle = find_dissector("ftp"); - dissector_add_uint("tcp.port", TCP_PORT_FTP, ftp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_FTP, ftp_handle); } /* diff --git a/epan/dissectors/packet-gadu-gadu.c b/epan/dissectors/packet-gadu-gadu.c index aeb1c5f088..1c41cfec69 100644 --- a/epan/dissectors/packet-gadu-gadu.c +++ b/epan/dissectors/packet-gadu-gadu.c @@ -2112,7 +2112,7 @@ proto_register_gadu_gadu(void) void proto_reg_handoff_gadu_gadu(void) { - dissector_add_uint("tcp.port", TCP_PORT_GADU_GADU, gadu_gadu_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_GADU_GADU, gadu_gadu_handle); xml_handle = find_dissector_add_dependency("xml", hfi_gadu_gadu->id); } diff --git a/epan/dissectors/packet-gdb.c b/epan/dissectors/packet-gdb.c index d930708bca..b6d3014ab9 100644 --- a/epan/dissectors/packet-gdb.c +++ b/epan/dissectors/packet-gdb.c @@ -217,8 +217,7 @@ proto_register_gdb(void) }; - proto_gdb = proto_register_protocol( - "GDB Remote Serial Protocol", "GDB remote", "gdb"); + proto_gdb = proto_register_protocol("GDB Remote Serial Protocol", "GDB remote", "gdb"); proto_register_field_array(proto_gdb, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -230,15 +229,11 @@ proto_register_gdb(void) void proto_reg_handoff_gdb(void) { - static gboolean initialized = FALSE; - static dissector_handle_t gdb_handle; + dissector_handle_t gdb_handle; - if (!initialized) { - gdb_handle = create_dissector_handle(dissect_gdb_tcp, proto_gdb); - initialized = TRUE; - } + gdb_handle = create_dissector_handle(dissect_gdb_tcp, proto_gdb); - dissector_add_for_decode_as("tcp.port", gdb_handle); + dissector_add_for_decode_as_with_preference("tcp.port", gdb_handle); } /* diff --git a/epan/dissectors/packet-gdsdb.c b/epan/dissectors/packet-gdsdb.c index f02945f91f..f6835e5fcf 100644 --- a/epan/dissectors/packet-gdsdb.c +++ b/epan/dissectors/packet-gdsdb.c @@ -2051,7 +2051,7 @@ proto_reg_handoff_gdsdb(void) gdsdb_handle = create_dissector_handle(dissect_gdsdb, proto_gdsdb); - dissector_add_uint("tcp.port", TCP_PORT, gdsdb_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT, gdsdb_handle); } /* diff --git a/epan/dissectors/packet-gearman.c b/epan/dissectors/packet-gearman.c index 3d2ef94458..b4c4ea3115 100644 --- a/epan/dissectors/packet-gearman.c +++ b/epan/dissectors/packet-gearman.c @@ -551,7 +551,7 @@ proto_reg_handoff_gearman(void) dissector_handle_t gearman_handle; gearman_handle = create_dissector_handle(dissect_gearman, proto_gearman); - dissector_add_uint("tcp.port", GEARMAN_PORT, gearman_handle); + dissector_add_uint_with_preference("tcp.port", GEARMAN_PORT, gearman_handle); } /* diff --git a/epan/dissectors/packet-ged125.c b/epan/dissectors/packet-ged125.c index 460958fae9..bea3b9bda1 100644 --- a/epan/dissectors/packet-ged125.c +++ b/epan/dissectors/packet-ged125.c @@ -155,7 +155,6 @@ static expert_field ei_ged125_TrunkCount_invalid = EI_INIT; static dissector_handle_t ged125_handle; /* Preferences */ -static guint global_tcp_port_ged125 = 0; static gboolean ged125_desegment_body = TRUE; #define GED125_FAILURE_CONF_VALUE 1 @@ -1756,10 +1755,6 @@ proto_register_ged125 (void) ged125_module = prefs_register_protocol(proto_ged125, NULL); - prefs_register_uint_preference(ged125_module, "tcp_port","GED125 TCP Port", - "Set up the TCP port for GED125", - 10, &global_tcp_port_ged125); - prefs_register_bool_preference(ged125_module, "desegment_body", "Reassemble GED125 bodies spanning multiple TCP segments", "Whether the GED125 dissector should desegment all messages spanning multiple TCP segments", @@ -1769,17 +1764,8 @@ proto_register_ged125 (void) void proto_reg_handoff_ged125(void) { - static guint old_ged125_tcp_port = 0; - /* Register TCP port for dissection */ - if (old_ged125_tcp_port != 0 && old_ged125_tcp_port != global_tcp_port_ged125) - dissector_delete_uint("tcp.port", old_ged125_tcp_port, ged125_handle); - - - if (global_tcp_port_ged125 != 0 && old_ged125_tcp_port != global_tcp_port_ged125) - dissector_add_uint("tcp.port", global_tcp_port_ged125, ged125_handle); - - old_ged125_tcp_port = global_tcp_port_ged125; + dissector_add_for_decode_as_with_preference("tcp.port", ged125_handle); } /* diff --git a/epan/dissectors/packet-gift.c b/epan/dissectors/packet-gift.c index 2178580b12..5ac2088c37 100644 --- a/epan/dissectors/packet-gift.c +++ b/epan/dissectors/packet-gift.c @@ -31,7 +31,7 @@ void proto_register_gift(void); void proto_reg_handoff_gift(void); -#define TCP_PORT_GIFT 1213 +#define TCP_PORT_GIFT 1213 /* Not IANA registered */ static int proto_gift = -1; static int hf_gift_response = -1; @@ -158,7 +158,7 @@ proto_reg_handoff_gift(void) dissector_handle_t gift_handle; gift_handle = create_dissector_handle(dissect_gift, proto_gift); - dissector_add_uint("tcp.port", TCP_PORT_GIFT, gift_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_GIFT, gift_handle); } /* diff --git a/epan/dissectors/packet-giop.c b/epan/dissectors/packet-giop.c index 8fff55bfc8..5002d78075 100644 --- a/epan/dissectors/packet-giop.c +++ b/epan/dissectors/packet-giop.c @@ -5569,7 +5569,7 @@ void proto_reg_handoff_giop (void) { heur_dissector_add("tcp", dissect_giop_heur, "GIOP over TCP", "giop_tcp", proto_giop, HEURISTIC_ENABLE); /* Support DIOP (GIOP/UDP) */ heur_dissector_add("udp", dissect_giop_heur, "DIOP (GIOP/UDP)", "giop_udp", proto_giop, HEURISTIC_ENABLE); - dissector_add_for_decode_as("tcp.port", giop_tcp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", giop_tcp_handle); } diff --git a/epan/dissectors/packet-git.c b/epan/dissectors/packet-git.c index b3c6759425..2f2c704bea 100644 --- a/epan/dissectors/packet-git.c +++ b/epan/dissectors/packet-git.c @@ -162,7 +162,7 @@ proto_register_git(void) void proto_reg_handoff_git(void) { - dissector_add_uint("tcp.port", TCP_PORT_GIT, git_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_GIT, git_handle); } /* diff --git a/epan/dissectors/packet-gnutella.c b/epan/dissectors/packet-gnutella.c index 79a9e9359a..a078e908c3 100644 --- a/epan/dissectors/packet-gnutella.c +++ b/epan/dissectors/packet-gnutella.c @@ -732,9 +732,7 @@ void proto_register_gnutella(void) { &ett_gnutella, }; - proto_gnutella = proto_register_protocol("Gnutella Protocol", - "GNUTELLA", - "gnutella"); + proto_gnutella = proto_register_protocol("Gnutella Protocol", "GNUTELLA", "gnutella"); proto_register_field_array(proto_gnutella, hf, array_length(hf)); @@ -744,9 +742,8 @@ void proto_register_gnutella(void) { void proto_reg_handoff_gnutella(void) { dissector_handle_t gnutella_handle; - gnutella_handle = create_dissector_handle(dissect_gnutella, - proto_gnutella); - dissector_add_uint("tcp.port", GNUTELLA_TCP_PORT, gnutella_handle); + gnutella_handle = create_dissector_handle(dissect_gnutella, proto_gnutella); + dissector_add_uint_with_preference("tcp.port", GNUTELLA_TCP_PORT, gnutella_handle); } /* diff --git a/epan/dissectors/packet-gopher.c b/epan/dissectors/packet-gopher.c index f8d0e3e633..73df6703f0 100644 --- a/epan/dissectors/packet-gopher.c +++ b/epan/dissectors/packet-gopher.c @@ -32,6 +32,7 @@ #include <epan/packet.h> #include <epan/prefs.h> +#include <epan/prefs-int.h> void proto_register_gopher(void); void proto_reg_handoff_gopher(void); @@ -77,7 +78,6 @@ static const value_string item_types[] = { #define TCP_DEFAULT_RANGE "70" -static range_t *global_gopher_tcp_range = NULL; static range_t *gopher_tcp_range = NULL; /* Returns TRUE if the packet is from a client */ @@ -202,21 +202,10 @@ dissect_gopher(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ /* Preference callbacks */ static void -range_delete_gopher_tcp_callback(guint32 port) { - dissector_delete_uint("tcp.port", port, gopher_handle); -} - -static void -range_add_gopher_tcp_callback(guint32 port) { - dissector_add_uint("tcp.port", port, gopher_handle); -} - -static void gopher_prefs_apply(void) { - range_foreach(gopher_tcp_range, range_delete_gopher_tcp_callback); - g_free(gopher_tcp_range); - gopher_tcp_range = range_copy(global_gopher_tcp_range); - range_foreach(gopher_tcp_range, range_add_gopher_tcp_callback); + pref_t *gopher_ports = prefs_find_preference(prefs_find_module("gopher"), "tcp.port"); + + gopher_tcp_range = range_copy(*gopher_ports->varp.range); } /* Register the protocol with Wireshark */ @@ -269,8 +258,6 @@ proto_register_gopher(void) } }; - module_t *gopher_module; - /* Setup protocol subtree array */ static gint *ett[] = { &ett_gopher, @@ -278,28 +265,24 @@ proto_register_gopher(void) }; /* Register the protocol name and description */ - proto_gopher = proto_register_protocol("Gopher", - "Gopher", "gopher"); + proto_gopher = proto_register_protocol("Gopher", "Gopher", "gopher"); /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_gopher, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - /* Initialize dissector preferences */ - gopher_module = prefs_register_protocol(proto_gopher, gopher_prefs_apply); - - range_convert_str(&global_gopher_tcp_range, TCP_DEFAULT_RANGE, 65535); - gopher_tcp_range = range_empty(); - prefs_register_range_preference(gopher_module, "tcp.port", "TCP Ports", - "TCP Ports range", - &global_gopher_tcp_range, 65535); + /* Preferences for this module are generated when registering with + dissector tables and need the callback function to get the + port range values + */ + prefs_register_protocol(proto_gopher, gopher_prefs_apply); } void proto_reg_handoff_gopher(void) { gopher_handle = create_dissector_handle(dissect_gopher, proto_gopher); - gopher_prefs_apply(); + dissector_add_uint_range_with_preference("tcp.port", TCP_DEFAULT_RANGE, gopher_handle); } /* diff --git a/epan/dissectors/packet-gsm_ipa.c b/epan/dissectors/packet-gsm_ipa.c index e9fa232a1f..8298d0fd2a 100644 --- a/epan/dissectors/packet-gsm_ipa.c +++ b/epan/dissectors/packet-gsm_ipa.c @@ -77,7 +77,6 @@ void proto_reg_handoff_gsm_ipa(void); static dissector_handle_t ipa_tcp_handle; static dissector_handle_t ipa_udp_handle; -static range_t *global_ipa_tcp_ports = NULL; static range_t *global_ipa_udp_ports = NULL; static gboolean global_ipa_in_root = FALSE; static gboolean global_ipa_in_info = FALSE; @@ -458,16 +457,9 @@ void proto_register_ipa(void) FT_UINT8, BASE_DEC); - range_convert_str(&global_ipa_tcp_ports, IPA_TCP_PORTS, MAX_TCP_PORT); range_convert_str(&global_ipa_udp_ports, IPA_UDP_PORTS_DEFAULT, MAX_UDP_PORT); - ipa_module = prefs_register_protocol(proto_ipa, - proto_reg_handoff_gsm_ipa); + ipa_module = prefs_register_protocol(proto_ipa, proto_reg_handoff_gsm_ipa); - prefs_register_range_preference(ipa_module, "tcp_ports", - "GSM IPA TCP Port(s)", - "Set the port(s) for ip.access IPA" - " (default: " IPA_TCP_PORTS ")", - &global_ipa_tcp_ports, MAX_TCP_PORT); prefs_register_range_preference(ipa_module, "udp_ports", "GSM IPA UDP Port(s)", "Set the port(s) for ip.access IPA" @@ -485,7 +477,7 @@ void proto_register_ipa(void) void proto_reg_handoff_gsm_ipa(void) { static gboolean ipa_initialized = FALSE; - static range_t *ipa_tcp_ports, *ipa_udp_ports; + static range_t *ipa_udp_ports; if (!ipa_initialized) { sub_handles[SUB_RSL] = find_dissector_add_dependency("gsm_abis_rsl", proto_ipa); @@ -496,19 +488,16 @@ void proto_reg_handoff_gsm_ipa(void) ipa_tcp_handle = create_dissector_handle(dissect_ipa_tcp, proto_ipa); ipa_udp_handle = create_dissector_handle(dissect_ipa_udp, proto_ipa); + dissector_add_uint_range_with_preference("tcp.port", IPA_TCP_PORTS, ipa_tcp_handle); ipa_initialized = TRUE; } else { - dissector_delete_uint_range("tcp.port", ipa_tcp_ports, ipa_tcp_handle); - g_free(ipa_tcp_ports); dissector_delete_uint_range("udp.port", ipa_udp_ports, ipa_udp_handle); g_free(ipa_udp_ports); } - ipa_tcp_ports = range_copy(global_ipa_tcp_ports); ipa_udp_ports = range_copy(global_ipa_udp_ports); dissector_add_uint_range("udp.port", ipa_udp_ports, ipa_udp_handle); - dissector_add_uint_range("tcp.port", ipa_tcp_ports, ipa_tcp_handle); } /* diff --git a/epan/dissectors/packet-gtp.c b/epan/dissectors/packet-gtp.c index 5a48869e2a..7378e39ea1 100644 --- a/epan/dissectors/packet-gtp.c +++ b/epan/dissectors/packet-gtp.c @@ -10106,6 +10106,8 @@ proto_reg_handoff_gtp(void) dissector_add_uint("udp.port", g_gtpv1u_port, gtp_handle); if (g_gtp_over_tcp) { + /* This doesn't use the "auto preference" API because the port + description is too specific */ dissector_add_uint("tcp.port", g_gtpv0_port, gtp_prime_handle); dissector_add_uint("tcp.port", g_gtpv1c_port, gtp_handle); dissector_add_uint("tcp.port", g_gtpv1u_port, gtp_handle); diff --git a/epan/dissectors/packet-h223.c b/epan/dissectors/packet-h223.c index 3e2e35996d..d62a46b0d8 100644 --- a/epan/dissectors/packet-h223.c +++ b/epan/dissectors/packet-h223.c @@ -1670,8 +1670,8 @@ void proto_reg_handoff_h223(void) data_handle = find_dissector("data"); srp_handle = find_dissector("srp"); - dissector_add_for_decode_as("tcp.port", create_dissector_handle( dissect_h223, proto_h223)); - dissector_add_for_decode_as("tcp.port", h223_bitswapped); + dissector_add_for_decode_as_with_preference("tcp.port", create_dissector_handle( dissect_h223, proto_h223)); + dissector_add_for_decode_as_with_preference("tcp.port", h223_bitswapped); dissector_add_string("rtp_dyn_payload_type","CLEARMODE", h223_bitswapped); dissector_add_uint("iax2.dataformat", AST_DATAFORMAT_H223_H245, create_dissector_handle(dissect_h223_bitswapped_circuit_data, proto_h223_bitswapped)); } diff --git a/epan/dissectors/packet-h245.c b/epan/dissectors/packet-h245.c index 401309d368..791523f9f3 100644 --- a/epan/dissectors/packet-h245.c +++ b/epan/dissectors/packet-h245.c @@ -20831,7 +20831,7 @@ void proto_reg_handoff_h245(void) { amr_handle = find_dissector("amr_if2_nb"); - dissector_add_for_decode_as("tcp.port", h245_handle); + dissector_add_for_decode_as_with_preference("tcp.port", h245_handle); dissector_add_for_decode_as("udp.port", MultimediaSystemControlMessage_handle); } diff --git a/epan/dissectors/packet-h248.c b/epan/dissectors/packet-h248.c index 3214cf21e7..f9b876a021 100644 --- a/epan/dissectors/packet-h248.c +++ b/epan/dissectors/packet-h248.c @@ -1312,7 +1312,7 @@ void gcp_analyze_msg(proto_tree* gcp_tree, packet_info* pinfo, tvbuff_t* gcp_tvb static gboolean keep_persistent_data = FALSE; static guint global_udp_port = 2945; -static guint global_tcp_port = 2945; +#define H248_TCP_PORT 2945 static gboolean h248_desegment = TRUE; @@ -7714,11 +7714,6 @@ void proto_register_h248(void) { "Port to be decoded as h248", 10, &global_udp_port); - prefs_register_uint_preference(h248_module, "tcp_port", - "TCP port", - "Port to be decoded as h248", - 10, - &global_tcp_port); prefs_register_bool_preference(h248_module, "desegment", "Desegment H.248 over TCP", "Desegment H.248 messages that span more TCP segments", @@ -7737,31 +7732,23 @@ void proto_reg_handoff_h248(void) { static gboolean initialized = FALSE; static guint32 udp_port; - static guint32 tcp_port; if (!initialized) { dissector_add_uint("mtp3.service_indicator", MTP_SI_GCP, h248_handle); h248_term_handle = find_dissector_add_dependency("h248term", proto_h248); + dissector_add_uint_with_preference("tcp.port", H248_TCP_PORT, h248_tpkt_handle); initialized = TRUE; } else { if (udp_port != 0) dissector_delete_uint("udp.port", udp_port, h248_handle); - - if (tcp_port != 0) - dissector_delete_uint("tcp.port", tcp_port, h248_tpkt_handle); } udp_port = global_udp_port; - tcp_port = global_tcp_port; if (udp_port != 0) { dissector_add_uint("udp.port", udp_port, h248_handle); } - if (tcp_port != 0) { - dissector_add_uint("tcp.port", tcp_port, h248_tpkt_handle); - } - ss7pc_address_type = address_type_get_by_name("AT_SS7PC"); exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_7); } diff --git a/epan/dissectors/packet-h248_annex_c.c b/epan/dissectors/packet-h248_annex_c.c index c87e95cecf..83f2406683 100644 --- a/epan/dissectors/packet-h248_annex_c.c +++ b/epan/dissectors/packet-h248_annex_c.c @@ -1572,6 +1572,11 @@ void proto_register_h248_annex_c(void) { &ett_codec }; + static ei_register_info ei[] = { + { &ei_h248_sdp_media_port_invalid, { "sdp.media.port.invalid", PI_MALFORMED, PI_ERROR, + "Invalid SDP media port", EXPFILL }} + }; + proto_h248_pkg_annexc = proto_register_protocol(PNAME, PSNAME, PFNAME); proto_register_field_array(proto_h248_pkg_annexc, hf, array_length(hf)); @@ -1580,11 +1585,6 @@ void proto_register_h248_annex_c(void) { h248_register_package(&h248_annexc_package,MERGE_PKG_HIGH); - static ei_register_info ei[] = { - { &ei_h248_sdp_media_port_invalid, { "sdp.media.port.invalid", PI_MALFORMED, PI_ERROR, - "Invalid SDP media port", EXPFILL }} - }; - expert_h248_pkg_annexc = expert_register_protocol(proto_h248_pkg_annexc); expert_register_field_array(expert_h248_pkg_annexc, ei, array_length(ei)); } diff --git a/epan/dissectors/packet-h501.c b/epan/dissectors/packet-h501.c index 0f217c7c5f..61b525de72 100644 --- a/epan/dissectors/packet-h501.c +++ b/epan/dissectors/packet-h501.c @@ -418,8 +418,8 @@ static gint ett_h501_TerminationCause = -1; static dissector_handle_t h501_pdu_handle; /* Preferences */ +#define H501_TCP_PORT 2099 static guint h501_udp_port = 2099; -static guint h501_tcp_port = 2099; static gboolean h501_desegment_tcp = TRUE; void proto_reg_handoff_h501(void); @@ -3682,10 +3682,6 @@ void proto_register_h501(void) { "UDP port", "Port to be decoded as h501", 10, &h501_udp_port); - prefs_register_uint_preference(h501_module, "tcp.port", - "TCP port", - "Port to be decoded as h501", - 10, &h501_tcp_port); prefs_register_bool_preference(h501_module, "desegment", "Desegment H.501 over TCP", "Desegment H.501 messages that span more TCP segments", @@ -3700,22 +3696,19 @@ void proto_reg_handoff_h501(void) static dissector_handle_t h501_udp_handle; static dissector_handle_t h501_tcp_handle; static guint saved_h501_udp_port; - static guint saved_h501_tcp_port; if (!h501_prefs_initialized) { h501_udp_handle = create_dissector_handle(dissect_h501_udp, proto_h501); h501_tcp_handle = create_dissector_handle(dissect_h501_tcp, proto_h501); + dissector_add_uint_with_preference("tcp.port", H501_TCP_PORT, h501_tcp_handle); h501_prefs_initialized = TRUE; } else { dissector_delete_uint("udp.port", saved_h501_udp_port, h501_udp_handle); - dissector_delete_uint("tcp.port", saved_h501_tcp_port, h501_tcp_handle); } /* Set our port number for future use */ saved_h501_udp_port = h501_udp_port; dissector_add_uint("udp.port", saved_h501_udp_port, h501_udp_handle); - saved_h501_tcp_port = h501_tcp_port; - dissector_add_uint("tcp.port", saved_h501_tcp_port, h501_tcp_handle); } diff --git a/epan/dissectors/packet-hartip.c b/epan/dissectors/packet-hartip.c index 8e3267c25e..1c84bc1562 100644 --- a/epan/dissectors/packet-hartip.c +++ b/epan/dissectors/packet-hartip.c @@ -2209,7 +2209,7 @@ proto_reg_handoff_hartip(void) hartip_tcp_handle = create_dissector_handle(dissect_hartip_tcp, proto_hartip); hartip_udp_handle = create_dissector_handle(dissect_hartip_udp, proto_hartip); dissector_add_uint("udp.port", HARTIP_PORT, hartip_udp_handle); - dissector_add_uint("tcp.port", HARTIP_PORT, hartip_tcp_handle); + dissector_add_uint_with_preference("tcp.port", HARTIP_PORT, hartip_tcp_handle); stats_tree_register("hart_ip", "hart_ip", "HART-IP", 0, hartip_stats_tree_packet, hartip_stats_tree_init, NULL); diff --git a/epan/dissectors/packet-hazelcast.c b/epan/dissectors/packet-hazelcast.c index f2c8217dcc..3217fae5ae 100644 --- a/epan/dissectors/packet-hazelcast.c +++ b/epan/dissectors/packet-hazelcast.c @@ -95,7 +95,7 @@ static gint ett_hazelcast_flags = -1; /* prefs */ static gboolean hazelcast_desegment = TRUE; -static guint gPORT_PREF = 5701; +#define HAZELCAST_PORT 5701 /* Not IANA registered */ static const value_string operationTypes[] = { {0, "NONE"}, @@ -571,12 +571,6 @@ void proto_register_hazelcast(void) { " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &hazelcast_desegment); - prefs_register_uint_preference(hazelcast_module, "tcp.port", - "Hazelcast TCP Port", - " Hazelcast TCP port if other than the default", - 10, - &gPORT_PREF); - hazelcast_tap = register_tap("hzlcst"); } @@ -584,19 +578,12 @@ void proto_register_hazelcast(void) { void proto_reg_handoff_hazelcast(void) { - static gboolean initialized = FALSE; - static dissector_handle_t hazelcast_handle; - static int currentPort; - - if (!initialized) { - hazelcast_handle = create_dissector_handle(dissect_hazelcast, proto_hazelcast); - initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", currentPort, hazelcast_handle); - } - currentPort = gPORT_PREF; - dissector_add_uint("tcp.port", currentPort, hazelcast_handle); + dissector_handle_t hazelcast_handle; + + hazelcast_handle = create_dissector_handle(dissect_hazelcast, proto_hazelcast); + + dissector_add_uint_with_preference("tcp.port", HAZELCAST_PORT, hazelcast_handle); } /* diff --git a/epan/dissectors/packet-hcrt.c b/epan/dissectors/packet-hcrt.c index 718f236360..1698241ebd 100644 --- a/epan/dissectors/packet-hcrt.c +++ b/epan/dissectors/packet-hcrt.c @@ -500,7 +500,7 @@ void proto_reg_handoff_hcrt(void) hcrt_handle = create_dissector_handle(dissect_hcrt, proto_hcrt); /* Also register as a dissector that can be selected by a TCP port number via "decode as" */ - dissector_add_for_decode_as("tcp.port", hcrt_handle); + dissector_add_for_decode_as_with_preference("tcp.port", hcrt_handle); hcrt_prefs_initialized = TRUE; } else { dissector_delete_uint("ethertype", hcrt_ethertype, hcrt_handle); diff --git a/epan/dissectors/packet-hdfs.c b/epan/dissectors/packet-hdfs.c index 7b084394e4..e8fb0e06d2 100644 --- a/epan/dissectors/packet-hdfs.c +++ b/epan/dissectors/packet-hdfs.c @@ -29,6 +29,7 @@ #include <epan/packet.h> #include <epan/prefs.h> +#include <epan/prefs-int.h> #include "packet-tcp.h" void proto_register_hdfs(void); @@ -683,6 +684,14 @@ dissect_hdfs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) return tvb_captured_length(tvb); } +static void +apply_hdfs_prefs(void) +{ + /* HDFS uses the port preference to determine request/response */ + pref_t *hdfs_port = prefs_find_preference(prefs_find_module("hdfs"), "tcp.port"); + tcp_port = *hdfs_port->varp.uint; +} + /* registers the protcol with the given names */ void proto_register_hdfs(void) @@ -1040,26 +1049,12 @@ proto_register_hdfs(void) &ett_hdfs }; - module_t *hdfs_module; - - proto_hdfs = proto_register_protocol ( - "HDFS Protocol", /* name */ - "HDFS", /* short name */ - "hdfs" /* abbrev */ - ); + proto_hdfs = proto_register_protocol ("HDFS Protocol", "HDFS", "hdfs"); proto_register_field_array(proto_hdfs, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - hdfs_module = prefs_register_protocol(proto_hdfs, proto_reg_handoff_hdfs); - - prefs_register_uint_preference(hdfs_module, - "tcp.port", - "TCP port for HDFS", - "Set the TCP port for HDFS", - 10, - &tcp_port); - + prefs_register_protocol(proto_hdfs, apply_hdfs_prefs); hdfs_handle = register_dissector("hdfs", dissect_hdfs, proto_hdfs); } @@ -1067,21 +1062,7 @@ proto_register_hdfs(void) void proto_reg_handoff_hdfs(void) { - static gboolean initialized = FALSE; - static guint saved_tcp_port; - - if (!initialized) { - dissector_add_for_decode_as("tcp.port", hdfs_handle); - initialized = TRUE; - } else if (saved_tcp_port != 0) { - dissector_delete_uint("tcp.port", saved_tcp_port, hdfs_handle); - } - - if (tcp_port != 0) { - dissector_add_uint("tcp.port", tcp_port, hdfs_handle); - } - - saved_tcp_port = tcp_port; + dissector_add_for_decode_as_with_preference("tcp.port", hdfs_handle); } /* * Editor modelines diff --git a/epan/dissectors/packet-hdfsdata.c b/epan/dissectors/packet-hdfsdata.c index a092a899a5..5d2520d1b8 100644 --- a/epan/dissectors/packet-hdfsdata.c +++ b/epan/dissectors/packet-hdfsdata.c @@ -28,7 +28,6 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> #include "packet-tcp.h" void proto_register_hdfsdata(void); @@ -67,8 +66,6 @@ static const int RESPONSE_METADATA = 2; static const int RESPONSE_DATA = 3; #endif -static guint tcp_port = 0; - static int proto_hdfsdata = -1; static int hf_hdfsdata_version = -1; static int hf_hdfsdata_cmd = -1; @@ -772,26 +769,11 @@ proto_register_hdfsdata(void) &ett_hdfsdata }; - module_t *hdfsdata_module; - - proto_hdfsdata = proto_register_protocol ( - "HDFSDATA Protocol", /* name */ - "HDFSDATA", /* short name */ - "hdfsdata" /* abbrev */ - ); + proto_hdfsdata = proto_register_protocol ("HDFSDATA Protocol", "HDFSDATA", "hdfsdata"); proto_register_field_array(proto_hdfsdata, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - hdfsdata_module = prefs_register_protocol(proto_hdfsdata, proto_reg_handoff_hdfsdata); - - prefs_register_uint_preference(hdfsdata_module, - "tcp.port", - "TCP port for HDFSDATA", - "Set the TCP port for HDFSDATA", - 10, - &tcp_port); - hdfsdata_handle = register_dissector("hdfsdata", dissect_hdfsdata, proto_hdfsdata); } @@ -799,21 +781,7 @@ proto_register_hdfsdata(void) void proto_reg_handoff_hdfsdata(void) { - static gboolean initialized = FALSE; - static guint saved_tcp_port; - - if (!initialized) { - dissector_add_for_decode_as("tcp.port", hdfsdata_handle); - initialized = TRUE; - } else if (saved_tcp_port != 0) { - dissector_delete_uint("tcp.port", saved_tcp_port, hdfsdata_handle); - } - - if (tcp_port != 0) { - dissector_add_uint("tcp.port", tcp_port, hdfsdata_handle); - } - - saved_tcp_port = tcp_port; + dissector_add_for_decode_as_with_preference("tcp.port", hdfsdata_handle); } /* * Editor modelines diff --git a/epan/dissectors/packet-hiqnet.c b/epan/dissectors/packet-hiqnet.c index 98bea90131..374442066d 100644 --- a/epan/dissectors/packet-hiqnet.c +++ b/epan/dissectors/packet-hiqnet.c @@ -1819,7 +1819,7 @@ proto_reg_handoff_hiqnet(void) hiqnet_udp_handle = create_dissector_handle(dissect_hiqnet_udp, proto_hiqnet); hiqnet_tcp_handle = create_dissector_handle(dissect_hiqnet_tcp, proto_hiqnet); dissector_add_uint("udp.port", HIQNET_PORT, hiqnet_udp_handle); - dissector_add_uint("tcp.port", HIQNET_PORT, hiqnet_tcp_handle); + dissector_add_uint_with_preference("tcp.port", HIQNET_PORT, hiqnet_tcp_handle); } /* diff --git a/epan/dissectors/packet-hislip.c b/epan/dissectors/packet-hislip.c index 1046411ef7..400dfc1cf7 100644 --- a/epan/dissectors/packet-hislip.c +++ b/epan/dissectors/packet-hislip.c @@ -104,8 +104,7 @@ typedef struct _hislipinfo void proto_register_hislip(void); void proto_reg_handoff_hislip(void); -static gint global_hislip_port = 4880; - +#define HISLIP_PORT 4880 /*Field indexs*/ static gint hf_hislip_messagetype = -1; @@ -1011,14 +1010,7 @@ proto_register_hislip(void) proto_register_field_array(proto_hislip, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - hislip_module = prefs_register_protocol(proto_hislip, proto_reg_handoff_hislip); - - prefs_register_uint_preference(hislip_module, - "tcp.port", - "TCP port for HiSLIP", - "Set the TCP port for HiSLIP traffic if other than the default", - 10, - &global_hislip_port); + hislip_module = prefs_register_protocol(proto_hislip, NULL); prefs_register_obsolete_preference(hislip_module, "enable_heuristic"); } @@ -1026,24 +1018,11 @@ proto_register_hislip(void) void proto_reg_handoff_hislip(void) { - static gboolean initialized = FALSE; - static int currentPort; - - if (!initialized) - { - hislip_handle = create_dissector_handle(dissect_hislip, proto_hislip); - /* disabled by default since heuristic is weak */ - heur_dissector_add("tcp", dissect_hislip_heur, "HiSLIP over TCP", "hislip_tcp", proto_hislip, HEURISTIC_DISABLE); - initialized = TRUE; - } - else - { - dissector_delete_uint("tcp.port", currentPort, hislip_handle); - } - - currentPort = global_hislip_port; + hislip_handle = create_dissector_handle(dissect_hislip, proto_hislip); + /* disabled by default since heuristic is weak */ + heur_dissector_add("tcp", dissect_hislip_heur, "HiSLIP over TCP", "hislip_tcp", proto_hislip, HEURISTIC_DISABLE); - dissector_add_uint("tcp.port", currentPort, hislip_handle); + dissector_add_uint_with_preference("tcp.port", HISLIP_PORT, hislip_handle); } /* diff --git a/epan/dissectors/packet-hpfeeds.c b/epan/dissectors/packet-hpfeeds.c index 532995edef..ac0995ae05 100644 --- a/epan/dissectors/packet-hpfeeds.c +++ b/epan/dissectors/packet-hpfeeds.c @@ -65,7 +65,6 @@ void proto_reg_handoff_hpfeeds(void); static heur_dissector_list_t heur_subdissector_list; /* Preferences */ -static guint hpfeeds_port_pref = 0; static gboolean hpfeeds_desegment = TRUE; static gboolean try_heuristic = TRUE; @@ -467,7 +466,7 @@ proto_register_hpfeeds(void) expert_hpfeeds = expert_register_protocol(proto_hpfeeds); expert_register_field_array(expert_hpfeeds, ei, array_length(ei)); - hpfeeds_module = prefs_register_protocol(proto_hpfeeds, proto_reg_handoff_hpfeeds); + hpfeeds_module = prefs_register_protocol(proto_hpfeeds, NULL); prefs_register_bool_preference(hpfeeds_module, "desegment_hpfeeds_messages", "Reassemble HPFEEDS messages spanning multiple TCP segments", "Whether the HPFEEDS dissector should reassemble messages spanning " @@ -476,12 +475,6 @@ proto_register_hpfeeds(void) "reassemble TCP streams\" in the TCP protocol settings.", &hpfeeds_desegment); - prefs_register_uint_preference(hpfeeds_module, - "dissector_port", - "Dissector TCP port", - "Set the TCP port for HPFEEDS messages", - 10, &hpfeeds_port_pref); - prefs_register_bool_preference(hpfeeds_module, "try_heuristic", "Try heuristic sub-dissectors", "Try to decode the payload using an heuristic sub-dissector", @@ -493,22 +486,12 @@ proto_register_hpfeeds(void) void proto_reg_handoff_hpfeeds(void) { - static dissector_handle_t hpfeeds_handle; - static gboolean hpfeeds_prefs_initialized = FALSE; - static gint16 hpfeeds_dissector_port; - - if (!hpfeeds_prefs_initialized) { - hpfeeds_handle = create_dissector_handle(dissect_hpfeeds, proto_hpfeeds); - stats_tree_register("hpfeeds", "hpfeeds", "HPFEEDS", 0, hpfeeds_stats_tree_packet, hpfeeds_stats_tree_init, NULL); - hpfeeds_prefs_initialized = TRUE; - } - else { - dissector_delete_uint("tcp.port",hpfeeds_dissector_port , hpfeeds_handle); - } + dissector_handle_t hpfeeds_handle; - hpfeeds_dissector_port = hpfeeds_port_pref; + hpfeeds_handle = create_dissector_handle(dissect_hpfeeds, proto_hpfeeds); + stats_tree_register("hpfeeds", "hpfeeds", "HPFEEDS", 0, hpfeeds_stats_tree_packet, hpfeeds_stats_tree_init, NULL); - dissector_add_uint("tcp.port", hpfeeds_dissector_port, hpfeeds_handle); + dissector_add_for_decode_as_with_preference("tcp.port", hpfeeds_handle); } /* diff --git a/epan/dissectors/packet-hsms.c b/epan/dissectors/packet-hsms.c index c56a837956..211d8e8e71 100644 --- a/epan/dissectors/packet-hsms.c +++ b/epan/dissectors/packet-hsms.c @@ -1,4 +1,4 @@ -/* packet-HSMS.c +/* packet-hsms.c * Routines for High-speed SECS message service dissection * Copyright 2016, Benjamin Parzella <bparzella@gmail.com> * @@ -766,7 +766,7 @@ proto_reg_handoff_hsms(void) hsms_handle = create_dissector_handle(dissect_hsms, proto_hsms); - dissector_add_for_decode_as("tcp.port", hsms_handle); + dissector_add_for_decode_as_with_preference("tcp.port", hsms_handle); } /* diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c index 0d2d41a798..2c7f724817 100644 --- a/epan/dissectors/packet-http.c +++ b/epan/dissectors/packet-http.c @@ -286,7 +286,6 @@ static gboolean http_decompress_body = FALSE; #define UPGRADE_SSTP 3 #define UPGRADE_SPDY 4 -static range_t *global_http_tcp_range = NULL; static range_t *global_http_sctp_range = NULL; static range_t *global_http_ssl_range = NULL; @@ -3267,11 +3266,6 @@ range_add_http_ssl_callback(guint32 port) { } static void reinit_http(void) { - dissector_delete_uint_range("tcp.port", http_tcp_range, http_tcp_handle); - g_free(http_tcp_range); - http_tcp_range = range_copy(global_http_tcp_range); - dissector_add_uint_range("tcp.port", http_tcp_range, http_tcp_handle); - dissector_delete_uint_range("sctp.port", http_sctp_range, http_sctp_handle); g_free(http_sctp_range); http_sctp_range = range_copy(global_http_sctp_range); @@ -3626,12 +3620,6 @@ proto_register_http(void) #endif prefs_register_obsolete_preference(http_module, "tcp_alternate_port"); - range_convert_str(&global_http_tcp_range, TCP_DEFAULT_RANGE, 65535); - http_tcp_range = range_empty(); - prefs_register_range_preference(http_module, "tcp.port", "TCP Ports", - "TCP Ports range", - &global_http_tcp_range, 65535); - range_convert_str(&global_http_sctp_range, SCTP_DEFAULT_RANGE, 65535); http_sctp_range = range_empty(); prefs_register_range_preference(http_module, "sctp.port", "SCTP Ports", @@ -3712,7 +3700,7 @@ http_tcp_dissector_add(guint32 port, dissector_handle_t handle) { /* * Register ourselves as the handler for that port number - * over TCP. + * over TCP. "Auto-preference" not needed */ dissector_add_uint("tcp.port", port, http_tcp_handle); @@ -3722,6 +3710,21 @@ http_tcp_dissector_add(guint32 port, dissector_handle_t handle) dissector_add_uint("http.port", port, handle); } +WS_DLL_PUBLIC +void http_tcp_dissector_delete(guint32 port) +{ + /* + * Unregister ourselves as the handler for that port number + * over TCP. "Auto-preference" not needed + */ + dissector_delete_uint("tcp.port", port, NULL); + + /* + * And unregister them in *our* table for that port. + */ + dissector_delete_uint("http.port", port, NULL); +} + void http_tcp_port_add(guint32 port) { @@ -3729,6 +3732,7 @@ http_tcp_port_add(guint32 port) * Register ourselves as the handler for that port number * over TCP. We rely on our caller having registered * themselves for the appropriate media type. + * No "auto-preference" used. */ dissector_add_uint("tcp.port", port, http_tcp_handle); } @@ -3820,6 +3824,8 @@ proto_reg_handoff_message_http(void) proto_http2 = proto_get_id_by_filter_name("http2"); + dissector_add_uint_range_with_preference("tcp.port", TCP_DEFAULT_RANGE, http_tcp_handle); + reinit_http(); } diff --git a/epan/dissectors/packet-http.h b/epan/dissectors/packet-http.h index 2ff906ca57..dfa65cbbd0 100644 --- a/epan/dissectors/packet-http.h +++ b/epan/dissectors/packet-http.h @@ -30,6 +30,8 @@ extern const value_string vals_http_status_code[]; WS_DLL_PUBLIC void http_tcp_dissector_add(guint32 port, dissector_handle_t handle); WS_DLL_PUBLIC +void http_tcp_dissector_delete(guint32 port); +WS_DLL_PUBLIC void http_tcp_port_add(guint32 port); /* Used for HTTP statistics */ diff --git a/epan/dissectors/packet-http2.c b/epan/dissectors/packet-http2.c index 57d50674cf..41c2c89677 100644 --- a/epan/dissectors/packet-http2.c +++ b/epan/dissectors/packet-http2.c @@ -1971,7 +1971,7 @@ static int http2_stats_tree_packet(stats_tree* st, packet_info* pinfo _U_, epan_ void proto_reg_handoff_http2(void) { - dissector_add_for_decode_as("tcp.port", http2_handle); + dissector_add_for_decode_as_with_preference("tcp.port", http2_handle); heur_dissector_add("ssl", dissect_http2_heur_ssl, "HTTP2 over SSL", "http2_ssl", proto_http2, HEURISTIC_ENABLE); heur_dissector_add("http", dissect_http2_heur, "HTTP2 over TCP", "http2_tcp", proto_http2, HEURISTIC_ENABLE); diff --git a/epan/dissectors/packet-icap.c b/epan/dissectors/packet-icap.c index 026b8718be..5ee8d5d571 100644 --- a/epan/dissectors/packet-icap.c +++ b/epan/dissectors/packet-icap.c @@ -323,7 +323,7 @@ proto_reg_handoff_icap(void) http_handle = find_dissector_add_dependency("http", proto_icap); icap_handle = create_dissector_handle(dissect_icap, proto_icap); - dissector_add_uint("tcp.port", TCP_PORT_ICAP, icap_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_ICAP, icap_handle); } /* diff --git a/epan/dissectors/packet-icep.c b/epan/dissectors/packet-icep.c index 5bb16fe117..fe9344f1b7 100644 --- a/epan/dissectors/packet-icep.c +++ b/epan/dissectors/packet-icep.c @@ -124,7 +124,6 @@ static expert_field ei_icep_context_too_long = EI_INIT; static guint icep_max_batch_requests = 64; static guint icep_max_ice_string_len = 512; static guint icep_max_ice_context_pairs = 64; -static guint icep_tcp_port = 0; static guint icep_udp_port = 0; @@ -1295,13 +1294,6 @@ void proto_register_icep(void) expert_register_field_array(expert_icep, ei, array_length(ei)); icep_module = prefs_register_protocol(proto_icep, NULL); - - prefs_register_uint_preference(icep_module, "tcp.port", - "ICEP TCP Port", - "ICEP TCP port", - 10, - &icep_tcp_port); - prefs_register_uint_preference(icep_module, "udp.port", "ICEP UDP Port", "ICEP UDP port", @@ -1329,7 +1321,6 @@ void proto_reg_handoff_icep(void) { static gboolean icep_prefs_initialized = FALSE; static dissector_handle_t icep_tcp_handle, icep_udp_handle; - static guint old_icep_tcp_port = 0; static guint old_icep_udp_port = 0; /* Register as a heuristic TCP/UDP dissector */ @@ -1340,20 +1331,12 @@ void proto_reg_handoff_icep(void) heur_dissector_add("tcp", dissect_icep_tcp, "ICEP over TCP", "icep_tcp", proto_icep, HEURISTIC_ENABLE); heur_dissector_add("udp", dissect_icep_udp, "ICEP over UDP", "icep_udp", proto_icep, HEURISTIC_ENABLE); - icep_prefs_initialized = TRUE; - } + /* Register TCP port for dissection */ + dissector_add_for_decode_as_with_preference("tcp.port", icep_tcp_handle); - /* Register TCP port for dissection */ - if(old_icep_tcp_port != 0 && old_icep_tcp_port != icep_tcp_port){ - dissector_delete_uint("tcp.port", old_icep_tcp_port, icep_tcp_handle); - } - - if(icep_tcp_port != 0 && old_icep_tcp_port != icep_tcp_port) { - dissector_add_uint("tcp.port", icep_tcp_port, icep_tcp_handle); + icep_prefs_initialized = TRUE; } - old_icep_tcp_port = icep_tcp_port; - /* Register UDP port for dissection */ if(old_icep_udp_port != 0 && old_icep_udp_port != icep_udp_port){ dissector_delete_uint("udp.port", old_icep_udp_port, icep_udp_handle); diff --git a/epan/dissectors/packet-idmp.c b/epan/dissectors/packet-idmp.c index e5bd4cb574..bf0816559b 100644 --- a/epan/dissectors/packet-idmp.c +++ b/epan/dissectors/packet-idmp.c @@ -55,13 +55,11 @@ void proto_register_idmp(void); void proto_reg_handoff_idm(void); -static void prefs_register_idmp(void); /* forward declaration for use in preferences registration */ void register_idmp_protocol_info(const char *oid, const ros_info_t *rinfo, int proto _U_, const char *name); static gboolean idmp_desegment = TRUE; -static guint global_idmp_tcp_port = 1102; /* made up for now */ +#define IDMP_TCP_PORT 1102 /* made up for now - not IANA registered */ static gboolean idmp_reassemble = TRUE; -static guint tcp_port = 0; static dissector_handle_t idmp_handle = NULL; static proto_tree *top_tree = NULL; @@ -173,7 +171,7 @@ static int hf_idmp_present = -1; /* INTEGER */ static int hf_idmp_absent = -1; /* NULL */ /*--- End of included file: packet-idmp-hf.c ---*/ -#line 132 "./asn1/idmp/packet-idmp-template.c" +#line 130 "./asn1/idmp/packet-idmp-template.c" /* Initialize the subtree pointers */ static gint ett_idmp = -1; @@ -192,7 +190,7 @@ static gint ett_idmp_Code = -1; static gint ett_idmp_InvokeId = -1; /*--- End of included file: packet-idmp-ett.c ---*/ -#line 136 "./asn1/idmp/packet-idmp-template.c" +#line 134 "./asn1/idmp/packet-idmp-template.c" /*--- Included file: packet-idmp-fn.c ---*/ @@ -620,7 +618,7 @@ dissect_idmp_IDM_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U /*--- End of included file: packet-idmp-fn.c ---*/ -#line 138 "./asn1/idmp/packet-idmp-template.c" +#line 136 "./asn1/idmp/packet-idmp-template.c" void register_idmp_protocol_info(const char *oid, const ros_info_t *rinfo, int proto _U_, const char *name) @@ -936,7 +934,7 @@ void proto_register_idmp(void) NULL, HFILL }}, /*--- End of included file: packet-idmp-hfarr.c ---*/ -#line 321 "./asn1/idmp/packet-idmp-template.c" +#line 319 "./asn1/idmp/packet-idmp-template.c" }; /* List of subtrees */ @@ -959,7 +957,7 @@ void proto_register_idmp(void) &ett_idmp_InvokeId, /*--- End of included file: packet-idmp-ettarr.c ---*/ -#line 329 "./asn1/idmp/packet-idmp-template.c" +#line 327 "./asn1/idmp/packet-idmp-template.c" }; module_t *idmp_module; @@ -977,7 +975,7 @@ void proto_register_idmp(void) /* Register our configuration options for IDMP, particularly our port */ - idmp_module = prefs_register_protocol_subtree("OSI/X.500", proto_idmp, prefs_register_idmp); + idmp_module = prefs_register_protocol_subtree("OSI/X.500", proto_idmp, NULL); prefs_register_bool_preference(idmp_module, "desegment_idmp_messages", "Reassemble IDMP messages spanning multiple TCP segments", @@ -991,33 +989,10 @@ void proto_register_idmp(void) " To use this option, you must also enable" " \"Allow subdissectors to reassemble TCP streams\"" " in the TCP protocol settings.", &idmp_reassemble); - - prefs_register_uint_preference(idmp_module, "tcp.port", "IDMP TCP Port", - "Set the port for Internet Directly Mapped Protocol requests/responses", - 10, &global_idmp_tcp_port); - } /*--- proto_reg_handoff_idm --- */ void proto_reg_handoff_idm(void) { - -} - - -static void -prefs_register_idmp(void) -{ - - /* de-register the old port */ - /* port 102 is registered by TPKT - don't undo this! */ - if(idmp_handle) - dissector_delete_uint("tcp.port", tcp_port, idmp_handle); - - /* Set our port number for future use */ - tcp_port = global_idmp_tcp_port; - - if((tcp_port > 0) && idmp_handle) - dissector_add_uint("tcp.port", global_idmp_tcp_port, idmp_handle); - + dissector_add_uint_with_preference("tcp.port", IDMP_TCP_PORT, idmp_handle); } diff --git a/epan/dissectors/packet-iec104.c b/epan/dissectors/packet-iec104.c index 8507fbd10d..47a6164d63 100644 --- a/epan/dissectors/packet-iec104.c +++ b/epan/dissectors/packet-iec104.c @@ -34,6 +34,7 @@ #include <epan/packet.h> #include <epan/prefs.h> +#include <epan/prefs-int.h> #include <epan/expert.h> #include "packet-tcp.h" @@ -76,7 +77,8 @@ typedef struct { gboolean SE; /* Select (1) / Execute (0) */ } td_CmdInfo; -static guint iec104_port = 2404; +#define IEC104_PORT 2404 +static guint iec104_port = IEC104_PORT; /* Define the iec104 proto */ static int proto_iec104apci = -1; @@ -1488,6 +1490,14 @@ static int dissect_iec104reas(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre return tvb_captured_length(tvb); } +static void +apply_iec104_prefs(void) +{ + /* IEC104 uses the port preference to determine direction */ + pref_t *iec104_port_pref = prefs_find_preference(prefs_find_module("104apci"), "tcp.port"); + iec104_port = *iec104_port_pref->varp.uint; +} + /* The protocol has two subprotocols: Register APCI */ void proto_register_iec104apci(void) @@ -1523,22 +1533,12 @@ proto_register_iec104apci(void) &ett_apci, }; - module_t *iec104_module; + proto_iec104apci = proto_register_protocol("IEC 60870-5-104-Apci", "104apci", "104apci"); - proto_iec104apci = proto_register_protocol( - "IEC 60870-5-104-Apci", - "104apci", - "104apci" - ); proto_register_field_array(proto_iec104apci, hf_ap, array_length(hf_ap)); proto_register_subtree_array(ett_ap, array_length(ett_ap)); - iec104_module = prefs_register_protocol(proto_iec104apci, proto_reg_handoff_iec104); - - prefs_register_uint_preference(iec104_module, "tcp.port", - "IEC104 TCP port used by source", - "TCP port used by source of IEC104, usually 2404", - 10, &iec104_port); + prefs_register_protocol(proto_iec104apci, apply_iec104_prefs); } @@ -1846,11 +1846,7 @@ proto_register_iec104asdu(void) expert_module_t* expert_iec104; - proto_iec104asdu = proto_register_protocol( - "IEC 60870-5-104-Asdu", - "104asdu", - "104asdu" - ); + proto_iec104asdu = proto_register_protocol("IEC 60870-5-104-Asdu", "104asdu", "104asdu"); proto_register_field_array(proto_iec104asdu, hf_as, array_length(hf_as)); proto_register_subtree_array(ett_as, array_length(ett_as)); @@ -1864,22 +1860,12 @@ proto_register_iec104asdu(void) void proto_reg_handoff_iec104(void) { - static dissector_handle_t iec104apci_handle; - static gboolean iec104_prefs_initialized = FALSE; - static guint saved_iec104_port; - - if (!iec104_prefs_initialized) { - iec104apci_handle = create_dissector_handle(dissect_iec104reas, proto_iec104apci); - iec104asdu_handle = create_dissector_handle(dissect_iec104asdu, proto_iec104asdu); - dissector_add_uint("tcp.port", iec104_port, iec104apci_handle); - } else { - dissector_delete_uint("tcp.port", saved_iec104_port, iec104apci_handle); - } + dissector_handle_t iec104apci_handle; - saved_iec104_port = iec104_port; - if (iec104_port != 0) { - dissector_add_uint("tcp.port", iec104_port, iec104apci_handle); - } + iec104apci_handle = create_dissector_handle(dissect_iec104reas, proto_iec104apci); + iec104asdu_handle = create_dissector_handle(dissect_iec104asdu, proto_iec104asdu); + + dissector_add_uint_with_preference("tcp.port", IEC104_PORT, iec104apci_handle); } /* diff --git a/epan/dissectors/packet-ifcp.c b/epan/dissectors/packet-ifcp.c index 1d519927d3..aa705f9516 100644 --- a/epan/dissectors/packet-ifcp.c +++ b/epan/dissectors/packet-ifcp.c @@ -610,7 +610,7 @@ proto_reg_handoff_ifcp (void) heur_dissector_add("tcp", dissect_ifcp_heur, "iFCP over TCP", "ifcp_tcp", proto_ifcp, HEURISTIC_ENABLE); ifcp_handle = create_dissector_handle(dissect_ifcp_handle, proto_ifcp); - dissector_add_for_decode_as("tcp.port", ifcp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", ifcp_handle); fc_handle = find_dissector_add_dependency("fc_ifcp", proto_ifcp); } diff --git a/epan/dissectors/packet-ilp.c b/epan/dissectors/packet-ilp.c index 868285c3a7..44516691a5 100644 --- a/epan/dissectors/packet-ilp.c +++ b/epan/dissectors/packet-ilp.c @@ -58,7 +58,7 @@ static dissector_handle_t ilp_handle; /* IANA Registered Ports * oma-ilp 7276/tcp OMA Internal Location */ -static guint gbl_ilp_port = 7276; +#define ILP_TCP_PORT 7276 /* Initialize the protocol and registered fields */ static int proto_ilp = -1; @@ -5863,21 +5863,13 @@ void proto_register_ilp(void) { proto_register_field_array(proto_ilp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - ilp_module = prefs_register_protocol(proto_ilp,proto_reg_handoff_ilp); + ilp_module = prefs_register_protocol(proto_ilp, NULL); prefs_register_bool_preference(ilp_module, "desegment_ilp_messages", "Reassemble ILP messages spanning multiple TCP segments", "Whether the ILP dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &ilp_desegment); - - /* Register a configuration option for port */ - prefs_register_uint_preference(ilp_module, "tcp.port", - "ILP TCP Port", - "Set the TCP port for ILP messages(IANA registered port is 7276)", - 10, - &gbl_ilp_port); - } @@ -5885,18 +5877,9 @@ void proto_register_ilp(void) { void proto_reg_handoff_ilp(void) { - static gboolean initialized = FALSE; - static guint local_ilp_port; - - if (!initialized) { - dissector_add_string("media_type","application/oma-supl-ilp", ilp_handle); - rrlp_handle = find_dissector_add_dependency("rrlp", proto_ilp); - lpp_handle = find_dissector_add_dependency("lpp", proto_ilp); - initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", local_ilp_port, ilp_handle); - } + dissector_add_string("media_type","application/oma-supl-ilp", ilp_handle); + rrlp_handle = find_dissector_add_dependency("rrlp", proto_ilp); + lpp_handle = find_dissector_add_dependency("lpp", proto_ilp); - local_ilp_port = gbl_ilp_port; - dissector_add_uint("tcp.port", gbl_ilp_port, ilp_handle); + dissector_add_uint_with_preference("tcp.port", ILP_TCP_PORT, ilp_handle); } diff --git a/epan/dissectors/packet-imap.c b/epan/dissectors/packet-imap.c index 8379bc5618..b49a5aed51 100644 --- a/epan/dissectors/packet-imap.c +++ b/epan/dissectors/packet-imap.c @@ -425,7 +425,7 @@ proto_register_imap(void) void proto_reg_handoff_imap(void) { - dissector_add_uint("tcp.port", TCP_PORT_IMAP, imap_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_IMAP, imap_handle); ssl_dissector_add(TCP_PORT_SSL_IMAP, imap_handle); ssl_handle = find_dissector("ssl"); } diff --git a/epan/dissectors/packet-ipdc.c b/epan/dissectors/packet-ipdc.c index fb569ad83b..66667c7c24 100644 --- a/epan/dissectors/packet-ipdc.c +++ b/epan/dissectors/packet-ipdc.c @@ -49,7 +49,7 @@ void proto_register_ipdc(void); void proto_reg_handoff_ipdc(void); -#define TCP_PORT_IPDC 6668 +#define TCP_PORT_IPDC 6668 /* Not IANA registered */ #define TRANS_ID_SIZE_IPDC 4 #define TEXT_UNDEFINED "UNDEFINED" @@ -708,7 +708,6 @@ static gint ett_ipdc_line_status = -1; static expert_field ei_ipdc_ipv4 = EI_INIT; static gboolean ipdc_desegment = TRUE; -static guint ipdc_port_pref = TCP_PORT_IPDC; static dissector_handle_t q931_handle; @@ -1079,29 +1078,18 @@ proto_register_ipdc(void) "Whether the IPDC dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &ipdc_desegment); - prefs_register_uint_preference(ipdc_module, "tcp.port", - "IPDC monitoring port", - "Set the IPDC monitoring port", 10, - &ipdc_port_pref); } void proto_reg_handoff_ipdc(void) { - static guint last_ipdc_port_pref = 0; static dissector_handle_t ipdc_tcp_handle = NULL; - if (ipdc_tcp_handle) { - dissector_delete_uint("tcp.port", last_ipdc_port_pref, - ipdc_tcp_handle); - } else { - ipdc_tcp_handle = - create_dissector_handle(dissect_ipdc_tcp, proto_ipdc); - q931_handle = find_dissector_add_dependency("q931", proto_ipdc); - } + ipdc_tcp_handle = + create_dissector_handle(dissect_ipdc_tcp, proto_ipdc); + q931_handle = find_dissector_add_dependency("q931", proto_ipdc); - last_ipdc_port_pref = ipdc_port_pref; - dissector_add_uint("tcp.port", ipdc_port_pref, ipdc_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_IPDC, ipdc_tcp_handle); } /* diff --git a/epan/dissectors/packet-ipdr.c b/epan/dissectors/packet-ipdr.c index f9bc12b1e0..dcba9b86ee 100644 --- a/epan/dissectors/packet-ipdr.c +++ b/epan/dissectors/packet-ipdr.c @@ -369,7 +369,7 @@ proto_reg_handoff_ipdr(void) dissector_handle_t ipdr_handle; ipdr_handle = create_dissector_handle(dissect_ipdr, proto_ipdr); - dissector_add_uint("tcp.port", IPDR_PORT, ipdr_handle); + dissector_add_uint_with_preference("tcp.port", IPDR_PORT, ipdr_handle); } /* diff --git a/epan/dissectors/packet-ipsec-tcp.c b/epan/dissectors/packet-ipsec-tcp.c index 9941c269a7..fd4e333cb4 100644 --- a/epan/dissectors/packet-ipsec-tcp.c +++ b/epan/dissectors/packet-ipsec-tcp.c @@ -32,7 +32,6 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> #include "packet-ndmp.h" void proto_register_tcpencap(void); @@ -67,11 +66,6 @@ static const value_string tcpencap_proto_vals[] = { #define TRAILERLENGTH 16 #define TCP_CISCO_IPSEC 10000 -/* Another case of several companies creating protocols and - choosing an easy-to-remember port. Playing tonight: Cisco vs NDMP. - Since NDMP has officially registered port 10000 with IANA, it should be the default -*/ -static guint global_tcpencap_tcp_port = 0; static dissector_handle_t esp_handle; static dissector_handle_t udp_handle; @@ -224,43 +218,25 @@ proto_register_tcpencap(void) &ett_tcpencap_unknown, }; - module_t *tcpencap_module; + proto_tcpencap = proto_register_protocol("TCP Encapsulation of IPsec Packets", "TCPENCAP", "tcpencap"); - proto_tcpencap = proto_register_protocol( - "TCP Encapsulation of IPsec Packets", "TCPENCAP", "tcpencap"); proto_register_field_array(proto_tcpencap, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - tcpencap_module = prefs_register_protocol(proto_tcpencap, proto_reg_handoff_tcpencap); - prefs_register_uint_preference(tcpencap_module, "tcp.port", "IPSEC TCP Port", - "Set the port for IPSEC/ISAKMP messages (typically 10000)", - 10, &global_tcpencap_tcp_port); } void proto_reg_handoff_tcpencap(void) { - static dissector_handle_t tcpencap_handle; - static gboolean initialized = FALSE; - static guint tcpencap_tcp_port = 0; + dissector_handle_t tcpencap_handle; - if (!initialized) { - tcpencap_handle = create_dissector_handle(dissect_tcpencap, proto_tcpencap); - esp_handle = find_dissector_add_dependency("esp", proto_tcpencap); - udp_handle = find_dissector_add_dependency("udp", proto_tcpencap); + tcpencap_handle = create_dissector_handle(dissect_tcpencap, proto_tcpencap); + esp_handle = find_dissector_add_dependency("esp", proto_tcpencap); + udp_handle = find_dissector_add_dependency("udp", proto_tcpencap); - heur_dissector_add("tcp", dissect_tcpencap_heur, "TCP Encapsulation of IPsec Packets", "ipsec_tcp", proto_tcpencap, HEURISTIC_ENABLE); - - initialized = TRUE; - } + heur_dissector_add("tcp", dissect_tcpencap_heur, "TCP Encapsulation of IPsec Packets", "ipsec_tcp", proto_tcpencap, HEURISTIC_ENABLE); /* Register TCP port for dissection */ - if(tcpencap_tcp_port != 0 && tcpencap_tcp_port != global_tcpencap_tcp_port){ - dissector_delete_uint("tcp.port", tcpencap_tcp_port, tcpencap_handle); - } - - if(global_tcpencap_tcp_port != 0 && tcpencap_tcp_port != global_tcpencap_tcp_port) { - dissector_add_uint("tcp.port", global_tcpencap_tcp_port, tcpencap_handle); - } + dissector_add_for_decode_as_with_preference("tcp.port", tcpencap_handle); } /* diff --git a/epan/dissectors/packet-ipsi-ctl.c b/epan/dissectors/packet-ipsi-ctl.c index bc22f520b4..b3cd065786 100644 --- a/epan/dissectors/packet-ipsi-ctl.c +++ b/epan/dissectors/packet-ipsi-ctl.c @@ -31,7 +31,7 @@ void proto_register_ipsictl(void); void proto_reg_handoff_ipsictl(void); -#define IPSICTL_PORT 5010 +#define IPSICTL_PORT 5010 /* Not IANA registered */ #define IPSICTL_PDU_MAGIC 0x0300 static int proto_ipsictl = -1; @@ -237,7 +237,7 @@ void proto_reg_handoff_ipsictl(void) ipsictl_handle = create_dissector_handle(dissect_ipsictl, proto_ipsictl); - dissector_add_uint("tcp.port", IPSICTL_PORT, ipsictl_handle); + dissector_add_uint_with_preference("tcp.port", IPSICTL_PORT, ipsictl_handle); } diff --git a/epan/dissectors/packet-irc.c b/epan/dissectors/packet-irc.c index 4a50e8c055..107a9ea450 100644 --- a/epan/dissectors/packet-irc.c +++ b/epan/dissectors/packet-irc.c @@ -79,9 +79,7 @@ static const guint8 TAG_DELIMITER[] = {0x01, 0x00}; static ws_mempbrk_pattern pbrk_tag_delimiter; -#define TCP_PORT_IRC 6667 -#define TCP_PORT_DIRCPROXY 57000 - /* good candidate for dynamic port specification */ +#define TCP_PORT_RANGE "6667,57000" /* Not IANA registered */ static void dissect_irc_tag_data(proto_tree *tree, proto_item *item, tvbuff_t *tvb, int offset, int datalen, packet_info *pinfo, const guint8* command) @@ -571,8 +569,7 @@ proto_reg_handoff_irc(void) dissector_handle_t irc_handle; irc_handle = create_dissector_handle(dissect_irc, proto_irc); - dissector_add_uint("tcp.port", TCP_PORT_IRC, irc_handle); - dissector_add_uint("tcp.port", TCP_PORT_DIRCPROXY, irc_handle); + dissector_add_uint_range_with_preference("tcp.port", TCP_PORT_RANGE, irc_handle); } /* diff --git a/epan/dissectors/packet-isakmp.c b/epan/dissectors/packet-isakmp.c index 963ccea286..1fb812d20c 100644 --- a/epan/dissectors/packet-isakmp.c +++ b/epan/dissectors/packet-isakmp.c @@ -7151,7 +7151,7 @@ proto_reg_handoff_isakmp(void) isakmp_handle = find_dissector("isakmp"); eap_handle = find_dissector_add_dependency("eap", proto_isakmp); dissector_add_uint("udp.port", UDP_PORT_ISAKMP, isakmp_handle); - dissector_add_uint("tcp.port", TCP_PORT_ISAKMP, isakmp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_ISAKMP, isakmp_handle); } /* diff --git a/epan/dissectors/packet-iscsi.c b/epan/dissectors/packet-iscsi.c index 8c58d7b98a..fd8e00fbef 100644 --- a/epan/dissectors/packet-iscsi.c +++ b/epan/dissectors/packet-iscsi.c @@ -3081,6 +3081,11 @@ proto_register_iscsi(void) /* #endif */ }; + static ei_register_info ei[] = { + { &ei_iscsi_keyvalue_invalid, { "iscsi.keyvalue.invalid", PI_MALFORMED, PI_ERROR, + "Invalid key/value pair", EXPFILL }} + }; + /* Register the protocol name and description */ proto_iscsi = proto_register_protocol("iSCSI", "iSCSI", "iscsi"); iscsi_handle = register_dissector("iscsi", dissect_iscsi_handle, proto_iscsi); @@ -3160,11 +3165,6 @@ proto_register_iscsi(void) prefs_register_obsolete_preference(iscsi_module, "enable_data_digests"); - static ei_register_info ei[] = { - { &ei_iscsi_keyvalue_invalid, { "iscsi.keyvalue.invalid", PI_MALFORMED, PI_ERROR, - "Invalid key/value pair", EXPFILL }} - }; - expert_iscsi = expert_register_protocol(proto_iscsi); expert_register_field_array(expert_iscsi, ei, array_length(ei)); } @@ -3184,7 +3184,7 @@ proto_reg_handoff_iscsi(void) { heur_dissector_add("tcp", dissect_iscsi_heur, "iSCSI over TCP", "iscsi_tcp", proto_iscsi, HEURISTIC_ENABLE); - dissector_add_for_decode_as("tcp.port", iscsi_handle); + dissector_add_for_decode_as_with_preference("tcp.port", iscsi_handle); } /* diff --git a/epan/dissectors/packet-isns.c b/epan/dissectors/packet-isns.c index 109213bf6a..78d852e42d 100644 --- a/epan/dissectors/packet-isns.c +++ b/epan/dissectors/packet-isns.c @@ -1727,7 +1727,7 @@ proto_reg_handoff_isns(void) isns_tcp_handle = create_dissector_handle(dissect_isns_tcp,proto_isns); isns_udp_handle = create_dissector_handle(dissect_isns_udp,proto_isns); - dissector_add_uint("tcp.port",ISNS_TCP_PORT,isns_tcp_handle); + dissector_add_uint_with_preference("tcp.port",ISNS_TCP_PORT,isns_tcp_handle); dissector_add_uint("udp.port",ISNS_UDP_PORT,isns_udp_handle); } diff --git a/epan/dissectors/packet-iso8583.c b/epan/dissectors/packet-iso8583.c index 545073d060..1673bf3053 100644 --- a/epan/dissectors/packet-iso8583.c +++ b/epan/dissectors/packet-iso8583.c @@ -373,9 +373,6 @@ static expert_field ei_iso8583_MALFORMED = EI_INIT; static struct iso_type *data_array = NULL; -/* Global port preference */ -#define iso8583_TCP_PORT 0 - /* Types definitions */ #define ASCII_CHARSET 1 #define NUM_NIBBLE_CHARSET 2 @@ -383,7 +380,6 @@ static struct iso_type *data_array = NULL; #define BIN_BIN_ENC 2 /* Global preference */ -static guint tcp_port_pref = iso8583_TCP_PORT; static gint charset_pref = ASCII_CHARSET; static gint bin_encode_pref = BIN_ASCII_ENC; @@ -1343,8 +1339,7 @@ proto_register_iso8583(void) expert_register_field_array(expert_iso8583, ei, array_length(ei)); /* Register preferences module */ - iso8583_module = prefs_register_protocol(proto_iso8583, - proto_reg_handoff_iso8583); + iso8583_module = prefs_register_protocol(proto_iso8583, NULL); prefs_register_enum_preference(iso8583_module, "len_endian", "Length field endian", @@ -1352,12 +1347,6 @@ proto_register_iso8583(void) &len_byte_order, enumendians, TRUE); - /* Register port preference */ - prefs_register_uint_preference(iso8583_module, "tcp.port", - "iso8583 TCP Port", - " iso8583 TCP port", - 10, &tcp_port_pref); - prefs_register_enum_preference(iso8583_module, "charset", "Charset for numbers", " charset for numbers", @@ -1371,22 +1360,11 @@ proto_register_iso8583(void) void proto_reg_handoff_iso8583(void) { - static gboolean initialized = FALSE; - static dissector_handle_t iso8583_handle; - static int current_port; - - if (!initialized) { - iso8583_handle = create_dissector_handle(dissect_iso8583, - proto_iso8583); - initialized = TRUE; - - } else { - dissector_delete_uint("tcp.port", current_port, iso8583_handle); - } + dissector_handle_t iso8583_handle; - current_port = tcp_port_pref; + iso8583_handle = create_dissector_handle(dissect_iso8583, proto_iso8583); - dissector_add_uint("tcp.port", current_port, iso8583_handle); + dissector_add_for_decode_as_with_preference("tcp.port", iso8583_handle); } /* diff --git a/epan/dissectors/packet-kafka.c b/epan/dissectors/packet-kafka.c index 78185c4a94..0f41a532ac 100644 --- a/epan/dissectors/packet-kafka.c +++ b/epan/dissectors/packet-kafka.c @@ -28,6 +28,7 @@ #include <epan/packet.h> #include <epan/expert.h> #include <epan/prefs.h> +#include <epan/prefs-int.h> #include <epan/proto_data.h> #include "packet-tcp.h" @@ -183,7 +184,6 @@ static const value_string kafka_codecs[] = { }; /* List/range of TCP ports to register */ -static range_t *new_kafka_tcp_range = NULL; static range_t *current_kafka_tcp_range = NULL; typedef struct _kafka_query_response_t { @@ -1203,11 +1203,17 @@ dissect_kafka_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, return tvb_captured_length(tvb); } + +static void +apply_kafka_prefs(void) { + pref_t *kafka_ports = prefs_find_preference(prefs_find_module("kafka"), "tcp.port"); + + current_kafka_tcp_range = range_copy(*kafka_ports->varp.range); +} + void proto_register_kafka(void) { - module_t *kafka_module; - static hf_register_info hf[] = { { &hf_kafka_len, { "Length", "kafka.len", @@ -1439,44 +1445,25 @@ proto_register_kafka(void) expert_module_t* expert_kafka; - proto_kafka = proto_register_protocol("Kafka", - "Kafka", "kafka"); + proto_kafka = proto_register_protocol("Kafka", "Kafka", "kafka"); proto_register_field_array(proto_kafka, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); expert_kafka = expert_register_protocol(proto_kafka); expert_register_field_array(expert_kafka, ei, array_length(ei)); - kafka_module = prefs_register_protocol(proto_kafka, - proto_reg_handoff_kafka); - - /* Preference for list/range of TCP server ports */ - new_kafka_tcp_range = range_empty(); - prefs_register_range_preference(kafka_module, "tcp.ports", "Broker TCP Ports", - "TCP Ports range", - &new_kafka_tcp_range, 65535); - - /* Single-port preference no longer in use */ - prefs_register_obsolete_preference(kafka_module, "tcp.port"); + prefs_register_protocol(proto_kafka, apply_kafka_prefs); } void proto_reg_handoff_kafka(void) { - static gboolean initialized = FALSE; - static dissector_handle_t kafka_handle; + dissector_handle_t kafka_handle; - if (!initialized) { - kafka_handle = create_dissector_handle(dissect_kafka_tcp, - proto_kafka); - initialized = TRUE; - } + kafka_handle = create_dissector_handle(dissect_kafka_tcp, proto_kafka); /* Replace range of ports with current */ - dissector_delete_uint_range("tcp.port", current_kafka_tcp_range, kafka_handle); - g_free(current_kafka_tcp_range); - current_kafka_tcp_range = range_copy(new_kafka_tcp_range); - dissector_add_uint_range("tcp.port", new_kafka_tcp_range, kafka_handle); + dissector_add_uint_range_with_preference("tcp.port", "", kafka_handle); } /* diff --git a/epan/dissectors/packet-kdsp.c b/epan/dissectors/packet-kdsp.c index 8f429098c4..e26586b42d 100644 --- a/epan/dissectors/packet-kdsp.c +++ b/epan/dissectors/packet-kdsp.c @@ -25,14 +25,13 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> #include <epan/expert.h> #include "packet-tcp.h" void proto_register_kdsp(void); void proto_reg_handoff_kdsp(void); -#define KDSP_PORT 2502 +#define KDSP_PORT 2502 /* Not IANA registered */ #define FRAME_HEADER_LEN 12 #define HELLO 1 @@ -100,7 +99,6 @@ void proto_reg_handoff_kdsp(void); static int proto_kdsp = -1; static dissector_table_t subdissector_dlt_table; -static guint global_kdsp_tcp_port = KDSP_PORT; static const value_string packettypenames[] = { {0, "NULL"}, @@ -552,8 +550,6 @@ dissect_kdsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ void proto_register_kdsp(void) { - module_t *kdsp_module; - static hf_register_info hf[] = { { &hf_kdsp_sentinel, { "Sentinel", "kdsp.sentinel", @@ -1132,57 +1128,35 @@ proto_register_kdsp(void) }; expert_module_t* expert_kdsp; - proto_kdsp = proto_register_protocol( - "Kismet Drone/Server Protocol", - "KDSP", - "kdsp" - ); + proto_kdsp = proto_register_protocol("Kismet Drone/Server Protocol", "KDSP", "kdsp"); proto_register_field_array(proto_kdsp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - kdsp_module = prefs_register_protocol(proto_kdsp, proto_reg_handoff_kdsp); expert_kdsp = expert_register_protocol(proto_kdsp); expert_register_field_array(expert_kdsp, ei, array_length(ei)); subdissector_dlt_table = register_dissector_table("kdsp.cpt.dlt", "KDSP DLT Type", proto_kdsp, FT_UINT32, BASE_DEC); - - prefs_register_uint_preference(kdsp_module, "tcp.port", - "Kismet Drone TCP Port", - "Set the port for Kismet Drone/Server messages (if other" - " than the default of 2502)", 10, - &global_kdsp_tcp_port); - } void proto_reg_handoff_kdsp(void) { - static gboolean initialized = FALSE; - static guint tcp_port; - static dissector_handle_t kdsp_handle; + dissector_handle_t kdsp_handle; dissector_handle_t dlt_handle; + /* XXX - Should be done in respective dissectors? */ + kdsp_handle = create_dissector_handle(dissect_kdsp, proto_kdsp); + dlt_handle = find_dissector("radiotap"); + if (dlt_handle) + dissector_add_uint( "kdsp.cpt.dlt", DATALINK_RADIOTAP, dlt_handle); - if (!initialized) { - kdsp_handle = create_dissector_handle(dissect_kdsp, proto_kdsp); - dlt_handle = find_dissector("radiotap"); - if (dlt_handle) - dissector_add_uint( "kdsp.cpt.dlt", DATALINK_RADIOTAP, dlt_handle); - - dlt_handle = find_dissector("wlan"); - if (dlt_handle) - dissector_add_uint( "kdsp.cpt.dlt", DATALINK_WLAN, dlt_handle); - - } else { - dissector_delete_uint("tcp.port", tcp_port, kdsp_handle); - } - - tcp_port = global_kdsp_tcp_port; - - dissector_add_uint("tcp.port", global_kdsp_tcp_port, kdsp_handle); + dlt_handle = find_dissector("wlan"); + if (dlt_handle) + dissector_add_uint( "kdsp.cpt.dlt", DATALINK_WLAN, dlt_handle); + dissector_add_uint_with_preference("tcp.port", KDSP_PORT, kdsp_handle); } /* diff --git a/epan/dissectors/packet-kerberos.c b/epan/dissectors/packet-kerberos.c index 3d1970ae39..57315e2c60 100644 --- a/epan/dissectors/packet-kerberos.c +++ b/epan/dissectors/packet-kerberos.c @@ -5434,7 +5434,7 @@ proto_reg_handoff_kerberos(void) proto_kerberos); dissector_add_uint("udp.port", UDP_PORT_KERBEROS, kerberos_handle_udp); - dissector_add_uint("tcp.port", TCP_PORT_KERBEROS, kerberos_handle_tcp); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_KERBEROS, kerberos_handle_tcp); register_dcerpc_auth_subdissector(DCE_C_AUTHN_LEVEL_CONNECT, DCE_C_RPC_AUTHN_PROTOCOL_GSS_KERBEROS, diff --git a/epan/dissectors/packet-kingfisher.c b/epan/dissectors/packet-kingfisher.c index 57b3c91127..d6cc0f4b1c 100644 --- a/epan/dissectors/packet-kingfisher.c +++ b/epan/dissectors/packet-kingfisher.c @@ -34,11 +34,12 @@ void proto_reg_handoff_kingfisher(void); #define SUPPORT_KINGFISHER_SERIES_2 -#define TCP_PORT_KINGFISHER 4058 #define UDP_PORT_KINGFISHER 4058 #ifdef SUPPORT_KINGFISHER_SERIES_2 -#define TCP_PORT_KINGFISHER_OLD 473 +#define TCP_PORT_KINGFISHER_RANGE "473,4058" /* 473 not IANA registered */ #define UDP_PORT_KINGFISHER_OLD 473 +#else +#define TCP_PORT_KINGFISHER_RANGE "4058" #endif static int proto_kingfisher = -1; @@ -384,11 +385,10 @@ proto_reg_handoff_kingfisher( void ) dissector_handle_t kingfisher_handle=NULL; kingfisher_handle = create_dissector_handle(dissect_kingfisher_heur, proto_kingfisher); - dissector_add_uint("tcp.port", TCP_PORT_KINGFISHER, kingfisher_handle); + dissector_add_uint_range_with_preference("tcp.port", TCP_PORT_KINGFISHER_RANGE, kingfisher_handle); dissector_add_uint("udp.port", UDP_PORT_KINGFISHER, kingfisher_handle); #ifdef SUPPORT_KINGFISHER_SERIES_2 - dissector_add_uint("tcp.port", TCP_PORT_KINGFISHER_OLD, kingfisher_handle); dissector_add_uint("udp.port", UDP_PORT_KINGFISHER_OLD, kingfisher_handle); #endif kingfisher_conv_handle = create_dissector_handle(dissect_kingfisher_conv, proto_kingfisher); diff --git a/epan/dissectors/packet-kismet.c b/epan/dissectors/packet-kismet.c index f86cbe5f06..71affab10e 100644 --- a/epan/dissectors/packet-kismet.c +++ b/epan/dissectors/packet-kismet.c @@ -29,7 +29,6 @@ #include <epan/packet.h> #include <epan/to_str.h> #include <epan/strutil.h> -#include <epan/prefs.h> #include <epan/expert.h> #include <wsutil/strtoi.h> @@ -49,9 +48,7 @@ static gint ett_kismet_reqresp = -1; static expert_field ei_time_invalid = EI_INIT; -#define TCP_PORT_KISMET 2501 - -static guint global_kismet_tcp_port = TCP_PORT_KISMET; +#define TCP_PORT_KISMET 2501 /* Not IANA registered */ static gboolean response_is_continuation(const guchar * data); void proto_reg_handoff_kismet(void); @@ -325,7 +322,6 @@ proto_register_kismet(void) &ett_kismet, &ett_kismet_reqresp, }; - module_t *kismet_module; expert_module_t* expert_kismet; proto_kismet = proto_register_protocol("Kismet Client/Server Protocol", "Kismet", "kismet"); @@ -333,36 +329,16 @@ proto_register_kismet(void) proto_register_subtree_array(ett, array_length (ett)); expert_kismet = expert_register_protocol(proto_kismet); expert_register_field_array(expert_kismet, ei, array_length(ei)); - - /* Register our configuration options for Kismet, particularly our port */ - - kismet_module = prefs_register_protocol(proto_kismet, proto_reg_handoff_kismet); - - prefs_register_uint_preference(kismet_module, "tcp.port", - "Kismet Server TCP Port", - "Set the port for Kismet Client/Server messages (if other" - " than the default of 2501)", 10, - &global_kismet_tcp_port); } void proto_reg_handoff_kismet(void) { - static gboolean kismet_prefs_initialized = FALSE; - static dissector_handle_t kismet_handle; - static guint tcp_port; - - if (!kismet_prefs_initialized) { - kismet_handle = create_dissector_handle(dissect_kismet, proto_kismet); - kismet_prefs_initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", tcp_port, kismet_handle); - } + dissector_handle_t kismet_handle; - /* Set our port number for future use */ - tcp_port = global_kismet_tcp_port; + kismet_handle = create_dissector_handle(dissect_kismet, proto_kismet); - dissector_add_uint("tcp.port", global_kismet_tcp_port, kismet_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_KISMET, kismet_handle); } /* diff --git a/epan/dissectors/packet-knet.c b/epan/dissectors/packet-knet.c index 25bd5bb004..ecaa151fa2 100644 --- a/epan/dissectors/packet-knet.c +++ b/epan/dissectors/packet-knet.c @@ -32,7 +32,7 @@ void proto_register_knet(void); void proto_reg_handoff_knet(void); #define PROTO_TAG_KNET "KNET" /*!< Definition of kNet Protocol */ -#define PORT 2345 +#define PORT 2345 /* Not IANA registered */ #define KNET_SCTP_PACKET 1000 #define KNET_TCP_PACKET 1001 @@ -119,7 +119,6 @@ static dissector_handle_t knet_handle_udp; /* Ports used by the dissectors */ static guint32 knet_sctp_port = PORT; /*!< Port used by kNet SCTP */ -static guint32 knet_tcp_port = PORT; /*!< Port used by kNet TCP */ static guint32 knet_udp_port = PORT; /*!< Port used by kNet UDP */ static const value_string packettypenames[] = { /*!< Messageid List */ @@ -758,10 +757,6 @@ proto_register_knet(void) "Set the SCTP port for kNet messages", 10, &knet_sctp_port); - prefs_register_uint_preference(knet_module, "tcp.port", "kNet TCP Port", - "Set the TCP port for kNet messages", - 10, &knet_tcp_port); - prefs_register_uint_preference(knet_module, "udp.port", "kNet UDP Port", "Set the UDP port for kNet messages", 10, &knet_udp_port); @@ -777,26 +772,22 @@ proto_reg_handoff_knet(void) static gboolean initialized = FALSE; static guint current_sctp_port; - static guint current_tcp_port; static guint current_udp_port; if(!initialized) { + dissector_add_uint_with_preference("tcp.port", PORT, knet_handle_tcp); initialized = TRUE; } else { dissector_delete_uint("sctp.port", current_sctp_port, knet_handle_sctp); - dissector_delete_uint("tcp.port", current_tcp_port, knet_handle_tcp); dissector_delete_uint("udp.port", current_udp_port, knet_handle_udp); } current_sctp_port = knet_sctp_port; dissector_add_uint("sctp.port", current_sctp_port, knet_handle_sctp); - current_tcp_port = knet_tcp_port; - dissector_add_uint("tcp.port", current_tcp_port, knet_handle_tcp); - current_udp_port = knet_udp_port; dissector_add_uint("udp.port", current_udp_port, knet_handle_udp); } diff --git a/epan/dissectors/packet-kpasswd.c b/epan/dissectors/packet-kpasswd.c index 27b906fc50..ef434c7ac6 100644 --- a/epan/dissectors/packet-kpasswd.c +++ b/epan/dissectors/packet-kpasswd.c @@ -329,7 +329,7 @@ proto_reg_handoff_kpasswd(void) kpasswd_handle_udp = create_dissector_handle(dissect_kpasswd_udp, proto_kpasswd); kpasswd_handle_tcp = create_dissector_handle(dissect_kpasswd_tcp, proto_kpasswd); dissector_add_uint("udp.port", UDP_PORT_KPASSWD, kpasswd_handle_udp); - dissector_add_uint("tcp.port", TCP_PORT_KPASSWD, kpasswd_handle_tcp); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_KPASSWD, kpasswd_handle_tcp); } /* diff --git a/epan/dissectors/packet-kt.c b/epan/dissectors/packet-kt.c index bcddbb0d18..bb878e2fe8 100644 --- a/epan/dissectors/packet-kt.c +++ b/epan/dissectors/packet-kt.c @@ -142,7 +142,6 @@ static const value_string kt_oper_vals[] = { * default configuration of the KT server all the same. */ #define DEFAULT_KT_PORT_RANGE "1978-1979" -static range_t *global_kt_tcp_port_range; static gboolean kt_present_key_val_as_ascii; /* Dissection routines */ @@ -780,18 +779,12 @@ proto_register_kt(void) }; proto_kt = proto_register_protocol("Kyoto Tycoon Protocol", "Kyoto Tycoon", "kt"); - register_dissector("kt", dissect_kt, proto_kt); + kt_handle = register_dissector("kt", dissect_kt, proto_kt); proto_register_field_array(proto_kt, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); /* Preferences */ - kt_module = prefs_register_protocol(proto_kt, proto_reg_handoff_kt); - - range_convert_str(&global_kt_tcp_port_range, DEFAULT_KT_PORT_RANGE, MAX_TCP_PORT); - prefs_register_range_preference(kt_module, "tcp.ports", "Kyoto Tycoon TCP ports", - "TCP ports to be decoded as Kyoto Tycoon (binary protocol) (default: " - DEFAULT_KT_PORT_RANGE ")", - &global_kt_tcp_port_range, MAX_TCP_PORT); + kt_module = prefs_register_protocol(proto_kt, NULL); prefs_register_bool_preference(kt_module, "present_key_val_as_ascii", "Attempt to also show ASCII string representation of keys and values", @@ -802,20 +795,7 @@ proto_register_kt(void) void proto_reg_handoff_kt(void) { - static gboolean Initialized = FALSE; - static range_t *kt_tcp_port_range; - - if (!Initialized) { - kt_handle = find_dissector("kt"); - Initialized = TRUE; - } - else { - dissector_delete_uint_range("tcp.port", kt_tcp_port_range, kt_handle); - g_free(kt_tcp_port_range); - } - - kt_tcp_port_range = range_copy(global_kt_tcp_port_range); - dissector_add_uint_range("tcp.port", kt_tcp_port_range, kt_handle); + dissector_add_uint_range_with_preference("tcp.port", DEFAULT_KT_PORT_RANGE, kt_handle); } /* diff --git a/epan/dissectors/packet-laplink.c b/epan/dissectors/packet-laplink.c index 363efa996d..717d7a0804 100644 --- a/epan/dissectors/packet-laplink.c +++ b/epan/dissectors/packet-laplink.c @@ -235,12 +235,10 @@ proto_reg_handoff_laplink(void) dissector_handle_t laplink_udp_handle; dissector_handle_t laplink_tcp_handle; - laplink_tcp_handle = create_dissector_handle(dissect_laplink_tcp, - proto_laplink); - dissector_add_uint("tcp.port", TCP_PORT_LAPLINK, laplink_tcp_handle); + laplink_tcp_handle = create_dissector_handle(dissect_laplink_tcp, proto_laplink); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_LAPLINK, laplink_tcp_handle); - laplink_udp_handle = create_dissector_handle(dissect_laplink_udp, - proto_laplink); + laplink_udp_handle = create_dissector_handle(dissect_laplink_udp, proto_laplink); dissector_add_uint("udp.port", UDP_PORT_LAPLINK, laplink_udp_handle); } diff --git a/epan/dissectors/packet-lbmpdmtcp.c b/epan/dissectors/packet-lbmpdmtcp.c index 006b067abd..5a13a49877 100644 --- a/epan/dissectors/packet-lbmpdmtcp.c +++ b/epan/dissectors/packet-lbmpdmtcp.c @@ -440,7 +440,7 @@ void proto_reg_handoff_lbmpdm_tcp(void) if (!already_registered) { lbmpdm_tcp_dissector_handle = create_dissector_handle(dissect_lbmpdm_tcp, lbmpdm_tcp_protocol_handle); - dissector_add_for_decode_as("tcp.port", lbmpdm_tcp_dissector_handle); + dissector_add_for_decode_as_with_preference("tcp.port", lbmpdm_tcp_dissector_handle); heur_dissector_add("tcp", test_lbmpdm_tcp_packet, "LBMPDM over TCP", "lbmpdm_tcp", lbmpdm_tcp_protocol_handle, HEURISTIC_ENABLE); } diff --git a/epan/dissectors/packet-lbttcp.c b/epan/dissectors/packet-lbttcp.c index d91f19e85d..a2d717c767 100644 --- a/epan/dissectors/packet-lbttcp.c +++ b/epan/dissectors/packet-lbttcp.c @@ -802,7 +802,7 @@ void proto_reg_handoff_lbttcp(void) if (!already_registered) { lbttcp_dissector_handle = create_dissector_handle(dissect_lbttcp, proto_lbttcp); - dissector_add_for_decode_as("tcp.port", lbttcp_dissector_handle); + dissector_add_for_decode_as_with_preference("tcp.port", lbttcp_dissector_handle); heur_dissector_add("tcp", test_lbttcp_packet, "LBT over TCP", "lbttcp_tcp", proto_lbttcp, HEURISTIC_ENABLE); } diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c index 2606dc1c9b..a8398c4f36 100644 --- a/epan/dissectors/packet-ldap.c +++ b/epan/dissectors/packet-ldap.c @@ -430,16 +430,13 @@ static gchar *attr_type = NULL; static gboolean is_binary_attr_type = FALSE; static gboolean ldap_found_in_frame = FALSE; -#define TCP_PORT_LDAP 389 +#define TCP_PORT_RANGE_LDAP "389,3268" /* 3268 is Windows 2000 Global Catalog */ #define TCP_PORT_LDAPS 636 #define UDP_PORT_CLDAP 389 -#define TCP_PORT_GLOBALCAT_LDAP 3268 /* Windows 2000 Global Catalog */ /* desegmentation of LDAP */ static gboolean ldap_desegment = TRUE; -static guint global_ldap_tcp_port = TCP_PORT_LDAP; static guint global_ldaps_tcp_port = TCP_PORT_LDAPS; -static guint tcp_port = 0; static guint ssl_port = 0; static dissector_handle_t gssapi_handle; @@ -3832,7 +3829,7 @@ static int dissect_PasswordPolicyResponseValue_PDU(tvbuff_t *tvb _U_, packet_inf /*--- End of included file: packet-ldap-fn.c ---*/ -#line 916 "./asn1/ldap/packet-ldap-template.c" +#line 913 "./asn1/ldap/packet-ldap-template.c" static int dissect_LDAPMessage_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ldap_conv_info_t *ldap_info) { int offset = 0; @@ -5643,7 +5640,7 @@ void proto_register_ldap(void) { NULL, HFILL }}, /*--- End of included file: packet-ldap-hfarr.c ---*/ -#line 2158 "./asn1/ldap/packet-ldap-template.c" +#line 2155 "./asn1/ldap/packet-ldap-template.c" }; /* List of subtrees */ @@ -5717,7 +5714,7 @@ void proto_register_ldap(void) { &ett_ldap_T_warning, /*--- End of included file: packet-ldap-ettarr.c ---*/ -#line 2172 "./asn1/ldap/packet-ldap-template.c" +#line 2169 "./asn1/ldap/packet-ldap-template.c" }; /* UAT for header fields */ static uat_field_t custom_attribute_types_uat_fields[] = { @@ -5752,10 +5749,6 @@ void proto_register_ldap(void) { " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &ldap_desegment); - prefs_register_uint_preference(ldap_module, "tcp.port", "LDAP TCP Port", - "Set the port for LDAP operations", - 10, &global_ldap_tcp_port); - prefs_register_uint_preference(ldap_module, "ssl.port", "LDAPS TCP Port", "Set the port for LDAP operations over SSL", 10, &global_ldaps_tcp_port); @@ -5801,8 +5794,6 @@ proto_reg_handoff_ldap(void) { dissector_handle_t cldap_handle; - dissector_add_uint("tcp.port", TCP_PORT_GLOBALCAT_LDAP, ldap_handle); - cldap_handle = create_dissector_handle(dissect_mscldap, proto_cldap); dissector_add_uint("udp.port", UDP_PORT_CLDAP, cldap_handle); @@ -5885,27 +5876,14 @@ proto_reg_handoff_ldap(void) /*--- End of included file: packet-ldap-dis-tab.c ---*/ -#line 2323 "./asn1/ldap/packet-ldap-template.c" - +#line 2314 "./asn1/ldap/packet-ldap-template.c" + dissector_add_uint_range_with_preference("tcp.port", TCP_PORT_RANGE_LDAP, ldap_handle); } static void prefs_register_ldap(void) { - - if(tcp_port != global_ldap_tcp_port) { - if(tcp_port) - dissector_delete_uint("tcp.port", tcp_port, ldap_handle); - - /* Set our port number for future use */ - tcp_port = global_ldap_tcp_port; - - if(tcp_port) - dissector_add_uint("tcp.port", tcp_port, ldap_handle); - - } - if(ssl_port != global_ldaps_tcp_port) { if(ssl_port) ssl_dissector_delete(ssl_port, ldap_handle); diff --git a/epan/dissectors/packet-ldp.c b/epan/dissectors/packet-ldp.c index dbaad8a1d5..ef668790aa 100644 --- a/epan/dissectors/packet-ldp.c +++ b/epan/dissectors/packet-ldp.c @@ -345,7 +345,6 @@ static expert_field ei_ldp_tlv_fec = EI_INIT; /* desegmentation of LDP over TCP */ static gboolean ldp_desegment = TRUE; -static guint32 global_ldp_tcp_port = TCP_PORT_LDP; static guint32 global_ldp_udp_port = UDP_PORT_LDP; /* @@ -4280,11 +4279,6 @@ proto_register_ldp(void) ldp_module = prefs_register_protocol(proto_ldp, proto_reg_handoff_ldp); - prefs_register_uint_preference(ldp_module, "tcp.port", "LDP TCP Port", - "Set the TCP port for messages (if other" - " than the default of 646)", - 10, &global_ldp_tcp_port); - prefs_register_uint_preference(ldp_module, "udp.port", "LDP UDP Port", "Set the UDP port for messages (if other" " than the default of 646)", @@ -4304,31 +4298,26 @@ proto_reg_handoff_ldp(void) { static gboolean ldp_prefs_initialized = FALSE; static dissector_handle_t ldp_tcp_handle, ldp_handle; - static int tcp_port; static int udp_port; - if (!ldp_prefs_initialized) { ldp_tcp_handle = create_dissector_handle(dissect_ldp_tcp, proto_ldp); ldp_handle = create_dissector_handle(dissect_ldp, proto_ldp); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_LDP, ldp_tcp_handle); ldp_prefs_initialized = TRUE; } else { - dissector_delete_uint("tcp.port", tcp_port, ldp_tcp_handle); dissector_delete_uint("udp.port", udp_port, ldp_handle); } /* Set our port number for future use */ - - tcp_port = global_ldp_tcp_port; udp_port = global_ldp_udp_port; - dissector_add_uint("tcp.port", global_ldp_tcp_port, ldp_tcp_handle); dissector_add_uint("udp.port", global_ldp_udp_port, ldp_handle); } diff --git a/epan/dissectors/packet-lg8979.c b/epan/dissectors/packet-lg8979.c index 910339270f..0a0d2573ee 100644 --- a/epan/dissectors/packet-lg8979.c +++ b/epan/dissectors/packet-lg8979.c @@ -152,11 +152,8 @@ static gint ett_lg8979_funccode = -1; static gint ett_lg8979_point = -1; static gint ett_lg8979_ts = -1; -#define PORT_LG8979 0 - /* Globals for L&G 8979 Protocol Preferences */ static gboolean lg8979_desegment = TRUE; -static guint global_lg8979_tcp_port = PORT_LG8979; /* Port 0, by default */ #define LG8979_HEADER 0xFF @@ -1543,46 +1540,25 @@ proto_register_lg8979(void) /* Register required preferences for L&G 8979 register decoding */ - lg8979_module = prefs_register_protocol(proto_lg8979, proto_reg_handoff_lg8979); + lg8979_module = prefs_register_protocol(proto_lg8979, NULL); /* L&G 8979 - Desegmentmentation; defaults to TRUE for TCP desegmentation*/ prefs_register_bool_preference(lg8979_module, "desegment", "Desegment all L&G 8979 Protocol packets spanning multiple TCP segments", "Whether the L&G 8979 dissector should desegment all messages spanning multiple TCP segments", &lg8979_desegment); - - - /* L&G 8979 Preference - Default TCP Port, allows for "user" port either than 0. */ - prefs_register_uint_preference(lg8979_module, "tcp.port", - "L&G 8979 Protocol Port", - "Set the TCP port for L&G 8979 Protocol packets (if other than the default of 0)", - 10, &global_lg8979_tcp_port); } /******************************************************************************************************/ void proto_reg_handoff_lg8979(void) { - static int lg8979_prefs_initialized = FALSE; - static dissector_handle_t lg8979_handle; - static unsigned int lg8979_port; + dissector_handle_t lg8979_handle; /* Make sure to use L&G 8979 Protocol Preferences field to determine default TCP port */ - if (! lg8979_prefs_initialized) { - lg8979_handle = create_dissector_handle(dissect_lg8979_tcp, proto_lg8979); - lg8979_prefs_initialized = TRUE; - } - - if(lg8979_port != 0 && lg8979_port != global_lg8979_tcp_port){ - dissector_delete_uint("tcp.port", lg8979_port, lg8979_handle); - } - - if(global_lg8979_tcp_port != 0 && lg8979_port != global_lg8979_tcp_port) { - dissector_add_uint("tcp.port", global_lg8979_tcp_port, lg8979_handle); - } - - lg8979_port = global_lg8979_tcp_port; + lg8979_handle = create_dissector_handle(dissect_lg8979_tcp, proto_lg8979); + dissector_add_for_decode_as_with_preference("tcp.port", lg8979_handle); dissector_add_for_decode_as("rtacser.data", lg8979_handle); } diff --git a/epan/dissectors/packet-linx.c b/epan/dissectors/packet-linx.c index c2003b82b3..beff3031bf 100644 --- a/epan/dissectors/packet-linx.c +++ b/epan/dissectors/packet-linx.c @@ -43,7 +43,6 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> #include <epan/expert.h> #include <epan/etypes.h> @@ -845,11 +844,6 @@ proto_reg_handoff_linx(void) /************ TCP CM **************/ -#define TCP_PORT_LINX 19790 - -/* Default the port to zero */ -static guint linx_tcp_port = 0; - static int dissect_linx_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { @@ -1062,46 +1056,22 @@ proto_register_linx_tcp(void) }; expert_module_t* expert_linx_tcp; - module_t *linx_tcp_module; proto_linx_tcp = proto_register_protocol("ENEA LINX over TCP", "LINX/TCP", "linxtcp"); proto_register_field_array(proto_linx_tcp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); expert_linx_tcp = expert_register_protocol(proto_linx_tcp); expert_register_field_array(expert_linx_tcp, ei, array_length(ei)); - - linx_tcp_module = prefs_register_protocol(proto_linx_tcp, proto_reg_handoff_linx_tcp); - - prefs_register_uint_preference(linx_tcp_module, "tcp.port", - "ENEA LINX over TCP Port", - "TCP port used by ENEA LINX, usually 19790", - 10, &linx_tcp_port); - } void proto_reg_handoff_linx_tcp(void) { - static dissector_handle_t linx_tcp_handle; - static gboolean linx_tcp_prefs_initialized = FALSE; - - static guint saved_linx_tcp_port; + dissector_handle_t linx_tcp_handle; + linx_tcp_handle = create_dissector_handle(dissect_linx_tcp, proto_linx_tcp); - if (!linx_tcp_prefs_initialized) { - linx_tcp_handle = create_dissector_handle(dissect_linx_tcp, proto_linx_tcp); - dissector_add_uint("tcp.port", linx_tcp_port, linx_tcp_handle); - linx_tcp_prefs_initialized = TRUE; - } - else { - dissector_delete_uint("tcp.port", saved_linx_tcp_port, linx_tcp_handle); - } - - saved_linx_tcp_port = linx_tcp_port; - if (linx_tcp_port != 0) { - dissector_add_uint("udp.port", linx_tcp_port, linx_tcp_handle); - } - + dissector_add_for_decode_as_with_preference("tcp.port", linx_tcp_handle); } /* diff --git a/epan/dissectors/packet-lisp-tcp.c b/epan/dissectors/packet-lisp-tcp.c index 3420b3487d..887bcbdb45 100644 --- a/epan/dissectors/packet-lisp-tcp.c +++ b/epan/dissectors/packet-lisp-tcp.c @@ -398,7 +398,7 @@ proto_register_lisp_tcp(void) void proto_reg_handoff_lisp_tcp(void) { - dissector_add_uint("tcp.port", LISP_CONTROL_PORT, lisp_tcp_handle); + dissector_add_uint_with_preference("tcp.port", LISP_CONTROL_PORT, lisp_tcp_handle); } /* diff --git a/epan/dissectors/packet-llrp.c b/epan/dissectors/packet-llrp.c index 9406c1de22..2569897414 100644 --- a/epan/dissectors/packet-llrp.c +++ b/epan/dissectors/packet-llrp.c @@ -3801,7 +3801,7 @@ proto_reg_handoff_llrp(void) dissector_handle_t llrp_handle; llrp_handle = create_dissector_handle(dissect_llrp, proto_llrp); - dissector_add_uint("tcp.port", LLRP_PORT, llrp_handle); + dissector_add_uint_with_preference("tcp.port", LLRP_PORT, llrp_handle); } diff --git a/epan/dissectors/packet-logcat.c b/epan/dissectors/packet-logcat.c index 62b5e73b72..2148a081d0 100644 --- a/epan/dissectors/packet-logcat.c +++ b/epan/dissectors/packet-logcat.c @@ -309,7 +309,7 @@ proto_reg_handoff_logcat(void) dissector_add_uint("wtap_encap", WTAP_ENCAP_LOGCAT, logcat_handle); - dissector_add_for_decode_as("tcp.port", logcat_handle); + dissector_add_for_decode_as_with_preference("tcp.port", logcat_handle); } /* diff --git a/epan/dissectors/packet-lpd.c b/epan/dissectors/packet-lpd.c index c20cfb1151..a4f28fbe2e 100644 --- a/epan/dissectors/packet-lpd.c +++ b/epan/dissectors/packet-lpd.c @@ -198,7 +198,7 @@ proto_reg_handoff_lpd(void) dissector_handle_t lpd_handle; lpd_handle = create_dissector_handle(dissect_lpd, proto_lpd); - dissector_add_uint("tcp.port", TCP_PORT_PRINTER, lpd_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_PRINTER, lpd_handle); } /* diff --git a/epan/dissectors/packet-lsc.c b/epan/dissectors/packet-lsc.c index eaa92736df..969118aead 100644 --- a/epan/dissectors/packet-lsc.c +++ b/epan/dissectors/packet-lsc.c @@ -407,8 +407,7 @@ proto_register_lsc(void) }; /* Register the protocol name and description */ - proto_lsc = proto_register_protocol("Pegasus Lightweight Stream Control", - "LSC", "lsc"); + proto_lsc = proto_register_protocol("Pegasus Lightweight Stream Control", "LSC", "lsc"); /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_lsc, hf, array_length(hf)); @@ -436,19 +435,17 @@ proto_reg_handoff_lsc(void) lsc_udp_handle = create_dissector_handle(dissect_lsc_udp, proto_lsc); lsc_tcp_handle = create_dissector_handle(dissect_lsc_tcp, proto_lsc); dissector_add_for_decode_as("udp.port", lsc_udp_handle); - dissector_add_for_decode_as("tcp.port", lsc_tcp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", lsc_tcp_handle); initialized = TRUE; } else { if (saved_lsc_port != 0) { dissector_delete_uint("udp.port", saved_lsc_port, lsc_udp_handle); - dissector_delete_uint("tcp.port", saved_lsc_port, lsc_tcp_handle); } } /* Set the port number */ if (global_lsc_port != 0) { dissector_add_uint("udp.port", global_lsc_port, lsc_udp_handle); - dissector_add_uint("tcp.port", global_lsc_port, lsc_tcp_handle); } saved_lsc_port = global_lsc_port; } diff --git a/epan/dissectors/packet-mausb.c b/epan/dissectors/packet-mausb.c index 4bb0869e8a..00a450f173 100644 --- a/epan/dissectors/packet-mausb.c +++ b/epan/dissectors/packet-mausb.c @@ -674,7 +674,6 @@ static guint mausb_get_pkt_len(packet_info *pinfo _U_, tvbuff_t *tvb, } /* Global Port Preference */ -static unsigned int mausb_tcp_port_pref = 0; static unsigned int mausb_udp_port_pref = 0; /* Initialize the subtree pointers */ @@ -2271,11 +2270,6 @@ proto_register_mausb(void) /* Register Protocol preferences */ mausb_module = prefs_register_protocol(proto_mausb, proto_reg_handoff_mausb); - /* Register TCP port preference */ - prefs_register_uint_preference(mausb_module, "tcp.port", "MAUSB TCP Port", - "Set the port for Media Agnostic Packets", - 10, &mausb_tcp_port_pref); - /* Register UDP port preference */ prefs_register_uint_preference(mausb_module, "udp.port", "MAUSB UDP Port", "Set the port for Media Agnostic Packets", @@ -2290,7 +2284,6 @@ proto_reg_handoff_mausb(void) static gboolean initialized = FALSE; static dissector_handle_t mausb_tcp_handle; static dissector_handle_t mausb_pkt_handle; - static guint saved_mausb_tcp_port_pref; static guint saved_mausb_udp_port_pref; if (!initialized) { @@ -2304,16 +2297,14 @@ proto_reg_handoff_mausb(void) dissector_add_uint("llc.wfa_pid", PID_MAUSB, mausb_pkt_handle); initialized = TRUE; + dissector_add_uint_range_with_preference("tcp.port", "", mausb_tcp_handle); } else { /* if we have already been initialized */ - dissector_delete_uint("tcp.port", saved_mausb_tcp_port_pref, mausb_tcp_handle); dissector_delete_uint("udp.port", saved_mausb_udp_port_pref, mausb_pkt_handle); } - saved_mausb_tcp_port_pref = mausb_tcp_port_pref; saved_mausb_udp_port_pref = mausb_udp_port_pref; - dissector_add_uint("tcp.port", mausb_tcp_port_pref, mausb_tcp_handle); dissector_add_uint("udp.port", mausb_udp_port_pref, mausb_pkt_handle); } diff --git a/epan/dissectors/packet-mbtcp.c b/epan/dissectors/packet-mbtcp.c index da11c9f8f4..aaefcd4a7b 100644 --- a/epan/dissectors/packet-mbtcp.c +++ b/epan/dissectors/packet-mbtcp.c @@ -67,6 +67,7 @@ #include "packet-tcp.h" #include "packet-mbtcp.h" #include <epan/prefs.h> +#include <epan/prefs-int.h> #include <epan/expert.h> #include <epan/crc16-tvb.h> /* For CRC verification */ #include <epan/proto_data.h> @@ -174,17 +175,19 @@ static dissector_table_t modbus_dissector_table; /* Globals for Modbus/TCP Preferences */ static gboolean mbtcp_desegment = TRUE; static guint global_mbus_tcp_port = PORT_MBTCP; /* Port 502, by default */ +static guint global_mbus_udp_port = PORT_MBTCP; /* Port 502, by default */ /* Globals for Modbus RTU over TCP Preferences */ static gboolean mbrtu_desegment = TRUE; -static guint global_mbus_rtu_port = PORT_MBRTU; /* 0, by default */ +static guint global_mbus_tcp_rtu_port = PORT_MBRTU; /* 0, by default */ +static guint global_mbus_udp_rtu_port = PORT_MBRTU; /* 0, by default */ static gboolean mbrtu_crc = FALSE; /* Globals for Modbus Preferences */ static gint global_mbus_register_format = MODBUS_PREF_REGISTER_FORMAT_UINT16; static int -classify_mbtcp_packet(packet_info *pinfo) +classify_mbtcp_packet(packet_info *pinfo, guint port) { /* see if nature of packets can be derived from src/dst ports */ /* if so, return as found */ @@ -193,9 +196,9 @@ classify_mbtcp_packet(packet_info *pinfo) /* the Modbus/TCP transaction ID for each pair of messages would allow for detection based on a new seq. number. */ /* Otherwise, we can stick with this method; a configurable port option has been added to allow for usage of */ /* user ports either than the default of 502. */ - if (( pinfo->srcport == global_mbus_tcp_port ) && ( pinfo->destport != global_mbus_tcp_port )) + if (( pinfo->srcport == port ) && ( pinfo->destport != port )) return RESPONSE_PACKET; - if (( pinfo->srcport != global_mbus_tcp_port ) && ( pinfo->destport == global_mbus_tcp_port )) + if (( pinfo->srcport != port ) && ( pinfo->destport == port )) return QUERY_PACKET; /* else, cannot classify */ @@ -203,7 +206,7 @@ classify_mbtcp_packet(packet_info *pinfo) } static int -classify_mbrtu_packet(packet_info *pinfo, tvbuff_t *tvb) +classify_mbrtu_packet(packet_info *pinfo, tvbuff_t *tvb, guint port) { guint8 func, len; @@ -212,9 +215,9 @@ classify_mbrtu_packet(packet_info *pinfo, tvbuff_t *tvb) /* see if nature of packets can be derived from src/dst ports */ /* if so, return as found */ - if (( pinfo->srcport == global_mbus_rtu_port ) && ( pinfo->destport != global_mbus_rtu_port )) + if (( pinfo->srcport == port ) && ( pinfo->destport != port )) return RESPONSE_PACKET; - if (( pinfo->srcport != global_mbus_rtu_port ) && ( pinfo->destport == global_mbus_rtu_port )) + if (( pinfo->srcport != port ) && ( pinfo->destport == port )) return QUERY_PACKET; @@ -393,7 +396,7 @@ static const enum_val_t mbus_register_format[] = { /* Code to dissect Modbus/TCP packets */ static int -dissect_mbtcp_pdu_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int proto) +dissect_mbtcp_pdu_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int proto, guint port) { /* Set up structures needed to add the protocol subtree and manage it */ proto_item *mi; @@ -416,7 +419,7 @@ dissect_mbtcp_pdu_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, in offset = 0; /* "Request" or "Response" */ - packet_type = classify_mbtcp_packet(pinfo); + packet_type = classify_mbtcp_packet(pinfo, port); switch ( packet_type ) { case QUERY_PACKET : @@ -517,12 +520,12 @@ dissect_mbtcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat col_set_str(pinfo->cinfo, COL_PROTOCOL, "Modbus/TCP"); col_clear(pinfo->cinfo, COL_INFO); - return dissect_mbtcp_pdu_common(tvb, pinfo, tree, proto_mbtcp); + return dissect_mbtcp_pdu_common(tvb, pinfo, tree, proto_mbtcp, global_mbus_tcp_port); } -/* Code to dissect Modbus RTU over TCP packets */ +/* Code to dissect Modbus RTU */ static int -dissect_mbrtu_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) +dissect_mbrtu_pdu_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint port) { /* Set up structures needed to add the protocol subtree and manage it */ proto_item *mi; @@ -547,7 +550,7 @@ dissect_mbrtu_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat offset = 0; /* "Request" or "Response" */ - packet_type = classify_mbrtu_packet(pinfo, tvb); + packet_type = classify_mbrtu_packet(pinfo, tvb, port); switch ( packet_type ) { case QUERY_PACKET : @@ -650,6 +653,12 @@ dissect_mbrtu_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat return tvb_captured_length(tvb); } +/* Code to dissect Modbus RTU over TCP packets */ +static int +dissect_mbrtu_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) +{ + return dissect_mbrtu_pdu_common(tvb, pinfo, tree, global_mbus_tcp_rtu_port); +} /* Return length of Modbus/TCP message */ static guint @@ -685,7 +694,7 @@ get_mbrtu_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, the rest can be added as pcap examples are made available */ /* Determine "Query" or "Response" */ - packet_type = classify_mbrtu_packet(pinfo, tvb); + packet_type = classify_mbrtu_packet(pinfo, tvb, global_mbus_tcp_rtu_port); switch ( packet_type ) { case QUERY_PACKET : @@ -786,7 +795,7 @@ dissect_mbudp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U col_set_str(pinfo->cinfo, COL_PROTOCOL, "Modbus/UDP"); col_clear(pinfo->cinfo, COL_INFO); - return dissect_mbtcp_pdu_common(tvb, pinfo, tree, proto_mbudp); + return dissect_mbtcp_pdu_common(tvb, pinfo, tree, proto_mbudp, global_mbus_udp_port); } /* Code to dissect Modbus RTU over TCP messages */ @@ -812,7 +821,7 @@ dissect_mbrtu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) } static int -dissect_mbrtu_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) +dissect_mbrtu_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { /* Make sure there's at least enough data to determine it's a Modbus packet */ @@ -820,7 +829,7 @@ dissect_mbrtu_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat if (tvb_reported_length(tvb) < 5) return 0; - return dissect_mbrtu_pdu(tvb, pinfo, tree, data); + return dissect_mbrtu_pdu_common(tvb, pinfo, tree, global_mbus_udp_rtu_port); } @@ -1573,6 +1582,28 @@ dissect_modbus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) return tvb_captured_length(tvb); } +static void +apply_mbtcp_prefs(void) +{ + /* Modbus/RTU uses the port preference to determine request/response */ + pref_t *tcp_port = prefs_find_preference(prefs_find_module("mbtcp"), "tcp.port"); + pref_t *udp_port = prefs_find_preference(prefs_find_module("mbudp"), "udp.port"); + + global_mbus_tcp_port = *tcp_port->varp.uint; + global_mbus_udp_port = *udp_port->varp.uint; +} + +static void +apply_mbrtu_prefs(void) +{ + /* Modbus/RTU uses the port preference to determine request/response */ + pref_t *rtu_tcp_port = prefs_find_preference(prefs_find_module("mbrtu"), "tcp.port"); + pref_t *rtu_udp_port = prefs_find_preference(prefs_find_module("mbrtu"), "udp.port"); + + global_mbus_tcp_rtu_port = *rtu_tcp_port->varp.uint; + global_mbus_udp_rtu_port = *rtu_udp_port->varp.uint; +} + /* Register the protocol with Wireshark */ void proto_register_modbus(void) @@ -1989,8 +2020,8 @@ proto_register_modbus(void) /* Register required preferences for Modbus Protocol variants */ - mbtcp_module = prefs_register_protocol(proto_mbtcp, proto_reg_handoff_mbtcp); - mbrtu_module = prefs_register_protocol(proto_mbrtu, proto_reg_handoff_mbrtu); + mbtcp_module = prefs_register_protocol(proto_mbtcp, apply_mbtcp_prefs); + mbrtu_module = prefs_register_protocol(proto_mbrtu, apply_mbrtu_prefs); modbus_module = prefs_register_protocol(proto_modbus, NULL); /* Modbus RTU Preference - Desegment, defaults to TRUE for TCP desegmentation */ @@ -1999,12 +2030,6 @@ proto_register_modbus(void) "Whether the Modbus RTU dissector should desegment all messages spanning multiple TCP segments", &mbtcp_desegment); - /* Modbus/TCP Preference - Default TCP Port, allows for "user" port either than 502. */ - prefs_register_uint_preference(mbtcp_module, "tcp.port", "Modbus/TCP Port", - "Set the TCP port for Modbus/TCP packets (if other" - " than the default of 502)", - 10, &global_mbus_tcp_port); - /* Modbus RTU Preference - Desegment, defaults to TRUE for TCP desegmentation */ prefs_register_bool_preference(mbrtu_module, "desegment", "Desegment all Modbus RTU packets spanning multiple TCP segments", @@ -2017,11 +2042,6 @@ proto_register_modbus(void) "Whether to validate the CRC", &mbrtu_crc); - /* Modbus RTU Preference - Default TCP Port, defaults to zero, allows custom user port. */ - prefs_register_uint_preference(mbrtu_module, "tcp.port", "Modbus RTU Port", - "Set the TCP/UDP port for encapsulated Modbus RTU packets", - 10, &global_mbus_rtu_port); - /* Modbus Preference - Holding/Input Register format, this allows for deeper dissection of response data */ prefs_register_enum_preference(modbus_module, "mbus_register_format", "Holding/Input Register Format", @@ -2046,20 +2066,8 @@ proto_register_modbus(void) void proto_reg_handoff_mbtcp(void) { - static unsigned int mbtcp_port; - - /* Make sure to use Modbus/TCP Preferences field to determine default TCP port */ - if(mbtcp_port != 0 && mbtcp_port != global_mbus_tcp_port){ - dissector_delete_uint("tcp.port", mbtcp_port, mbtcp_handle); - dissector_delete_uint("udp.port", mbtcp_port, mbudp_handle); - } - - if(global_mbus_tcp_port != 0 && mbtcp_port != global_mbus_tcp_port) { - dissector_add_uint("tcp.port", global_mbus_tcp_port, mbtcp_handle); - dissector_add_uint("udp.port", global_mbus_tcp_port, mbudp_handle); - } - - mbtcp_port = global_mbus_tcp_port; + dissector_add_uint_with_preference("tcp.port", PORT_MBTCP, mbtcp_handle); + dissector_add_uint_with_preference("udp.port", PORT_MBTCP, mbudp_handle); dissector_add_uint("mbtcp.prot_id", MODBUS_PROTOCOL_ID, modbus_handle); @@ -2068,22 +2076,11 @@ proto_reg_handoff_mbtcp(void) void proto_reg_handoff_mbrtu(void) { - static unsigned int mbrtu_port = 0; dissector_handle_t mbrtu_udp_handle = create_dissector_handle(dissect_mbrtu_udp, proto_mbrtu); /* Make sure to use Modbus RTU Preferences field to determine default TCP port */ - - if(mbrtu_port != 0 && mbrtu_port != global_mbus_rtu_port){ - dissector_delete_uint("tcp.port", mbrtu_port, mbrtu_handle); - dissector_delete_uint("udp.port", mbrtu_port, mbrtu_udp_handle); - } - - if(global_mbus_rtu_port != 0 && mbrtu_port != global_mbus_rtu_port) { - dissector_add_uint("tcp.port", global_mbus_rtu_port, mbrtu_handle); - dissector_add_uint("udp.port", global_mbus_rtu_port, mbrtu_udp_handle); - } - - mbrtu_port = global_mbus_rtu_port; + dissector_add_for_decode_as_with_preference("udp.port", mbrtu_udp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", mbrtu_handle); dissector_add_uint("mbtcp.prot_id", MODBUS_PROTOCOL_ID, modbus_handle); dissector_add_for_decode_as("rtacser.data", mbrtu_handle); diff --git a/epan/dissectors/packet-megaco.c b/epan/dissectors/packet-megaco.c index 62886c2ee0..96c96017cc 100644 --- a/epan/dissectors/packet-megaco.c +++ b/epan/dissectors/packet-megaco.c @@ -189,7 +189,6 @@ static ws_mempbrk_pattern pbrk_braces; * decode. */ static guint global_megaco_txt_sctp_port = PORT_MEGACO_TXT; -static guint global_megaco_txt_tcp_port = PORT_MEGACO_TXT; static guint global_megaco_txt_udp_port = PORT_MEGACO_TXT; #if 0 static guint global_megaco_bin_sctp_port = PORT_MEGACO_BIN; @@ -3775,8 +3774,7 @@ proto_register_megaco(void) module_t *megaco_module; expert_module_t* expert_megaco; - proto_megaco = proto_register_protocol("MEGACO", - "MEGACO", "megaco"); + proto_megaco = proto_register_protocol("MEGACO", "MEGACO", "megaco"); register_dissector("megaco", dissect_megaco_text, proto_megaco); @@ -3794,11 +3792,6 @@ proto_register_megaco(void) "Set the SCTP port for MEGACO text messages", 10, &global_megaco_txt_sctp_port); - prefs_register_uint_preference(megaco_module, "tcp.txt_port", - "MEGACO Text TCP Port", - "Set the TCP port for MEGACO text messages", - 10, &global_megaco_txt_tcp_port); - prefs_register_uint_preference(megaco_module, "udp.txt_port", "MEGACO Text UDP Port", "Set the UDP port for MEGACO text messages", @@ -3863,7 +3856,6 @@ proto_reg_handoff_megaco(void) * the user changes port from the gui. */ static guint txt_sctp_port; - static guint txt_tcp_port; static guint txt_udp_port; #if 0 static guint bin_sctp_port; @@ -3881,23 +3873,21 @@ proto_reg_handoff_megaco(void) megaco_text_handle = find_dissector("megaco"); megaco_text_tcp_handle = create_dissector_handle(dissect_megaco_text_tcp, proto_megaco); + dissector_add_uint_with_preference("tcp.port", PORT_MEGACO_TXT, megaco_text_tcp_handle); dissector_add_uint("sctp.ppi", H248_PAYLOAD_PROTOCOL_ID, megaco_text_handle); megaco_prefs_initialized = TRUE; } else { dissector_delete_uint("sctp.port", txt_sctp_port, megaco_text_handle); - dissector_delete_uint("tcp.port", txt_tcp_port, megaco_text_tcp_handle); dissector_delete_uint("udp.port", txt_udp_port, megaco_text_handle); } /* Set our port number for future use */ txt_sctp_port = global_megaco_txt_sctp_port; - txt_tcp_port = global_megaco_txt_tcp_port; txt_udp_port = global_megaco_txt_udp_port; dissector_add_uint("sctp.port", global_megaco_txt_sctp_port, megaco_text_handle); - dissector_add_uint("tcp.port", global_megaco_txt_tcp_port, megaco_text_tcp_handle); dissector_add_uint("udp.port", global_megaco_txt_udp_port, megaco_text_handle); exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_7); diff --git a/epan/dissectors/packet-memcache.c b/epan/dissectors/packet-memcache.c index 3d1e12bb87..66c5e4559d 100644 --- a/epan/dissectors/packet-memcache.c +++ b/epan/dissectors/packet-memcache.c @@ -104,7 +104,6 @@ void proto_reg_handoff_memcache(void); static int proto_memcache = -1; -static range_t *memcache_tcp_port_range = NULL; static range_t *memcache_udp_port_range = NULL; static dissector_handle_t memcache_tcp_handle; static dissector_handle_t memcache_udp_handle; @@ -2140,14 +2139,8 @@ proto_register_memcache (void) " to reassemble TCP streams\" in the TCP protocol settings.", &memcache_desegment_body); - range_convert_str(&memcache_tcp_port_range, MEMCACHE_DEFAULT_RANGE, 65535); range_convert_str(&memcache_udp_port_range, MEMCACHE_DEFAULT_RANGE, 65535); - prefs_register_range_preference(memcache_module, "tcp.ports", \ - "MEMCACHE TCP Port range", \ - "MEMCACHE TCP Port range", \ - &memcache_tcp_port_range, \ - 65535); prefs_register_range_preference(memcache_module, "udp.ports", \ "MEMCACHE UDP Port range", \ "MEMCACHE UDP Port range", \ @@ -2159,17 +2152,12 @@ proto_register_memcache (void) void proto_reg_handoff_memcache (void) { - static range_t *orig_memcache_tcp_port_range = NULL; static range_t *orig_memcache_udp_port_range = NULL; - dissector_delete_uint_range("tcp.port", orig_memcache_tcp_port_range, memcache_tcp_handle); - dissector_delete_uint_range("udp.port", orig_memcache_udp_port_range, memcache_udp_handle); - g_free(orig_memcache_tcp_port_range); g_free(orig_memcache_udp_port_range); - orig_memcache_tcp_port_range = range_copy(memcache_tcp_port_range); orig_memcache_udp_port_range = range_copy(memcache_udp_port_range); - dissector_add_uint_range("tcp.port", orig_memcache_tcp_port_range, memcache_tcp_handle); + dissector_add_uint_range_with_preference("tcp.port", MEMCACHE_DEFAULT_RANGE, memcache_tcp_handle); dissector_add_uint_range("udp.port", orig_memcache_udp_port_range, memcache_udp_handle); } diff --git a/epan/dissectors/packet-mgcp.c b/epan/dissectors/packet-mgcp.c index dc353f7727..10988ba01d 100644 --- a/epan/dissectors/packet-mgcp.c +++ b/epan/dissectors/packet-mgcp.c @@ -2362,6 +2362,7 @@ void proto_reg_handoff_mgcp(void) callagent_tcp_port = global_mgcp_callagent_tcp_port; callagent_udp_port = global_mgcp_callagent_udp_port; + /* Names of port preferences too specific to add "auto" preference here */ dissector_add_uint("tcp.port", global_mgcp_gateway_tcp_port, mgcp_tpkt_handle); dissector_add_uint("udp.port", global_mgcp_gateway_udp_port, mgcp_handle); dissector_add_uint("tcp.port", global_mgcp_callagent_tcp_port, mgcp_tpkt_handle); diff --git a/epan/dissectors/packet-mih.c b/epan/dissectors/packet-mih.c index 31c7a89e88..c5c885115b 100644 --- a/epan/dissectors/packet-mih.c +++ b/epan/dissectors/packet-mih.c @@ -4872,7 +4872,7 @@ void proto_reg_handoff_mih(void) mih_handle = create_dissector_handle(dissect_mih, proto_mih); /*Layer 3 handle*/ dissector_add_uint("udp.port", MIH_PORT, mih_handle); - dissector_add_uint("tcp.port", MIH_PORT, mih_handle); + dissector_add_uint_with_preference("tcp.port", MIH_PORT, mih_handle); /*Layer 2 handle*/ dissector_add_uint("ethertype", ETHERTYPE_MIH, mih_handle); diff --git a/epan/dissectors/packet-mikey.c b/epan/dissectors/packet-mikey.c index 333cb501da..abb6693982 100644 --- a/epan/dissectors/packet-mikey.c +++ b/epan/dissectors/packet-mikey.c @@ -47,8 +47,6 @@ void proto_register_mikey(void); void proto_reg_handoff_mikey(void); #define PORT_MIKEY 2269 -static guint global_mikey_tcp_port = PORT_MIKEY; - static guint global_mikey_udp_port = PORT_MIKEY; static const value_string on_off_vals[] = { @@ -1855,34 +1853,26 @@ proto_register_mikey(void) prefs_register_uint_preference(mikey_module, "udp.port", "MIKEY UDP Port", "Set the port for MIKEY messages (if other than the default of 2269)", 10, &global_mikey_udp_port); - - prefs_register_uint_preference(mikey_module, "tcp.port", "MIKEY TCP Port", - "Set the port for MIKEY messages (if other than the default of 2269)", - 10, &global_mikey_tcp_port); - } void proto_reg_handoff_mikey(void) { - static guint mikey_tcp_port; static guint mikey_udp_port; static gboolean inited = FALSE; if (!inited) { dissector_add_string("key_mgmt", "mikey", mikey_handle); + dissector_add_uint_with_preference("tcp.port", PORT_MIKEY, mikey_handle); inited = TRUE; } else { dissector_delete_uint("udp.port", mikey_udp_port, mikey_handle); - dissector_delete_uint("tcp.port", mikey_tcp_port, mikey_handle); } dissector_add_uint("udp.port", global_mikey_udp_port, mikey_handle); - dissector_add_uint("tcp.port", global_mikey_tcp_port, mikey_handle); mikey_udp_port = global_mikey_udp_port; - mikey_tcp_port = global_mikey_tcp_port; } /* * Editor modelines - http://www.wireshark.org/tools/modelines.html diff --git a/epan/dissectors/packet-mongo.c b/epan/dissectors/packet-mongo.c index 7b8083b573..8817d9e306 100644 --- a/epan/dissectors/packet-mongo.c +++ b/epan/dissectors/packet-mongo.c @@ -33,7 +33,6 @@ #include <epan/packet.h> #include <epan/exceptions.h> -#include <epan/prefs.h> #include <epan/expert.h> #include "packet-tcp.h" @@ -215,8 +214,6 @@ static int hf_mongo_commandreply = -1; static int hf_mongo_outputdocs = -1; static int hf_mongo_unknown = -1; -static guint global_mongo_tcp_port = TCP_PORT_MONGO; - static gint ett_mongo = -1; static gint ett_mongo_doc = -1; static gint ett_mongo_elements = -1; @@ -726,7 +723,6 @@ dissect_mongo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) void proto_register_mongo(void) { - module_t *mongo_module; expert_module_t* expert_mongo; static hf_register_info hf[] = { @@ -1122,32 +1118,13 @@ proto_register_mongo(void) proto_register_subtree_array(ett, array_length(ett)); expert_mongo = expert_register_protocol(proto_mongo); expert_register_field_array(expert_mongo, ei, array_length(ei)); - - mongo_module = prefs_register_protocol(proto_mongo, - proto_reg_handoff_mongo); - - prefs_register_uint_preference(mongo_module, "tcp.port", "MONGO TCP Port", - "MONGO TCP port if other than the default", - 10, &global_mongo_tcp_port); } void proto_reg_handoff_mongo(void) { - static gboolean initialized = FALSE; - static int currentPort; - - if (!initialized) { - initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", currentPort, mongo_handle); - } - - currentPort = global_mongo_tcp_port; - - dissector_add_uint("tcp.port", currentPort, mongo_handle); - + dissector_add_uint_with_preference("tcp.port", TCP_PORT_MONGO, mongo_handle); } /* * Editor modelines diff --git a/epan/dissectors/packet-mp2t.c b/epan/dissectors/packet-mp2t.c index f116c50c3d..c5011df8c1 100644 --- a/epan/dissectors/packet-mp2t.c +++ b/epan/dissectors/packet-mp2t.c @@ -1552,7 +1552,7 @@ proto_reg_handoff_mp2t(void) heur_dissector_add("udp", heur_dissect_mp2t, "MP2T over UDP", "mp2t_udp", proto_mp2t, HEURISTIC_ENABLE); dissector_add_uint("rtp.pt", PT_MP2T, mp2t_handle); - dissector_add_for_decode_as("tcp.port", mp2t_handle); + dissector_add_for_decode_as_with_preference("tcp.port", mp2t_handle); dissector_add_for_decode_as("udp.port", mp2t_handle); heur_dissector_add("usb.bulk", heur_dissect_mp2t, "MP2T USB bulk endpoint", "mp2t_usb_bulk", proto_mp2t, HEURISTIC_ENABLE); dissector_add_uint("wtap_encap", WTAP_ENCAP_MPEG_2_TS, mp2t_handle); diff --git a/epan/dissectors/packet-mpeg-dsmcc.c b/epan/dissectors/packet-mpeg-dsmcc.c index 191f15289f..cb10daf1b3 100644 --- a/epan/dissectors/packet-mpeg-dsmcc.c +++ b/epan/dissectors/packet-mpeg-dsmcc.c @@ -1230,7 +1230,7 @@ proto_reg_handoff_dsmcc(void) dissector_add_uint("mpeg_sect.tid", DSMCC_TID_DESC_LIST, dsmcc_ts_handle); dissector_add_uint("mpeg_sect.tid", DSMCC_TID_PRIVATE, dsmcc_ts_handle); - dissector_add_uint("tcp.port", DSMCC_TCP_PORT, dsmcc_tcp_handle); + dissector_add_uint_with_preference("tcp.port", DSMCC_TCP_PORT, dsmcc_tcp_handle); } /* diff --git a/epan/dissectors/packet-mq.c b/epan/dissectors/packet-mq.c index 612a45d9d8..6fa713a027 100644 --- a/epan/dissectors/packet-mq.c +++ b/epan/dissectors/packet-mq.c @@ -4782,7 +4782,7 @@ void proto_reg_handoff_mq(void) mq_spx_handle = create_dissector_handle(dissect_mq_spx, proto_mq); - dissector_add_for_decode_as("tcp.port", mq_handle); + dissector_add_for_decode_as_with_preference("tcp.port", mq_handle); ssl_dissector_add(0, mq_handle); heur_dissector_add("tcp", dissect_mq_heur_tcp, "WebSphere MQ over TCP", "mq_tcp", proto_mq, HEURISTIC_ENABLE); heur_dissector_add("netbios", dissect_mq_heur_nontcp, "WebSphere MQ over Netbios", "mq_netbios", proto_mq, HEURISTIC_ENABLE); diff --git a/epan/dissectors/packet-mqtt.c b/epan/dissectors/packet-mqtt.c index e856aa1f65..0ec71507c3 100644 --- a/epan/dissectors/packet-mqtt.c +++ b/epan/dissectors/packet-mqtt.c @@ -654,7 +654,7 @@ void proto_register_mqtt(void) */ void proto_reg_handoff_mqtt(void) { - dissector_add_uint("tcp.port", MQTT_DEFAULT_PORT, mqtt_handle); + dissector_add_uint_with_preference("tcp.port", MQTT_DEFAULT_PORT, mqtt_handle); ssl_dissector_add(MQTT_SSL_DEFAULT_PORT, mqtt_handle); } diff --git a/epan/dissectors/packet-mrcpv2.c b/epan/dissectors/packet-mrcpv2.c index b15869124a..b38e4f6da8 100644 --- a/epan/dissectors/packet-mrcpv2.c +++ b/epan/dissectors/packet-mrcpv2.c @@ -38,7 +38,6 @@ #include <stdlib.h> #include <epan/packet.h> -#include <epan/prefs.h> #include "packet-tcp.h" #include <wsutil/str_util.h> @@ -379,8 +378,7 @@ static int hf_mrcpv2_Waveform_URI = -1; static int hf_mrcpv2_Weight = -1; /* Global MRCPv2 port pref */ -#define TCP_DEFAULT_RANGE "6075, 30000-30200" -static range_t *global_mrcpv2_tcp_range = NULL; +#define TCP_DEFAULT_RANGE "6075, 30000-30200" /* Not IANA registered */ /* Initialize the subtree pointers */ static gint ett_mrcpv2 = -1; @@ -1049,8 +1047,6 @@ dissect_mrcpv2_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da void proto_register_mrcpv2(void) { - module_t *mrcpv2_module; - static hf_register_info hf[] = { { &hf_mrcpv2_Request_Line, { "Request-Line", "mrcpv2.Request-Line", @@ -1498,41 +1494,20 @@ proto_register_mrcpv2(void) &ett_Status_Code }; - range_convert_str(&global_mrcpv2_tcp_range, TCP_DEFAULT_RANGE, 65535); - - proto_mrcpv2 = proto_register_protocol( - "Media Resource Control Protocol Version 2 (MRCPv2)", - "MRCPv2", - "mrcpv2"); + proto_mrcpv2 = proto_register_protocol("Media Resource Control Protocol Version 2 (MRCPv2)", "MRCPv2", "mrcpv2"); proto_register_field_array(proto_mrcpv2, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - mrcpv2_module = prefs_register_protocol(proto_mrcpv2, proto_reg_handoff_mrcpv2); - - prefs_register_obsolete_preference(mrcpv2_module, "tcp.port"); - prefs_register_range_preference(mrcpv2_module, "tcp.port_range", "MRCPv2 TCP Port", - "MRCPv2 TCP Ports Range", - &global_mrcpv2_tcp_range, 65535); } void proto_reg_handoff_mrcpv2(void) { - static gboolean initialized = FALSE; - static dissector_handle_t mrcpv2_handle; - static range_t *mrcpv2_tcp_range = NULL; + dissector_handle_t mrcpv2_handle; - if (!initialized) { - mrcpv2_handle = create_dissector_handle(dissect_mrcpv2_tcp, proto_mrcpv2); - initialized = TRUE; - } else { - dissector_delete_uint_range ("tcp.port", mrcpv2_tcp_range, mrcpv2_handle); - g_free (mrcpv2_tcp_range); - } + mrcpv2_handle = create_dissector_handle(dissect_mrcpv2_tcp, proto_mrcpv2); - mrcpv2_tcp_range = range_copy (global_mrcpv2_tcp_range); - dissector_add_uint_range ("tcp.port", mrcpv2_tcp_range, mrcpv2_handle); + dissector_add_uint_range_with_preference ("tcp.port", TCP_DEFAULT_RANGE, mrcpv2_handle); } /* * Editor modelines diff --git a/epan/dissectors/packet-ms-mms.c b/epan/dissectors/packet-ms-mms.c index 4c3ba7de4c..626e8d259a 100644 --- a/epan/dissectors/packet-ms-mms.c +++ b/epan/dissectors/packet-ms-mms.c @@ -1880,7 +1880,7 @@ void proto_reg_handoff_msmms_command(void) { msmms_handle = find_dissector("msmms"); /* Control commands using TCP port */ - dissector_add_uint("tcp.port", MSMMS_PORT, msmms_handle); + dissector_add_uint_with_preference("tcp.port", MSMMS_PORT, msmms_handle); /* Data command(s) using UDP port */ dissector_add_uint("udp.port", MSMMS_PORT, msmms_handle); } diff --git a/epan/dissectors/packet-msdp.c b/epan/dissectors/packet-msdp.c index 081c6cde24..b28fef8f3d 100644 --- a/epan/dissectors/packet-msdp.c +++ b/epan/dissectors/packet-msdp.c @@ -127,6 +127,7 @@ static const value_string sa_unspec_error_vals[] = { { 0, NULL }, }; +#define MSDP_PORT 639 /* Initialize the protocol and registered fields */ static int proto_msdp = -1; @@ -586,7 +587,7 @@ proto_reg_handoff_msdp(void) dissector_handle_t msdp_handle; msdp_handle = create_dissector_handle(dissect_msdp, proto_msdp); - dissector_add_uint("tcp.port", 639, msdp_handle); + dissector_add_uint_with_preference("tcp.port", MSDP_PORT, msdp_handle); ip_handle = find_dissector_add_dependency("ip", proto_msdp); } diff --git a/epan/dissectors/packet-msn-messenger.c b/epan/dissectors/packet-msn-messenger.c index fb068945ab..22b60560cb 100644 --- a/epan/dissectors/packet-msn-messenger.c +++ b/epan/dissectors/packet-msn-messenger.c @@ -133,7 +133,7 @@ proto_reg_handoff_msnms(void) dissector_handle_t msnms_handle; msnms_handle = create_dissector_handle(dissect_msnms, proto_msnms); - dissector_add_uint("tcp.port", TCP_PORT_MSNMS, msnms_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_MSNMS, msnms_handle); /* * For MSN Messenger Protocol over HTTP */ diff --git a/epan/dissectors/packet-msrp.c b/epan/dissectors/packet-msrp.c index e58acbf40e..a0ae6ef54e 100644 --- a/epan/dissectors/packet-msrp.c +++ b/epan/dissectors/packet-msrp.c @@ -943,9 +943,8 @@ void proto_reg_handoff_msrp(void) { msrp_handle = find_dissector("msrp"); - dissector_add_for_decode_as("tcp.port", msrp_handle); /* for "decode-as" */ heur_dissector_add("tcp", dissect_msrp_heur, "MSRP over TCP", "msrp_tcp", proto_msrp, HEURISTIC_ENABLE); - dissector_add_uint("tcp.port", TCP_PORT_MSRP, msrp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_MSRP, msrp_handle); media_type_dissector_table = find_dissector_table("media_type"); } diff --git a/epan/dissectors/packet-mysql.c b/epan/dissectors/packet-mysql.c index 9ccbfb15d7..4cf5780c17 100644 --- a/epan/dissectors/packet-mysql.c +++ b/epan/dissectors/packet-mysql.c @@ -3283,7 +3283,7 @@ void proto_register_mysql(void) void proto_reg_handoff_mysql(void) { ssl_handle = find_dissector("ssl"); - dissector_add_uint("tcp.port", TCP_PORT_MySQL, mysql_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_MySQL, mysql_handle); } /* diff --git a/epan/dissectors/packet-nasdaq-soup.c b/epan/dissectors/packet-nasdaq-soup.c index 84b8260a29..67bce1f137 100644 --- a/epan/dissectors/packet-nasdaq-soup.c +++ b/epan/dissectors/packet-nasdaq-soup.c @@ -61,9 +61,6 @@ static dissector_handle_t nasdaq_itch_handle; /* desegmentation of Nasdaq Soup */ static gboolean nasdaq_soup_desegment = TRUE; -static range_t *global_nasdaq_soup_tcp_range = NULL; -static range_t *nasdaq_soup_tcp_range = NULL; - /* Initialize the subtree pointers */ static gint ett_nasdaq_soup = -1; @@ -196,15 +193,6 @@ dissect_nasdaq_soup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d return tvb_captured_length(tvb); } -/* Register the protocol with Wireshark */ -static void nasdaq_soup_prefs(void) -{ - dissector_delete_uint_range("tcp.port", nasdaq_soup_tcp_range, nasdaq_soup_handle); - g_free(nasdaq_soup_tcp_range); - nasdaq_soup_tcp_range = range_copy(global_nasdaq_soup_tcp_range); - dissector_add_uint_range("tcp.port", nasdaq_soup_tcp_range, nasdaq_soup_handle); -} - void proto_register_nasdaq_soup(void) { @@ -272,15 +260,11 @@ proto_register_nasdaq_soup(void) proto_register_field_array(proto_nasdaq_soup, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - nasdaq_soup_module = prefs_register_protocol(proto_nasdaq_soup, nasdaq_soup_prefs); + nasdaq_soup_module = prefs_register_protocol(proto_nasdaq_soup, NULL); prefs_register_bool_preference(nasdaq_soup_module, "desegment", "Reassemble Nasdaq-SoupTCP messages spanning multiple TCP segments", "Whether the Nasdaq-SoupTCP dissector should reassemble messages spanning multiple TCP segments.", &nasdaq_soup_desegment); - - prefs_register_range_preference(nasdaq_soup_module, "tcp.port", "TCP Ports", "TCP Ports range", &global_nasdaq_soup_tcp_range, 65535); - - nasdaq_soup_tcp_range = range_empty(); } /* If this dissector uses sub-dissector registration add a registration routine. @@ -292,7 +276,7 @@ proto_reg_handoff_nasdaq_soup(void) { nasdaq_soup_handle = create_dissector_handle(dissect_nasdaq_soup, proto_nasdaq_soup); nasdaq_itch_handle = find_dissector_add_dependency("nasdaq-itch", proto_nasdaq_soup); - dissector_add_for_decode_as("tcp.port", nasdaq_soup_handle); + dissector_add_uint_range_with_preference("tcp.port", "", nasdaq_soup_handle); } /* diff --git a/epan/dissectors/packet-nbt.c b/epan/dissectors/packet-nbt.c index d62406b3f2..cceaaee562 100644 --- a/epan/dissectors/packet-nbt.c +++ b/epan/dissectors/packet-nbt.c @@ -151,6 +151,7 @@ static gboolean nbss_desegment = TRUE; #define UDP_PORT_NBDGM 138 #define TCP_PORT_NBSS 139 #define TCP_PORT_CIFS 445 +#define TCP_NBSS_PORT_RANGE "139,445" /* Packet structure taken from RFC 1002. See also RFC 1001. * Opcode, flags, and rcode treated as "flags", similarly to DNS, @@ -2091,8 +2092,7 @@ proto_reg_handoff_nbt(void) dissector_add_uint("udp.port", UDP_PORT_NBDGM, nbdgm_handle); nbss_handle = create_dissector_handle(dissect_nbss, proto_nbss); - dissector_add_uint("tcp.port", TCP_PORT_NBSS, nbss_handle); - dissector_add_uint("tcp.port", TCP_PORT_CIFS, nbss_handle); + dissector_add_uint_range_with_preference("tcp.port", TCP_NBSS_PORT_RANGE, nbss_handle); netbios_heur_subdissector_list = find_heur_dissector_list("netbios"); } diff --git a/epan/dissectors/packet-ncp.c b/epan/dissectors/packet-ncp.c index 6521c6f451..ae8226c053 100644 --- a/epan/dissectors/packet-ncp.c +++ b/epan/dissectors/packet-ncp.c @@ -1578,7 +1578,7 @@ proto_reg_handoff_ncp(void) ncp_handle = create_dissector_handle(dissect_ncp, proto_ncp); ncp_tcp_handle = create_dissector_handle(dissect_ncp_tcp, proto_ncp); - dissector_add_uint("tcp.port", TCP_PORT_NCP, ncp_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_NCP, ncp_tcp_handle); dissector_add_uint("udp.port", UDP_PORT_NCP, ncp_handle); dissector_add_uint("ipx.packet_type", IPX_PACKET_TYPE_NCP, ncp_handle); dissector_add_uint("ipx.socket", IPX_SOCKET_NCP, ncp_handle); diff --git a/epan/dissectors/packet-ndmp.c b/epan/dissectors/packet-ndmp.c index f3f0d4600d..f8d0f8f5ed 100644 --- a/epan/dissectors/packet-ndmp.c +++ b/epan/dissectors/packet-ndmp.c @@ -4267,7 +4267,7 @@ void proto_reg_handoff_ndmp(void) { ndmp_handle = create_dissector_handle(dissect_ndmp, proto_ndmp); - dissector_add_uint("tcp.port",TCP_PORT_NDMP, ndmp_handle); + dissector_add_uint_with_preference("tcp.port",TCP_PORT_NDMP, ndmp_handle); heur_dissector_add("tcp", dissect_ndmp_heur, "NDMP over TCP", "ndmp_tcp", proto_ndmp, HEURISTIC_ENABLE); } diff --git a/epan/dissectors/packet-ndps.c b/epan/dissectors/packet-ndps.c index 63f135dd81..21bf94d77c 100644 --- a/epan/dissectors/packet-ndps.c +++ b/epan/dissectors/packet-ndps.c @@ -9514,12 +9514,7 @@ proto_reg_handoff_ndps(void) dissector_add_uint("spx.socket", SPX_SOCKET_ENS, ndps_handle); dissector_add_uint("spx.socket", SPX_SOCKET_RMS, ndps_handle); dissector_add_uint("spx.socket", SPX_SOCKET_NOTIFY_LISTENER, ndps_handle); - dissector_add_uint("tcp.port", TCP_PORT_PA, ndps_tcp_handle); - dissector_add_uint("tcp.port", TCP_PORT_BROKER, ndps_tcp_handle); - dissector_add_uint("tcp.port", TCP_PORT_SRS, ndps_tcp_handle); - dissector_add_uint("tcp.port", TCP_PORT_ENS, ndps_tcp_handle); - dissector_add_uint("tcp.port", TCP_PORT_RMS, ndps_tcp_handle); - dissector_add_uint("tcp.port", TCP_PORT_NOTIFY_LISTENER, ndps_tcp_handle); + dissector_add_uint_range_with_preference("tcp.port", TCP_PORT_RANGE, ndps_tcp_handle); } /* diff --git a/epan/dissectors/packet-ndps.h b/epan/dissectors/packet-ndps.h index 3895f61a12..a21d623612 100644 --- a/epan/dissectors/packet-ndps.h +++ b/epan/dissectors/packet-ndps.h @@ -30,6 +30,7 @@ #define TCP_PORT_ENS 0x0bc8 /* NDPS Event Notification Service */ #define TCP_PORT_RMS 0x0bcb /* NDPS Remote Management Service */ #define TCP_PORT_NOTIFY_LISTENER 0x0bc9 /* NDPS Notify Listener */ +#define TCP_PORT_RANGE "3014,3016-3019,3369" /* diff --git a/epan/dissectors/packet-netflow.c b/epan/dissectors/packet-netflow.c index 88a4e954f0..126bd90604 100644 --- a/epan/dissectors/packet-netflow.c +++ b/epan/dissectors/packet-netflow.c @@ -12012,7 +12012,6 @@ ipfix_delete_callback(guint32 port) { if ( port ) { dissector_delete_uint("udp.port", port, netflow_handle); - dissector_delete_uint("tcp.port", port, netflow_handle); dissector_delete_uint("sctp.port", port, netflow_handle); } } @@ -12022,7 +12021,6 @@ ipfix_add_callback(guint32 port) { if ( port ) { dissector_add_uint("udp.port", port, netflow_handle); - dissector_add_uint("tcp.port", port, netflow_handle); dissector_add_uint("sctp.port", port, netflow_handle); } } @@ -12038,6 +12036,7 @@ proto_reg_handoff_netflow(void) netflow_handle = create_dissector_handle(dissect_netflow, proto_netflow); netflow_prefs_initialized = TRUE; dissector_add_uint("wtap_encap", WTAP_ENCAP_RAW_IPFIX, netflow_handle); + dissector_add_uint_range_with_preference("tcp.port", IPFIX_UDP_PORTS, netflow_handle); } else { dissector_delete_uint_range("udp.port", netflow_ports, netflow_handle); g_free(netflow_ports); diff --git a/epan/dissectors/packet-netsync.c b/epan/dissectors/packet-netsync.c index f399b9423a..91e46ce9e3 100644 --- a/epan/dissectors/packet-netsync.c +++ b/epan/dissectors/packet-netsync.c @@ -152,7 +152,6 @@ static int ett_netsync = -1; * for monotone netsync */ -static guint global_tcp_port_netsync = TCP_PORT_NETSYNC; static gboolean netsync_desegment = TRUE; static gint dissect_netsync_cmd_error( tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_) @@ -725,14 +724,7 @@ proto_register_netsync(void) proto_register_field_array(proto_netsync, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - netsync_module = prefs_register_protocol(proto_netsync, - proto_reg_handoff_netsync); - - prefs_register_uint_preference(netsync_module, "tcp_port", - "Monotone Netsync TCP Port", - "The TCP port on which Monotone Netsync packets will be sent", - 10, &global_tcp_port_netsync); - + netsync_module = prefs_register_protocol(proto_netsync, NULL); prefs_register_bool_preference(netsync_module, "desegment_netsync_messages", "Reassemble Netsync messages spanning multiple TCP segments", @@ -745,19 +737,11 @@ proto_register_netsync(void) void proto_reg_handoff_netsync(void) { - static dissector_handle_t netsync_handle; - static guint tcp_port_netsync; - static gboolean initialized = FALSE; - - if (!initialized) { - netsync_handle = create_dissector_handle(dissect_netsync, proto_netsync); - initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", tcp_port_netsync, netsync_handle); - } + dissector_handle_t netsync_handle; + + netsync_handle = create_dissector_handle(dissect_netsync, proto_netsync); - tcp_port_netsync = global_tcp_port_netsync; - dissector_add_uint("tcp.port", global_tcp_port_netsync, netsync_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_NETSYNC, netsync_handle); } /* diff --git a/epan/dissectors/packet-nntp.c b/epan/dissectors/packet-nntp.c index aeb3059654..afed7e8d7b 100644 --- a/epan/dissectors/packet-nntp.c +++ b/epan/dissectors/packet-nntp.c @@ -134,7 +134,7 @@ proto_reg_handoff_nntp(void) dissector_handle_t nntp_handle; nntp_handle = create_dissector_handle(dissect_nntp, proto_nntp); - dissector_add_uint("tcp.port", TCP_PORT_NNTP, nntp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_NNTP, nntp_handle); } /* diff --git a/epan/dissectors/packet-ntp.c b/epan/dissectors/packet-ntp.c index c4bad5b0e8..b073ae7872 100644 --- a/epan/dissectors/packet-ntp.c +++ b/epan/dissectors/packet-ntp.c @@ -1705,7 +1705,7 @@ proto_reg_handoff_ntp(void) ntp_handle = create_dissector_handle(dissect_ntp, proto_ntp); dissector_add_uint("udp.port", UDP_PORT_NTP, ntp_handle); - dissector_add_uint("tcp.port", TCP_PORT_NTP, ntp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_NTP, ntp_handle); } /* diff --git a/epan/dissectors/packet-obex.c b/epan/dissectors/packet-obex.c index 35e9190879..0c75cdeb73 100644 --- a/epan/dissectors/packet-obex.c +++ b/epan/dissectors/packet-obex.c @@ -3959,7 +3959,7 @@ proto_reg_handoff_obex(void) dissector_add_for_decode_as("usb.product", obex_handle); dissector_add_for_decode_as("usb.device", obex_handle); dissector_add_for_decode_as("usb.protocol", obex_handle); - dissector_add_for_decode_as("tcp.port", obex_handle); + dissector_add_for_decode_as_with_preference("tcp.port", obex_handle); dissector_add_for_decode_as("udp.port", obex_handle); } diff --git a/epan/dissectors/packet-ocfs2.c b/epan/dissectors/packet-ocfs2.c index 4966f7ddef..458aca1424 100644 --- a/epan/dissectors/packet-ocfs2.c +++ b/epan/dissectors/packet-ocfs2.c @@ -1686,7 +1686,7 @@ void proto_reg_handoff_ocfs2(void) ocfs2_handle = create_dissector_handle(dissect_ocfs2, proto_ocfs2); - dissector_add_for_decode_as("tcp.port", ocfs2_handle); + dissector_add_for_decode_as_with_preference("tcp.port", ocfs2_handle); } diff --git a/epan/dissectors/packet-omapi.c b/epan/dissectors/packet-omapi.c index 1e104a2da1..7a42e972ab 100644 --- a/epan/dissectors/packet-omapi.c +++ b/epan/dissectors/packet-omapi.c @@ -78,7 +78,7 @@ static int hf_omapi_no_value = -1; static gint ett_omapi = -1; -#define OMAPI_PORT 7911 +#define OMAPI_PORT 7911 /* Not IANA registered */ #define OP_OPEN 1 #define OP_REFRESH 2 @@ -318,7 +318,7 @@ proto_reg_handoff_omapi(void) dissector_handle_t omapi_handle; omapi_handle = create_dissector_handle(dissect_omapi, proto_omapi); - dissector_add_uint("tcp.port", OMAPI_PORT, omapi_handle); + dissector_add_uint_with_preference("tcp.port", OMAPI_PORT, omapi_handle); } /* diff --git a/epan/dissectors/packet-opa-fe.c b/epan/dissectors/packet-opa-fe.c index 06922cd4d4..11ca863f81 100644 --- a/epan/dissectors/packet-opa-fe.c +++ b/epan/dissectors/packet-opa-fe.c @@ -31,7 +31,7 @@ void proto_reg_handoff_opa_fe(void); void proto_register_opa_fe(void); -#define OPA_FE_TCP_RANGE "3245-3248" +#define OPA_FE_TCP_RANGE "3245-3248" /* Not IANA registered */ #define OPA_FE_SSL_RANGE "3249-3252" /* Wireshark ID */ @@ -51,10 +51,8 @@ static gint hf_opa_fe_Reserved64 = -1; static dissector_handle_t opa_fe_handle; static dissector_handle_t opa_mad_handle; -static range_t *global_fe_tcp_range = NULL; static range_t *global_fe_ssl_range = NULL; -static range_t *fe_tcp_range = NULL; static range_t *fe_ssl_range = NULL; static int dissect_opa_fe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) @@ -142,26 +140,24 @@ void proto_register_opa_fe(void) prefs_register_range_preference(opa_fe_module, "ssl.port", "SSL/TLS Ports", "SSL/TLS Ports range", &global_fe_ssl_range, 65535); - range_convert_str(&global_fe_tcp_range, OPA_FE_TCP_RANGE, 65535); - fe_tcp_range = range_empty(); - prefs_register_range_preference(opa_fe_module, "tcp.port", "TCP Ports", - "TCP Ports range", - &global_fe_tcp_range, 65535); } void proto_reg_handoff_opa_fe(void) { - opa_mad_handle = find_dissector("opa.mad"); + static gboolean initialized = FALSE; + + if (!initialized) + { + opa_mad_handle = find_dissector("opa.mad"); + dissector_add_uint_range_with_preference("tcp.port", OPA_FE_TCP_RANGE, opa_fe_handle); + initialized = TRUE; + } range_foreach(fe_ssl_range, range_delete_fe_ssl_callback); g_free(fe_ssl_range); fe_ssl_range = range_copy(global_fe_ssl_range); range_foreach(fe_ssl_range, range_add_fe_ssl_callback); - dissector_delete_uint_range("tcp.port", fe_tcp_range, opa_fe_handle); - g_free(fe_tcp_range); - fe_tcp_range = range_copy(global_fe_tcp_range); - dissector_add_uint_range("tcp.port", fe_tcp_range, opa_fe_handle); } /* diff --git a/epan/dissectors/packet-openflow.c b/epan/dissectors/packet-openflow.c index 825fa473f6..27410ebda4 100644 --- a/epan/dissectors/packet-openflow.c +++ b/epan/dissectors/packet-openflow.c @@ -29,6 +29,7 @@ #include <epan/packet.h> #include <epan/expert.h> #include <epan/prefs.h> +#include <epan/prefs-int.h> #include "packet-tcp.h" @@ -134,6 +135,14 @@ dissect_openflow_heur(tvbuff_t *tvb, packet_info *pinfo, return TRUE; } +static void +apply_openflow_prefs(void) +{ + /* Openflow uses the port preference for heuristics */ + pref_t *openflow_port = prefs_find_preference(prefs_find_module("openflow"), "tcp.port"); + g_openflow_port = *openflow_port->varp.uint; +} + /* * Register the protocol with Wireshark. */ @@ -166,12 +175,7 @@ proto_register_openflow(void) expert_openflow = expert_register_protocol(proto_openflow); expert_register_field_array(expert_openflow, ei, array_length(ei)); - openflow_module = prefs_register_protocol(proto_openflow, proto_reg_handoff_openflow); - - /* Register port preference */ - prefs_register_uint_preference(openflow_module, "tcp.port", "OpenFlow TCP port", - "OpenFlow TCP port (6653 is the IANA assigned port)", - 10, &g_openflow_port); + openflow_module = prefs_register_protocol(proto_openflow, apply_openflow_prefs); /* Register heuristic preference */ prefs_register_obsolete_preference(openflow_module, "heuristic"); @@ -187,19 +191,9 @@ proto_register_openflow(void) void proto_reg_handoff_openflow(void) { - static gboolean initialized = FALSE; - static int currentPort; - - if (!initialized) { - heur_dissector_add("tcp", dissect_openflow_heur, "OpenFlow over TCP", "openflow_tcp", proto_openflow, HEURISTIC_ENABLE); - initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", currentPort, openflow_handle); - } - - currentPort = g_openflow_port; + heur_dissector_add("tcp", dissect_openflow_heur, "OpenFlow over TCP", "openflow_tcp", proto_openflow, HEURISTIC_ENABLE); - dissector_add_uint("tcp.port", currentPort, openflow_handle); + dissector_add_uint_with_preference("tcp.port", OFP_IANA_PORT, openflow_handle); openflow_v1_handle = find_dissector_add_dependency("openflow_v1", proto_openflow); openflow_v4_handle = find_dissector_add_dependency("openflow_v4", proto_openflow); diff --git a/epan/dissectors/packet-openvpn.c b/epan/dissectors/packet-openvpn.c index b3781674df..2d40d47085 100644 --- a/epan/dissectors/packet-openvpn.c +++ b/epan/dissectors/packet-openvpn.c @@ -90,7 +90,6 @@ static dissector_handle_t ssl_handle; static gboolean pref_long_format = TRUE; static gboolean pref_tls_auth = FALSE; static gboolean pref_tls_auth_override = FALSE; -static guint pref_tcp_port = OPENVPN_PORT; static guint pref_udp_port = OPENVPN_PORT; static guint tls_auth_hmac_size = 20; /* Default SHA-1 160 Bits */ @@ -619,11 +618,6 @@ proto_register_openvpn(void) openvpn_module = prefs_register_protocol(proto_openvpn, proto_reg_handoff_openvpn); prefs_register_uint_preference(openvpn_module, - "tcp.port", - "OpenVPN TCP Port", - "TCP Port of the OpenVPN tunnel", - 10, &pref_tcp_port); - prefs_register_uint_preference(openvpn_module, "udp.port", "OpenVPN UDP Port", "UDP Port of the OpenVPN tunnel", @@ -661,25 +655,20 @@ proto_register_openvpn(void) void proto_reg_handoff_openvpn(void) { - static guint tcp_port; static guint udp_port; static gboolean initialized = FALSE; if (! initialized) { ssl_handle = find_dissector_add_dependency("ssl", proto_openvpn); + dissector_add_uint_with_preference("tcp.port", OPENVPN_PORT, openvpn_tcp_handle); initialized = TRUE; } else { - if (tcp_port > 0) - dissector_delete_uint("tcp.port", tcp_port, openvpn_tcp_handle); if (udp_port > 0) dissector_delete_uint("udp.port", udp_port, openvpn_udp_handle); } - tcp_port = pref_tcp_port; udp_port = pref_udp_port; - if (tcp_port > 0) - dissector_add_uint("tcp.port", tcp_port, openvpn_tcp_handle); if (udp_port > 0) dissector_add_uint("udp.port", udp_port, openvpn_udp_handle); } diff --git a/epan/dissectors/packet-openwire.c b/epan/dissectors/packet-openwire.c index 8f5b4f6bef..46952ac2a6 100644 --- a/epan/dissectors/packet-openwire.c +++ b/epan/dissectors/packet-openwire.c @@ -2006,7 +2006,7 @@ proto_reg_handoff_openwire(void) { heur_dissector_add("tcp", dissect_openwire_heur, "OpenWire over TCP", "openwire_tcp", proto_openwire, HEURISTIC_ENABLE); openwire_tcp_handle = create_dissector_handle(dissect_openwire_tcp, proto_openwire); - dissector_add_for_decode_as("tcp.port", openwire_tcp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", openwire_tcp_handle); } /* diff --git a/epan/dissectors/packet-opsi.c b/epan/dissectors/packet-opsi.c index bccf467d9a..486e5f077b 100644 --- a/epan/dissectors/packet-opsi.c +++ b/epan/dissectors/packet-opsi.c @@ -33,7 +33,7 @@ void proto_register_opsi(void); void proto_reg_handoff_opsi(void); /* TCP destination port dedicated to the OPSI protocol */ -#define TCP_PORT_OPSI 4002 +#define TCP_PORT_OPSI 4002 /* Not IANA registered */ /* Information position in OPSI header */ #define MAJOR_VERSION_OFFSET 0 @@ -882,7 +882,7 @@ proto_reg_handoff_opsi(void) { dissector_handle_t opsi_handle; opsi_handle = create_dissector_handle(dissect_opsi, proto_opsi); - dissector_add_uint("tcp.port", TCP_PORT_OPSI, opsi_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_OPSI, opsi_handle); } /* diff --git a/epan/dissectors/packet-optommp.c b/epan/dissectors/packet-optommp.c index 4913787a3f..fdb06301bc 100644 --- a/epan/dissectors/packet-optommp.c +++ b/epan/dissectors/packet-optommp.c @@ -24,7 +24,6 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> #include "packet-tcp.h" #define OPTO_FRAME_HEADER_LEN 8 @@ -59,9 +58,6 @@ static gint ett_optommp = -1; static gint ett_dest_id = -1; static gint ett_data_block_q = -1; static gint ett_data_block_b = -1; -/* PORT_PREF */ -static guint gOPTOMMP_PORT_PREF = 0; - static const value_string optommp_tcode_names[] = { { 0, "Write Quadlet Request" }, @@ -808,7 +804,6 @@ purpose: create and register the protocol, trees, and fields ****************************************************************************/ void proto_register_optommp(void) { - module_t *optommp_module; /* The fields */ static hf_register_info hf[] = { @@ -896,17 +891,9 @@ void proto_register_optommp(void) &ett_data_block_b }; /* The protocol */ - proto_optommp = proto_register_protocol( - "OptoMMP", - "OptoMMP", - "optommp"); + proto_optommp = proto_register_protocol("OptoMMP", "OptoMMP", "optommp"); proto_register_field_array(proto_optommp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - optommp_module = prefs_register_protocol(proto_optommp, - proto_reg_handoff_optommp); - prefs_register_uint_preference(optommp_module, "tcp.port", - "OptoMMP TCP or UDP Port", " OptoMMP TCP or UDP port if other than the default", - 10, &gOPTOMMP_PORT_PREF); } /**************************************************************************** @@ -916,26 +903,11 @@ purpose: plug into wireshark with a handle ****************************************************************************/ void proto_reg_handoff_optommp(void) { - static gboolean initialized = FALSE; - static gint currentPort; - - if( !initialized ) - { - optommp_tcp_handle = create_dissector_handle( - dissect_optommp_reassemble_tcp, proto_optommp); - optommp_udp_handle = create_dissector_handle( - dissect_optommp_reassemble_udp, proto_optommp); - initialized = TRUE; - } - else - { - dissector_delete_uint("tcp.port", currentPort, optommp_tcp_handle); - dissector_delete_uint("udp.port", currentPort, optommp_udp_handle); - } + optommp_tcp_handle = create_dissector_handle(dissect_optommp_reassemble_tcp, proto_optommp); + optommp_udp_handle = create_dissector_handle(dissect_optommp_reassemble_udp, proto_optommp); - currentPort = gOPTOMMP_PORT_PREF; - dissector_add_uint("tcp.port", currentPort, optommp_tcp_handle); - dissector_add_uint("udp.port", currentPort, optommp_udp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", optommp_tcp_handle); + dissector_add_for_decode_as_with_preference("udp.port", optommp_udp_handle); } /* diff --git a/epan/dissectors/packet-osc.c b/epan/dissectors/packet-osc.c index e4170a942a..d62acb5acf 100644 --- a/epan/dissectors/packet-osc.c +++ b/epan/dissectors/packet-osc.c @@ -45,7 +45,6 @@ #include <string.h> #include <epan/packet.h> -#include <epan/prefs.h> #include <epan/exceptions.h> #include "packet-tcp.h" @@ -307,9 +306,6 @@ static const char *immediate_fmt = "%s"; static const char *immediate_str = "Immediate"; static const char *bundle_str = "#bundle"; -/* Preference */ -static guint global_osc_tcp_port = 0; - /* Initialize the protocol and registered fields */ static dissector_handle_t osc_udp_handle = NULL; @@ -1284,51 +1280,26 @@ proto_register_osc(void) &ett_osc_midi }; - module_t *osc_module; - proto_osc = proto_register_protocol("Open Sound Control Encoding", "OSC", "osc"); proto_register_field_array(proto_osc, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - osc_module = prefs_register_protocol(proto_osc, proto_reg_handoff_osc); - - prefs_register_uint_preference(osc_module, "tcp.port", - "OSC TCP Port", - "Set the TCP port for OSC", - 10, &global_osc_tcp_port); } void proto_reg_handoff_osc(void) { - static dissector_handle_t osc_tcp_handle; - static guint osc_tcp_port; - static gboolean initialized = FALSE; - - if(! initialized) - { - osc_tcp_handle = create_dissector_handle(dissect_osc_tcp, proto_osc); - /* register for "decode as" for TCP connections */ - dissector_add_for_decode_as("tcp.port", osc_tcp_handle); + dissector_handle_t osc_tcp_handle; - /* XXX: Add port pref and "decode as" for UDP ? */ - /* (The UDP heuristic is a bit expensive */ - osc_udp_handle = create_dissector_handle(dissect_osc_udp, proto_osc); - /* register as heuristic dissector for UDP connections */ - heur_dissector_add("udp", dissect_osc_heur_udp, "Open Sound Control over UDP", "osc_udp", proto_osc, HEURISTIC_ENABLE); + osc_tcp_handle = create_dissector_handle(dissect_osc_tcp, proto_osc); - initialized = TRUE; - } - else - { - if(osc_tcp_port != 0) - dissector_delete_uint("tcp.port", osc_tcp_port, osc_tcp_handle); - } + /* XXX: Add port pref and "decode as" for UDP ? */ + /* (The UDP heuristic is a bit expensive */ + osc_udp_handle = create_dissector_handle(dissect_osc_udp, proto_osc); + /* register as heuristic dissector for UDP connections */ + heur_dissector_add("udp", dissect_osc_heur_udp, "Open Sound Control over UDP", "osc_udp", proto_osc, HEURISTIC_ENABLE); - osc_tcp_port = global_osc_tcp_port; - if(osc_tcp_port != 0) - dissector_add_uint("tcp.port", osc_tcp_port, osc_tcp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", osc_tcp_handle); } /* diff --git a/epan/dissectors/packet-osi.c b/epan/dissectors/packet-osi.c index 7d7868c37d..5471d2a0cf 100644 --- a/epan/dissectors/packet-osi.c +++ b/epan/dissectors/packet-osi.c @@ -50,7 +50,6 @@ static dissector_handle_t osi_handle; /* Preferences for OSI over TPKT over TCP */ static gboolean tpkt_desegment = FALSE; -static guint global_tcp_port_osi_over_tpkt = 0; gboolean osi_calc_checksum( tvbuff_t *tvb, int offset, guint len, guint32* c0, guint32* c1) { @@ -500,44 +499,30 @@ static int dissect_osi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void void proto_reg_handoff_osi(void) { - static gboolean osi_prefs_initialized = FALSE; - static dissector_handle_t osi_tpkt_handle, osi_juniper_handle; - static guint tcp_port_osi_over_tpkt; - - if (!osi_prefs_initialized) { - osi_handle = create_dissector_handle(dissect_osi, proto_osi); - dissector_add_uint("llc.dsap", SAP_OSINL1, osi_handle); - dissector_add_uint("llc.dsap", SAP_OSINL2, osi_handle); - dissector_add_uint("llc.dsap", SAP_OSINL3, osi_handle); - dissector_add_uint("llc.dsap", SAP_OSINL4, osi_handle); - dissector_add_uint("llc.dsap", SAP_OSINL5, osi_handle); - dissector_add_uint("ppp.protocol", PPP_OSI, osi_handle); - dissector_add_uint("chdlc.protocol", CHDLCTYPE_OSI, osi_handle); - dissector_add_uint("null.type", BSD_AF_ISO, osi_handle); - dissector_add_uint("gre.proto", SAP_OSINL5, osi_handle); - dissector_add_uint("ip.proto", IP_PROTO_ISOIP, osi_handle); /* ISO network layer PDUs [RFC 1070] */ - - osi_juniper_handle = create_dissector_handle(dissect_osi_juniper, proto_osi); - dissector_add_uint("juniper.proto", JUNIPER_PROTO_ISO, osi_juniper_handle); - dissector_add_uint("juniper.proto", JUNIPER_PROTO_CLNP, osi_juniper_handle); - dissector_add_uint("juniper.proto", JUNIPER_PROTO_MPLS_CLNP, osi_juniper_handle); - - ppp_handle = find_dissector("ppp"); - - - osi_tpkt_handle = create_dissector_handle(dissect_osi_tpkt, proto_osi); - dissector_add_for_decode_as("tcp.port", osi_tpkt_handle); - osi_prefs_initialized = TRUE; - } else { - if (tcp_port_osi_over_tpkt != 0) { - dissector_delete_uint("tcp.port", tcp_port_osi_over_tpkt, osi_tpkt_handle); - } - } - - if (global_tcp_port_osi_over_tpkt != 0) { - dissector_add_uint("tcp.port", global_tcp_port_osi_over_tpkt, osi_tpkt_handle); - } - tcp_port_osi_over_tpkt = global_tcp_port_osi_over_tpkt; + dissector_handle_t osi_tpkt_handle, osi_juniper_handle; + + osi_handle = create_dissector_handle(dissect_osi, proto_osi); + dissector_add_uint("llc.dsap", SAP_OSINL1, osi_handle); + dissector_add_uint("llc.dsap", SAP_OSINL2, osi_handle); + dissector_add_uint("llc.dsap", SAP_OSINL3, osi_handle); + dissector_add_uint("llc.dsap", SAP_OSINL4, osi_handle); + dissector_add_uint("llc.dsap", SAP_OSINL5, osi_handle); + dissector_add_uint("ppp.protocol", PPP_OSI, osi_handle); + dissector_add_uint("chdlc.protocol", CHDLCTYPE_OSI, osi_handle); + dissector_add_uint("null.type", BSD_AF_ISO, osi_handle); + dissector_add_uint("gre.proto", SAP_OSINL5, osi_handle); + dissector_add_uint("ip.proto", IP_PROTO_ISOIP, osi_handle); /* ISO network layer PDUs [RFC 1070] */ + + osi_juniper_handle = create_dissector_handle(dissect_osi_juniper, proto_osi); + dissector_add_uint("juniper.proto", JUNIPER_PROTO_ISO, osi_juniper_handle); + dissector_add_uint("juniper.proto", JUNIPER_PROTO_CLNP, osi_juniper_handle); + dissector_add_uint("juniper.proto", JUNIPER_PROTO_MPLS_CLNP, osi_juniper_handle); + + ppp_handle = find_dissector("ppp"); + + osi_tpkt_handle = create_dissector_handle(dissect_osi_tpkt, proto_osi); + + dissector_add_for_decode_as_with_preference("tcp.port", osi_tpkt_handle); } void @@ -569,12 +554,8 @@ proto_register_osi(void) "OSI excl NLPID", proto_osi, FT_UINT8, BASE_HEX); /* Preferences how OSI protocols should be dissected */ - osi_module = prefs_register_protocol(proto_osi, proto_reg_handoff_osi); + osi_module = prefs_register_protocol(proto_osi, NULL); - prefs_register_uint_preference(osi_module, "tpkt_port", - "TCP port for OSI over TPKT", - "TCP port for OSI over TPKT", - 10, &global_tcp_port_osi_over_tpkt); prefs_register_bool_preference(osi_module, "tpkt_reassemble", "Reassemble segmented TPKT datagrams", "Whether segmented TPKT datagrams should be reassembled", diff --git a/epan/dissectors/packet-ouch.c b/epan/dissectors/packet-ouch.c index c2eb1641b6..0c97e9f172 100644 --- a/epan/dissectors/packet-ouch.c +++ b/epan/dissectors/packet-ouch.c @@ -48,7 +48,6 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> void proto_register_ouch(void); void proto_reg_handoff_ouch(void); @@ -275,9 +274,6 @@ static const value_string ouch_trade_correction_reason_val[] = { static int proto_ouch = -1; static dissector_handle_t ouch_handle; -static range_t *global_ouch_range = NULL; -static range_t *ouch_range = NULL; - /* Initialize the subtree pointers */ static gint ett_ouch = -1; @@ -1239,19 +1235,6 @@ dissect_ouch( return offset; } - -/* Register the protocol with Wireshark */ - -static void -ouch_prefs(void) -{ - dissector_delete_uint_range("tcp.port", ouch_range, ouch_handle); - g_free(ouch_range); - ouch_range = range_copy(global_ouch_range); - dissector_add_uint_range("tcp.port", ouch_range, ouch_handle); -} - - /** Returns a guess if a packet is OUCH or not * * Since SOUP doesn't have a sub-protocol type flag, we have to use a @@ -1387,8 +1370,6 @@ dissect_ouch_heur( void proto_register_ouch(void) { - module_t *ouch_module; - /* Setup list of header fields See Section 1.6.1 for details*/ static hf_register_info hf[] = { @@ -1591,16 +1572,6 @@ proto_register_ouch(void) * subtrees used */ proto_register_field_array(proto_ouch, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - ouch_module = prefs_register_protocol(proto_ouch, ouch_prefs); - - prefs_register_range_preference(ouch_module, - "tcp.port", - "TCP Ports", - "TCP Ports range", - &global_ouch_range, - 65535); - ouch_range = range_empty(); } @@ -1613,6 +1584,7 @@ proto_reg_handoff_ouch(void) { ouch_handle = create_dissector_handle(dissect_ouch, proto_ouch); heur_dissector_add("soupbintcp", dissect_ouch_heur, "OUCH over SoupBinTCP", "ouch_soupbintcp", proto_ouch, HEURISTIC_ENABLE); + dissector_add_uint_range_with_preference("tcp.port", "", ouch_handle); } diff --git a/epan/dissectors/packet-pcep.c b/epan/dissectors/packet-pcep.c index 7856e3f76f..d9e8b4e332 100644 --- a/epan/dissectors/packet-pcep.c +++ b/epan/dissectors/packet-pcep.c @@ -5616,7 +5616,7 @@ proto_reg_handoff_pcep(void) dissector_handle_t pcep_handle; pcep_handle = create_dissector_handle(dissect_pcep, proto_pcep); - dissector_add_uint("tcp.port", TCP_PORT_PCEP, pcep_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_PCEP, pcep_handle); } /* diff --git a/epan/dissectors/packet-pcp.c b/epan/dissectors/packet-pcp.c index 9a364c67f9..2c77173832 100644 --- a/epan/dissectors/packet-pcp.c +++ b/epan/dissectors/packet-pcp.c @@ -2561,7 +2561,7 @@ void proto_register_pcp(void) void proto_reg_handoff_pcp(void) { - dissector_add_uint("tcp.port", PCP_PORT, pcp_handle); + dissector_add_uint_with_preference("tcp.port", PCP_PORT, pcp_handle); } /* diff --git a/epan/dissectors/packet-pdc.c b/epan/dissectors/packet-pdc.c index eba89fab7a..e1c8d23949 100644 --- a/epan/dissectors/packet-pdc.c +++ b/epan/dissectors/packet-pdc.c @@ -24,7 +24,6 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> #include "packet-tcp.h" void proto_register_pdc(void); @@ -57,7 +56,6 @@ void proto_reg_handoff_pdc(void); static dissector_handle_t asterix_handle; static int proto_pdc = -1; -static guint gPREF_PORT_NUM_TCP = 0; /*HF Declarations*/ static gint hf_pdc_len = -1; @@ -475,8 +473,6 @@ static int tcp_dissect_pdc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void proto_register_pdc(void) { - module_t *pdc_pref_module; - static hf_register_info hf[] = { { &hf_pdc_len, @@ -579,37 +575,17 @@ void proto_register_pdc(void) /*Required Function Calls to register the header fields and subtrees used*/ proto_register_field_array(proto_pdc, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - /*Register Preferences Module*/ - pdc_pref_module = prefs_register_protocol(proto_pdc, proto_reg_handoff_pdc); - - /*Register Preferences*/ - prefs_register_uint_preference(pdc_pref_module, "tcp.port", "PDC Port", "PDC Port if other then the default", 10, &gPREF_PORT_NUM_TCP); } /* Function to add pdc dissector to tcp.port dissector table and to get handle for asterix dissector */ void proto_reg_handoff_pdc(void) { - static dissector_handle_t pdc_tcp_handle; - static int pdc_tcp_port; - static gboolean initialized = FALSE; + dissector_handle_t pdc_tcp_handle; - if (! initialized) - { - asterix_handle = find_dissector_add_dependency("asterix", proto_pdc); - pdc_tcp_handle = create_dissector_handle(tcp_dissect_pdc, proto_pdc); - dissector_add_for_decode_as("tcp.port", pdc_tcp_handle); - initialized = TRUE; - } - else - { - if (pdc_tcp_port != 0) - dissector_delete_uint("tcp.port", pdc_tcp_port, pdc_tcp_handle); - } + asterix_handle = find_dissector_add_dependency("asterix", proto_pdc); + pdc_tcp_handle = create_dissector_handle(tcp_dissect_pdc, proto_pdc); - pdc_tcp_port = gPREF_PORT_NUM_TCP; - if (pdc_tcp_port != 0) - dissector_add_uint("tcp.port", pdc_tcp_port, pdc_tcp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", pdc_tcp_handle); } /* diff --git a/epan/dissectors/packet-pgsql.c b/epan/dissectors/packet-pgsql.c index d20618d5fe..74e51dabe0 100644 --- a/epan/dissectors/packet-pgsql.c +++ b/epan/dissectors/packet-pgsql.c @@ -25,7 +25,6 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> #include "packet-ssl-utils.h" #include "packet-tcp.h" @@ -88,7 +87,7 @@ static int hf_routine = -1; static gint ett_pgsql = -1; static gint ett_values = -1; -static guint pgsql_port = 5432; +#define PGSQL_PORT 5432 static gboolean pgsql_desegment = TRUE; static gboolean first_message = TRUE; @@ -884,36 +883,19 @@ proto_register_pgsql(void) &ett_values }; - module_t *mod_pgsql; - proto_pgsql = proto_register_protocol("PostgreSQL", "PGSQL", "pgsql"); proto_register_field_array(proto_pgsql, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - mod_pgsql = prefs_register_protocol(proto_pgsql, proto_reg_handoff_pgsql); - prefs_register_uint_preference( - mod_pgsql, "tcp.port", "PGSQL TCP port", "Set the port for PGSQL " - "messages (if different from the default of 5432)", 10, &pgsql_port - ); } void proto_reg_handoff_pgsql(void) { - static gboolean initialized = FALSE; - static guint saved_pgsql_port; - - if (!initialized) { - pgsql_handle = create_dissector_handle(dissect_pgsql, proto_pgsql); - initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", saved_pgsql_port, pgsql_handle); - } + pgsql_handle = create_dissector_handle(dissect_pgsql, proto_pgsql); - dissector_add_uint("tcp.port", pgsql_port, pgsql_handle); - saved_pgsql_port = pgsql_port; + dissector_add_uint_with_preference("tcp.port", PGSQL_PORT, pgsql_handle); - ssl_handle = find_dissector("ssl"); + ssl_handle = find_dissector_add_dependency("ssl", proto_pgsql); } /* diff --git a/epan/dissectors/packet-pmproxy.c b/epan/dissectors/packet-pmproxy.c index e8ec8a037f..ec70628cea 100644 --- a/epan/dissectors/packet-pmproxy.c +++ b/epan/dissectors/packet-pmproxy.c @@ -258,7 +258,7 @@ void proto_reg_handoff_pmproxy(void) { pmproxy_handle = create_dissector_handle(dissect_pmproxy, proto_pmproxy); pcp_handle = find_dissector_add_dependency("pcp", proto_pmproxy); - dissector_add_uint("tcp.port", PMPROXY_PORT, pmproxy_handle); + dissector_add_uint_with_preference("tcp.port", PMPROXY_PORT, pmproxy_handle); } diff --git a/epan/dissectors/packet-pop.c b/epan/dissectors/packet-pop.c index 79b28055bb..63da2c167f 100644 --- a/epan/dissectors/packet-pop.c +++ b/epan/dissectors/packet-pop.c @@ -469,7 +469,7 @@ void proto_reg_handoff_pop(void) { pop_handle = find_dissector("pop"); - dissector_add_uint("tcp.port", TCP_PORT_POP, pop_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_POP, pop_handle); ssl_dissector_add(TCP_PORT_SSL_POP, pop_handle); /* find the IMF dissector */ diff --git a/epan/dissectors/packet-pptp.c b/epan/dissectors/packet-pptp.c index be6b0fe946..16cf444eb7 100644 --- a/epan/dissectors/packet-pptp.c +++ b/epan/dissectors/packet-pptp.c @@ -961,7 +961,7 @@ proto_reg_handoff_pptp(void) dissector_handle_t pptp_handle; pptp_handle = create_dissector_handle(dissect_pptp, proto_pptp); - dissector_add_uint("tcp.port", TCP_PORT_PPTP, pptp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_PPTP, pptp_handle); } /* diff --git a/epan/dissectors/packet-ptpip.c b/epan/dissectors/packet-ptpip.c index ef0edd55e3..a763a41d02 100644 --- a/epan/dissectors/packet-ptpip.c +++ b/epan/dissectors/packet-ptpip.c @@ -1124,7 +1124,7 @@ void proto_reg_handoff_ptpIP( void ) { */ ptpIP_handle = create_dissector_handle(dissect_ptpIP, proto_ptpIP); - dissector_add_uint("tcp.port", PTPIP_PORT, ptpIP_handle); + dissector_add_uint_with_preference("tcp.port", PTPIP_PORT, ptpIP_handle); } /* diff --git a/epan/dissectors/packet-pvfs2.c b/epan/dissectors/packet-pvfs2.c index 563ed38082..462af09a39 100644 --- a/epan/dissectors/packet-pvfs2.c +++ b/epan/dissectors/packet-pvfs2.c @@ -39,7 +39,7 @@ #include <epan/expert.h> #include "packet-tcp.h" -#define TCP_PORT_PVFS2 3334 +#define TCP_PORT_PVFS2 3334 /* Not IANA registered */ #define PVFS2_FH_LENGTH 8 @@ -3624,7 +3624,7 @@ proto_reg_handoff_pvfs(void) dissector_handle_t pvfs_handle; pvfs_handle = create_dissector_handle(dissect_pvfs_heur, proto_pvfs); - dissector_add_uint("tcp.port", TCP_PORT_PVFS2, pvfs_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_PVFS2, pvfs_handle); heur_dissector_add("tcp", dissect_pvfs_heur, "PVFS over TCP", "pvfs_tcp", proto_pvfs, HEURISTIC_ENABLE); } diff --git a/epan/dissectors/packet-reload-framing.c b/epan/dissectors/packet-reload-framing.c index dba4a8c9c3..142c0cdc7c 100644 --- a/epan/dissectors/packet-reload-framing.c +++ b/epan/dissectors/packet-reload-framing.c @@ -592,7 +592,7 @@ proto_reg_handoff_reload_framing(void) reload_handle = find_dissector_add_dependency("reload", proto_reload_framing); - dissector_add_uint("tcp.port", TCP_PORT_RELOAD, reload_framing_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_RELOAD, reload_framing_tcp_handle); dissector_add_uint("udp.port", UDP_PORT_RELOAD, reload_framing_udp_handle); heur_dissector_add("udp", dissect_reload_framing_heur, "RELOAD Framing over UDP", "reload_framing_udp", proto_reload_framing, HEURISTIC_ENABLE); diff --git a/epan/dissectors/packet-riemann.c b/epan/dissectors/packet-riemann.c index 3ae459d0ff..5ee4093fd1 100644 --- a/epan/dissectors/packet-riemann.c +++ b/epan/dissectors/packet-riemann.c @@ -112,7 +112,6 @@ static int hf_riemann_state_state = -1; static int hf_riemann_state_once = -1; static guint udp_port_pref = 0; -static guint tcp_port_pref = 0; static gint ett_riemann = -1; static gint ett_query = -1; @@ -819,10 +818,6 @@ proto_register_riemann(void) prefs_register_uint_preference(riemann_module, "udp.port", "Riemann UDP Port", " riemann UDP port if other than the default", 10, &udp_port_pref); - - prefs_register_uint_preference(riemann_module, "tcp.port", "Riemann TCP Port", - " riemann TCP port if other than the default", - 10, &tcp_port_pref); } void @@ -830,20 +825,18 @@ proto_reg_handoff_riemann(void) { static gboolean initialized = FALSE; static dissector_handle_t riemann_udp_handle, riemann_tcp_handle; - static int current_udp_port, current_tcp_port; + static int current_udp_port; if (!initialized) { riemann_udp_handle = create_dissector_handle(dissect_riemann_udp, proto_riemann); riemann_tcp_handle = create_dissector_handle(dissect_riemann_tcp, proto_riemann); + dissector_add_for_decode_as_with_preference("tcp.port", riemann_tcp_handle); initialized = TRUE; } else { dissector_delete_uint("udp.port", current_udp_port, riemann_udp_handle); - dissector_delete_uint("tcp.port", current_tcp_port, riemann_tcp_handle); } current_udp_port = udp_port_pref; dissector_add_uint("udp.port", current_udp_port, riemann_udp_handle); - current_tcp_port = tcp_port_pref; - dissector_add_uint("tcp.port", current_tcp_port, riemann_tcp_handle); } /* diff --git a/epan/dissectors/packet-rlogin.c b/epan/dissectors/packet-rlogin.c index a7e92d364c..58f135b45f 100644 --- a/epan/dissectors/packet-rlogin.c +++ b/epan/dissectors/packet-rlogin.c @@ -603,7 +603,7 @@ void proto_reg_handoff_rlogin(void) { /* Dissector install routine */ dissector_handle_t rlogin_handle = create_dissector_handle(dissect_rlogin,proto_rlogin); - dissector_add_uint("tcp.port", RLOGIN_PORT, rlogin_handle); + dissector_add_uint_with_preference("tcp.port", RLOGIN_PORT, rlogin_handle); } /* diff --git a/epan/dissectors/packet-rmi.c b/epan/dissectors/packet-rmi.c index 550c6fe6cf..6552cd8c8a 100644 --- a/epan/dissectors/packet-rmi.c +++ b/epan/dissectors/packet-rmi.c @@ -373,7 +373,7 @@ proto_reg_handoff_rmi(void) dissector_handle_t rmi_handle; rmi_handle = create_dissector_handle(dissect_rmi, proto_rmi); - dissector_add_uint("tcp.port", TCP_PORT_RMI, rmi_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_RMI, rmi_handle); } /* diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c index 77d10c2718..498c4bd94f 100644 --- a/epan/dissectors/packet-rpc.c +++ b/epan/dissectors/packet-rpc.c @@ -69,6 +69,8 @@ void proto_register_rpc(void); void proto_reg_handoff_rpc(void); +#define RPC_TCP_PORT 111 + /* desegmentation of RPC over TCP */ static gboolean rpc_desegment = TRUE; @@ -4434,7 +4436,7 @@ proto_reg_handoff_rpc(void) to match some port for which we have a dissector) */ rpc_tcp_handle = find_dissector("rpc-tcp"); - dissector_add_uint("tcp.port", 111, rpc_tcp_handle); + dissector_add_uint_with_preference("tcp.port", RPC_TCP_PORT, rpc_tcp_handle); rpc_handle = find_dissector("rpc"); dissector_add_uint("udp.port", 111, rpc_handle); diff --git a/epan/dissectors/packet-rpki-rtr.c b/epan/dissectors/packet-rpki-rtr.c index 0187120e74..926a5214ad 100644 --- a/epan/dissectors/packet-rpki-rtr.c +++ b/epan/dissectors/packet-rpki-rtr.c @@ -29,6 +29,7 @@ #include <epan/packet.h> #include <epan/prefs.h> #include "packet-tcp.h" +#include "packet-ssl.h" #include <epan/expert.h> #include <epan/asn1.h> #include "packet-x509af.h" @@ -62,8 +63,9 @@ static int hf_rpkirtr_expire_interval = -1; static int hf_rpkirtr_subject_key_identifier = -1; static int hf_rpkirtr_subject_public_key_info = -1; -static guint g_port_rpkirtr = 323; -static guint g_port_rpkirtr_tls = 324; +#define RPKI_RTR_TCP_PORT 323 +#define RPKI_RTR_TLS_PORT 324 +static guint g_port_rpkirtr_tls = RPKI_RTR_TLS_PORT; static gint ett_rpkirtr = -1; static gint ett_flags = -1; @@ -466,15 +468,13 @@ proto_register_rpkirtr(void) rpkirtr_module = prefs_register_protocol(proto_rpkirtr, proto_reg_handoff_rpkirtr); - prefs_register_uint_preference(rpkirtr_module, "tcp.rpkirtr.port", "RPKI-RTR TCP Port", - "RPKI-Router Protocol TCP port if other than the default", - 10, &g_port_rpkirtr); prefs_register_uint_preference(rpkirtr_module, "tcp.rpkirtr_tls.port", "RPKI-RTR TCP TLS Port", "RPKI-Router Protocol TCP TLS port if other than the default", 10, &g_port_rpkirtr_tls); expert_rpkirtr = expert_register_protocol(proto_rpkirtr); expert_register_field_array(expert_rpkirtr, ei, array_length(ei)); + register_dissector("rpkirtr", dissect_rpkirtr, proto_rpkirtr); } @@ -483,26 +483,18 @@ proto_reg_handoff_rpkirtr(void) { static gboolean initialized = FALSE; static dissector_handle_t rpkirtr_handle; - static dissector_handle_t ssl_handle; - static int rpki_rtr_port, rpki_rtr_tls_port; + static int rpki_rtr_tls_port; if (!initialized) { - - rpkirtr_handle = create_dissector_handle(dissect_rpkirtr, - proto_rpkirtr); - ssl_handle = find_dissector("ssl"); + rpkirtr_handle = find_dissector("rpkirtr"); + dissector_add_uint_with_preference("tcp.port", RPKI_RTR_TCP_PORT, rpkirtr_handle); initialized = TRUE; } else { - - dissector_delete_uint("tcp.port", rpki_rtr_port, rpkirtr_handle); - dissector_delete_uint("tcp.port", rpki_rtr_tls_port, ssl_handle); + ssl_dissector_delete(rpki_rtr_tls_port, rpkirtr_handle); } - rpki_rtr_port = g_port_rpkirtr; rpki_rtr_tls_port = g_port_rpkirtr_tls; - - dissector_add_uint("tcp.port", rpki_rtr_port, rpkirtr_handle); - dissector_add_uint("tcp.port", rpki_rtr_tls_port, ssl_handle); + ssl_dissector_add(rpki_rtr_tls_port, rpkirtr_handle); } diff --git a/epan/dissectors/packet-rsh.c b/epan/dissectors/packet-rsh.c index 34ed9460f5..7b9d792135 100644 --- a/epan/dissectors/packet-rsh.c +++ b/epan/dissectors/packet-rsh.c @@ -432,7 +432,7 @@ proto_reg_handoff_rsh(void) dissector_handle_t rsh_handle; rsh_handle = create_dissector_handle(dissect_rsh, proto_rsh); - dissector_add_uint("tcp.port", RSH_PORT, rsh_handle); + dissector_add_uint_with_preference("tcp.port", RSH_PORT, rsh_handle); } /* diff --git a/epan/dissectors/packet-rsip.c b/epan/dissectors/packet-rsip.c index 22c849426f..2c4689038a 100644 --- a/epan/dissectors/packet-rsip.c +++ b/epan/dissectors/packet-rsip.c @@ -1242,18 +1242,11 @@ proto_register_rsip(void) void proto_reg_handoff_rsip(void) { - static gboolean initialized = FALSE; dissector_handle_t rsip_handle; - if (!initialized) { - - rsip_handle = create_dissector_handle(dissect_rsip, - proto_rsip); - dissector_add_uint("udp.port", UDP_PORT_RSIP, rsip_handle); - dissector_add_uint("tcp.port", TCP_PORT_RSIP, rsip_handle); - - initialized = TRUE; - } + rsip_handle = create_dissector_handle(dissect_rsip, proto_rsip); + dissector_add_uint("udp.port", UDP_PORT_RSIP, rsip_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_RSIP, rsip_handle); } /* diff --git a/epan/dissectors/packet-rsync.c b/epan/dissectors/packet-rsync.c index a849ed88f7..9ca13d66c6 100644 --- a/epan/dissectors/packet-rsync.c +++ b/epan/dissectors/packet-rsync.c @@ -30,9 +30,11 @@ #include <epan/packet.h> #include <epan/conversation.h> #include <epan/prefs.h> +#include <epan/prefs-int.h> #include <epan/proto_data.h> void proto_register_rsync(void); +void proto_reg_handoff_rsync(void); #define RSYNCD_MAGIC_HEADER "@RSYNCD:" #define RSYNCD_MAGIC_HEADER_LEN 8 @@ -306,10 +308,15 @@ dissect_rsync(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U return dissect_rsync_encap(tvb, pinfo, tree, rsync_desegment); } -/* Register protocol with Wireshark. */ - -void proto_reg_handoff_rsync(void); +static void +apply_rsync_prefs(void) +{ + /* Rsync uses the port preference to determine client/server */ + pref_t *rsync_port = prefs_find_preference(prefs_find_module("rsync"), "tcp.port"); + glb_rsync_tcp_port = *rsync_port->varp.uint; +} +/* Register protocol with Wireshark. */ void proto_register_rsync(void) { @@ -334,14 +341,13 @@ proto_register_rsync(void) int proto_rsync; - proto_rsync = proto_register_protocol("RSYNC File Synchroniser", - "RSYNC", "rsync"); + proto_rsync = proto_register_protocol("RSYNC File Synchroniser", "RSYNC", "rsync"); hfi_rsync = proto_registrar_get_nth(proto_rsync); proto_register_fields(proto_rsync, hfi, array_length(hfi)); proto_register_subtree_array(ett, array_length(ett)); - rsync_module = prefs_register_protocol(proto_rsync, proto_reg_handoff_rsync); + rsync_module = prefs_register_protocol(proto_rsync, apply_rsync_prefs); prefs_register_uint_preference(rsync_module, "tcp_port", "rsync TCP Port", "Set the TCP port for RSYNC messages", @@ -359,17 +365,7 @@ proto_register_rsync(void) void proto_reg_handoff_rsync(void) { - static gboolean initialized = FALSE; - static guint saved_rsync_tcp_port; - - if (!initialized) { - initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", saved_rsync_tcp_port, rsync_handle); - } - - dissector_add_uint("tcp.port", glb_rsync_tcp_port, rsync_handle); - saved_rsync_tcp_port = glb_rsync_tcp_port; + dissector_add_uint_with_preference("tcp.port", TCP_PORT_RSYNC, rsync_handle); } /* diff --git a/epan/dissectors/packet-rtmpt.c b/epan/dissectors/packet-rtmpt.c index c675b450b9..74e88f4e72 100644 --- a/epan/dissectors/packet-rtmpt.c +++ b/epan/dissectors/packet-rtmpt.c @@ -156,7 +156,7 @@ static gboolean rtmpt_desegment = TRUE; */ static guint rtmpt_max_packet_size = 32768; -#define RTMP_PORT 1935 +#define RTMP_PORT 1935 /* Not IANA registered */ #define RTMPT_MAGIC 0x03 #define RTMPT_HANDSHAKE_OFFSET_1 1 @@ -2927,8 +2927,7 @@ proto_reg_handoff_rtmpt(void) heur_dissector_add("tcp", dissect_rtmpt_heur, "RTMPT over TCP", "rtmpt_tcp", proto_rtmpt, HEURISTIC_DISABLE); rtmpt_tcp_handle = create_dissector_handle(dissect_rtmpt_tcp, proto_rtmpt); -/* dissector_add_for_decode_as("tcp.port", rtmpt_tcp_handle); */ - dissector_add_uint("tcp.port", RTMP_PORT, rtmpt_tcp_handle); + dissector_add_uint_with_preference("tcp.port", RTMP_PORT, rtmpt_tcp_handle); rtmpt_http_handle = create_dissector_handle(dissect_rtmpt_http, proto_rtmpt); dissector_add_string("media_type", "application/x-fcs", rtmpt_http_handle); diff --git a/epan/dissectors/packet-rtpproxy.c b/epan/dissectors/packet-rtpproxy.c index fb4002678f..3600e56d9a 100644 --- a/epan/dissectors/packet-rtpproxy.c +++ b/epan/dissectors/packet-rtpproxy.c @@ -276,8 +276,8 @@ static gint ett_rtpproxy_reply = -1; static gint ett_rtpproxy_ng_bencode = -1; /* Default values */ -static guint rtpproxy_tcp_port = 22222; -static guint rtpproxy_udp_port = 22222; +#define RTPPROXY_PORT 22222 /* Not IANA registered */ +static guint rtpproxy_udp_port = RTPPROXY_PORT; static gboolean rtpproxy_establish_conversation = TRUE; /* See - https://www.opensips.org/html/docs/modules/1.10.x/rtpproxy.html#id293555 */ /* See - http://www.kamailio.org/docs/modules/4.3.x/modules/rtpproxy.html#idp15794952 */ @@ -1454,12 +1454,6 @@ proto_register_rtpproxy(void) rtpproxy_module = prefs_register_protocol(proto_rtpproxy, proto_reg_handoff_rtpproxy); - prefs_register_uint_preference(rtpproxy_module, "tcp.port", - "RTPproxy TCP Port", /* Title */ - "RTPproxy TCP Port", /* Descr */ - 10, - &rtpproxy_tcp_port); - prefs_register_uint_preference(rtpproxy_module, "udp.port", "RTPproxy UDP Port", /* Title */ "RTPproxy UDP Port", /* Descr */ @@ -1482,7 +1476,6 @@ proto_register_rtpproxy(void) void proto_reg_handoff_rtpproxy(void) { - static guint old_rtpproxy_tcp_port = 0; static guint old_rtpproxy_udp_port = 0; static gboolean rtpproxy_initialized = FALSE; @@ -1492,16 +1485,12 @@ proto_reg_handoff_rtpproxy(void) if(!rtpproxy_initialized){ rtpproxy_tcp_handle = create_dissector_handle(dissect_rtpproxy, proto_rtpproxy); rtpproxy_udp_handle = create_dissector_handle(dissect_rtpproxy, proto_rtpproxy); + + /* Register TCP port for dissection */ + dissector_add_uint_with_preference("tcp.port", RTPPROXY_PORT, rtpproxy_tcp_handle); rtpproxy_initialized = TRUE; } - /* Register TCP port for dissection */ - if(old_rtpproxy_tcp_port != 0 && old_rtpproxy_tcp_port != rtpproxy_tcp_port) - dissector_delete_uint("tcp.port", old_rtpproxy_tcp_port, rtpproxy_tcp_handle); - if(rtpproxy_tcp_port != 0 && old_rtpproxy_tcp_port != rtpproxy_tcp_port) - dissector_add_uint("tcp.port", rtpproxy_tcp_port, rtpproxy_tcp_handle); - old_rtpproxy_tcp_port = rtpproxy_tcp_port; - /* Register UDP port for dissection */ if(old_rtpproxy_udp_port != 0 && old_rtpproxy_udp_port != rtpproxy_udp_port) dissector_delete_uint("udp.port", old_rtpproxy_udp_port, rtpproxy_udp_handle); diff --git a/epan/dissectors/packet-rtsp.c b/epan/dissectors/packet-rtsp.c index 255db652ad..063251d193 100644 --- a/epan/dissectors/packet-rtsp.c +++ b/epan/dissectors/packet-rtsp.c @@ -253,8 +253,6 @@ static gboolean rtsp_desegment_body = TRUE; */ #define RTSP_TCP_PORT_RANGE "554,8554,7236" -static range_t *global_rtsp_tcp_port_range = NULL; - /* * Takes an array of bytes, assumed to contain a null-terminated * string, as an argument, and returns the length of the string - @@ -1467,8 +1465,7 @@ proto_register_rtsp(void) module_t *rtsp_module; expert_module_t *expert_rtsp; - proto_rtsp = proto_register_protocol("Real Time Streaming Protocol", - "RTSP", "rtsp"); + proto_rtsp = proto_register_protocol("Real Time Streaming Protocol", "RTSP", "rtsp"); proto_register_field_array(proto_rtsp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -1481,15 +1478,10 @@ proto_register_rtsp(void) /* Register our configuration options, particularly our ports */ - rtsp_module = prefs_register_protocol(proto_rtsp, proto_reg_handoff_rtsp); + rtsp_module = prefs_register_protocol(proto_rtsp, NULL); prefs_register_obsolete_preference(rtsp_module, "tcp.alternate_port"); - prefs_register_obsolete_preference(rtsp_module, "tcp.port"); - range_convert_str(&global_rtsp_tcp_port_range, RTSP_TCP_PORT_RANGE, 65535); - prefs_register_range_preference(rtsp_module, "tcp.port_range", "RTSP TCP Ports", - "RTSP TCP Ports range", - &global_rtsp_tcp_port_range, 65535); prefs_register_bool_preference(rtsp_module, "desegment_headers", "Reassemble RTSP headers spanning multiple TCP segments", "Whether the RTSP dissector should reassemble headers " @@ -1520,26 +1512,17 @@ proto_register_rtsp(void) void proto_reg_handoff_rtsp(void) { - static dissector_handle_t rtsp_handle; - static gboolean rtsp_prefs_initialized = FALSE; - static range_t *rtsp_tcp_port_range = NULL; - - if (!rtsp_prefs_initialized) { - rtsp_handle = find_dissector("rtsp"); - rtp_handle = find_dissector("rtp"); - rtcp_handle = find_dissector("rtcp"); - rdt_handle = find_dissector("rdt"); - media_type_dissector_table = find_dissector_table("media_type"); - voip_tap = find_tap_id("voip"); - rtsp_prefs_initialized = TRUE; - } - else { - dissector_delete_uint_range("tcp.port", rtsp_tcp_port_range, rtsp_handle); - g_free(rtsp_tcp_port_range); - } + dissector_handle_t rtsp_handle; + + rtsp_handle = find_dissector("rtsp"); + rtp_handle = find_dissector_add_dependency("rtp", proto_rtsp); + rtcp_handle = find_dissector_add_dependency("rtcp", proto_rtsp); + rdt_handle = find_dissector_add_dependency("rdt", proto_rtsp); + media_type_dissector_table = find_dissector_table("media_type"); + voip_tap = find_tap_id("voip"); + /* Set our port number for future use */ - rtsp_tcp_port_range = range_copy(global_rtsp_tcp_port_range); - dissector_add_uint_range("tcp.port", rtsp_tcp_port_range, rtsp_handle); + dissector_add_uint_range_with_preference("tcp.port", RTSP_TCP_PORT_RANGE, rtsp_handle); /* XXX: Do the following only once ?? */ stats_tree_register("rtsp","rtsp","RTSP/Packet Counter", 0, rtsp_stats_tree_packet, rtsp_stats_tree_init, NULL ); diff --git a/epan/dissectors/packet-s5066dts.c b/epan/dissectors/packet-s5066dts.c index 4956675c27..91cac818cb 100644 --- a/epan/dissectors/packet-s5066dts.c +++ b/epan/dissectors/packet-s5066dts.c @@ -29,6 +29,7 @@ #include <epan/packet.h> #include <epan/prefs.h> +#include <epan/prefs-int.h> #include <epan/expert.h> #include "packet-tcp.h" /* For tcp_dissect_pdus() */ #include <epan/crc16-tvb.h> @@ -950,6 +951,14 @@ static int dissect_s5066dts_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t return b_length; } +static void +apply_s5066dts_prefs(void) +{ + /* STANAG 5066 uses the port preference for some heuristics */ + pref_t *s5066dts_port = prefs_find_preference(prefs_find_module("s5066dts"), "tcp.port"); + config_s5066dts_port = *s5066dts_port->varp.uint; +} + void proto_register_s5066dts (void) { module_t *s5066dts_module; @@ -1333,39 +1342,25 @@ void proto_register_s5066dts (void) register_dissector(DISSECTOR_NAME, dissect_s5066dts_tcp, proto_s5066dts); } - s5066dts_module = prefs_register_protocol(proto_s5066dts, proto_reg_handoff_s5066dts); + s5066dts_module = prefs_register_protocol(proto_s5066dts, apply_s5066dts_prefs); prefs_register_bool_preference(s5066dts_module, "proto_desegment", "Reassemble STANAG 5066 DPDUs spanning multiple TCP segments", "Whether the STANAG 5066 DTS Layer dissector should reassemble DPDUs spanning multiple TCP segments", &config_proto_desegment); - - prefs_register_uint_preference(s5066dts_module, "tcp.port", - "STANAG 5066 DTS Layer TCP Port", - "Set the port for STANAG 5066 DTS Layer. (If other than the default 5067.)", - 10, &config_s5066dts_port); } /* Routine that will be called when s5066dts is handing off to the next dissector */ void proto_reg_handoff_s5066dts(void) { - static gint initialized = FALSE; - static dissector_handle_t s5066dts_handle; - static dissector_handle_t s5066dts_over_tcp_handle; - static int currentPort; - - if (!initialized) { - s5066dts_handle = create_dissector_handle(dissect_s5066dts_raw, proto_s5066dts); - dissector_add_uint("wtap_encap", WTAP_ENCAP_STANAG_5066_D_PDU, s5066dts_handle); - s5066dts_over_tcp_handle = create_dissector_handle(dissect_s5066dts_tcp, proto_s5066dts); - initialized = TRUE; - } - else { - dissector_delete_uint("tcp.port", currentPort, s5066dts_over_tcp_handle); - } + dissector_handle_t s5066dts_handle; + dissector_handle_t s5066dts_over_tcp_handle; + + s5066dts_handle = create_dissector_handle(dissect_s5066dts_raw, proto_s5066dts); + dissector_add_uint("wtap_encap", WTAP_ENCAP_STANAG_5066_D_PDU, s5066dts_handle); + s5066dts_over_tcp_handle = create_dissector_handle(dissect_s5066dts_tcp, proto_s5066dts); - currentPort = config_s5066dts_port; - dissector_add_uint("tcp.port", currentPort, s5066dts_over_tcp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", s5066dts_over_tcp_handle); } /* diff --git a/epan/dissectors/packet-s5066sis.c b/epan/dissectors/packet-s5066sis.c index fc69b13d3d..e1cfe3d1f6 100644 --- a/epan/dissectors/packet-s5066sis.c +++ b/epan/dissectors/packet-s5066sis.c @@ -87,7 +87,7 @@ static gboolean s5066_desegment = TRUE; /* Dissect old 'edition 1' of STANAG 5066 (It lacks the 'version' field.) */ static gboolean s5066_edition_one = FALSE; /* This port is registered with IANA */ -static guint global_s5066_port = 5066; +#define S5066_PORT 5066 /* Size of header outside 'size' field */ static gint s5066_header_size = 5; /* Offset of 'size' field */ @@ -1421,11 +1421,7 @@ proto_register_s5066(void) module_t *s5066_module; - proto_s5066 = proto_register_protocol ( - "STANAG 5066 (SIS layer)", /* name */ - "STANAG 5066 SIS", /* short name*/ - "s5066sis" /* abbrev */ - ); + proto_s5066 = proto_register_protocol ("STANAG 5066 (SIS layer)", "STANAG 5066 SIS", "s5066sis"); proto_register_field_array(proto_s5066, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -1440,11 +1436,6 @@ proto_register_s5066(void) "Whether the S5066 SIS dissector should dissect this edition of the STANAG." " This edition was never formally approved and is very rare. The common edition is edition 1.2.", &s5066_edition_one); - prefs_register_uint_preference(s5066_module, "tcp.port", - "STANAG 5066 SIS TCP Port", - "Set the port for STANAG 5066 SIS. (If other than the default 5066." - " This number is registered with IANA.)", - 10, &global_s5066_port); s5066sis_dissector_table = register_dissector_table("s5066sis.ctl.appid", "STANAG 5066 Application Identifier", proto_s5066, FT_UINT16, BASE_DEC); @@ -1455,18 +1446,13 @@ proto_reg_handoff_s5066(void) { static gboolean Initialized = FALSE; static dissector_handle_t s5066_tcp_handle; - static guint saved_s5066_port; if (!Initialized) { s5066_tcp_handle = create_dissector_handle(dissect_s5066_tcp, proto_s5066); + dissector_add_uint_with_preference("tcp.port", S5066_PORT, s5066_tcp_handle); Initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", saved_s5066_port, s5066_tcp_handle); } - dissector_add_uint("tcp.port", global_s5066_port, s5066_tcp_handle); - saved_s5066_port = global_s5066_port; - if (!s5066_edition_one) { s5066_header_size = 5; s5066_size_offset = 3; diff --git a/epan/dissectors/packet-sabp.c b/epan/dissectors/packet-sabp.c index 6f81d37bb3..f7297d81e1 100644 --- a/epan/dissectors/packet-sabp.c +++ b/epan/dissectors/packet-sabp.c @@ -255,6 +255,8 @@ static guint32 ProtocolIE_ID; static guint32 ProtocolExtensionID; static guint8 sms_encoding; +#define SABP_PORT 3452 + /* desegmentation of sabp over TCP */ static gboolean gbl_sabp_desegment = TRUE; @@ -1730,7 +1732,7 @@ static int dissect_SABP_PDU_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto /*--- End of included file: packet-sabp-fn.c ---*/ -#line 97 "./asn1/sabp/packet-sabp-template.c" +#line 99 "./asn1/sabp/packet-sabp-template.c" static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { @@ -2204,7 +2206,7 @@ void proto_register_sabp(void) { "UnsuccessfulOutcome_value", HFILL }}, /*--- End of included file: packet-sabp-hfarr.c ---*/ -#line 250 "./asn1/sabp/packet-sabp-template.c" +#line 252 "./asn1/sabp/packet-sabp-template.c" }; /* List of subtrees */ @@ -2261,7 +2263,7 @@ void proto_register_sabp(void) { &ett_sabp_UnsuccessfulOutcome, /*--- End of included file: packet-sabp-ettarr.c ---*/ -#line 263 "./asn1/sabp/packet-sabp-template.c" +#line 265 "./asn1/sabp/packet-sabp-template.c" }; @@ -2288,8 +2290,8 @@ void proto_register_sabp(void) { void proto_reg_handoff_sabp(void) { - dissector_add_uint("udp.port", 3452, sabp_handle); - dissector_add_uint("tcp.port", 3452, sabp_tcp_handle); + dissector_add_uint("udp.port", SABP_PORT, sabp_handle); + dissector_add_uint_with_preference("tcp.port", SABP_PORT, sabp_tcp_handle); dissector_add_uint("sctp.ppi", SABP_PAYLOAD_PROTOCOL_ID, sabp_handle); @@ -2338,7 +2340,7 @@ proto_reg_handoff_sabp(void) /*--- End of included file: packet-sabp-dis-tab.c ---*/ -#line 294 "./asn1/sabp/packet-sabp-template.c" +#line 296 "./asn1/sabp/packet-sabp-template.c" } diff --git a/epan/dissectors/packet-sametime.c b/epan/dissectors/packet-sametime.c index d8c2627612..451b7c0756 100644 --- a/epan/dissectors/packet-sametime.c +++ b/epan/dissectors/packet-sametime.c @@ -28,13 +28,12 @@ #include <epan/stats_tree.h> #include "packet-tcp.h" -#define DEFAULT_SAMETIME_PORT 1533 +#define DEFAULT_SAMETIME_PORT 1533 /* Not IANA registered */ void proto_register_sametime(void); void proto_reg_handoff_sametime(void); static int proto_sametime = -1; -static guint global_sametime_port = DEFAULT_SAMETIME_PORT; static dissector_handle_t sametime_handle; /*preferences*/ @@ -886,11 +885,7 @@ proto_register_sametime(void) module_t *sametime_module; - proto_sametime = proto_register_protocol ( - "Sametime Protocol", /* name */ - "SAMETIME", /* short name */ - "sametime" /* abbrev */ - ); + proto_sametime = proto_register_protocol ("Sametime Protocol", "SAMETIME", "sametime"); proto_register_field_array(proto_sametime, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -905,10 +900,6 @@ proto_register_sametime(void) prefs_register_bool_preference(sametime_module, "reassemble", "Reassemble","reassemble packets", &global_sametime_reassemble_packets); - prefs_register_uint_preference(sametime_module, "tcp_port", - "SAMETIME port number", - "port number for sametime traffic", - 10, &global_sametime_port); } @@ -918,21 +909,13 @@ proto_register_sametime(void) void proto_reg_handoff_sametime(void) { - static gboolean initialized = FALSE; - static guint saved_sametime_tcp_port; - - if (!initialized) { - sametime_handle = create_dissector_handle(dissect_sametime, proto_sametime); - stats_tree_register("sametime", "sametime", "Sametime/Messages", 0, - sametime_stats_tree_packet, - sametime_stats_tree_init, NULL ); - initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", saved_sametime_tcp_port, sametime_handle); - } + sametime_handle = create_dissector_handle(dissect_sametime, proto_sametime); + dissector_add_uint_with_preference("tcp.port", DEFAULT_SAMETIME_PORT, sametime_handle); + + stats_tree_register("sametime", "sametime", "Sametime/Messages", 0, + sametime_stats_tree_packet, + sametime_stats_tree_init, NULL ); - dissector_add_uint("tcp.port", global_sametime_port, sametime_handle); - saved_sametime_tcp_port = global_sametime_port; } diff --git a/epan/dissectors/packet-sasp.c b/epan/dissectors/packet-sasp.c index 7a973062ca..b611295c10 100644 --- a/epan/dissectors/packet-sasp.c +++ b/epan/dissectors/packet-sasp.c @@ -1545,7 +1545,7 @@ proto_reg_handoff_sasp(void) dissector_handle_t sasp_handle; sasp_handle = create_dissector_handle(dissect_sasp, proto_sasp); - dissector_add_uint("tcp.port", SASP_GLOBAL_PORT, sasp_handle); + dissector_add_uint_with_preference("tcp.port", SASP_GLOBAL_PORT, sasp_handle); } /* diff --git a/epan/dissectors/packet-sccp.c b/epan/dissectors/packet-sccp.c index 80ca6c29f9..40a4db1f49 100644 --- a/epan/dissectors/packet-sccp.c +++ b/epan/dissectors/packet-sccp.c @@ -46,6 +46,8 @@ #include <epan/expert.h> #include <epan/tap.h> #include <epan/to_str.h> +#include <epan/decode_as.h> +#include <epan/proto_data.h> #include <wiretap/wtap.h> #include <wsutil/str_util.h> #include "packet-mtp3.h" @@ -826,6 +828,18 @@ static const value_string assoc_protos[] = { return FALSE; \ } while (0) + +static void sccp_prompt(packet_info *pinfo _U_, gchar* result) +{ + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Dissect SSN %d as", + GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_sccp, 0))); +} + +static gpointer sccp_value(packet_info *pinfo) +{ + return p_get_proto_data(pinfo->pool, pinfo, proto_sccp, 0); +} + static gboolean sccp_called_calling_looks_valid(guint32 frame_num _U_, tvbuff_t *tvb, guint8 my_mtp3_standard, gboolean is_co) { @@ -2346,6 +2360,9 @@ dissect_sccp_data_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, scc } + /* Save SSN for Decode As */ + p_add_proto_data(pinfo->pool, pinfo, proto_sccp, 0, GUINT_TO_POINTER((guint)ssn)); + if ((ssn != INVALID_SSN) && dissector_try_uint_new(sccp_ssn_dissector_table, ssn, tvb, pinfo, tree, TRUE, sccp_info)) { return; } @@ -4059,6 +4076,12 @@ proto_register_sccp(void) { &ei_sccp_gt_digits_missing, { "sccp.gt_digits_missing", PI_MALFORMED, PI_ERROR, "Address digits missing", EXPFILL }}, }; + /* Decode As handling */ + static build_valid_func sccp_da_build_value[1] = {sccp_value}; + static decode_as_value_t sccp_da_values = {sccp_prompt, 1, sccp_da_build_value}; + static decode_as_t sccp_da = {"sccp", "SCCP SSN", "sccp.ssn", 1, 0, &sccp_da_values, NULL, NULL, + decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; + module_t *sccp_module; expert_module_t* expert_sccp; @@ -4079,8 +4102,7 @@ proto_register_sccp(void) NULL, users_flds ); /* Register the protocol name and description */ - proto_sccp = proto_register_protocol("Signalling Connection Control Part", - "SCCP", "sccp"); + proto_sccp = proto_register_protocol("Signalling Connection Control Part", "SCCP", "sccp"); register_dissector("sccp", dissect_sccp, proto_sccp); @@ -4142,6 +4164,7 @@ proto_register_sccp(void) sccp_tap = register_tap("sccp"); + register_decode_as(&sccp_da); } void diff --git a/epan/dissectors/packet-scop.c b/epan/dissectors/packet-scop.c index 11d62beca5..2996962212 100644 --- a/epan/dissectors/packet-scop.c +++ b/epan/dissectors/packet-scop.c @@ -410,6 +410,7 @@ void proto_reg_handoff_scop(void) dissector_delete_uint("udp.port", lastPort_secured, scop_udp_handle); dissector_delete_uint("tcp.port", lastPort_secured, scop_tcp_handle); } + /* XXX - Should this be a range with "auto" preference? */ dissector_add_uint("udp.port", gPREF_scop_port, scop_udp_handle); dissector_add_uint("tcp.port", gPREF_scop_port, scop_tcp_handle); dissector_add_uint("udp.port", gPREF_scop_port_secured, scop_udp_handle); diff --git a/epan/dissectors/packet-selfm.c b/epan/dissectors/packet-selfm.c index a977a50586..70dea920cc 100644 --- a/epan/dissectors/packet-selfm.c +++ b/epan/dissectors/packet-selfm.c @@ -257,8 +257,6 @@ static expert_field ei_selfm_crc16_incorrect = EI_INIT; static dissector_handle_t selfm_handle; -#define PORT_SELFM 0 - #define CMD_FAST_MSG 0xA546 #define CMD_CLEAR_STATBIT 0xA5B9 #define CMD_RELAY_DEF 0xA5C0 @@ -347,7 +345,6 @@ static dissector_handle_t selfm_handle; /* Globals for SEL Protocol Preferences */ static gboolean selfm_desegment = TRUE; static gboolean selfm_telnet_clean = TRUE; -static guint global_selfm_tcp_port = PORT_SELFM; /* Port 0, by default */ static gboolean selfm_crc16 = FALSE; /* Default CRC16 valdiation to false */ static const char *selfm_ser_list = NULL; @@ -3092,7 +3089,7 @@ proto_register_selfm(void) /* Register required preferences for SEL Protocol register decoding */ - selfm_module = prefs_register_protocol(proto_selfm, proto_reg_handoff_selfm); + selfm_module = prefs_register_protocol(proto_selfm, NULL); /* SEL Protocol - Desegmentmentation; defaults to TRUE for TCP desegmentation*/ prefs_register_bool_preference(selfm_module, "desegment", @@ -3106,11 +3103,6 @@ proto_register_selfm(void) "Whether the SEL Protocol dissector should automatically pre-process Telnet data to remove duplicate 0xFF IAC bytes", &selfm_telnet_clean); - /* SEL Protocol Preference - Default TCP Port, allows for "user" port either than 0. */ - prefs_register_uint_preference(selfm_module, "tcp.port", "SEL Protocol Port", - "Set the TCP port for SEL FM Protocol packets (if other than the default of 0)", - 10, &global_selfm_tcp_port); - /* SEL Protocol Preference - Disable/Enable CRC verification, */ prefs_register_bool_preference(selfm_module, "crc_verification", "Validate Fast Message CRC16", "Perform CRC16 validation on Fast Messages", @@ -3131,20 +3123,7 @@ proto_register_selfm(void) void proto_reg_handoff_selfm(void) { - static int selfm_prefs_initialized = FALSE; - static unsigned int selfm_port; - - /* Make sure to use SEL FM Protocol Preferences field to determine default TCP port */ - if (! selfm_prefs_initialized) { - selfm_prefs_initialized = TRUE; - } - else { - dissector_delete_uint("tcp.port", selfm_port, selfm_handle); - } - - selfm_port = global_selfm_tcp_port; - - dissector_add_uint("tcp.port", selfm_port, selfm_handle); + dissector_add_for_decode_as_with_preference("tcp.port", selfm_handle); dissector_add_for_decode_as("rtacser.data", selfm_handle); } diff --git a/epan/dissectors/packet-sigcomp.c b/epan/dissectors/packet-sigcomp.c index 25c9489838..4a4e78770c 100644 --- a/epan/dissectors/packet-sigcomp.c +++ b/epan/dissectors/packet-sigcomp.c @@ -173,8 +173,7 @@ static guint SigCompUDPPort1 = 5555; static guint SigCompUDPPort2 = 6666; /* set the tcp ports */ -static guint SigCompTCPPort1 = 5555; -static guint SigCompTCPPort2 = 6666; +#define SIGCOMP_TCP_PORT_RANGE "5555,6666" /* Not IANA registered */ /* Default preference whether to display the bytecode in UDVM operands or not */ static gboolean display_udvm_bytecode = FALSE; @@ -6692,10 +6691,8 @@ proto_register_sigcomp(void) /* Register the protocol name and description */ - proto_sigcomp = proto_register_protocol("Signaling Compression", - "SIGCOMP", "sigcomp"); - proto_raw_sigcomp = proto_register_protocol("Decompressed SigComp message as raw text", - "Raw_SigComp", "raw_sigcomp"); + proto_sigcomp = proto_register_protocol("Signaling Compression", "SIGCOMP", "sigcomp"); + proto_raw_sigcomp = proto_register_protocol("Decompressed SigComp message as raw text", "Raw_SigComp", "raw_sigcomp"); register_dissector("sigcomp", dissect_sigcomp, proto_sigcomp); @@ -6721,17 +6718,7 @@ proto_register_sigcomp(void) "Set UDP port 2 for SigComp messages", 10, &SigCompUDPPort2); - prefs_register_uint_preference(sigcomp_module, "tcp.port", - "Sigcomp TCP Port 1", - "Set TCP port 1 for SigComp messages", - 10, - &SigCompTCPPort1); - prefs_register_uint_preference(sigcomp_module, "tcp.port2", - "Sigcomp TCP Port 2", - "Set TCP port 2 for SigComp messages", - 10, - &SigCompTCPPort2); prefs_register_bool_preference(sigcomp_module, "display.udvm.code", "Dissect the UDVM code", "Preference whether to Dissect the UDVM code or not", @@ -6773,32 +6760,23 @@ proto_reg_handoff_sigcomp(void) static gboolean Initialized = FALSE; static guint udp_port1; static guint udp_port2; - static guint tcp_port1; - static guint tcp_port2; if (!Initialized) { sigcomp_handle = find_dissector("sigcomp"); sigcomp_tcp_handle = create_dissector_handle(dissect_sigcomp_tcp,proto_sigcomp); sip_handle = find_dissector_add_dependency("sip",proto_sigcomp); + dissector_add_uint_range_with_preference("tcp.port", SIGCOMP_TCP_PORT_RANGE, sigcomp_tcp_handle); Initialized=TRUE; } else { dissector_delete_uint("udp.port", udp_port1, sigcomp_handle); dissector_delete_uint("udp.port", udp_port2, sigcomp_handle); - dissector_delete_uint("tcp.port", tcp_port1, sigcomp_tcp_handle); - dissector_delete_uint("tcp.port", tcp_port2, sigcomp_tcp_handle); } udp_port1 = SigCompUDPPort1; udp_port2 = SigCompUDPPort2; - tcp_port1 = SigCompTCPPort1; - tcp_port2 = SigCompTCPPort2; - dissector_add_uint("udp.port", SigCompUDPPort1, sigcomp_handle); dissector_add_uint("udp.port", SigCompUDPPort2, sigcomp_handle); - dissector_add_uint("tcp.port", SigCompTCPPort1, sigcomp_tcp_handle); - dissector_add_uint("tcp.port", SigCompTCPPort2, sigcomp_tcp_handle); - } /* diff --git a/epan/dissectors/packet-simple.c b/epan/dissectors/packet-simple.c index 71035bfdb3..396efb2ef0 100644 --- a/epan/dissectors/packet-simple.c +++ b/epan/dissectors/packet-simple.c @@ -686,7 +686,7 @@ void proto_reg_handoff_simple(void) dissector_handle_t simple_dissector_handle; simple_dissector_handle = create_dissector_handle(dissect_simple, proto_simple); dissector_add_for_decode_as("udp.port", simple_dissector_handle); - dissector_add_for_decode_as("tcp.port", simple_dissector_handle); + dissector_add_for_decode_as_with_preference("tcp.port", simple_dissector_handle); link16_handle = find_dissector_add_dependency("link16", proto_simple); } diff --git a/epan/dissectors/packet-simulcrypt.c b/epan/dissectors/packet-simulcrypt.c index 9bd27d5f7c..7f16632044 100644 --- a/epan/dissectors/packet-simulcrypt.c +++ b/epan/dissectors/packet-simulcrypt.c @@ -73,7 +73,6 @@ static void dissect_simulcrypt_data(proto_tree *simulcrypt_tree, proto_item *sim static guint proto_simulcrypt = -1; /* Preferences (with default values) */ -static guint global_simulcrypt_tcp_port = 0; /* Simulcrypt registered only if pref set to non-zero value */ static guint global_simulcrypt_udp_port = 0; /* Simulcrypt registered only if pref set to non-zero value */ static int ca_system_id_mikey = CA_SYSTEM_ID_MIKEY; /* MIKEY ECM CA_system_ID */ @@ -1838,10 +1837,6 @@ proto_register_simulcrypt (void) /* called when preferences are applied. */ simulcrypt_module = prefs_register_protocol(proto_simulcrypt, proto_reg_handoff_simulcrypt); - prefs_register_uint_preference(simulcrypt_module, "tcp.port", "Simulcrypt TCP Port", - "Set the TCP port for Simulcrypt messages ('0' means no port is assigned)", - 10, &global_simulcrypt_tcp_port); - prefs_register_uint_preference(simulcrypt_module, "udp.port", "Simulcrypt UDP Port", "Set the UDP port for Simulcrypt messages ('0' means no port is assigned)", 10, &global_simulcrypt_udp_port); @@ -1856,7 +1851,7 @@ proto_reg_handoff_simulcrypt(void) { static gboolean initialized=FALSE; static dissector_handle_t simulcrypt_handle; - static guint tcp_port, udp_port; + static guint udp_port; guint i; if (!initialized) { @@ -1865,21 +1860,17 @@ proto_reg_handoff_simulcrypt(void) { tab_ecm_inter[i].protocol_handle = find_dissector(tab_ecm_inter[i].protocol_name); } - dissector_add_for_decode_as("tcp.port", simulcrypt_handle); dissector_add_for_decode_as("udp.port", simulcrypt_handle); + dissector_add_for_decode_as_with_preference("tcp.port", simulcrypt_handle); initialized = TRUE; } else { - dissector_delete_uint("tcp.port", tcp_port, simulcrypt_handle); dissector_delete_uint("udp.port", udp_port, simulcrypt_handle); } - if (global_simulcrypt_tcp_port != 0) { - dissector_add_uint("tcp.port", global_simulcrypt_tcp_port, simulcrypt_handle); - } + if (global_simulcrypt_udp_port != 0) { dissector_add_uint("udp.port", global_simulcrypt_udp_port, simulcrypt_handle); } - tcp_port = global_simulcrypt_tcp_port; udp_port = global_simulcrypt_udp_port; /* update tab_ecm_inter table (always do this) */ diff --git a/epan/dissectors/packet-sip.c b/epan/dissectors/packet-sip.c index 16497be3d4..80609eb42f 100644 --- a/epan/dissectors/packet-sip.c +++ b/epan/dissectors/packet-sip.c @@ -857,7 +857,6 @@ typedef enum { /* Preferences */ static guint sip_tls_port = TLS_PORT_SIP; -static range_t *global_sip_tcp_port_range; /* global_sip_raw_text determines whether we are going to display */ /* the raw text of the SIP message, much like the MEGACO dissector does. */ @@ -6654,8 +6653,7 @@ void proto_register_sip(void) }; /* Register the protocol name and description */ - proto_sip = proto_register_protocol("Session Initiation Protocol", - "SIP", "sip"); + proto_sip = proto_register_protocol("Session Initiation Protocol", "SIP", "sip"); proto_raw_sip = proto_register_protocol("Session Initiation Protocol (SIP as raw text)", "Raw_SIP", "raw_sip"); register_dissector("sip", dissect_sip, proto_sip); @@ -6672,13 +6670,6 @@ void proto_register_sip(void) proto_register_field_array(proto_raw_sip, raw_hf, array_length(raw_hf)); sip_module = prefs_register_protocol(proto_sip, proto_reg_handoff_sip); - range_convert_str(&global_sip_tcp_port_range, DEFAULT_SIP_PORT_RANGE, MAX_UDP_PORT); - - - prefs_register_range_preference(sip_module, "tcp.ports", "SIP TCP ports", - "TCP ports to be decoded as SIP (default: " - DEFAULT_SIP_PORT_RANGE ")", - &global_sip_tcp_port_range, MAX_UDP_PORT); prefs_register_uint_preference(sip_module, "tls.port", "SIP TLS Port", @@ -6759,8 +6750,6 @@ void proto_register_sip(void) "A table to define custom SIP header for which fields can be setup and used for filtering/data extraction etc.", sip_custom_headers_uat); - prefs_register_obsolete_preference(sip_module, "tcp.port"); - register_init_routine(&sip_init_protocol); register_cleanup_routine(&sip_cleanup_protocol); heur_subdissector_list = register_heur_dissector_list("sip", proto_sip); @@ -6789,8 +6778,6 @@ void proto_register_sip(void) void proto_reg_handoff_sip(void) { - static range_t *sip_tcp_port_range; - static guint saved_sip_tls_port; static gboolean sip_prefs_initialized = FALSE; @@ -6810,20 +6797,17 @@ proto_reg_handoff_sip(void) dissector_add_uint("udp.port", UDP_PORT_SIP, sip_handle); dissector_add_string("media_type", "message/sip", sip_handle); + dissector_add_uint_range_with_preference("tcp.port", DEFAULT_SIP_PORT_RANGE, sip_tcp_handle); + heur_dissector_add("udp", dissect_sip_heur, "SIP over UDP", "sip_udp", proto_sip, HEURISTIC_ENABLE); heur_dissector_add("tcp", dissect_sip_tcp_heur, "SIP over TCP", "sip_tcp", proto_sip, HEURISTIC_ENABLE); heur_dissector_add("sctp", dissect_sip_heur, "SIP over SCTP", "sip_sctp", proto_sip, HEURISTIC_ENABLE); heur_dissector_add("stun", dissect_sip_heur, "SIP over TURN", "sip_stun", proto_sip, HEURISTIC_ENABLE); sip_prefs_initialized = TRUE; } else { - dissector_delete_uint_range("tcp.port", sip_tcp_port_range, sip_tcp_handle); - g_free(sip_tcp_port_range); ssl_dissector_delete(saved_sip_tls_port, sip_tcp_handle); } /* Set our port number for future use */ - sip_tcp_port_range = range_copy(global_sip_tcp_port_range); - dissector_add_uint_range("tcp.port", sip_tcp_port_range, sip_tcp_handle); - saved_sip_tls_port = sip_tls_port; ssl_dissector_add(saved_sip_tls_port, sip_tcp_handle); exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_7); diff --git a/epan/dissectors/packet-skinny.c b/epan/dissectors/packet-skinny.c index b54afb34a1..2692fbe651 100644 --- a/epan/dissectors/packet-skinny.c +++ b/epan/dissectors/packet-skinny.c @@ -58,7 +58,7 @@ void proto_register_skinny(void); void proto_reg_handoff_skinny(void); -#define TCP_PORT_SKINNY 2000 +#define TCP_PORT_SKINNY 2000 /* Not IANA registered */ #define SSL_PORT_SKINNY 2443 /* IANA assigned to PowerClient Central Storage Facility */ #define BASIC_MSG_TYPE 0x00 @@ -9799,7 +9799,7 @@ proto_reg_handoff_skinny(void) { /* Skinny content type and internet media type used by other dissectors are the same */ xml_handle = find_dissector("xml"); - dissector_add_uint("tcp.port", TCP_PORT_SKINNY, skinny_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_SKINNY, skinny_handle); ssl_dissector_add(SSL_PORT_SKINNY, skinny_handle); } diff --git a/epan/dissectors/packet-skinny.c.in b/epan/dissectors/packet-skinny.c.in index cebf3151a5..c0779d8638 100644 --- a/epan/dissectors/packet-skinny.c.in +++ b/epan/dissectors/packet-skinny.c.in @@ -71,7 +71,7 @@ void proto_register_skinny(void); void proto_reg_handoff_skinny(void); -#define TCP_PORT_SKINNY 2000 +#define TCP_PORT_SKINNY 2000 /* Not IANA registered */ #define SSL_PORT_SKINNY 2443 /* IANA assigned to PowerClient Central Storage Facility */ #define BASIC_MSG_TYPE 0x00 @@ -540,7 +540,7 @@ proto_reg_handoff_skinny(void) { /* Skinny content type and internet media type used by other dissectors are the same */ xml_handle = find_dissector("xml"); - dissector_add_uint("tcp.port", TCP_PORT_SKINNY, skinny_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_SKINNY, skinny_handle); ssl_dissector_add(SSL_PORT_SKINNY, skinny_handle); } diff --git a/epan/dissectors/packet-skype.c b/epan/dissectors/packet-skype.c index 3a190d6b5f..68feb56063 100644 --- a/epan/dissectors/packet-skype.c +++ b/epan/dissectors/packet-skype.c @@ -444,7 +444,7 @@ proto_reg_handoff_skype(void) dissector_handle_t skype_handle; skype_handle = create_dissector_handle(dissect_skype_static, proto_skype); - dissector_add_for_decode_as("tcp.port", skype_handle); + dissector_add_for_decode_as_with_preference("tcp.port", skype_handle); dissector_add_for_decode_as("udp.port", skype_handle); heur_dissector_add("tcp", dissect_skype_heur, "Skype over TCP", "skype_tcp", proto_skype, HEURISTIC_DISABLE); diff --git a/epan/dissectors/packet-slsk.c b/epan/dissectors/packet-slsk.c index 0ccba62fb6..e0aa8acf53 100644 --- a/epan/dissectors/packet-slsk.c +++ b/epan/dissectors/packet-slsk.c @@ -114,9 +114,7 @@ static gint ett_slsk_compr_packet = -1; static expert_field ei_slsk_unknown_data = EI_INIT; static expert_field ei_slsk_zlib_decompression_failed = EI_INIT; -#define TCP_PORT_SLSK_1 2234 -#define TCP_PORT_SLSK_2 5534 -#define TCP_PORT_SLSK_3 2240 +#define SLSK_TCP_PORT_RANGE "2234,2240,5534" /* desegmentation of SoulSeek Message over TCP */ @@ -2632,9 +2630,7 @@ proto_reg_handoff_slsk(void) dissector_handle_t slsk_handle; slsk_handle = create_dissector_handle(dissect_slsk, proto_slsk); - dissector_add_uint("tcp.port", TCP_PORT_SLSK_1, slsk_handle); - dissector_add_uint("tcp.port", TCP_PORT_SLSK_2, slsk_handle); - dissector_add_uint("tcp.port", TCP_PORT_SLSK_3, slsk_handle); + dissector_add_uint_range_with_preference("tcp.port", SLSK_TCP_PORT_RANGE, slsk_handle); } /* diff --git a/epan/dissectors/packet-sml.c b/epan/dissectors/packet-sml.c index 6f4916e24f..75b66f4e38 100644 --- a/epan/dissectors/packet-sml.c +++ b/epan/dissectors/packet-sml.c @@ -37,7 +37,6 @@ Short description of the SML protocol on the SML Wireshark Wiki page: https://w #include <wsutil/str_util.h> -#define TCP_PORT_SML 0 #define UDP_PORT_SML 0 #define ESC_SEQ_END G_GUINT64_CONSTANT(0x1b1b1b1b1a) @@ -74,7 +73,6 @@ Short description of the SML protocol on the SML Wireshark Wiki page: https://w #define LIST_6_ELEMENTS 0x76 #define MSB 0x80 -static guint tcp_port_pref = TCP_PORT_SML; static guint udp_port_pref = UDP_PORT_SML; /* Forward declaration we need below (if using proto_reg_handoff as a prefs callback)*/ @@ -2796,7 +2794,6 @@ void proto_register_sml (void) { prefs_register_bool_preference (sml_module, "reassemble", "Enable reassemble", "Enable reassembling (default is enabled)", &sml_reassemble); prefs_register_bool_preference (sml_module, "crc", "Enable crc calculation", "Enable crc (default is disabled)", &sml_crc_enabled); - prefs_register_uint_preference(sml_module, "tcp.port", "SML TCP Port", "Set the TCP port for SML (Default is 0), recommended port is 7259", 10, &tcp_port_pref); prefs_register_uint_preference(sml_module, "udp.port", "SML UDP Port", "Set the UDP port for SML (Default is 0), recommended port is 7259", 10, &udp_port_pref); proto_register_field_array(proto_sml, hf, array_length(hf)); @@ -2807,21 +2804,18 @@ void proto_register_sml (void) { void proto_reg_handoff_sml(void) { static gboolean initialized = FALSE; - static int old_tcp_port; static int old_udp_port; static dissector_handle_t sml_handle; if (!initialized) { sml_handle = create_dissector_handle(dissect_sml, proto_sml); + dissector_add_for_decode_as_with_preference("tcp.port", sml_handle); initialized = TRUE; } else { - dissector_delete_uint("tcp.port", old_tcp_port, sml_handle); dissector_delete_uint("udp.port", old_udp_port, sml_handle); } - old_tcp_port = tcp_port_pref; old_udp_port = udp_port_pref; - dissector_add_uint("tcp.port", tcp_port_pref, sml_handle); dissector_add_uint("udp.port", udp_port_pref, sml_handle); } diff --git a/epan/dissectors/packet-smpp.c b/epan/dissectors/packet-smpp.c index 0da266bd37..7f80206a09 100644 --- a/epan/dissectors/packet-smpp.c +++ b/epan/dissectors/packet-smpp.c @@ -3796,7 +3796,7 @@ proto_reg_handoff_smpp(void) * however. */ smpp_handle = find_dissector("smpp"); - dissector_add_for_decode_as("tcp.port", smpp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", smpp_handle); heur_dissector_add("tcp", dissect_smpp_heur, "SMPP over TCP", "smpp_tcp", proto_smpp, HEURISTIC_ENABLE); heur_dissector_add("x.25", dissect_smpp_heur, "SMPP over X.25", "smpp_x25", proto_smpp, HEURISTIC_ENABLE); diff --git a/epan/dissectors/packet-smrse.c b/epan/dissectors/packet-smrse.c index 71b64a3899..30f23e7824 100644 --- a/epan/dissectors/packet-smrse.c +++ b/epan/dissectors/packet-smrse.c @@ -41,7 +41,7 @@ #define PSNAME "SMRSE" #define PFNAME "smrse" -#define TCP_PORT_SMRSE 4321 +#define TCP_PORT_SMRSE 4321 /* Not IANA registered */ void proto_register_smrse(void); void proto_reg_handoff_smrse(void); @@ -731,6 +731,6 @@ void proto_reg_handoff_smrse(void) { dissector_handle_t smrse_handle; smrse_handle = create_dissector_handle(dissect_smrse, proto_smrse); - dissector_add_uint("tcp.port",TCP_PORT_SMRSE, smrse_handle); + dissector_add_uint_with_preference("tcp.port",TCP_PORT_SMRSE, smrse_handle); } diff --git a/epan/dissectors/packet-smtp.c b/epan/dissectors/packet-smtp.c index 5e5b22f70c..c99c582a14 100644 --- a/epan/dissectors/packet-smtp.c +++ b/epan/dissectors/packet-smtp.c @@ -1316,8 +1316,9 @@ void proto_reg_handoff_smtp(void) { smtp_handle = find_dissector("smtp"); - dissector_add_uint("tcp.port", TCP_PORT_SMTP, smtp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_SMTP, smtp_handle); ssl_dissector_add(TCP_PORT_SSL_SMTP, smtp_handle); + /* No "auto" preference since handle is shared with SMTP */ dissector_add_uint("tcp.port", TCP_PORT_SUBMISSION, smtp_handle); /* find the IMF dissector */ diff --git a/epan/dissectors/packet-snmp.c b/epan/dissectors/packet-snmp.c index faf3f1128e..2f4e5b93d1 100644 --- a/epan/dissectors/packet-snmp.c +++ b/epan/dissectors/packet-snmp.c @@ -4086,7 +4086,10 @@ void proto_reg_handoff_snmp(void) { dissector_add_uint("hpext.dxsap", HPEXT_SNMP, snmp_handle); snmp_tcp_handle = create_dissector_handle(dissect_snmp_tcp, proto_snmp); - dissector_add_uint("tcp.port", TCP_PORT_SNMP, snmp_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_SNMP, snmp_tcp_handle); + /* Since "regular" SNMP port and "trap" SNMP port use the same handler, + the "trap" port doesn't really need a separate preference. Just register + normally */ dissector_add_uint("tcp.port", TCP_PORT_SNMP_TRAP, snmp_tcp_handle); data_handle = find_dissector("data"); @@ -4129,7 +4132,7 @@ proto_reg_handoff_smux(void) dissector_handle_t smux_handle; smux_handle = create_dissector_handle(dissect_smux, proto_smux); - dissector_add_uint("tcp.port", TCP_PORT_SMUX, smux_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_SMUX, smux_handle); } /* diff --git a/epan/dissectors/packet-socks.c b/epan/dissectors/packet-socks.c index 1d7e02982f..4c26125612 100644 --- a/epan/dissectors/packet-socks.c +++ b/epan/dissectors/packet-socks.c @@ -1311,7 +1311,7 @@ proto_reg_handoff_socks(void) { socks_udp_handle = create_dissector_handle(socks_udp_dissector, proto_socks); socks_handle = create_dissector_handle(dissect_socks, proto_socks); - dissector_add_uint("tcp.port", TCP_PORT_SOCKS, socks_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_SOCKS, socks_handle); } /* diff --git a/epan/dissectors/packet-soupbintcp.c b/epan/dissectors/packet-soupbintcp.c index baf0a55dc8..c1f680e630 100644 --- a/epan/dissectors/packet-soupbintcp.c +++ b/epan/dissectors/packet-soupbintcp.c @@ -117,8 +117,6 @@ static heur_dissector_list_t heur_subdissector_list; /* Preferences */ static gboolean soupbintcp_desegment = TRUE; -static range_t *global_soupbintcp_range = NULL; -static range_t *soupbintcp_range = NULL; /* Initialize the subtree pointers */ static gint ett_soupbintcp = -1; @@ -472,16 +470,6 @@ dissect_soupbintcp_tcp( return tvb_captured_length(tvb); } -static void -soupbintcp_prefs(void) -{ - dissector_delete_uint_range("tcp.port", soupbintcp_range, soupbintcp_handle); - g_free(soupbintcp_range); - soupbintcp_range = range_copy(global_soupbintcp_range); - dissector_add_uint_range("tcp.port", soupbintcp_range, soupbintcp_handle); -} - - void proto_register_soupbintcp(void) { @@ -572,15 +560,12 @@ proto_register_soupbintcp(void) module_t *soupbintcp_module; - proto_soupbintcp - = proto_register_protocol("SoupBinTCP", "SoupBinTCP", "soupbintcp"); + proto_soupbintcp = proto_register_protocol("SoupBinTCP", "SoupBinTCP", "soupbintcp"); proto_register_field_array(proto_soupbintcp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - soupbintcp_module - = prefs_register_protocol(proto_soupbintcp, - soupbintcp_prefs); + soupbintcp_module = prefs_register_protocol(proto_soupbintcp, NULL); prefs_register_bool_preference( soupbintcp_module, @@ -590,16 +575,6 @@ proto_register_soupbintcp(void) "spanning multiple TCP segments.", &soupbintcp_desegment); - prefs_register_range_preference( - soupbintcp_module, - "tcp.port", - "TCP Ports", - "TCP Ports range", - &global_soupbintcp_range, - 65535); - - soupbintcp_range = range_empty(); - heur_subdissector_list = register_heur_dissector_list("soupbintcp", proto_soupbintcp); expert_soupbinttcp = expert_register_protocol(proto_soupbintcp); @@ -610,11 +585,8 @@ proto_register_soupbintcp(void) void proto_reg_handoff_soupbintcp(void) { - soupbintcp_handle = create_dissector_handle(dissect_soupbintcp_tcp, - proto_soupbintcp); - - /* For "decode-as" */ - dissector_add_for_decode_as("tcp.port", soupbintcp_handle); + soupbintcp_handle = create_dissector_handle(dissect_soupbintcp_tcp, proto_soupbintcp); + dissector_add_uint_range_with_preference("tcp.port", "", soupbintcp_handle); } diff --git a/epan/dissectors/packet-spdy.c b/epan/dissectors/packet-spdy.c index 30835896c8..d5078ae6af 100644 --- a/epan/dissectors/packet-spdy.c +++ b/epan/dissectors/packet-spdy.c @@ -1949,7 +1949,7 @@ void proto_register_spdy(void) void proto_reg_handoff_spdy(void) { - dissector_add_uint("tcp.port", TCP_PORT_SPDY, spdy_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_SPDY, spdy_handle); /* Use "0" to avoid overwriting HTTPS port and still offer support over SSL */ ssl_dissector_add(0, spdy_handle); diff --git a/epan/dissectors/packet-spice.c b/epan/dissectors/packet-spice.c index 4c9d96432e..d6fe2abe6a 100644 --- a/epan/dissectors/packet-spice.c +++ b/epan/dissectors/packet-spice.c @@ -4563,7 +4563,7 @@ void proto_reg_handoff_spice(void) { spice_handle = create_dissector_handle(dissect_spice, proto_spice); - dissector_add_for_decode_as("tcp.port", spice_handle); + dissector_add_for_decode_as_with_preference("tcp.port", spice_handle); heur_dissector_add("tcp", test_spice_protocol, "Spice over TCP", "spice_tcp", proto_spice, HEURISTIC_ENABLE); jpeg_handle = find_dissector_add_dependency("image-jfif", proto_spice); } diff --git a/epan/dissectors/packet-srvloc.c b/epan/dissectors/packet-srvloc.c index df8c467340..e550d43a65 100644 --- a/epan/dissectors/packet-srvloc.c +++ b/epan/dissectors/packet-srvloc.c @@ -1893,7 +1893,7 @@ proto_reg_handoff_srvloc(void) dissector_add_uint("udp.port", UDP_PORT_SRVLOC, srvloc_handle); srvloc_tcp_handle = create_dissector_handle(dissect_srvloc_tcp, proto_srvloc); - dissector_add_uint("tcp.port", TCP_PORT_SRVLOC, srvloc_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_SRVLOC, srvloc_tcp_handle); } /* diff --git a/epan/dissectors/packet-ssh.c b/epan/dissectors/packet-ssh.c index 4e51fdb732..505b7cc698 100644 --- a/epan/dissectors/packet-ssh.c +++ b/epan/dissectors/packet-ssh.c @@ -1476,7 +1476,7 @@ proto_register_ssh(void) void proto_reg_handoff_ssh(void) { - dissector_add_uint("tcp.port", TCP_PORT_SSH, ssh_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_SSH, ssh_handle); dissector_add_uint("sctp.port", SCTP_PORT_SSH, ssh_handle); dissector_add_uint("sctp.ppi", SSH_PAYLOAD_PROTOCOL_ID, ssh_handle); } diff --git a/epan/dissectors/packet-stun.c b/epan/dissectors/packet-stun.c index 65ab0dafaf..7531b2c48c 100644 --- a/epan/dissectors/packet-stun.c +++ b/epan/dissectors/packet-stun.c @@ -1728,13 +1728,9 @@ proto_reg_handoff_stun(void) stun_tcp_handle = create_dissector_handle(dissect_stun_tcp, proto_stun); stun_udp_handle = create_dissector_handle(dissect_stun_udp, proto_stun); - dissector_add_uint("tcp.port", TCP_PORT_STUN, stun_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_STUN, stun_tcp_handle); dissector_add_uint("udp.port", UDP_PORT_STUN, stun_udp_handle); - /* Used for "Decode As" in case STUN negotiation isn't captured */ - dissector_add_for_decode_as("tcp.port", stun_tcp_handle); - dissector_add_for_decode_as("udp.port", stun_udp_handle); - heur_dissector_add("udp", dissect_stun_heur, "STUN over UDP", "stun_udp", proto_stun, HEURISTIC_ENABLE); data_handle = find_dissector("data"); diff --git a/epan/dissectors/packet-synergy.c b/epan/dissectors/packet-synergy.c index 7cfe86eeaa..bdb23485d4 100644 --- a/epan/dissectors/packet-synergy.c +++ b/epan/dissectors/packet-synergy.c @@ -29,6 +29,8 @@ void proto_register_synergy(void); void proto_reg_handoff_synergy(void); +#define SYNERGY_PORT 24800 /* Not IANA registered */ + static int proto_synergy = -1; static int hf_synergy_unknown = -1; @@ -556,8 +558,7 @@ proto_register_synergy(void) }; /* Register the protocol name and description */ - proto_synergy = proto_register_protocol("Synergy", - "Synergy", "synergy"); + proto_synergy = proto_register_protocol("Synergy", "Synergy", "synergy"); /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_synergy, hf, array_length(hf)); @@ -571,7 +572,7 @@ proto_reg_handoff_synergy(void) dissector_handle_t synergy_handle; synergy_handle = find_dissector("synergy"); - dissector_add_uint("tcp.port",24800, synergy_handle); + dissector_add_uint_with_preference("tcp.port", SYNERGY_PORT, synergy_handle); } /* diff --git a/epan/dissectors/packet-synphasor.c b/epan/dissectors/packet-synphasor.c index 07f6a58dc4..a581bfaf82 100644 --- a/epan/dissectors/packet-synphasor.c +++ b/epan/dissectors/packet-synphasor.c @@ -48,7 +48,7 @@ void proto_reg_handoff_synphasor(void); static int proto_synphasor = -1; /* user preferences */ -static guint global_pref_tcp_port = 4712; +#define SYNPHASOR_TCP_PORT 4712 /* Not IANA registered */ static guint global_pref_udp_port = 4713; /* the ett... variables hold the state (open/close) of the treeview in the GUI */ @@ -1372,10 +1372,6 @@ void proto_register_synphasor(void) "Set the port number for synchrophasor frames over UDP" \ "(if other than the default of 4713)", 10, &global_pref_udp_port); - prefs_register_uint_preference(synphasor_module, "tcp_port", "Synchrophasor TCP port", - "Set the port number for synchrophasor frames over TCP" \ - "(if other than the default of 4712)", - 10, &global_pref_tcp_port); } /* proto_register_synphasor() */ @@ -1385,24 +1381,21 @@ void proto_reg_handoff_synphasor(void) static gboolean initialized = FALSE; static dissector_handle_t synphasor_tcp_handle; static guint current_udp_port; - static guint current_tcp_port; if (!initialized) { synphasor_tcp_handle = create_dissector_handle(dissect_tcp, proto_synphasor); dissector_add_for_decode_as("rtacser.data", synphasor_udp_handle); + dissector_add_uint_with_preference("tcp.port", SYNPHASOR_TCP_PORT, synphasor_tcp_handle); initialized = TRUE; } else { /* update preferences */ dissector_delete_uint("udp.port", current_udp_port, synphasor_udp_handle); - dissector_delete_uint("tcp.port", current_tcp_port, synphasor_tcp_handle); } current_udp_port = global_pref_udp_port; - current_tcp_port = global_pref_tcp_port; dissector_add_uint("udp.port", current_udp_port, synphasor_udp_handle); - dissector_add_uint("tcp.port", current_tcp_port, synphasor_tcp_handle); } /* proto_reg_handoff_synphasor() */ /* diff --git a/epan/dissectors/packet-syslog.c b/epan/dissectors/packet-syslog.c index 15a413c2ea..15321553cd 100644 --- a/epan/dissectors/packet-syslog.c +++ b/epan/dissectors/packet-syslog.c @@ -353,7 +353,7 @@ void proto_reg_handoff_syslog(void) { dissector_add_uint("udp.port", UDP_PORT_SYSLOG, syslog_handle); - dissector_add_for_decode_as("tcp.port", syslog_handle); + dissector_add_for_decode_as_with_preference("tcp.port", syslog_handle); /* Find the mtp3 dissector */ mtp_handle = find_dissector_add_dependency("mtp3", proto_syslog); diff --git a/epan/dissectors/packet-t38.c b/epan/dissectors/packet-t38.c index 6d7ad7f80a..50b9c129ce 100644 --- a/epan/dissectors/packet-t38.c +++ b/epan/dissectors/packet-t38.c @@ -1407,7 +1407,7 @@ proto_register_t38(void) t38_tap = register_tap("t38"); - t38_module = prefs_register_protocol(proto_t38, proto_reg_handoff_t38); + t38_module = prefs_register_protocol(proto_t38, NULL); prefs_register_bool_preference(t38_module, "use_pre_corrigendum_asn1_specification", "Use the Pre-Corrigendum ASN.1 specification", "Whether the T.38 dissector should decode using the Pre-Corrigendum T.38 " @@ -1419,7 +1419,6 @@ proto_register_t38(void) "be dissected as RTP packet or T.38 packet. If enabled there is a risk that T.38 UDPTL " "packets with sequence number higher than 32767 may be dissected as RTP.", &dissect_possible_rtpv2_packets_as_rtp); - prefs_register_obsolete_preference(t38_module, "tcp.port"); prefs_register_obsolete_preference(t38_module, "udp.port"); prefs_register_bool_preference(t38_module, "reassembly", "Reassemble T.38 PDUs over TPKT over TCP", @@ -1444,16 +1443,11 @@ proto_register_t38(void) void proto_reg_handoff_t38(void) { - static gboolean t38_prefs_initialized = FALSE; - - if (!t38_prefs_initialized) { - t38_udp_handle=create_dissector_handle(dissect_t38_udp, proto_t38); - t38_tcp_handle=create_dissector_handle(dissect_t38_tcp, proto_t38); - t38_tcp_pdu_handle=create_dissector_handle(dissect_t38_tcp_pdu, proto_t38); - rtp_handle = find_dissector_add_dependency("rtp", proto_t38); - t30_hdlc_handle = find_dissector_add_dependency("t30.hdlc""rtp", proto_t38); - data_handle = find_dissector("data"); - t38_prefs_initialized = TRUE; - } + t38_udp_handle=create_dissector_handle(dissect_t38_udp, proto_t38); + t38_tcp_handle=create_dissector_handle(dissect_t38_tcp, proto_t38); + t38_tcp_pdu_handle=create_dissector_handle(dissect_t38_tcp_pdu, proto_t38); + rtp_handle = find_dissector_add_dependency("rtp", proto_t38); + t30_hdlc_handle = find_dissector_add_dependency("t30.hdlc""rtp", proto_t38); + data_handle = find_dissector("data"); } diff --git a/epan/dissectors/packet-tacacs.c b/epan/dissectors/packet-tacacs.c index bf40af19c3..6c2c901bb9 100644 --- a/epan/dissectors/packet-tacacs.c +++ b/epan/dissectors/packet-tacacs.c @@ -1277,7 +1277,7 @@ proto_reg_handoff_tacplus(void) tacplus_handle = create_dissector_handle(dissect_tacplus, proto_tacplus); - dissector_add_uint("tcp.port", TCP_PORT_TACACS, tacplus_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_TACACS, tacplus_handle); } diff --git a/epan/dissectors/packet-tcpros.c b/epan/dissectors/packet-tcpros.c index 429c69d68c..baf75e7906 100644 --- a/epan/dissectors/packet-tcpros.c +++ b/epan/dissectors/packet-tcpros.c @@ -580,7 +580,7 @@ proto_register_tcpros(void) proto_register_subtree_array(ett, array_length(ett)); - tcpros_module = prefs_register_protocol(proto_tcpros, proto_reg_handoff_tcpros); + tcpros_module = prefs_register_protocol(proto_tcpros, NULL); prefs_register_bool_preference(tcpros_module, "desegment_tcpros_messages", "Reassemble TCPROS messages spanning multiple TCP segments", @@ -629,18 +629,12 @@ dissect_tcpros_heur_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi void proto_reg_handoff_tcpros(void) { - static gboolean Initialized = FALSE; + tcpros_handle = create_dissector_handle(dissect_tcpros, proto_tcpros); + dissector_add_for_decode_as_with_preference("tcp.port", tcpros_handle); /* for "decode-as" */ - if (!Initialized) { - tcpros_handle = create_dissector_handle(dissect_tcpros, proto_tcpros); - dissector_add_for_decode_as("tcp.port", tcpros_handle); /* for "decode-as" */ - - /* register as heuristic dissector */ - heur_dissector_add("tcp", dissect_tcpros_heur_tcp, "TCPROS over TCP", - "TCPROS_tcp", proto_tcpros, HEURISTIC_DISABLE); - - Initialized = TRUE; - } + /* register as heuristic dissector */ + heur_dissector_add("tcp", dissect_tcpros_heur_tcp, "TCPROS over TCP", + "TCPROS_tcp", proto_tcpros, HEURISTIC_DISABLE); } diff --git a/epan/dissectors/packet-tds.c b/epan/dissectors/packet-tds.c index 3743d02dcc..c0937c8fe1 100644 --- a/epan/dissectors/packet-tds.c +++ b/epan/dissectors/packet-tds.c @@ -471,6 +471,8 @@ static const value_string tds_data_type_names[] = { void proto_reg_handoff_tds(void); void proto_register_tds(void); +#define TDS_PORT_RANGE "1433,2433" /* Not IANA registered */ + /************************ Message definitions ***********************/ /* Bulk Load BCP stream */ @@ -5637,9 +5639,7 @@ void proto_reg_handoff_tds(void) { /* Initial TDS ports: MS SQL default ports */ - dissector_add_uint("tcp.port", 1433, tds_tcp_handle); - dissector_add_uint("tcp.port", 2433, tds_tcp_handle); - + dissector_add_uint_range_with_preference("tcp.port", TDS_PORT_RANGE, tds_tcp_handle); heur_dissector_add("tcp", dissect_tds_tcp_heur, "Tabular Data Stream over TCP", "tds_tcp", proto_tds, HEURISTIC_ENABLE); ntlmssp_handle = find_dissector_add_dependency("ntlmssp", proto_tds); diff --git a/epan/dissectors/packet-telnet.c b/epan/dissectors/packet-telnet.c index 8fb6d2a791..59a73f4682 100644 --- a/epan/dissectors/packet-telnet.c +++ b/epan/dissectors/packet-telnet.c @@ -2190,7 +2190,7 @@ proto_register_telnet(void) void proto_reg_handoff_telnet(void) { - dissector_add_uint("tcp.port", TCP_PORT_TELNET, telnet_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_TELNET, telnet_handle); tn3270_handle = find_dissector_add_dependency("tn3270", proto_telnet); tn5250_handle = find_dissector_add_dependency("tn5250", proto_telnet); ssl_handle = find_dissector("ssl"); diff --git a/epan/dissectors/packet-tfp.c b/epan/dissectors/packet-tfp.c index d7ae0a03dd..ccf26eff32 100644 --- a/epan/dissectors/packet-tfp.c +++ b/epan/dissectors/packet-tfp.c @@ -28,7 +28,7 @@ #include "packet-usb.h" /* defines */ -#define tfp_PORT 4223 +#define tfp_PORT 4223 /* Not IANA registered */ #define tfp_USB_VENDOR_ID 0x16D0 #define tfp_USB_PRODUCT_ID 0x063D @@ -413,7 +413,7 @@ proto_reg_handoff_tfp(void) { tfp_handle_tcp = create_dissector_handle(dissect_tfp_tcp, proto_tfp); - dissector_add_uint("tcp.port", tfp_PORT, tfp_handle_tcp); + dissector_add_uint_with_preference("tcp.port", tfp_PORT, tfp_handle_tcp); heur_dissector_add("usb.bulk", dissect_tfp_bulk_heur, "Tinkerforge USB bulk endpoint", "tfp_usb_bulk", proto_tfp, HEURISTIC_ENABLE); } diff --git a/epan/dissectors/packet-time.c b/epan/dissectors/packet-time.c index 1ca8dd8375..c0017ab155 100644 --- a/epan/dissectors/packet-time.c +++ b/epan/dissectors/packet-time.c @@ -122,7 +122,7 @@ proto_reg_handoff_time(void) time_handle = create_dissector_handle(dissect_time, proto_time); dissector_add_uint("udp.port", TIME_PORT, time_handle); - dissector_add_uint("tcp.port", TIME_PORT, time_handle); + dissector_add_uint_with_preference("tcp.port", TIME_PORT, time_handle); } /* diff --git a/epan/dissectors/packet-tipc.c b/epan/dissectors/packet-tipc.c index 71ad52f8ce..58e0c4639f 100644 --- a/epan/dissectors/packet-tipc.c +++ b/epan/dissectors/packet-tipc.c @@ -207,7 +207,6 @@ static gboolean try_heuristic_first = FALSE; #define V2_AS_1_6 0x2 #define V2_AS_1_7 0x4 static gint handle_v2_as = V2_AS_ALL; -static guint tipc_alternate_tcp_port = 0; static gboolean tipc_tcp_desegment = TRUE; static dissector_handle_t tipc_handle; @@ -3012,8 +3011,7 @@ proto_register_tipc(void) }; /* Register the protocol name and description */ - proto_tipc = proto_register_protocol("Transparent Inter Process Communication(TIPC)", - "TIPC", "tipc"); + proto_tipc = proto_register_protocol("Transparent Inter Process Communication(TIPC)", "TIPC", "tipc"); /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_tipc, hf, array_length(hf)); @@ -3079,10 +3077,6 @@ proto_register_tipc(void) handle_v2_as_options, TRUE); - prefs_register_uint_preference(tipc_module, "alternate_port", - "TIPC-over-TCP port", "Decode this TCP ports traffic as TIPC. Set to \"0\" to disable.", 10, - &tipc_alternate_tcp_port); - prefs_register_bool_preference(tipc_module, "desegment", "Reassemble TIPC-over-TCP messages spanning multiple TCP segments", "Whether the TIPC-over-TCP dissector should reassemble messages spanning multiple TCP segments. " @@ -3095,7 +3089,6 @@ proto_reg_handoff_tipc(void) { static gboolean inited = FALSE; static dissector_handle_t tipc_tcp_handle; - static guint tipc_alternate_tcp_port_prev = 0; static range_t *tipc_udp_port_range; if (!inited) { @@ -3104,16 +3097,9 @@ proto_reg_handoff_tipc(void) dissector_add_uint("ethertype", ETHERTYPE_TIPC, tipc_handle); + dissector_add_for_decode_as_with_preference("tcp.port", tipc_tcp_handle); inited = TRUE; } else { - /* change TIPC-over-TCP port if changed in the preferences */ - if (tipc_alternate_tcp_port != tipc_alternate_tcp_port_prev) { - if (tipc_alternate_tcp_port_prev != 0) - dissector_delete_uint("tcp.port", tipc_alternate_tcp_port_prev, tipc_tcp_handle); - if (tipc_alternate_tcp_port != 0) - dissector_add_uint("tcp.port", tipc_alternate_tcp_port, tipc_tcp_handle); - tipc_alternate_tcp_port_prev = tipc_alternate_tcp_port; - } dissector_add_uint_range("udp.port", tipc_udp_port_range, tipc_handle); g_free(tipc_udp_port_range); } diff --git a/epan/dissectors/packet-tivoconnect.c b/epan/dissectors/packet-tivoconnect.c index 762ad20715..a51a80a068 100644 --- a/epan/dissectors/packet-tivoconnect.c +++ b/epan/dissectors/packet-tivoconnect.c @@ -40,6 +40,8 @@ void proto_reg_handoff_tivoconnect(void); void proto_register_tivoconnect(void); +#define TIVOCONNECT_PORT 2190 + static int proto_tivoconnect = -1; static int hf_tivoconnect_flavor = -1; static int hf_tivoconnect_method = -1; @@ -240,8 +242,8 @@ proto_reg_handoff_tivoconnect(void) tivoconnect_tcp_handle = create_dissector_handle(dissect_tivoconnect_tcp, proto_tivoconnect); tivoconnect_udp_handle = create_dissector_handle(dissect_tivoconnect_udp, proto_tivoconnect); - dissector_add_uint("udp.port", 2190, tivoconnect_udp_handle); - dissector_add_uint("tcp.port", 2190, tivoconnect_tcp_handle); + dissector_add_uint("udp.port", TIVOCONNECT_PORT, tivoconnect_udp_handle); + dissector_add_uint_with_preference("tcp.port", TIVOCONNECT_PORT, tivoconnect_tcp_handle); } /* diff --git a/epan/dissectors/packet-tns.c b/epan/dissectors/packet-tns.c index 137d4b71a1..ef0ee5cf0a 100644 --- a/epan/dissectors/packet-tns.c +++ b/epan/dissectors/packet-tns.c @@ -157,7 +157,7 @@ static gint ett_tns_ntp_flag = -1; static gint ett_tns_conn_flag = -1; static gint ett_sql = -1; -#define TCP_PORT_TNS 1521 +#define TCP_PORT_TNS 1521 /* Not IANA registered */ static const value_string tns_type_vals[] = { {TNS_TYPE_CONNECT, "Connect" }, @@ -1223,7 +1223,7 @@ proto_reg_handoff_tns(void) dissector_handle_t tns_handle; tns_handle = create_dissector_handle(dissect_tns, proto_tns); - dissector_add_uint("tcp.port", TCP_PORT_TNS, tns_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_TNS, tns_handle); } /* diff --git a/epan/dissectors/packet-tpkt.c b/epan/dissectors/packet-tpkt.c index 964ed7263d..5f6c9de002 100644 --- a/epan/dissectors/packet-tpkt.c +++ b/epan/dissectors/packet-tpkt.c @@ -53,6 +53,8 @@ static gint ett_tpkt = -1; /* desegmentation of OSI over TPKT over TCP */ static gboolean tpkt_desegment = TRUE; +#define TCP_PORT_TPKT_RANGE "102" + /* find the dissector for OSI TP (aka COTP) */ static dissector_handle_t osi_tp_handle; @@ -669,19 +671,10 @@ proto_reg_handoff_tpkt(void) { static dissector_handle_t tpkt_handle; static range_t *port_range; - static gboolean initialized = FALSE; - if (!initialized) - { - osi_tp_handle = find_dissector("ositp"); - tpkt_handle = find_dissector("tpkt"); - initialized = TRUE; - } - else - { - dissector_delete_uint_range("tcp.port", port_range, tpkt_handle); - g_free(port_range); - } + osi_tp_handle = find_dissector("ositp"); + tpkt_handle = find_dissector("tpkt"); + dissector_add_uint_range_with_preference("tcp.port", TCP_PORT_TPKT_RANGE, tpkt_handle); port_range = range_copy(tpkt_tcp_port_range); dissector_add_uint_range("tcp.port", port_range, tpkt_handle); diff --git a/epan/dissectors/packet-turnchannel.c b/epan/dissectors/packet-turnchannel.c index 4ff189905b..f9f0c71b79 100644 --- a/epan/dissectors/packet-turnchannel.c +++ b/epan/dissectors/packet-turnchannel.c @@ -205,7 +205,7 @@ proto_reg_handoff_turnchannel(void) turnchannel_udp_handle = find_dissector("turnchannel"); /* Register for "Decode As" in case STUN negotiation isn't captured */ - dissector_add_for_decode_as("tcp.port", turnchannel_tcp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", turnchannel_tcp_handle); dissector_add_for_decode_as("udp.port", turnchannel_udp_handle); /* TURN negotiation is handled through STUN2 dissector (packet-stun.c), diff --git a/epan/dissectors/packet-tuxedo.c b/epan/dissectors/packet-tuxedo.c index 231daadd8a..4628cce277 100644 --- a/epan/dissectors/packet-tuxedo.c +++ b/epan/dissectors/packet-tuxedo.c @@ -186,7 +186,7 @@ void proto_reg_handoff_tuxedo(void) { tuxedo_handle = create_dissector_handle(dissect_tuxedo, proto_tuxedo); - dissector_add_for_decode_as("tcp.port", tuxedo_handle); + dissector_add_for_decode_as_with_preference("tcp.port", tuxedo_handle); heur_dissector_add("tcp", dissect_tuxedo_heur, "Tuxedo over TCP", "tuxedo_tcp", proto_tuxedo, HEURISTIC_ENABLE); } diff --git a/epan/dissectors/packet-ucp.c b/epan/dissectors/packet-ucp.c index 40b8dd6575..e688ad6012 100644 --- a/epan/dissectors/packet-ucp.c +++ b/epan/dissectors/packet-ucp.c @@ -2828,7 +2828,7 @@ proto_reg_handoff_ucp(void) * Also register as a dissector that can be selected by a TCP port number via "decode as". */ ucp_handle = create_dissector_handle(dissect_ucp_tcp, proto_ucp); - dissector_add_for_decode_as("tcp.port", ucp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", ucp_handle); /* Tapping setup */ stats_tree_register_with_group("ucp", "ucp_messages", "_UCP Messages", 0, diff --git a/epan/dissectors/packet-ulp.c b/epan/dissectors/packet-ulp.c index 8c8b5dbd90..eebb9548ca 100644 --- a/epan/dissectors/packet-ulp.c +++ b/epan/dissectors/packet-ulp.c @@ -59,8 +59,8 @@ static dissector_handle_t lpp_handle; * oma-ulp 7275/tcp OMA UserPlane Location * oma-ulp 7275/udp OMA UserPlane Location */ -static guint gbl_ulp_tcp_port = 7275; -static guint gbl_ulp_udp_port = 7275; +#define ULP_PORT 7275 +static guint gbl_ulp_udp_port = ULP_PORT; /* Initialize the protocol and registered fields */ static int proto_ulp = -1; @@ -10639,11 +10639,6 @@ void proto_register_ulp(void) { &ulp_desegment); /* Register a configuration option for port */ - prefs_register_uint_preference(ulp_module, "tcp.port", - "ULP TCP Port", - "Set the TCP port for ULP messages (IANA registered port is 7275)", - 10, - &gbl_ulp_tcp_port); prefs_register_uint_preference(ulp_module, "udp.port", "ULP UDP Port", "Set the UDP port for ULP messages (IANA registered port is 7275)", @@ -10659,7 +10654,7 @@ proto_reg_handoff_ulp(void) { static gboolean initialized = FALSE; static dissector_handle_t ulp_udp_handle; - static guint local_ulp_tcp_port, local_ulp_udp_port; + static guint local_ulp_udp_port; if (!initialized) { dissector_add_string("media_type","application/oma-supl-ulp", ulp_tcp_handle); @@ -10667,14 +10662,12 @@ proto_reg_handoff_ulp(void) ulp_udp_handle = create_dissector_handle(dissect_ULP_PDU_PDU, proto_ulp); rrlp_handle = find_dissector_add_dependency("rrlp", proto_ulp); lpp_handle = find_dissector_add_dependency("lpp", proto_ulp); + dissector_add_uint_with_preference("tcp.port", ULP_PORT, ulp_tcp_handle); initialized = TRUE; } else { - dissector_delete_uint("tcp.port", local_ulp_tcp_port, ulp_tcp_handle); dissector_delete_uint("udp.port", local_ulp_udp_port, ulp_udp_handle); } - local_ulp_tcp_port = gbl_ulp_tcp_port; - dissector_add_uint("tcp.port", gbl_ulp_tcp_port, ulp_tcp_handle); local_ulp_udp_port = gbl_ulp_udp_port; dissector_add_uint("udp.port", gbl_ulp_udp_port, ulp_udp_handle); } diff --git a/epan/dissectors/packet-uma.c b/epan/dissectors/packet-uma.c index 14e60e48a4..94084b1d79 100644 --- a/epan/dissectors/packet-uma.c +++ b/epan/dissectors/packet-uma.c @@ -195,10 +195,7 @@ static expert_field ei_uma_cbs_frames = EI_INIT; static expert_field ei_uma_unknown_format = EI_INIT; /* The dynamic payload type which will be dissected as uma */ - -static range_t *global_uma_tcp_port_range; - -#define DEFAULT_UMA_PORT_RANGE "14001" +#define DEFAULT_UMA_PORT_RANGE "14001" /* Not IANA registered */ /* Global variables */ static guint32 sgw_ipv4_address; @@ -1755,24 +1752,14 @@ dissect_uma_urlc_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * void proto_reg_handoff_uma(void) { - static gboolean Initialized=FALSE; - static range_t *uma_tcp_port_range; - - if (!Initialized) { - uma_tcp_handle = find_dissector("umatcp"); - uma_udp_handle = find_dissector("umaudp"); - dissector_add_for_decode_as("udp.port", uma_udp_handle); - rtcp_handle = find_dissector_add_dependency("rtcp", proto_uma); - llc_handle = find_dissector_add_dependency("llcgprs", proto_uma); - bssap_pdu_type_table = find_dissector_table("bssap.pdu_type"); - Initialized=TRUE; - } else { - dissector_delete_uint_range("tcp.port", uma_tcp_port_range, uma_tcp_handle); - g_free(uma_tcp_port_range); - } - - uma_tcp_port_range = range_copy(global_uma_tcp_port_range); - dissector_add_uint_range("tcp.port", uma_tcp_port_range, uma_tcp_handle); + uma_tcp_handle = find_dissector("umatcp"); + uma_udp_handle = find_dissector("umaudp"); + dissector_add_for_decode_as("udp.port", uma_udp_handle); + rtcp_handle = find_dissector_add_dependency("rtcp", proto_uma); + llc_handle = find_dissector_add_dependency("llcgprs", proto_uma); + bssap_pdu_type_table = find_dissector_table("bssap.pdu_type"); + + dissector_add_uint_range_with_preference("tcp.port", DEFAULT_UMA_PORT_RANGE, uma_tcp_handle); } /* this format is require because a script is used to build the C function @@ -2311,10 +2298,7 @@ proto_register_uma(void) expert_register_field_array(expert_uma, ei, array_length(ei)); /* Register a configuration option for port */ - uma_module = prefs_register_protocol(proto_uma, proto_reg_handoff_uma); - - /* Set default TCP ports */ - range_convert_str(&global_uma_tcp_port_range, DEFAULT_UMA_PORT_RANGE, MAX_UDP_PORT); + uma_module = prefs_register_protocol(proto_uma, NULL); prefs_register_bool_preference(uma_module, "desegment_ucp_messages", "Reassemble UMA messages spanning multiple TCP segments", @@ -2323,11 +2307,6 @@ proto_register_uma(void) &uma_desegment); prefs_register_obsolete_preference(uma_module, "tcp.port1"); prefs_register_obsolete_preference(uma_module, "udp.ports"); - prefs_register_range_preference(uma_module, "tcp.ports", "UMA TCP ports", - "TCP ports to be decoded as UMA (default: " - DEFAULT_UMA_PORT_RANGE ")", - &global_uma_tcp_port_range, MAX_UDP_PORT); - } /* diff --git a/epan/dissectors/packet-usbip.c b/epan/dissectors/packet-usbip.c index fa47eaf9e6..4f949e16c9 100644 --- a/epan/dissectors/packet-usbip.c +++ b/epan/dissectors/packet-usbip.c @@ -1079,7 +1079,7 @@ proto_reg_handoff_usbip(void) dissector_handle_t usbip_handle; usbip_handle = create_dissector_handle(dissect_usbip, proto_usbip); - dissector_add_for_decode_as("tcp.port", usbip_handle); + dissector_add_for_decode_as_with_preference("tcp.port", usbip_handle); } /* diff --git a/epan/dissectors/packet-vicp.c b/epan/dissectors/packet-vicp.c index e96a95d771..f03e988587 100644 --- a/epan/dissectors/packet-vicp.c +++ b/epan/dissectors/packet-vicp.c @@ -116,7 +116,7 @@ void proto_reg_handoff_vicp(void) { dissector_handle_t vicp_handle; vicp_handle = create_dissector_handle(dissect_vicp, proto_vicp); - dissector_add_uint("tcp.port", VICP_PORT, vicp_handle); + dissector_add_uint_with_preference("tcp.port", VICP_PORT, vicp_handle); } /* diff --git a/epan/dissectors/packet-vnc.c b/epan/dissectors/packet-vnc.c index e65ada4012..f8991b168d 100644 --- a/epan/dissectors/packet-vnc.c +++ b/epan/dissectors/packet-vnc.c @@ -82,6 +82,7 @@ #include <epan/packet.h> #include <epan/conversation.h> #include <epan/prefs.h> +#include <epan/prefs-int.h> #include <epan/expert.h> #include <epan/proto_data.h> #include "packet-x11.h" /* This contains the extern for the X11 value_string_ext @@ -562,17 +563,10 @@ static guint vnc_slrle_encoding(tvbuff_t *tvb, packet_info *pinfo, gint *offset, static guint vnc_h264_encoding(tvbuff_t *tvb, gint *offset, proto_tree *tree); -#define DEST_PORT_VNC pinfo->destport == 5500 || pinfo->destport == 5501 || \ - pinfo->destport == 5900 || pinfo->destport == 5901 || \ - pinfo->destport == vnc_preference_alternate_port - #define VNC_BYTES_NEEDED(a) \ if((a) > (guint)tvb_reported_length_remaining(tvb, *offset)) \ return (a); -/* Variables for our preferences */ -static guint vnc_preference_alternate_port = 0; - /* Initialize the protocol and registered fields */ static int proto_vnc = -1; /* Protocol subtree */ static int hf_vnc_padding = -1; @@ -915,7 +909,9 @@ static expert_field ei_vnc_reassemble = EI_INIT; guint8 vnc_bytes_per_pixel; guint8 vnc_depth; +#define VNC_PORT_RANGE "5500-5501,5900-5901" /* Not IANA registered */ +static range_t *vnc_tcp_range = NULL; static dissector_handle_t vnc_handle; /* Code to dissect the packets */ @@ -969,7 +965,7 @@ dissect_vnc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) return tvb_captured_length(tvb); /* We're in a "startup" state; Cannot yet do "normal" processing */ } - if(DEST_PORT_VNC || per_conversation_info->server_port == pinfo->destport) { + if(value_is_in_range(vnc_tcp_range, pinfo->destport) || per_conversation_info->server_port == pinfo->destport) { vnc_client_to_server(tvb, pinfo, &offset, vnc_tree); } else { @@ -3462,6 +3458,13 @@ vnc_get_depth(packet_info *pinfo) return per_packet_info->depth; } +/* Preference callbacks */ +static void +apply_vnc_prefs(void) { + pref_t *vnc_ports = prefs_find_preference(prefs_find_module("vnc"), "tcp.port"); + + vnc_tcp_range = range_copy(*vnc_ports->varp.range); +} /* Register the protocol with Wireshark */ void @@ -4739,8 +4742,7 @@ proto_register_vnc(void) }; /* Register the protocol name and description */ - proto_vnc = proto_register_protocol("Virtual Network Computing", - "VNC", "vnc"); + proto_vnc = proto_register_protocol("Virtual Network Computing", "VNC", "vnc"); /* Required function calls to register the header fields and subtrees */ proto_register_field_array(proto_vnc, hf, array_length(hf)); @@ -4749,7 +4751,7 @@ proto_register_vnc(void) expert_register_field_array(expert_vnc, ei, array_length(ei)); /* Register our preferences module */ - vnc_module = prefs_register_protocol(proto_vnc, proto_reg_handoff_vnc); + vnc_module = prefs_register_protocol(proto_vnc, apply_vnc_prefs); prefs_register_bool_preference(vnc_module, "desegment", "Reassemble VNC messages spanning multiple TCP segments.", @@ -4757,62 +4759,19 @@ proto_register_vnc(void) "multiple TCP segments. To use this option, you must also enable " "\"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &vnc_preference_desegment); - - prefs_register_uint_preference(vnc_module, "alternate_port", "Alternate TCP port", - "Decode this port's traffic as VNC in addition to the default ports (5500, 5501, 5900, 5901)", - 10, &vnc_preference_alternate_port); - } void proto_reg_handoff_vnc(void) { - static gboolean inited = FALSE; - - /* This is a behind the scenes variable that is not changed by the user. - * This stores last setting of the vnc_preference_alternate_port. Used to keep - * track of when the user has changed the setting so that we can delete - * and re-register with the new port number. */ - static guint vnc_preference_alternate_port_last = 0; - - if(!inited) { - vnc_handle = create_dissector_handle(dissect_vnc, proto_vnc); - - dissector_add_uint("tcp.port", 5500, vnc_handle); - dissector_add_uint("tcp.port", 5501, vnc_handle); - dissector_add_uint("tcp.port", 5900, vnc_handle); - dissector_add_uint("tcp.port", 5901, vnc_handle); - - heur_dissector_add("tcp", test_vnc_protocol, "VNC over TCP", "vnc_tcp", proto_vnc, HEURISTIC_ENABLE); - /* We don't register a port for the VNC HTTP server because - * that simply provides a java program for download via the - * HTTP protocol. The java program then connects to a standard - * VNC port. */ - - inited = TRUE; - } else { /* only after preferences have been read/changed */ - if(vnc_preference_alternate_port != vnc_preference_alternate_port_last && - vnc_preference_alternate_port != 5500 && - vnc_preference_alternate_port != 5501 && - vnc_preference_alternate_port != 5900 && - vnc_preference_alternate_port != 5901) { - if (vnc_preference_alternate_port_last != 0) { - dissector_delete_uint("tcp.port", - vnc_preference_alternate_port_last, - vnc_handle); - } - /* Save this setting to see if has changed later */ - vnc_preference_alternate_port_last = - vnc_preference_alternate_port; - - /* Register the new port setting */ - if (vnc_preference_alternate_port != 0) { - dissector_add_uint("tcp.port", - vnc_preference_alternate_port, - vnc_handle); - } - } - } + vnc_handle = create_dissector_handle(dissect_vnc, proto_vnc); + + dissector_add_uint_range_with_preference("tcp.port", VNC_PORT_RANGE, vnc_handle); + heur_dissector_add("tcp", test_vnc_protocol, "VNC over TCP", "vnc_tcp", proto_vnc, HEURISTIC_ENABLE); + /* We don't register a port for the VNC HTTP server because + * that simply provides a java program for download via the + * HTTP protocol. The java program then connects to a standard + * VNC port. */ } /* diff --git a/epan/dissectors/packet-vsip.c b/epan/dissectors/packet-vsip.c index 740a680053..7613d6af60 100644 --- a/epan/dissectors/packet-vsip.c +++ b/epan/dissectors/packet-vsip.c @@ -2082,7 +2082,7 @@ void proto_reg_handoff_vsip(void) vsip_handle = create_dissector_handle(dissect_vsip, proto_vsip); dissector_add_for_decode_as("udp.port", vsip_handle); - dissector_add_for_decode_as("tcp.port", vsip_handle); + dissector_add_for_decode_as_with_preference("tcp.port", vsip_handle); } /* diff --git a/epan/dissectors/packet-whois.c b/epan/dissectors/packet-whois.c index 4913a820fa..282fc3b4f6 100644 --- a/epan/dissectors/packet-whois.c +++ b/epan/dissectors/packet-whois.c @@ -203,7 +203,7 @@ proto_reg_handoff_whois(void) static dissector_handle_t whois_handle; whois_handle = create_dissector_handle(dissect_whois, proto_whois); - dissector_add_uint("tcp.port", WHOIS_PORT, whois_handle); + dissector_add_uint_with_preference("tcp.port", WHOIS_PORT, whois_handle); } /* diff --git a/epan/dissectors/packet-winsrepl.c b/epan/dissectors/packet-winsrepl.c index deca83b993..022b883eef 100644 --- a/epan/dissectors/packet-winsrepl.c +++ b/epan/dissectors/packet-winsrepl.c @@ -120,8 +120,6 @@ enum wrepl_mess_type { WREPL_REPLICATION=3 }; -static unsigned int glb_winsrepl_tcp_port = WINS_REPLICATION_PORT; - static const value_string replication_cmd_vals[] = { {WREPL_REPL_TABLE_QUERY, "WREPL_REPL_TABLE_QUERY"}, {WREPL_REPL_TABLE_REPLY, "WREPL_REPL_TABLE_REPLY"}, @@ -880,7 +878,7 @@ proto_reg_handoff_winsrepl(void) dissector_handle_t winsrepl_handle; winsrepl_handle = create_dissector_handle(dissect_winsrepl, proto_winsrepl); - dissector_add_uint("tcp.port", glb_winsrepl_tcp_port, winsrepl_handle); + dissector_add_uint_with_preference("tcp.port", WINS_REPLICATION_PORT, winsrepl_handle); } /* diff --git a/epan/dissectors/packet-wow.c b/epan/dissectors/packet-wow.c index c4148df6cd..e458e660d8 100644 --- a/epan/dissectors/packet-wow.c +++ b/epan/dissectors/packet-wow.c @@ -636,7 +636,7 @@ proto_reg_handoff_wow(void) dissector_handle_t wow_handle; wow_handle = create_dissector_handle(dissect_wow, proto_wow); - dissector_add_uint("tcp.port", WOW_PORT, wow_handle); + dissector_add_uint_with_preference("tcp.port", WOW_PORT, wow_handle); } diff --git a/epan/dissectors/packet-x11.c b/epan/dissectors/packet-x11.c index 30a2c83a5f..95ce5fa728 100644 --- a/epan/dissectors/packet-x11.c +++ b/epan/dissectors/packet-x11.c @@ -216,7 +216,6 @@ static expert_field ei_x11_keycode_value_out_of_range = EI_INIT; /* desegmentation of X11 messages */ static gboolean x11_desegment = TRUE; -static range_t *global_x11_tcp_port_range; #define DEFAULT_X11_PORT_RANGE "6000-6063" @@ -5849,42 +5848,22 @@ void proto_register_x11(void) reply_table = g_hash_table_new(g_str_hash, g_str_equal); register_x11_extensions(); - /* Set default TCP ports */ - range_convert_str(&global_x11_tcp_port_range, DEFAULT_X11_PORT_RANGE, MAX_TCP_PORT); - x11_module = prefs_register_protocol(proto_x11, NULL); prefs_register_bool_preference(x11_module, "desegment", "Reassemble X11 messages spanning multiple TCP segments", "Whether the X11 dissector should reassemble messages spanning multiple TCP segments. " "To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &x11_desegment); - - prefs_register_range_preference(x11_module, "tcp.ports", "X11 TCP ports", - "TCP ports to be decoded as X11 (default: " - DEFAULT_X11_PORT_RANGE ")", - &global_x11_tcp_port_range, MAX_TCP_PORT); } void proto_reg_handoff_x11(void) { - static gboolean initialized = FALSE; - static range_t *x11_tcp_port_range; - static dissector_handle_t x11_handle = NULL; - - if (!initialized) - { - x11_handle = create_dissector_handle(dissect_x11, proto_x11); - initialized = TRUE; - } - else - { - dissector_delete_uint_range("tcp.port", x11_tcp_port_range, x11_handle); - g_free(x11_tcp_port_range); - } + dissector_handle_t x11_handle = NULL; + + x11_handle = create_dissector_handle(dissect_x11, proto_x11); - x11_tcp_port_range = range_copy(global_x11_tcp_port_range); - dissector_add_uint_range("tcp.port", x11_tcp_port_range, x11_handle); + dissector_add_uint_range_with_preference("tcp.port", DEFAULT_X11_PORT_RANGE, x11_handle); } /* diff --git a/epan/dissectors/packet-xmcp.c b/epan/dissectors/packet-xmcp.c index 79a8aa1fee..2fd0453228 100644 --- a/epan/dissectors/packet-xmcp.c +++ b/epan/dissectors/packet-xmcp.c @@ -33,7 +33,6 @@ #include <epan/packet.h> #include <epan/ipproto.h> #include <epan/addr_resolv.h> -#include <epan/prefs.h> #include <epan/expert.h> #include "packet-tcp.h" @@ -140,7 +139,6 @@ static expert_field ei_xmcp_attr_error_code_unusual = EI_INIT; #define XMCP_MAGIC_COOKIE 0x7f5a9bc7 void proto_reg_handoff_xmcp(void); -static guint global_xmcp_tcp_port = TCP_PORT_XMCP; #define XMCP_HDR_LEN 20 #define XMCP_ATTR_HDR_LEN 4 @@ -1340,45 +1338,26 @@ proto_register_xmcp(void) { &ei_xmcp_session_termination, { "xmcp.session_termination", PI_SEQUENCE, PI_CHAT, "Session termination", EXPFILL }}, }; - module_t *xmcp_module; expert_module_t* expert_xmcp; - proto_xmcp = proto_register_protocol("eXtensible Messaging Client Protocol", - "XMCP", "xmcp"); + proto_xmcp = proto_register_protocol("eXtensible Messaging Client Protocol", "XMCP", "xmcp"); proto_register_field_array(proto_xmcp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); expert_xmcp = expert_register_protocol(proto_xmcp); expert_register_field_array(expert_xmcp, ei, array_length(ei)); - - /* Register XMCP configuration options */ - xmcp_module = prefs_register_protocol(proto_xmcp, proto_reg_handoff_xmcp); - - prefs_register_uint_preference(xmcp_module, "tcp.port", "XMCP TCP Port", - "Set the port for XMCP messages (if other" - " than the default of 4788)", - 10, &global_xmcp_tcp_port); - } void proto_reg_handoff_xmcp(void) { - static gboolean xmcp_prefs_initialized = FALSE; - static dissector_handle_t xmcp_tcp_handle; - static guint xmcp_tcp_port; - - if (!xmcp_prefs_initialized) { - xmcp_tcp_handle = create_dissector_handle(dissect_xmcp_tcp, proto_xmcp); - heur_dissector_add("tcp", dissect_xmcp_heur, "XMCP over TCP", "xmcp_tcp", proto_xmcp, HEURISTIC_ENABLE); - media_type_dissector_table = find_dissector_table("media_type"); - xmcp_prefs_initialized = TRUE; - } else { - dissector_delete_uint("tcp.port", xmcp_tcp_port, xmcp_tcp_handle); - } + dissector_handle_t xmcp_tcp_handle; + + xmcp_tcp_handle = create_dissector_handle(dissect_xmcp_tcp, proto_xmcp); + heur_dissector_add("tcp", dissect_xmcp_heur, "XMCP over TCP", "xmcp_tcp", proto_xmcp, HEURISTIC_ENABLE); + media_type_dissector_table = find_dissector_table("media_type"); - xmcp_tcp_port = global_xmcp_tcp_port; - dissector_add_uint("tcp.port", global_xmcp_tcp_port, xmcp_tcp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_XMCP, xmcp_tcp_handle); } /* diff --git a/epan/dissectors/packet-xml.c b/epan/dissectors/packet-xml.c index bafd884832..7bd78509e2 100644 --- a/epan/dissectors/packet-xml.c +++ b/epan/dissectors/packet-xml.c @@ -83,7 +83,6 @@ static xml_ns_t *root_ns; static gboolean pref_heuristic_unicode = FALSE; -static range_t *global_xml_tcp_range = NULL; static range_t *xml_tcp_range = NULL; @@ -1365,14 +1364,6 @@ static void init_xml_names(void) g_free(dummy); } -static void apply_prefs(void) -{ - dissector_delete_uint_range("tcp.port", xml_tcp_range, xml_handle); - g_free(xml_tcp_range); - xml_tcp_range = range_copy(global_xml_tcp_range); - dissector_add_uint_range("tcp.port", xml_tcp_range, xml_handle); -} - void proto_register_xml(void) { @@ -1455,12 +1446,9 @@ proto_register_xml(void) expert_xml = expert_register_protocol(xml_ns.hf_tag); expert_register_field_array(expert_xml, ei, array_length(ei)); - xml_module = prefs_register_protocol(xml_ns.hf_tag, apply_prefs); + xml_module = prefs_register_protocol(xml_ns.hf_tag, NULL); prefs_register_obsolete_preference(xml_module, "heuristic"); prefs_register_obsolete_preference(xml_module, "heuristic_tcp"); - prefs_register_range_preference(xml_module, "tcp.port", "TCP Ports", - "TCP Ports range", - &global_xml_tcp_range, 65535); prefs_register_obsolete_preference(xml_module, "heuristic_udp"); /* XXX - UCS-2, or UTF-16? */ prefs_register_bool_preference(xml_module, "heuristic_unicode", "Use Unicode in heuristics", @@ -1490,6 +1478,7 @@ proto_reg_handoff_xml(void) xml_handle = find_dissector("xml"); g_hash_table_foreach(media_types, add_dissector_media, NULL); + dissector_add_uint_range_with_preference("tcp.port", "", xml_handle); heur_dissector_add("http", dissect_xml_heur, "XML in HTTP", "xml_http", xml_ns.hf_tag, HEURISTIC_DISABLE); heur_dissector_add("sip", dissect_xml_heur, "XML in SIP", "xml_sip", xml_ns.hf_tag, HEURISTIC_DISABLE); diff --git a/epan/dissectors/packet-xmpp.c b/epan/dissectors/packet-xmpp.c index ab14f127d8..d6608cddf9 100644 --- a/epan/dissectors/packet-xmpp.c +++ b/epan/dissectors/packet-xmpp.c @@ -1490,7 +1490,7 @@ void proto_reg_handoff_xmpp(void) { xml_handle = find_dissector_add_dependency("xml", proto_xmpp); - dissector_add_uint("tcp.port", XMPP_PORT, xmpp_handle); + dissector_add_uint_with_preference("tcp.port", XMPP_PORT, xmpp_handle); } /* diff --git a/epan/dissectors/packet-xot.c b/epan/dissectors/packet-xot.c index 248aa973c9..6ece8f407a 100644 --- a/epan/dissectors/packet-xot.c +++ b/epan/dissectors/packet-xot.c @@ -448,7 +448,7 @@ proto_register_xot(void) void proto_reg_handoff_xot(void) { - dissector_add_uint("tcp.port", TCP_PORT_XOT, xot_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_XOT, xot_handle); x25_handle = find_dissector_add_dependency("x.25", proto_xot); } diff --git a/epan/dissectors/packet-yami.c b/epan/dissectors/packet-yami.c index cbf51c8f5e..c7bb2d8a48 100644 --- a/epan/dissectors/packet-yami.c +++ b/epan/dissectors/packet-yami.c @@ -37,7 +37,6 @@ void proto_reg_handoff_yami(void); void proto_register_yami(void); static gboolean yami_desegment = TRUE; -static guint global_yami_config_tcp_port = 0; static guint global_yami_config_udp_port = 0; static dissector_handle_t yami_handle; @@ -588,7 +587,6 @@ proto_register_yami(void) proto_register_subtree_array(ett, array_length(ett)); yami_module = prefs_register_protocol(proto_yami, proto_reg_handoff_yami); - prefs_register_uint_preference(yami_module, "tcp.port", "YAMI TCP Port", "The TCP port on which YAMI messages will be read(3000)", 10, &global_yami_config_tcp_port); prefs_register_uint_preference(yami_module, "udp.port", "YAMI UDP Port", "The UDP port on which YAMI messages will be read(5000)", 10, &global_yami_config_udp_port); prefs_register_bool_preference(yami_module, "desegment", "Reassemble YAMI messages spanning multiple TCP segments", @@ -603,21 +601,18 @@ void proto_reg_handoff_yami(void) { static int yami_prefs_initialized = FALSE; - static guint yami_tcp_port, yami_udp_port; + static guint yami_udp_port; if(yami_prefs_initialized == FALSE){ yami_prefs_initialized = TRUE; - yami_tcp_port = global_yami_config_tcp_port; yami_udp_port = global_yami_config_udp_port; + dissector_add_for_decode_as_with_preference("tcp.port", yami_handle); }else{ - dissector_delete_uint("tcp.port", yami_tcp_port, yami_handle); dissector_delete_uint("udp.port", yami_udp_port, yami_handle); } - yami_tcp_port = global_yami_config_tcp_port; yami_udp_port = global_yami_config_udp_port; - dissector_add_uint("tcp.port", yami_tcp_port, yami_handle); dissector_add_uint("udp.port", yami_udp_port, yami_handle); } diff --git a/epan/dissectors/packet-zebra.c b/epan/dissectors/packet-zebra.c index 6f8d2c2920..e650e4890a 100644 --- a/epan/dissectors/packet-zebra.c +++ b/epan/dissectors/packet-zebra.c @@ -88,7 +88,7 @@ static gint ett_zebra = -1; static gint ett_zebra_request = -1; static gint ett_message = -1; -#define TCP_PORT_ZEBRA 2600 +#define TCP_PORT_ZEBRA 2600 /* Not IANA registered */ /* Zebra message types. */ #define ZEBRA_INTERFACE_ADD 1 @@ -879,7 +879,7 @@ proto_reg_handoff_zebra(void) dissector_handle_t zebra_handle; zebra_handle = create_dissector_handle(dissect_zebra, proto_zebra); - dissector_add_uint("tcp.port", TCP_PORT_ZEBRA, zebra_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_ZEBRA, zebra_handle); } /* diff --git a/epan/dissectors/packet-zvt.c b/epan/dissectors/packet-zvt.c index 0d371788c9..c27350d752 100644 --- a/epan/dissectors/packet-zvt.c +++ b/epan/dissectors/packet-zvt.c @@ -44,7 +44,6 @@ #include "config.h" #include <epan/packet.h> -#include <epan/prefs.h> #include <epan/addr_resolv.h> #include <epan/expert.h> @@ -180,10 +179,6 @@ static const bitmap_info_t bitmap_info[] = { void proto_register_zvt(void); void proto_reg_handoff_zvt(void); -/* the specification mentions tcp port 20007 - this port is not officially registered with IANA */ -static guint pref_zvt_tcp_port = 0; - static int proto_zvt = -1; static int ett_zvt = -1; @@ -842,7 +837,6 @@ void proto_register_zvt(void) { guint i; - module_t *zvt_module; expert_module_t* expert_zvt; static gint *ett[] = { @@ -939,44 +933,28 @@ proto_register_zvt(void) (gpointer)(&bitmap_info[i])); } - proto_zvt = proto_register_protocol( - "ZVT Kassenschnittstelle", "ZVT", "zvt"); + proto_zvt = proto_register_protocol("ZVT Kassenschnittstelle", "ZVT", "zvt"); + proto_register_field_array(proto_zvt, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); expert_zvt = expert_register_protocol(proto_zvt); expert_register_field_array(expert_zvt, ei, array_length(ei)); - zvt_module = prefs_register_protocol(proto_zvt, proto_reg_handoff_zvt); - prefs_register_uint_preference(zvt_module, "tcp.port", - "ZVT TCP Port", - "Set the TCP port for ZVT messages (port 20007 according to the spec)", - 10, - &pref_zvt_tcp_port); - transactions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); + + /* register by name to allow mapping to a user DLT */ + register_dissector("zvt", dissect_zvt, proto_zvt); } void proto_reg_handoff_zvt(void) { - static gboolean registered_dissector = FALSE; - static int zvt_tcp_port; - static dissector_handle_t zvt_tcp_handle; + dissector_handle_t zvt_tcp_handle; - if (!registered_dissector) { - /* register by name to allow mapping to a user DLT */ - register_dissector("zvt", dissect_zvt, proto_zvt); - - zvt_tcp_handle = create_dissector_handle(dissect_zvt_tcp, proto_zvt); - - registered_dissector = TRUE; - } - else - dissector_delete_uint("tcp.port", zvt_tcp_port, zvt_tcp_handle); + zvt_tcp_handle = create_dissector_handle(dissect_zvt_tcp, proto_zvt); - zvt_tcp_port = pref_zvt_tcp_port; - dissector_add_uint("tcp.port", zvt_tcp_port, zvt_tcp_handle); + dissector_add_for_decode_as_with_preference("tcp.port", zvt_tcp_handle); } |