aboutsummaryrefslogtreecommitdiffstats
path: root/ui/tap_export_pdu.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui/tap_export_pdu.c')
-rw-r--r--ui/tap_export_pdu.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c
index f385499674..6865b0c839 100644
--- a/ui/tap_export_pdu.c
+++ b/ui/tap_export_pdu.c
@@ -90,8 +90,6 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
/* pcapng defs */
wtap_block_t shb_hdr;
- GArray *shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
- wtapng_iface_descriptions_t *idb_inf;
wtap_block_t int_data;
wtapng_if_descr_mandatory_t *int_data_mand;
GString *os_info_str;
@@ -125,8 +123,8 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
wtap_block_add_string_option_format(shb_hdr, OPT_SHB_USERAPPL, "Wireshark %s", get_ws_vcs_version_info());
/* Create fake IDB info */
- idb_inf = g_new(wtapng_iface_descriptions_t,1);
- idb_inf->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
+ exp_pdu_tap_data->idb_inf = g_new(wtapng_iface_descriptions_t,1);
+ exp_pdu_tap_data->idb_inf->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
/* create the fake interface data */
int_data = wtap_block_create(WTAP_BLOCK_IF_DESCR);
@@ -138,18 +136,19 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
wtap_block_add_string_option(int_data, OPT_IDB_NAME, "Fake IF, PDU->Export", strlen("Fake IF, PDU->Export"));
wtap_block_add_uint8_option(int_data, OPT_IDB_TSRESOL, 9);
- g_array_append_val(idb_inf->interface_data, int_data);
+ g_array_append_val(exp_pdu_tap_data->idb_inf->interface_data, int_data);
- g_array_append_val(shb_hdrs, shb_hdr);
+ exp_pdu_tap_data->shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
+ g_array_append_val(exp_pdu_tap_data->shb_hdrs, shb_hdr);
if (fd == 1) {
exp_pdu_tap_data->wdh = wtap_dump_open_stdout_ng(WTAP_FILE_TYPE_SUBTYPE_PCAPNG,
WTAP_ENCAP_WIRESHARK_UPPER_PDU, WTAP_MAX_PACKET_SIZE_STANDARD, FALSE,
- shb_hdrs, idb_inf, NULL, &err);
+ exp_pdu_tap_data->shb_hdrs, exp_pdu_tap_data->idb_inf, NULL, &err);
} else {
exp_pdu_tap_data->wdh = wtap_dump_fdopen_ng(fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG,
WTAP_ENCAP_WIRESHARK_UPPER_PDU, WTAP_MAX_PACKET_SIZE_STANDARD, FALSE,
- shb_hdrs, idb_inf, NULL, &err);
+ exp_pdu_tap_data->shb_hdrs, exp_pdu_tap_data->idb_inf, NULL, &err);
}
if (exp_pdu_tap_data->wdh == NULL) {
g_assert(err != 0);
@@ -166,6 +165,9 @@ exp_pdu_close(exp_pdu_t *exp_pdu_tap_data)
if (!wtap_dump_close(exp_pdu_tap_data->wdh, &err))
g_assert(err != 0);
+ wtap_block_array_free(exp_pdu_tap_data->shb_hdrs);
+ wtap_free_idb_info(exp_pdu_tap_data->idb_inf);
+
remove_tap_listener(exp_pdu_tap_data);
return err;
}