Write the if_hardware option, if available, to pcapng files when capturing.
Change-Id: Ib9ff78d148a2364c84d84b4a9b020b3d783654a3 Reviewed-on: https://code.wireshark.org/review/36602 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
This commit is contained in:
parent
5e77ab8b95
commit
fd88bfa348
|
@ -45,6 +45,8 @@ capture_opts_init(capture_options *capture_opts)
|
||||||
capture_opts->num_selected = 0;
|
capture_opts->num_selected = 0;
|
||||||
capture_opts->default_options.name = NULL;
|
capture_opts->default_options.name = NULL;
|
||||||
capture_opts->default_options.descr = NULL;
|
capture_opts->default_options.descr = NULL;
|
||||||
|
capture_opts->default_options.hardware = NULL;
|
||||||
|
capture_opts->default_options.display_name = NULL;
|
||||||
capture_opts->default_options.cfilter = NULL;
|
capture_opts->default_options.cfilter = NULL;
|
||||||
capture_opts->default_options.has_snaplen = FALSE;
|
capture_opts->default_options.has_snaplen = FALSE;
|
||||||
capture_opts->default_options.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
|
capture_opts->default_options.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
|
||||||
|
@ -158,6 +160,7 @@ capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_optio
|
||||||
interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
|
interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
|
||||||
g_log(log_domain, log_level, "Interface name[%02d] : %s", i, interface_opts->name ? interface_opts->name : "(unspecified)");
|
g_log(log_domain, log_level, "Interface name[%02d] : %s", i, interface_opts->name ? interface_opts->name : "(unspecified)");
|
||||||
g_log(log_domain, log_level, "Interface description[%02d] : %s", i, interface_opts->descr ? interface_opts->descr : "(unspecified)");
|
g_log(log_domain, log_level, "Interface description[%02d] : %s", i, interface_opts->descr ? interface_opts->descr : "(unspecified)");
|
||||||
|
g_log(log_domain, log_level, "Interface vendor description[%02d] : %s", i, interface_opts->hardware ? interface_opts->hardware : "(unspecified)");
|
||||||
g_log(log_domain, log_level, "Display name[%02d]: %s", i, interface_opts->display_name ? interface_opts->display_name : "(unspecified)");
|
g_log(log_domain, log_level, "Display name[%02d]: %s", i, interface_opts->display_name ? interface_opts->display_name : "(unspecified)");
|
||||||
g_log(log_domain, log_level, "Capture filter[%02d] : %s", i, interface_opts->cfilter ? interface_opts->cfilter : "(unspecified)");
|
g_log(log_domain, log_level, "Capture filter[%02d] : %s", i, interface_opts->cfilter ? interface_opts->cfilter : "(unspecified)");
|
||||||
g_log(log_domain, log_level, "Snap length[%02d] (%u) : %d", i, interface_opts->has_snaplen, interface_opts->snaplen);
|
g_log(log_domain, log_level, "Snap length[%02d] (%u) : %d", i, interface_opts->has_snaplen, interface_opts->snaplen);
|
||||||
|
@ -199,6 +202,8 @@ capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_optio
|
||||||
}
|
}
|
||||||
g_log(log_domain, log_level, "Interface name[df] : %s", capture_opts->default_options.name ? capture_opts->default_options.name : "(unspecified)");
|
g_log(log_domain, log_level, "Interface name[df] : %s", capture_opts->default_options.name ? capture_opts->default_options.name : "(unspecified)");
|
||||||
g_log(log_domain, log_level, "Interface Descr[df] : %s", capture_opts->default_options.descr ? capture_opts->default_options.descr : "(unspecified)");
|
g_log(log_domain, log_level, "Interface Descr[df] : %s", capture_opts->default_options.descr ? capture_opts->default_options.descr : "(unspecified)");
|
||||||
|
g_log(log_domain, log_level, "Interface Hardware Descr[df] : %s", capture_opts->default_options.hardware ? capture_opts->default_options.hardware : "(unspecified)");
|
||||||
|
g_log(log_domain, log_level, "Interface display name[df] : %s", capture_opts->default_options.display_name ? capture_opts->default_options.display_name : "(unspecified)");
|
||||||
g_log(log_domain, log_level, "Capture filter[df] : %s", capture_opts->default_options.cfilter ? capture_opts->default_options.cfilter : "(unspecified)");
|
g_log(log_domain, log_level, "Capture filter[df] : %s", capture_opts->default_options.cfilter ? capture_opts->default_options.cfilter : "(unspecified)");
|
||||||
g_log(log_domain, log_level, "Snap length[df] (%u) : %d", capture_opts->default_options.has_snaplen, capture_opts->default_options.snaplen);
|
g_log(log_domain, log_level, "Snap length[df] (%u) : %d", capture_opts->default_options.has_snaplen, capture_opts->default_options.snaplen);
|
||||||
g_log(log_domain, log_level, "Link Type[df] : %d", capture_opts->default_options.linktype);
|
g_log(log_domain, log_level, "Link Type[df] : %d", capture_opts->default_options.linktype);
|
||||||
|
@ -539,6 +544,7 @@ fill_in_interface_opts_from_ifinfo(interface_options *interface_opts,
|
||||||
{
|
{
|
||||||
interface_opts->name = g_strdup(if_info->name);
|
interface_opts->name = g_strdup(if_info->name);
|
||||||
|
|
||||||
|
interface_opts->hardware = g_strdup(if_info->vendor_description);
|
||||||
if (if_info->friendly_name != NULL) {
|
if (if_info->friendly_name != NULL) {
|
||||||
/*
|
/*
|
||||||
* We have a friendly name; remember it as the
|
* We have a friendly name; remember it as the
|
||||||
|
@ -718,6 +724,7 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str
|
||||||
*/
|
*/
|
||||||
interface_opts.name = g_strdup(optarg_str_p);
|
interface_opts.name = g_strdup(optarg_str_p);
|
||||||
interface_opts.descr = NULL;
|
interface_opts.descr = NULL;
|
||||||
|
interface_opts.hardware = NULL;
|
||||||
interface_opts.display_name = g_strdup(optarg_str_p);
|
interface_opts.display_name = g_strdup(optarg_str_p);
|
||||||
interface_opts.if_type = capture_opts->default_options.if_type;
|
interface_opts.if_type = capture_opts->default_options.if_type;
|
||||||
interface_opts.extcap = g_strdup(capture_opts->default_options.extcap);
|
interface_opts.extcap = g_strdup(capture_opts->default_options.extcap);
|
||||||
|
@ -1168,6 +1175,7 @@ capture_opts_del_iface(capture_options *capture_opts, guint if_index)
|
||||||
|
|
||||||
g_free(interface_opts->name);
|
g_free(interface_opts->name);
|
||||||
g_free(interface_opts->descr);
|
g_free(interface_opts->descr);
|
||||||
|
g_free(interface_opts->hardware);
|
||||||
g_free(interface_opts->display_name);
|
g_free(interface_opts->display_name);
|
||||||
g_free(interface_opts->cfilter);
|
g_free(interface_opts->cfilter);
|
||||||
g_free(interface_opts->timestamp_type);
|
g_free(interface_opts->timestamp_type);
|
||||||
|
@ -1214,6 +1222,7 @@ collect_ifaces(capture_options *capture_opts)
|
||||||
if (!device->hidden && device->selected) {
|
if (!device->hidden && device->selected) {
|
||||||
interface_opts.name = g_strdup(device->name);
|
interface_opts.name = g_strdup(device->name);
|
||||||
interface_opts.descr = g_strdup(device->friendly_name);
|
interface_opts.descr = g_strdup(device->friendly_name);
|
||||||
|
interface_opts.hardware = g_strdup(device->vendor_description);
|
||||||
interface_opts.display_name = g_strdup(device->display_name);
|
interface_opts.display_name = g_strdup(device->display_name);
|
||||||
interface_opts.linktype = device->active_dlt;
|
interface_opts.linktype = device->active_dlt;
|
||||||
interface_opts.cfilter = g_strdup(device->cfilter);
|
interface_opts.cfilter = g_strdup(device->cfilter);
|
||||||
|
@ -1280,6 +1289,7 @@ capture_opts_free_interface_t(interface_t *device)
|
||||||
if (device != NULL) {
|
if (device != NULL) {
|
||||||
g_free(device->name);
|
g_free(device->name);
|
||||||
g_free(device->display_name);
|
g_free(device->display_name);
|
||||||
|
g_free(device->vendor_description);
|
||||||
g_free(device->friendly_name);
|
g_free(device->friendly_name);
|
||||||
g_free(device->addresses);
|
g_free(device->addresses);
|
||||||
g_free(device->cfilter);
|
g_free(device->cfilter);
|
||||||
|
|
|
@ -153,6 +153,7 @@ typedef struct interface_tag {
|
||||||
gchar *name;
|
gchar *name;
|
||||||
gchar *display_name;
|
gchar *display_name;
|
||||||
gchar *friendly_name;
|
gchar *friendly_name;
|
||||||
|
gchar *vendor_description;
|
||||||
guint type;
|
guint type;
|
||||||
gchar *addresses;
|
gchar *addresses;
|
||||||
gint no_addresses;
|
gint no_addresses;
|
||||||
|
@ -191,6 +192,7 @@ typedef struct link_row_tag {
|
||||||
typedef struct interface_options_tag {
|
typedef struct interface_options_tag {
|
||||||
gchar *name; /* the name of the interface supplied to libpcap/WinPcap/Npcap to specify the interface */
|
gchar *name; /* the name of the interface supplied to libpcap/WinPcap/Npcap to specify the interface */
|
||||||
gchar *descr; /* a more user-friendly description of the interface; may be NULL if none */
|
gchar *descr; /* a more user-friendly description of the interface; may be NULL if none */
|
||||||
|
gchar *hardware; /* description of the hardware */
|
||||||
gchar *display_name; /* the name displayed in the console and title bar */
|
gchar *display_name; /* the name displayed in the console and title bar */
|
||||||
gchar *cfilter;
|
gchar *cfilter;
|
||||||
gboolean has_snaplen;
|
gboolean has_snaplen;
|
||||||
|
|
|
@ -2948,6 +2948,7 @@ capture_loop_init_pcapng_output(capture_options *capture_opts, loop_data *ld)
|
||||||
"Dumpcap dummy interface", /* IDB_DESCRIPTION 3 */
|
"Dumpcap dummy interface", /* IDB_DESCRIPTION 3 */
|
||||||
NULL, /* IDB_FILTER 11 */
|
NULL, /* IDB_FILTER 11 */
|
||||||
os_info_str->str, /* IDB_OS 12 */
|
os_info_str->str, /* IDB_OS 12 */
|
||||||
|
NULL, /* IDB_HARDWARE 15 */
|
||||||
-1,
|
-1,
|
||||||
0,
|
0,
|
||||||
&(global_ld.bytes_written),
|
&(global_ld.bytes_written),
|
||||||
|
@ -2973,6 +2974,7 @@ capture_loop_init_pcapng_output(capture_options *capture_opts, loop_data *ld)
|
||||||
interface_opts->descr, /* IDB_DESCRIPTION 3 */
|
interface_opts->descr, /* IDB_DESCRIPTION 3 */
|
||||||
interface_opts->cfilter, /* IDB_FILTER 11 */
|
interface_opts->cfilter, /* IDB_FILTER 11 */
|
||||||
os_info_str->str, /* IDB_OS 12 */
|
os_info_str->str, /* IDB_OS 12 */
|
||||||
|
interface_opts->hardware, /* IDB_HARDWARE 15 */
|
||||||
pcap_src->linktype,
|
pcap_src->linktype,
|
||||||
pcap_src->snaplen,
|
pcap_src->snaplen,
|
||||||
&(global_ld.bytes_written),
|
&(global_ld.bytes_written),
|
||||||
|
|
|
@ -895,6 +895,7 @@ write_file_header (void)
|
||||||
NULL,
|
NULL,
|
||||||
"",
|
"",
|
||||||
NULL,
|
NULL,
|
||||||
|
NULL,
|
||||||
pcap_link_type,
|
pcap_link_type,
|
||||||
WTAP_MAX_PACKET_SIZE_STANDARD,
|
WTAP_MAX_PACKET_SIZE_STANDARD,
|
||||||
&bytes_written,
|
&bytes_written,
|
||||||
|
|
|
@ -204,6 +204,7 @@ scan_local_interfaces(void (*update_cb)(void))
|
||||||
}
|
}
|
||||||
device.name = g_strdup(if_info->name);
|
device.name = g_strdup(if_info->name);
|
||||||
device.friendly_name = g_strdup(if_info->friendly_name);
|
device.friendly_name = g_strdup(if_info->friendly_name);
|
||||||
|
device.vendor_description = g_strdup(if_info->vendor_description);
|
||||||
device.hidden = FALSE;
|
device.hidden = FALSE;
|
||||||
memset(&temp, 0, sizeof(temp));
|
memset(&temp, 0, sizeof(temp));
|
||||||
temp.name = g_strdup(if_info->name);
|
temp.name = g_strdup(if_info->name);
|
||||||
|
@ -377,6 +378,7 @@ scan_local_interfaces(void (*update_cb)(void))
|
||||||
if (!found) { /* new interface, maybe a pipe */
|
if (!found) { /* new interface, maybe a pipe */
|
||||||
memset(&device, 0, sizeof(device));
|
memset(&device, 0, sizeof(device));
|
||||||
device.name = g_strdup(interface_opts->name);
|
device.name = g_strdup(interface_opts->name);
|
||||||
|
device.vendor_description = g_strdup(interface_opts->hardware);
|
||||||
device.display_name = interface_opts->descr ?
|
device.display_name = interface_opts->descr ?
|
||||||
g_strdup_printf("%s: %s", device.name, interface_opts->descr) :
|
g_strdup_printf("%s: %s", device.name, interface_opts->descr) :
|
||||||
g_strdup(device.name);
|
g_strdup(device.name);
|
||||||
|
|
|
@ -157,6 +157,7 @@ struct option {
|
||||||
#define IDB_TSRESOL 9
|
#define IDB_TSRESOL 9
|
||||||
#define IDB_FILTER 11
|
#define IDB_FILTER 11
|
||||||
#define IDB_OS 12
|
#define IDB_OS 12
|
||||||
|
#define IDB_HARDWARE 15
|
||||||
#define ISB_STARTTIME 2
|
#define ISB_STARTTIME 2
|
||||||
#define ISB_ENDTIME 3
|
#define ISB_ENDTIME 3
|
||||||
#define ISB_IFRECV 4
|
#define ISB_IFRECV 4
|
||||||
|
@ -370,16 +371,17 @@ pcapng_write_section_header_block(FILE* pfile,
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
pcapng_write_interface_description_block(FILE* pfile,
|
pcapng_write_interface_description_block(FILE* pfile,
|
||||||
const char *comment, /* OPT_COMMENT 1 */
|
const char *comment, /* OPT_COMMENT 1 */
|
||||||
const char *name, /* IDB_NAME 2 */
|
const char *name, /* IDB_NAME 2 */
|
||||||
const char *descr, /* IDB_DESCRIPTION 3 */
|
const char *descr, /* IDB_DESCRIPTION 3 */
|
||||||
const char *filter, /* IDB_FILTER 11 */
|
const char *filter, /* IDB_FILTER 11 */
|
||||||
const char *os, /* IDB_OS 12 */
|
const char *os, /* IDB_OS 12 */
|
||||||
|
const char *hardware, /* IDB_HARDWARE 15 */
|
||||||
int link_type,
|
int link_type,
|
||||||
int snap_len,
|
int snap_len,
|
||||||
guint64 *bytes_written,
|
guint64 *bytes_written,
|
||||||
guint64 if_speed, /* IDB_IF_SPEED 8 */
|
guint64 if_speed, /* IDB_IF_SPEED 8 */
|
||||||
guint8 tsresol, /* IDB_TSRESOL 9 */
|
guint8 tsresol, /* IDB_TSRESOL 9 */
|
||||||
int *err)
|
int *err)
|
||||||
{
|
{
|
||||||
struct idb idb;
|
struct idb idb;
|
||||||
|
@ -421,6 +423,9 @@ pcapng_write_interface_description_block(FILE* pfile,
|
||||||
/* 12 - IDB_OS */
|
/* 12 - IDB_OS */
|
||||||
options_length += pcapng_count_string_option(os);
|
options_length += pcapng_count_string_option(os);
|
||||||
|
|
||||||
|
/* 15 - IDB_HARDWARE */
|
||||||
|
options_length += pcapng_count_string_option(hardware);
|
||||||
|
|
||||||
/* If we have options add size of end-of-options */
|
/* If we have options add size of end-of-options */
|
||||||
if (options_length != 0) {
|
if (options_length != 0) {
|
||||||
options_length += (guint32)sizeof(struct option);
|
options_length += (guint32)sizeof(struct option);
|
||||||
|
@ -504,6 +509,11 @@ pcapng_write_interface_description_block(FILE* pfile,
|
||||||
bytes_written, err))
|
bytes_written, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
/* 15 - IDB_HARDWARE - write hardware string if applicable */
|
||||||
|
if (!pcapng_write_string_option(pfile, IDB_HARDWARE, hardware,
|
||||||
|
bytes_written, err))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (options_length != 0) {
|
if (options_length != 0) {
|
||||||
/* write end of options */
|
/* write end of options */
|
||||||
option.type = OPT_ENDOFOPT;
|
option.type = OPT_ENDOFOPT;
|
||||||
|
|
|
@ -68,6 +68,7 @@ pcapng_write_interface_description_block(FILE* pfile,
|
||||||
const char *descr, /* IDB_DESCRIPTION 3 */
|
const char *descr, /* IDB_DESCRIPTION 3 */
|
||||||
const char *filter, /* IDB_FILTER 11 */
|
const char *filter, /* IDB_FILTER 11 */
|
||||||
const char *os, /* IDB_OS 12 */
|
const char *os, /* IDB_OS 12 */
|
||||||
|
const char *hardware, /* IDB_HARDWARE 15 */
|
||||||
int link_type,
|
int link_type,
|
||||||
int snap_len,
|
int snap_len,
|
||||||
guint64 *bytes_written,
|
guint64 *bytes_written,
|
||||||
|
|
Loading…
Reference in New Issue