wiretap: clean up option definitions a bit.

Spell out "DESCRIPTION" for the IDB description option, as it's spelled
out in the pcapng spec.

Put the #defines for various options in the same order as the block
types for them are in the pcapng spec.
This commit is contained in:
Guy Harris 2021-07-13 23:48:19 -07:00 committed by Wireshark GitLab Utility
parent b531a6aa61
commit 7b0c4950a5
8 changed files with 28 additions and 29 deletions

View File

@ -40,7 +40,7 @@ cap_file_provider_get_interface_name(struct packet_provider_data *prov, guint32
if (wtapng_if_descr) {
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_NAME, &interface_name) == WTAP_OPTTYPE_SUCCESS)
return interface_name;
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_DESCR, &interface_name) == WTAP_OPTTYPE_SUCCESS)
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_DESCRIPTION, &interface_name) == WTAP_OPTTYPE_SUCCESS)
return interface_name;
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_HARDWARE, &interface_name) == WTAP_OPTTYPE_SUCCESS)
return interface_name;
@ -63,7 +63,7 @@ cap_file_provider_get_interface_description(struct packet_provider_data *prov, g
g_free(idb_info);
if (wtapng_if_descr) {
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_DESCR, &interface_name) == WTAP_OPTTYPE_SUCCESS)
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_DESCRIPTION, &interface_name) == WTAP_OPTTYPE_SUCCESS)
return interface_name;
}
return NULL;

View File

