tshark: Restore deprecated default column field titles

Restore the ability in tshark -e to filter based on column titles,
at least for the seven default columns.  Internally alias the fields
based on their titles to the column type based fields, e.g.
"_ws.col.Info" to "_ws.col.info"

This may be removed in the future, but is useful to have as there
are tools and scripts that use the old beahvior (and there are
supports versions, 3.6.x and 4.0.x, that only support the old
behavior.)
This commit is contained in:
John Thacker 2023-08-19 08:08:00 -04:00
parent 50ece15a8c
commit c3fa423bc9
5 changed files with 54 additions and 9 deletions

View File

@ -199,9 +199,13 @@ The following features are new (or have been significantly updated) since versio
* With the addition of the universal and consistent filtering support for
column text, the previous support in the -e option to tshark for displaying
column text via the column title, e.g. "_ws.col.Info", has been removed.
The previous implementation allowed names that are not legal filter names
and wsbuglink:16576[silently ignored columns that didn't exist.]
column text via the column title has been removed in general. Those field names
cannot be used elsewhere (as they may not be legal filter names) and create
confusion if more than one column has the same title or if a column is renamed.
Prefer the column format instead, e.g. "_ws.col.info" for "_ws.col.Info".
However, for backwards compatibilty with existing tools and scripts, the
titles of the default columns can continue to be used with "tshark -e"
(but not elsewhere.)
* The bundled script "dtd_gen.lua" that was disabled by default has been removed
from the installation. It can be found in the Wireshark Wiki under "Contrib".

View File

@ -251,6 +251,31 @@ static struct deprecated_columns migrated_columns[] = {
{ /* COL_TEI */ "%E", "lapd.tei" },
};
const char*
try_convert_to_column_field(const char *field)
{
static const value_string migrated_fields[] = {
{ COL_NUMBER, COLUMN_FIELD_FILTER"No." },
{ COL_CLS_TIME, COLUMN_FIELD_FILTER"Time" },
{ COL_DEF_SRC, COLUMN_FIELD_FILTER"Source" },
{ COL_DEF_DST, COLUMN_FIELD_FILTER"Destination" },
{ COL_PROTOCOL, COLUMN_FIELD_FILTER"Protocol" },
{ COL_PACKET_LENGTH, COLUMN_FIELD_FILTER"Length" },
{ COL_INFO, COLUMN_FIELD_FILTER"Info" },
{ 0, NULL },
};
int idx;
idx = str_to_val_idx(field, migrated_fields);
if (idx >= 0) {
return col_format_abbrev(migrated_fields[idx].value);
}
return NULL;
}
/*
* Parse a column format, filling in the relevant fields of a fmt_data.
*/

View File

@ -120,6 +120,16 @@ gboolean parse_column_format(fmt_data *cfmt, const char *fmt);
WS_DLL_PUBLIC
void try_convert_to_custom_column(char **fmt);
/** Checks a column field string to see if it is a name of a filter
* field created using a default column title (as used in tshark -e),
* and alias it to the new column type based field.
*
* @param[in] field The old title based field, e.g. "_ws.col.Info"
* @return The new field, e.g. "_ws.col.info", or NULL
*/
WS_DLL_PUBLIC
const char* try_convert_to_column_field(const char *field);
WS_DLL_PUBLIC
void column_register_fields(void);
#ifdef __cplusplus

View File

@ -1804,6 +1804,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
try_conversation_dissector@Base 2.6.3
try_conversation_dissector_by_id@Base 2.6.3
try_convert_to_custom_column@Base 4.1.0
try_convert_to_column_field@Base 4.1.0
try_enterprises_lookup@Base 2.5.0
try_rval64_to_str@Base 2.3.0
try_rval64_to_str_idx@Base 2.3.0
@ -2186,4 +2187,4 @@ libwireshark.so.0 libwireshark0 #MINVER#
xml_get_attrib@Base 1.9.1
xml_get_cdata@Base 1.9.1
xml_get_tag@Base 1.9.1
zbee_zcl_init_cluster@Base 2.5.2
zbee_zcl_init_cluster@Base 2.5.2

View File

@ -1356,11 +1356,16 @@ main(int argc, char *argv[])
case 'e':
/* Field entry */
{
header_field_info *hfi = proto_registrar_get_byalias(ws_optarg);
if (hfi)
output_fields_add(output_fields, hfi->abbrev);
else
output_fields_add(output_fields, ws_optarg);
const char* col_field = try_convert_to_column_field(ws_optarg);
if (col_field) {
output_fields_add(output_fields, col_field);
} else {
header_field_info *hfi = proto_registrar_get_byalias(ws_optarg);
if (hfi)
output_fields_add(output_fields, hfi->abbrev);
else
output_fields_add(output_fields, ws_optarg);
}
}
break;
case 'E':