epan: Allow FT_IPv4, FT_IPv6 custom columns to be resolved or not.

Similar to commit dbb9fe2a37, proto_item_fill_display_label
now uses address_to_display for FT_IPv4, FT_IPv6, and FT_FCWWN,
the other three address types that double as field types and which
have optional name resolution.

Add these to the list of types that, if present in a custom column,
has the GUI enable the checkbox to switch between "resolved" (names)
and not (values).

This allows adding custom columns with these field types with both
resolved and non resolved text. Note that the appropriate Name
Resolution preference settings must be enabled for the type as well.
This commit is contained in:
John Thacker 2022-12-25 16:12:48 -05:00
parent 079ef9a165
commit f0f72927b4
3 changed files with 16 additions and 9 deletions

View File

@ -6649,21 +6649,24 @@ proto_item_fill_display_label(field_info *finfo, gchar *display_label_str, const
case FT_IPv4:
ipv4 = fvalue_get_uinteger(&finfo->value);
set_address (&addr, AT_IPv4, 4, &ipv4);
address_to_str_buf(&addr, display_label_str, label_str_size);
label_len = (int)strlen(display_label_str);
tmp_str = address_to_display(NULL, &addr);
label_len = protoo_strlcpy(display_label_str, tmp_str, label_str_size);
wmem_free(NULL, tmp_str);
break;
case FT_IPv6:
bytes = fvalue_get_bytes(&finfo->value);
set_address (&addr, AT_IPv6, sizeof(ws_in6_addr), bytes);
address_to_str_buf(&addr, display_label_str, label_str_size);
label_len = (int)strlen(display_label_str);
tmp_str = address_to_display(NULL, &addr);
label_len = protoo_strlcpy(display_label_str, tmp_str, label_str_size);
wmem_free(NULL, tmp_str);
break;
case FT_FCWWN:
set_address (&addr, AT_FCWWN, FCWWN_ADDR_LEN, fvalue_get_bytes(&finfo->value));
address_to_str_buf(&addr, display_label_str, label_str_size);
label_len = (int)strlen(display_label_str);
tmp_str = address_to_display(NULL, &addr);
label_len = protoo_strlcpy(display_label_str, tmp_str, label_str_size);
wmem_free(NULL, tmp_str);
break;
case FT_ETHER:

View File

@ -90,8 +90,12 @@ resolve_column (gint col, capture_file *cf)
field_idx = (guint *) g_slist_nth_data(cf->cinfo.columns[col].col_custom_fields_ids, ii);
hfi = proto_registrar_get_nth(*field_idx);
/* Check if we have an OID or a strings table with integer values */
if ((hfi->type == FT_OID) || (hfi->type == FT_REL_OID) || (hfi->type == FT_ETHER) || (hfi->type == FT_BOOLEAN) ||
/* Check if we have an OID, a (potentially) resolvable network
* address, a Boolean, or a strings table with integer values */
/* XXX: Should this checkbox be disabled if the Name Resolution
* preference for a given type is off?
*/
if ((hfi->type == FT_OID) || (hfi->type == FT_REL_OID) || (hfi->type == FT_ETHER) || (hfi->type == FT_IPv4) || (hfi->type == FT_IPv6) || (hfi->type == FT_FCWWN) || (hfi->type == FT_BOOLEAN) ||
((hfi->strings != NULL) &&
(IS_FT_INT(hfi->type) || IS_FT_UINT(hfi->type))))
{

View File

@ -242,7 +242,7 @@ column_prefs_custom_resolve(const gchar* custom_field)
for (guint i = 0; i < g_strv_length(fields); i++) {
if (fields[i] && *fields[i]) {
hfi = proto_registrar_get_byname(fields[i]);
if (hfi && ((hfi->type == FT_OID) || (hfi->type == FT_REL_OID) || (hfi->type == FT_ETHER) || (hfi->type == FT_BOOLEAN) ||
if (hfi && ((hfi->type == FT_OID) || (hfi->type == FT_REL_OID) || (hfi->type == FT_ETHER) || (hfi->type == FT_IPv4) || (hfi->type == FT_IPv6) || (hfi->type == FT_FCWWN) || (hfi->type == FT_BOOLEAN) ||
((hfi->strings != NULL) &&
(IS_FT_INT(hfi->type) || IS_FT_UINT(hfi->type)))))
{