Add support for reading and writing the new if_hardware IDB option.
Support for writing it in live captures will come later; this change, but not that one, will be backported so older versions of Wireshark won't remove it when writing a file out. Change-Id: I9fd4067991acfd2d18c03d0a373ce8337a9f3a76 Reviewed-on: https://code.wireshark.org/review/29064 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
f4ac263564
commit
08cbe559b3
|
@ -42,6 +42,8 @@ cap_file_provider_get_interface_name(struct packet_provider_data *prov, guint32
|
||||||
return interface_name;
|
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_DESCR, &interface_name) == WTAP_OPTTYPE_SUCCESS)
|
||||||
return interface_name;
|
return interface_name;
|
||||||
|
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_HARDWARE, &interface_name) == WTAP_OPTTYPE_SUCCESS)
|
||||||
|
return interface_name;
|
||||||
}
|
}
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
|
@ -453,8 +453,11 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2)
|
||||||
guint64 idb1_if_speed, idb2_if_speed;
|
guint64 idb1_if_speed, idb2_if_speed;
|
||||||
guint8 idb1_if_tsresol, idb2_if_tsresol;
|
guint8 idb1_if_tsresol, idb2_if_tsresol;
|
||||||
guint8 idb1_if_fcslen, idb2_if_fcslen;
|
guint8 idb1_if_fcslen, idb2_if_fcslen;
|
||||||
char *idb1_opt_comment, *idb2_opt_comment, *idb1_if_name, *idb2_if_name,
|
char *idb1_opt_comment, *idb2_opt_comment;
|
||||||
*idb1_if_description, *idb2_if_description, *idb1_if_os, *idb2_if_os;
|
char *idb1_if_name, *idb2_if_name;
|
||||||
|
char *idb1_if_description, *idb2_if_description;
|
||||||
|
char *idb1_if_hardware, *idb2_if_hardware;
|
||||||
|
char *idb1_if_os, *idb2_if_os;
|
||||||
|
|
||||||
g_assert(idb1 && idb2);
|
g_assert(idb1 && idb2);
|
||||||
idb1_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(idb1);
|
idb1_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(idb1);
|
||||||
|
@ -577,6 +580,18 @@ 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_HARDWARE, &idb1_if_hardware) == WTAP_OPTTYPE_SUCCESS);
|
||||||
|
have_idb2_value = (wtap_block_get_string_option_value(idb2, OPT_IDB_HARDWARE, &idb2_if_hardware) == WTAP_OPTTYPE_SUCCESS);
|
||||||
|
if (have_idb1_value && have_idb2_value) {
|
||||||
|
merge_debug("g_strcmp0(idb1_if_hardware, idb2_if_hardware) == 0: %s",
|
||||||
|
(g_strcmp0(idb1_if_hardware, idb2_if_hardware) == 0) ? "TRUE":"FALSE");
|
||||||
|
if (g_strcmp0(idb1_if_hardware, idb2_if_hardware) != 0) {
|
||||||
|
merge_debug("merge::is_duplicate_idb() returning FALSE");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* XXX - what do to if we have only one value? */
|
/* XXX - what do to if we have only one value? */
|
||||||
have_idb1_value = (wtap_block_get_string_option_value(idb1, OPT_IDB_OS, &idb1_if_os) == WTAP_OPTTYPE_SUCCESS);
|
have_idb1_value = (wtap_block_get_string_option_value(idb1, OPT_IDB_OS, &idb1_if_os) == WTAP_OPTTYPE_SUCCESS);
|
||||||
have_idb2_value = (wtap_block_get_string_option_value(idb2, OPT_IDB_OS, &idb2_if_os) == WTAP_OPTTYPE_SUCCESS);
|
have_idb2_value = (wtap_block_get_string_option_value(idb2, OPT_IDB_OS, &idb2_if_os) == WTAP_OPTTYPE_SUCCESS);
|
||||||
|
|
|
@ -939,6 +939,17 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh,
|
||||||
pcapng_debug("pcapng_read_if_descr_block: if_fcslen length %u not 1 as expected", oh.option_length);
|
pcapng_debug("pcapng_read_if_descr_block: if_fcslen length %u not 1 as expected", oh.option_length);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case(OPT_IDB_HARDWARE): /* if_hardware */
|
||||||
|
if (oh.option_length > 0 && oh.option_length < opt_cont_buf_len) {
|
||||||
|
tmp_content = g_strndup((char *)option_content, oh.option_length);
|
||||||
|
/* Fails with multiple options; we silently ignore the failure */
|
||||||
|
wtap_block_add_string_option(wblock->block, oh.option_code, option_content, oh.option_length);
|
||||||
|
pcapng_debug("pcapng_read_if_descr_block: if_hardware %s", tmp_content);
|
||||||
|
g_free(tmp_content);
|
||||||
|
} else {
|
||||||
|
pcapng_debug("pcapng_read_if_descr_block: if_description length %u seems strange", oh.option_length);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
/* TODO: process these! */
|
/* TODO: process these! */
|
||||||
case(OPT_IDB_IP4ADDR):
|
case(OPT_IDB_IP4ADDR):
|
||||||
|
@ -3844,6 +3855,7 @@ static void compute_idb_option_size(wtap_block_t block _U_, guint option_id, wta
|
||||||
case OPT_IDB_NAME:
|
case OPT_IDB_NAME:
|
||||||
case OPT_IDB_DESCR:
|
case OPT_IDB_DESCR:
|
||||||
case OPT_IDB_OS:
|
case OPT_IDB_OS:
|
||||||
|
case OPT_IDB_HARDWARE:
|
||||||
size = pcapng_compute_option_string_size(optval->stringval);
|
size = pcapng_compute_option_string_size(optval->stringval);
|
||||||
break;
|
break;
|
||||||
case OPT_IDB_SPEED:
|
case OPT_IDB_SPEED:
|
||||||
|
@ -3900,6 +3912,7 @@ static void write_wtap_idb_option(wtap_block_t block _U_, guint option_id, wtap_
|
||||||
case OPT_IDB_NAME:
|
case OPT_IDB_NAME:
|
||||||
case OPT_IDB_DESCR:
|
case OPT_IDB_DESCR:
|
||||||
case OPT_IDB_OS:
|
case OPT_IDB_OS:
|
||||||
|
case OPT_IDB_HARDWARE:
|
||||||
if (!pcapng_write_option_string(write_block->wdh, option_id, optval->stringval, write_block->err)) {
|
if (!pcapng_write_option_string(write_block->wdh, option_id, optval->stringval, write_block->err)) {
|
||||||
write_block->success = FALSE;
|
write_block->success = FALSE;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -203,6 +203,13 @@ wtap_get_debug_if_descr(const wtap_block_t if_descr,
|
||||||
wtap_encap_short_string(if_descr_mand->wtap_encap),
|
wtap_encap_short_string(if_descr_mand->wtap_encap),
|
||||||
line_end);
|
line_end);
|
||||||
|
|
||||||
|
if (wtap_block_get_string_option_value(if_descr, OPT_IDB_HARDWARE, &tmp_content) == WTAP_OPTTYPE_SUCCESS) {
|
||||||
|
g_string_append_printf(info,
|
||||||
|
"%*cHardware = %s%s", indent, ' ',
|
||||||
|
tmp_content ? tmp_content : "NONE",
|
||||||
|
line_end);
|
||||||
|
}
|
||||||
|
|
||||||
if (wtap_block_get_uint64_option_value(if_descr, OPT_IDB_SPEED, &tmp64) == WTAP_OPTTYPE_SUCCESS) {
|
if (wtap_block_get_uint64_option_value(if_descr, OPT_IDB_SPEED, &tmp64) == WTAP_OPTTYPE_SUCCESS) {
|
||||||
g_string_append_printf(info,
|
g_string_append_printf(info,
|
||||||
"%*cSpeed = %" G_GINT64_MODIFIER "u%s", indent, ' ',
|
"%*cSpeed = %" G_GINT64_MODIFIER "u%s", indent, ' ',
|
||||||
|
|
|
@ -1073,6 +1073,14 @@ void wtap_opttypes_initialize(void)
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
static wtap_opttype_t if_hardware = {
|
||||||
|
"hardware",
|
||||||
|
"IDB Hardware",
|
||||||
|
WTAP_OPTTYPE_STRING,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
static wtap_blocktype_t nrb_block = {
|
static wtap_blocktype_t nrb_block = {
|
||||||
WTAP_BLOCK_NG_NRB, /* block_type */
|
WTAP_BLOCK_NG_NRB, /* block_type */
|
||||||
|
@ -1198,6 +1206,7 @@ void wtap_opttypes_initialize(void)
|
||||||
wtap_opttype_option_register(&idb_block, OPT_IDB_FILTER, &if_filter);
|
wtap_opttype_option_register(&idb_block, OPT_IDB_FILTER, &if_filter);
|
||||||
wtap_opttype_option_register(&idb_block, OPT_IDB_OS, &if_os);
|
wtap_opttype_option_register(&idb_block, OPT_IDB_OS, &if_os);
|
||||||
wtap_opttype_option_register(&idb_block, OPT_IDB_FCSLEN, &if_fcslen);
|
wtap_opttype_option_register(&idb_block, OPT_IDB_FCSLEN, &if_fcslen);
|
||||||
|
wtap_opttype_option_register(&idb_block, OPT_IDB_HARDWARE, &if_hardware);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Register the NRB and the options that can appear in it.
|
* Register the NRB and the options that can appear in it.
|
||||||
|
|
|
@ -44,7 +44,9 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define OPT_IDB_DESCR 3 /**< A UTF-8 string containing the description
|
#define OPT_IDB_DESCR 3 /**< A UTF-8 string containing the description
|
||||||
* of the device used to capture data.
|
* of the device used to capture data.
|
||||||
* "Broadcom NetXtreme" / "First Ethernet Interface"
|
* "Wi-Fi" / "Local Area Connection" /
|
||||||
|
* "Wireless Network Connection" /
|
||||||
|
* "First Ethernet Interface"
|
||||||
*/
|
*/
|
||||||
#define OPT_IDB_IP4ADDR 4 /**< XXX: if_IPv4addr Interface network address and netmask.
|
#define OPT_IDB_IP4ADDR 4 /**< XXX: if_IPv4addr Interface network address and netmask.
|
||||||
* This option can be repeated multiple times within the same Interface Description Block
|
* This option can be repeated multiple times within the same Interface Description Block
|
||||||
|
@ -98,6 +100,14 @@ extern "C" {
|
||||||
* option if_tzone. TODO: won't a if_tsoffset_low for fractional
|
* option if_tzone. TODO: won't a if_tsoffset_low for fractional
|
||||||
* second offsets be useful for highly syncronized capture systems?
|
* second offsets be useful for highly syncronized capture systems?
|
||||||
*/
|
*/
|
||||||
|
#define OPT_IDB_HARDWARE 15 /**< A UTF-8 string containing the description
|
||||||
|
* of the hardware of the device used
|
||||||
|
* to capture data.
|
||||||
|
* "Broadcom NetXtreme" /
|
||||||
|
* "Intel(R) PRO/1000 MT Network Connection" /
|
||||||
|
* "NETGEAR WNA1000Mv2 N150 Wireless USB Micro Adapter"
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define OPT_NS_DNSNAME 2
|
#define OPT_NS_DNSNAME 2
|
||||||
#define OPT_NS_DNSIP4ADDR 3
|
#define OPT_NS_DNSIP4ADDR 3
|
||||||
|
|
Loading…
Reference in New Issue