prefs: Make add_for_decode_as_with_preference add ranges

Make add_for_decode_as_with_preference create a range preference,
instead of a single uint preference. Decode As allows multiple
ports to be set for a dissector, so a range preference is correct.
This prevents an odd situation where the quasi preference only
holds the last value set in the Decode As table, and changing it
only changes that one value, not all the other values. Moving
the preference to a range also means that the empty string clears
the result instead of doing nothing. (With uint preferences
inputing 0 is required to not dissect.)

This moves a lot of the automatic port preferences over to ranges.

Ping #14319. Fix #15554.
This commit is contained in:
John Thacker 2022-08-02 16:35:49 -04:00 committed by A Wireshark GitLab Utility
parent 71f32ef2a8
commit ab6f902216
1 changed files with 13 additions and 4 deletions

View File

@ -1250,8 +1250,8 @@ void dissector_add_uint_with_preference(const char *name, const guint32 pattern,
dissector_add_uint(name, pattern, handle);
}
void dissector_add_uint_range_with_preference(const char *name, const char* range_str,
dissector_handle_t handle)
static range_t*
dissector_add_range_preference(const char *name, dissector_handle_t handle, const char* range_str)
{
range_t** range;
module_t *module;
@ -1305,7 +1305,16 @@ void dissector_add_uint_range_with_preference(const char *name, const char* rang
prefs_register_decode_as_range_preference(module, name, title, description, range, max_value);
}
dissector_add_uint_range(name, *range, handle);
return *range;
}
void dissector_add_uint_range_with_preference(const char *name, const char* range_str,
dissector_handle_t handle)
{
range_t* range;
range = dissector_add_range_preference(name, handle, range_str);
dissector_add_uint_range(name, range, handle);
}
/* Delete the entry for a dissector in a uint dissector table
@ -2242,7 +2251,7 @@ void dissector_add_for_decode_as_with_preference(const char *name,
table value would default to 0.
Set up a preference value with that information
*/
dissector_add_preference(name, handle, 0);
dissector_add_range_preference(name, handle, "");
dissector_add_for_decode_as(name, handle);
}