@ -185,7 +185,7 @@ summary_fill_in(capture_file *cf, summary_tally *st)
} else {
iface.name = NULL;
}
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_DESCR, &if_string) == WTAP_OPTTYPE_SUCCESS) {
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_DESCRIPTION, &if_string) == WTAP_OPTTYPE_SUCCESS) {
iface.descr = g_strdup(if_string);
} else {
iface.descr = NULL;

View File

@ -1084,7 +1084,7 @@ static gboolean erf_write_wtap_option_to_interface_tag(wtap_block_t block _U_,
tag_ptr->value = (guint8*)g_strdup(optval->stringval);
tag_ptr->length = (guint16)strlen((char*)tag_ptr->value);
break;
case OPT_IDB_DESCR:
case OPT_IDB_DESCRIPTION:
tag_ptr->type = ERF_META_TAG_descr;
tag_ptr->value = (guint8*)g_strdup(optval->stringval);
tag_ptr->length = (guint16)strlen((char*)tag_ptr->value);
@ -2345,7 +2345,7 @@ static int erf_update_implicit_host_id(erf_t *erf_priv, wtap *wth, guint64 impli
g_free(oldstr);
erf_set_interface_descr(int_data, OPT_IDB_NAME, implicit_host_id, if_map->source_id, (guint8) i, if_info->name);
erf_set_interface_descr(int_data, OPT_IDB_DESCR, implicit_host_id, if_map->source_id, (guint8) i, if_info->descr);
erf_set_interface_descr(int_data, OPT_IDB_DESCRIPTION, implicit_host_id, if_map->source_id, (guint8) i, if_info->descr);
}
}
}
@ -2365,7 +2365,7 @@ static int erf_update_implicit_host_id(erf_t *erf_priv, wtap *wth, guint64 impli
/* XXX: this is a pointer! */
int_data = g_array_index(wth->interface_data, wtap_block_t, if_info->if_index);
erf_set_interface_descr(int_data, OPT_IDB_NAME, implicit_host_id, if_map->source_id, (guint8) i, if_info->name);
erf_set_interface_descr(int_data, OPT_IDB_DESCR, implicit_host_id, if_map->source_id, (guint8) i, if_info->descr);
erf_set_interface_descr(int_data, OPT_IDB_DESCRIPTION, implicit_host_id, if_map->source_id, (guint8) i, if_info->descr);
}
}
@ -2505,7 +2505,7 @@ static int erf_populate_interface(erf_t *erf_priv, wtap *wth, union wtap_pseudo_
int_data_mand->interface_statistics = NULL;
erf_set_interface_descr(int_data, OPT_IDB_NAME, host_id, source_id, if_num, NULL);
erf_set_interface_descr(int_data, OPT_IDB_DESCR, host_id, source_id, if_num, NULL);
erf_set_interface_descr(int_data, OPT_IDB_DESCRIPTION, host_id, source_id, if_num, NULL);
if_map->interfaces[if_num].if_index = (int) wth->interface_data->len;
wtap_add_idb(wth, int_data);
@ -2880,14 +2880,14 @@ static int populate_interface_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo
/* If we have no description, also copy to wtap if_description */
if (!if_info->descr) {
erf_set_interface_descr(int_data, OPT_IDB_DESCR, state->if_map->host_id, state->if_map->source_id, (guint8) if_num, if_info->name);
erf_set_interface_descr(int_data, OPT_IDB_DESCRIPTION, state->if_map->host_id, state->if_map->source_id, (guint8) if_num, if_info->name);
}
}
break;
case ERF_META_TAG_descr:
if (!if_info->descr) {
if_info->descr = g_strndup((gchar*) tag.value, tag.length);
erf_set_interface_descr(int_data, OPT_IDB_DESCR, state->if_map->host_id, state->if_map->source_id, (guint8) if_num, if_info->descr);
erf_set_interface_descr(int_data, OPT_IDB_DESCRIPTION, state->if_map->host_id, state->if_map->source_id, (guint8) if_num, if_info->descr);
/* If we have no name, also copy to wtap if_name */
if (!if_info->name) {
@ -3563,7 +3563,7 @@ static const struct supported_option_type section_block_options_supported[] = {
static const struct supported_option_type interface_block_options_supported[] = {
{ OPT_COMMENT, ONE_OPTION_SUPPORTED }, /* XXX - multiple? */
{ OPT_IDB_NAME, ONE_OPTION_SUPPORTED },
{ OPT_IDB_DESCR, ONE_OPTION_SUPPORTED },
{ OPT_IDB_DESCRIPTION, ONE_OPTION_SUPPORTED },
{ OPT_IDB_OS, ONE_OPTION_SUPPORTED },
{ OPT_IDB_TSOFFSET, ONE_OPTION_SUPPORTED },
{ OPT_IDB_SPEED, ONE_OPTION_SUPPORTED },

View File

@ -576,8 +576,8 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2)
}
/* XXX - what do to if we have only one value? */
have_idb1_value = (wtap_block_get_string_option_value(idb1, OPT_IDB_DESCR, &idb1_if_description) == WTAP_OPTTYPE_SUCCESS);
have_idb2_value = (wtap_block_get_string_option_value(idb2, OPT_IDB_DESCR, &idb2_if_description) == WTAP_OPTTYPE_SUCCESS);
have_idb1_value = (wtap_block_get_string_option_value(idb1, OPT_IDB_DESCRIPTION, &idb1_if_description) == WTAP_OPTTYPE_SUCCESS);
have_idb2_value = (wtap_block_get_string_option_value(idb2, OPT_IDB_DESCRIPTION, &idb2_if_description) == WTAP_OPTTYPE_SUCCESS);
if (have_idb1_value && have_idb2_value) {
ws_debug("g_strcmp0(idb1_if_description, idb2_if_description) == 0: %s",
(g_strcmp0(idb1_if_description, idb2_if_description) == 0) ? "TRUE":"FALSE");

View File

@ -1038,7 +1038,7 @@ pcapng_process_if_descr_block_option(wtapng_block_t *wblock,
pcapng_process_string_option(wblock, option_code, option_length,
option_content);
break;
case(OPT_IDB_DESCR): /* if_description */
case(OPT_IDB_DESCRIPTION): /* if_description */
pcapng_process_string_option(wblock, option_code, option_length,
option_content);
break;
@ -5258,7 +5258,7 @@ static guint32 compute_idb_option_size(wtap_block_t block _U_, guint option_id,
switch(option_id)
{
case OPT_IDB_NAME:
case OPT_IDB_DESCR:
case OPT_IDB_DESCRIPTION:
case OPT_IDB_OS:
case OPT_IDB_HARDWARE:
size = pcapng_compute_string_option_size(optval);
@ -5288,7 +5288,7 @@ static gboolean write_wtap_idb_option(wtap_dumper *wdh, wtap_block_t block _U_,
switch(option_id)
{
case OPT_IDB_NAME:
case OPT_IDB_DESCR:
case OPT_IDB_DESCRIPTION:
case OPT_IDB_OS:
case OPT_IDB_HARDWARE:
if (!pcapng_write_string_option(wdh, option_id, optval, err))
@ -5633,7 +5633,7 @@ static const struct supported_option_type interface_block_options_supported[] =
{ OPT_CUSTOM_STR_NO_COPY, MULTIPLE_OPTIONS_SUPPORTED },
{ OPT_CUSTOM_BIN_NO_COPY, MULTIPLE_OPTIONS_SUPPORTED },
{ OPT_IDB_NAME, ONE_OPTION_SUPPORTED },
{ OPT_IDB_DESCR, ONE_OPTION_SUPPORTED },
{ OPT_IDB_DESCRIPTION, ONE_OPTION_SUPPORTED },
{ OPT_IDB_IP4ADDR, MULTIPLE_OPTIONS_SUPPORTED },
{ OPT_IDB_IP6ADDR, MULTIPLE_OPTIONS_SUPPORTED },
{ OPT_IDB_MACADDR, ONE_OPTION_SUPPORTED },

View File

@ -328,7 +328,7 @@ wtap_get_debug_if_descr(const wtap_block_t if_descr,
line_end);
}
if (wtap_block_get_string_option_value(if_descr, OPT_IDB_DESCR, &tmp_content) == WTAP_OPTTYPE_SUCCESS) {
if (wtap_block_get_string_option_value(if_descr, OPT_IDB_DESCRIPTION, &tmp_content) == WTAP_OPTTYPE_SUCCESS) {
g_string_append_printf(info,
"%*cDescription = %s%s", indent, ' ',
tmp_content ? tmp_content : "NONE",

View File

@ -1655,7 +1655,7 @@ void wtap_opttypes_initialize(void)
*/
wtap_opttype_block_register(&idb_block);
wtap_opttype_option_register(&idb_block, OPT_IDB_NAME, &if_name);
wtap_opttype_option_register(&idb_block, OPT_IDB_DESCR, &if_description);
wtap_opttype_option_register(&idb_block, OPT_IDB_DESCRIPTION, &if_description);
wtap_opttype_option_register(&idb_block, OPT_IDB_SPEED, &if_speed);
wtap_opttype_option_register(&idb_block, OPT_IDB_TSRESOL, &if_tsresol);
wtap_opttype_option_register(&idb_block, OPT_IDB_FILTER, &if_filter);

View File

@ -47,7 +47,7 @@ extern "C" {
* of the device used to capture data.
* "eth0" / "\Device\NPF_{AD1CE675-96D0-47C5-ADD0-2504B9126B68}"
*/
#define OPT_IDB_DESCR 3 /**< A UTF-8 string containing the description
#define OPT_IDB_DESCRIPTION 3 /**< A UTF-8 string containing the description
* of the device used to capture data.
* "Wi-Fi" / "Local Area Connection" /
* "Wireless Network Connection" /
@ -114,6 +114,15 @@ extern "C" {
* "NETGEAR WNA1000Mv2 N150 Wireless USB Micro Adapter"
*/
/*
* These are the flags for an EPB, but we use them for all WTAP_BLOCK_PACKET
*/
#define OPT_PKT_FLAGS 2
#define OPT_PKT_HASH 3
#define OPT_PKT_DROPCOUNT 4
#define OPT_PKT_PACKETID 5
#define OPT_PKT_QUEUE 6
#define OPT_PKT_VERDICT 7
/* Name Resolution Block (NRB) */
#define OPT_NS_DNSNAME 2
@ -129,16 +138,6 @@ extern "C" {
#define OPT_ISB_OSDROP 7
#define OPT_ISB_USRDELIV 8
/*
* These are the flags for an EPB, but we use them for all WTAP_BLOCK_PACKET
*/
#define OPT_PKT_FLAGS 2
#define OPT_PKT_HASH 3
#define OPT_PKT_DROPCOUNT 4
#define OPT_PKT_PACKETID 5
#define OPT_PKT_QUEUE 6
#define OPT_PKT_VERDICT 7
struct wtap_block;
typedef struct wtap_block *wtap_block_t;