+static gboolean
+deprecated_enable_dissector_pref(gchar *pref_name, const gchar *value)
+{
+ struct dissector_pref_name
+ {
+ const char* pref_name;
+ const char* short_name;
+ };
+
+ struct dissector_pref_name dissector_prefs[] = {
+ {"transum.tsumenabled", "TRANSUM"},
+ {"snort.enable_snort_dissector", "Snort"},
+ {"prp.enable", "PRP"},
+ };
+
+ unsigned int i;
+ int proto_id;
+
+ for (i = 0; i < sizeof(dissector_prefs)/sizeof(struct dissector_pref_name); i++)
+ {
+ if (strcmp(pref_name, dissector_prefs[i].pref_name) == 0)
+ {
+ proto_id = proto_get_id_by_short_name(dissector_prefs[i].short_name);
+ if (proto_id >= 0)
+ proto_set_decoding(proto_id, ((g_ascii_strcasecmp(value, "true") == 0) ? TRUE : FALSE));
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean
+deprecated_port_pref(gchar *pref_name, const gchar *value)
+{
+ struct port_pref_name
+ {
+ const char* pref_name;
+ const char* module_name;
+ const char* table_name;
+ guint base;
+ };
+
+ struct obsolete_pref_name
+ {
+ const char* pref_name;
+ };
+
+ /* For now this is only supporting TCP/UDP port dissector preferences
+ which are assumed to be decimal */
+ struct port_pref_name port_prefs[] = {
+ /* TCP */
+ {"cmp.tcp_alternate_port", "CMP", "tcp.port", 10},
+ {"h248.tcp_port", "H248", "tcp.port", 10},
+ {"cops.tcp.cops_port", "COPS", "tcp.port", 10},
+ {"dhcpfo.tcp_port", "DHCPFO", "tcp.port", 10},
+ {"enttec.tcp_port", "ENTTEC", "tcp.port", 10},
+ {"forces.tcp_alternate_port", "ForCES", "tcp.port", 10},
+ {"ged125.tcp_port", "GED125", "tcp.port", 10},
+ {"hpfeeds.dissector_port", "HPFEEDS", "tcp.port", 10},
+ {"lsc.port", "LSC", "tcp.port", 10},
+ {"megaco.tcp.txt_port", "MEGACO", "tcp.port", 10},
+ {"netsync.tcp_port", "Netsync", "tcp.port", 10},
+ {"osi.tpkt_port", "OSI", "tcp.port", 10},
+ {"rsync.tcp_port", "RSYNC", "tcp.port", 10},
+ {"sametime.tcp_port", "SAMETIME", "tcp.port", 10},
+ {"sigcomp.tcp.port2", "SIGCOMP", "tcp.port", 10},
+ {"synphasor.tcp_port", "SYNCHROPHASOR", "tcp.port", 10},
+ {"tipc.alternate_port", "TIPC", "tcp.port", 10},
+ {"vnc.alternate_port", "VNC", "tcp.port", 10},
+ {"scop.port", "SCoP", "tcp.port", 10},
+ {"scop.port_secure", "SCoP", "tcp.port", 10},
+ /* UDP */
+ {"h248.udp_port", "H248", "udp.port", 10},
+ {"actrace.udp_port", "ACtrace", "udp.port", 10},
+ {"brp.port", "BRP", "udp.port", 10},
+ {"bvlc.additional_udp_port", "BVLC", "udp.port", 10},
+ {"capwap.udp.port.control", "CAPWAP-CONTROL", "udp.port", 10},
+ {"capwap.udp.port.data", "CAPWAP-CONTROL", "udp.port", 10},
+ {"coap.udp_port", "CoAP", "udp.port", 10},
+ {"enttec.udp_port", "ENTTEC", "udp.port", 10},
+ {"forces.udp_alternate_port", "ForCES", "udp.port", 10},
+ {"ldss.udp_port", "LDSS", "udp.port", 10},
+ {"lmp.udp_port", "LMP", "udp.port", 10},
+ {"ltp.port", "LTP", "udp.port", 10},
+ {"lwres.udp.lwres_port", "LWRES", "udp.port", 10},
+ {"megaco.udp.txt_port", "MEGACO", "udp.port", 10},
+ {"pgm.udp.encap_ucast_port", "PGM", "udp.port", 10},
+ {"pgm.udp.encap_mcast_port", "PGM", "udp.port", 10},
+ {"quic.udp.quic.port", "QUIC", "udp.port", 10},
+ {"quic.udp.quics.port", "QUIC", "udp.port", 10},
+ {"radius.alternate_port", "RADIUS", "udp.port", 10},
+ {"rdt.default_udp_port", "RDT", "udp.port", 10},
+ {"alc.default.udp_port", "ALC", "udp.port", 10},
+ {"sigcomp.udp.port2", "SIGCOMP", "udp.port", 10},
+ {"synphasor.udp_port", "SYNCHROPHASOR", "udp.port", 10},
+ {"tdmop.udpport", "TDMoP", "udp.port", 10},
+ {"uaudp.port1", "UAUDP", "udp.port", 10},
+ {"uaudp.port2", "UAUDP", "udp.port", 10},
+ {"uaudp.port3", "UAUDP", "udp.port", 10},
+ {"uaudp.port4", "UAUDP", "udp.port", 10},
+ {"uhd.dissector_port", "UHD", "udp.port", 10},
+ {"vrt.dissector_port", "VITA 49", "udp.port", 10},
+ {"vuze-dht.udp_port", "Vuze-DHT", "udp.port", 10},
+ {"wimaxasncp.udp.wimax_port", "WiMAX ASN CP", "udp.port", 10},
+ };
+
+ struct port_pref_name port_range_prefs[] = {
+ /* TCP */
+ {"couchbase.tcp.ports", "Couchbase", "tcp.port", 10},
+ {"gsm_ipa.tcp_ports", "GSM over IP", "tcp.port", 10},
+ {"kafka.tcp.ports", "Kafka", "tcp.port", 10},
+ {"kt.tcp.ports", "Kyoto Tycoon", "tcp.port", 10},
+ {"memcache.tcp.ports", "MEMCACHE", "tcp.port", 10},
+ {"mrcpv2.tcp.port_range", "MRCPv2", "tcp.port", 10},
+ {"rtsp.tcp.port_range", "RTSP", "tcp.port", 10},
+ {"sip.tcp.ports", "SIP", "tcp.port", 10},
+ {"tds.tcp_ports", "TDS", "tcp.port", 10},
+ {"uma.tcp.ports", "UMA", "tcp.port", 10},
+ /* UDP */
+ {"aruba_erm.udp.ports", "ARUBA_ERM", "udp.port", 10},
+ {"diameter.udp.ports", "DIAMETER", "udp.port", 10},
+ {"dmp.udp_ports", "DMP", "udp.port", 10},
+ {"dns.udp.ports", "DNS", "udp.port", 10},
+ {"gsm_ipa.udp_ports", "GSM over IP", "udp.port", 10},
+ {"hcrt.dissector_udp_port", "HCrt", "udp.port", 10},
+ {"memcache.udp.ports", "MEMCACHE", "udp.port", 10},
+ {"nb_rtpmux.udp_ports", "NB_RTPMUX", "udp.port", 10},
+ {"gprs-ns.udp.ports", "GPRS-NS", "udp.port", 10},
+ {"p_mul.udp_ports", "P_MUL", "udp.port", 10},
+ {"radius.ports", "RADIUS", "udp.port", 10},
+ {"sflow.ports", "sFlow", "udp.port", 10},
+ {"sscop.udp.ports", "SSCOP", "udp.port", 10},
+ {"tftp.udp_ports", "TFTP", "udp.port", 10},
+ {"tipc.udp.ports", "TIPC", "udp.port", 10},
+ };
+
+ /* These are subdissectors of TPKT/OSITP that used to have a
+ TCP port preference even though they were never
+ directly on TCP. Convert them to use Decode As
+ with the TPKT dissector handle */
+ struct port_pref_name tpkt_subdissector_port_prefs[] = {
+ {"dap.tcp.port", "DAP", "tcp.port", 10},
+ {"disp.tcp.port", "DISP", "tcp.port", 10},
+ {"dop.tcp.port", "DOP", "tcp.port", 10},
+ {"dsp.tcp.port", "DSP", "tcp.port", 10},
+ {"p1.tcp.port", "P1", "tcp.port", 10},
+ {"p7.tcp.port", "P7", "tcp.port", 10},
+ {"rdp.tcp.port", "RDP", "tcp.port", 10},
+ };
+
+ /* These are obsolete preferences from the dissectors' view,
+ (typically because of a switch from a single value to a
+ range value) but the name of the preference conflicts
+ with the generated preference name from the dissector table.
+ Don't allow the obsolete preference through to be handled */
+ struct obsolete_pref_name obsolete_prefs[] = {
+ {"diameter.tcp.port"},
+ {"kafka.tcp.port"},
+ {"mrcpv2.tcp.port"},
+ {"rtsp.tcp.port"},
+ {"sip.tcp.port"},
+ {"t38.tcp.port"},
+ };
+
+ unsigned int i;
+ char *p;
+ guint uval;
+ dissector_table_t sub_dissectors;
+ dissector_handle_t handle, tpkt_handle;
+ module_t *module;
+ pref_t *pref;
+
+ for (i = 0; i < sizeof(port_prefs)/sizeof(struct port_pref_name); i++)
+ {
+ if (strcmp(pref_name, port_prefs[i].pref_name) == 0)
+ {
+ /* XXX - give an error if it doesn't fit in a guint? */
+ uval = (guint)strtoul(value, &p, port_prefs[i].base);
+ if (p == value || *p != '\0')
+ return FALSE; /* number was bad */
+
+ module = prefs_find_module(port_prefs[i].module_name);
+ pref = prefs_find_preference(module, port_prefs[i].table_name);
+ if (pref != NULL)
+ {
+ module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ *pref->varp.uint = uval;
+ }
+
+ /* If the value is zero, it wouldn't add to the Decode As tables */
+ if (uval != 0)
+ {
+ sub_dissectors = find_dissector_table(port_prefs[i].table_name);
+ if (sub_dissectors != NULL) {
+ handle = dissector_table_get_dissector_handle(sub_dissectors, port_prefs[i].module_name);
+ if (handle != NULL) {
+ dissector_change_uint(port_prefs[i].table_name, uval, handle);
+ decode_build_reset_list(port_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(uval), NULL, NULL);
+ }
+ }
+ }
+
+ return TRUE;
+ }
+ }
+
+ for (i = 0; i < sizeof(port_range_prefs)/sizeof(struct port_pref_name); i++)
+ {
+ if (strcmp(pref_name, port_range_prefs[i].pref_name) == 0)
+ {
+ guint32 range_i, range_j;
+
+ sub_dissectors = find_dissector_table(port_range_prefs[i].table_name);
+ if (sub_dissectors != NULL) {
+ switch (dissector_table_get_type(sub_dissectors)) {
+ case FT_UINT8:
+ case FT_UINT16:
+ case FT_UINT24:
+ case FT_UINT32:
+ break;
+
+ default:
+ g_error("The dissector table %s (%s) is not an integer type - are you using a buggy plugin?", port_range_prefs[i].table_name, get_dissector_table_ui_name(port_range_prefs[i].table_name));
+ g_assert_not_reached();
+ }
+
+ module = prefs_find_module(port_range_prefs[i].module_name);
+ pref = prefs_find_preference(module, port_range_prefs[i].table_name);
+ if (pref != NULL)
+ {
+ if (!prefs_set_range_value_work(pref, value, TRUE, &module->prefs_changed_flags))
+ {
+ return FALSE; /* number was bad */
+ }
+
+ handle = dissector_table_get_dissector_handle(sub_dissectors, port_range_prefs[i].module_name);
+ if (handle != NULL) {
+
+ for (range_i = 0; range_i < (*pref->varp.range)->nranges; range_i++) {
+ for (range_j = (*pref->varp.range)->ranges[range_i].low; range_j < (*pref->varp.range)->ranges[range_i].high; range_j++) {
+ dissector_change_uint(port_range_prefs[i].table_name, range_j, handle);
+ decode_build_reset_list(port_range_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(range_j), NULL, NULL);
+ }
+
+ dissector_change_uint(port_range_prefs[i].table_name, (*pref->varp.range)->ranges[range_i].high, handle);
+ decode_build_reset_list(port_range_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[range_i].high), NULL, NULL);
+ }
+ }
+ }
+ }
+
+ return TRUE;
+ }
+ }
+
+ for (i = 0; i < sizeof(tpkt_subdissector_port_prefs)/sizeof(struct port_pref_name); i++)
+ {
+ if (strcmp(pref_name, tpkt_subdissector_port_prefs[i].pref_name) == 0)
+ {
+ /* XXX - give an error if it doesn't fit in a guint? */
+ uval = (guint)strtoul(value, &p, tpkt_subdissector_port_prefs[i].base);
+ if (p == value || *p != '\0')
+ return FALSE; /* number was bad */
+
+ /* If the value is 0 or 102 (default TPKT port), don't add to the Decode As tables */
+ if ((uval != 0) && (uval != 102))
+ {
+ tpkt_handle = find_dissector("tpkt");
+ if (tpkt_handle != NULL) {
+ dissector_change_uint(tpkt_subdissector_port_prefs[i].table_name, uval, tpkt_handle);
+ }
+ }
+
+ return TRUE;
+ }
+ }
+
+ for (i = 0; i < sizeof(obsolete_prefs)/sizeof(struct obsolete_pref_name); i++)
+ {
+ if (strcmp(pref_name, obsolete_prefs[i].pref_name) == 0)
+ {
+ /* Just ignore the preference */
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+