BER: Make the Decode As functionality mostly work again

The BER Decode As table is unique, and doesn't actually change
the FT_STRING dissector table it refers to, but rather acts more
like a Payload dissector table. As it is, it calls
dissector_table_foreach instead of dissector_table_foreach_handle
like most Decode As tables. That means that it iterates over the
hash_table and not the dissector_handles, which means that the
value refers to a dtbl_entry_t and not a dissector_handle_t.

The Decode As Model's decodeAddProtocol function expects to receive
a dissector_handle_t, and for the last 6-10 years has been casting
a dtbl_entry_t to a dissector_handle_t, which has not worked.
Retrieve the actual dissector_handle.

Also give the name as a description to the dissector handles, because
even though the decode as list is populated through a custom function,
the Decode As model and delegate expect to look at the description
of the handle.

The FT_STRING part of the table is used for the UAT that associates
OID to the string, which is then used to look up the dissector.
Perhaps the UAT should map to the dissector handle (or a dissector
handle name) more directly?
This commit is contained in:
John Thacker 2024-08-05 20:55:00 -04:00 committed by AndersBroman
parent d218d6754f
commit bd94e40a3f
2 changed files with 7 additions and 6 deletions

View File

@ -394,7 +394,8 @@ static void
decode_ber_add_to_list(void *key, void *value, void *user_data)
{
struct ber_decode_as_populate* populate = (struct ber_decode_as_populate*)user_data;
populate->add_to_list("ASN.1", (char *)key, value, populate->ui_element);
dtbl_entry_t *dtbl_entry = (dtbl_entry_t*)value;
populate->add_to_list("ASN.1", (char *)key, dtbl_entry_get_initial_handle(dtbl_entry), populate->ui_element);
}
static void ber_populate_list(const char *table_name _U_, decode_as_add_to_list_func add_to_list, void *ui_element)
@ -450,7 +451,7 @@ register_ber_syntax_dissector(const char *syntax, int proto, dissector_t dissect
{
dissector_handle_t dissector_handle;
dissector_handle = create_dissector_handle(dissector, proto);
dissector_handle = create_dissector_handle_with_name_and_description(dissector, proto, NULL, syntax);
dissector_add_string("ber.syntax", syntax, dissector_handle);
}

View File

@ -2315,10 +2315,10 @@ dissector_add_for_decode_as(const char *name, dissector_handle_t handle)
with the same descriptions.
FT_STRING can at least show the string value in the dialog,
so we don't do the check for them. XXX - ? It can show the
string value the dissector is being set to, but can't distinguish
the dissectors. See the Decode As table for Internet media types
(which packet-obex.c adds.)
so we don't do the check for them. XXX - It can show the
string value the dissector is being set to if there's a custom
populate function (like BER uses) but the GUI model still uses
the description.
*/
const char *dissector_name;