diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-11-11 16:59:10 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-11-12 00:59:40 +0000 |
commit | 75dc2051e861294a0e75955e896de7494f086b42 (patch) | |
tree | 5e4738506009583066d083b648958bef11115590 /ui/tap_export_pdu.c | |
parent | af8c70cb7d7b81492df7dc11690195598086990c (diff) | |
download | wireshark-75dc2051e861294a0e75955e896de7494f086b42.tar.gz |
Add wtap_dump_open_tempfile routines, to write to a temporary file.
It includes the temporary-file generation, so you don't have to do it
yourself.
Change-Id: I0798df95a5c5646224ec49612f50b423ed78547a
Reviewed-on: https://code.wireshark.org/review/11751
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/tap_export_pdu.c')
-rw-r--r-- | ui/tap_export_pdu.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c index f1dcacc63c..b6a15e8db7 100644 --- a/ui/tap_export_pdu.c +++ b/ui/tap_export_pdu.c @@ -98,7 +98,6 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const static void exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data) { - int import_file_fd; char *tmpname, *capfile_name; int err; @@ -108,10 +107,6 @@ exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data) wtapng_if_descr_t int_data; GString *os_info_str; - /* Choose a random name for the temporary import buffer */ - import_file_fd = create_tempfile(&tmpname, "Wireshark_PDU_"); - capfile_name = g_strdup(tmpname); - /* Create data for SHB */ os_info_str = g_string_new(""); get_os_version_info(os_info_str); @@ -160,15 +155,17 @@ exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data) g_array_append_val(idb_inf->interface_data, int_data); - exp_pdu_tap_data->wdh = wtap_dump_fdopen_ng(import_file_fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, - WTAP_ENCAP_WIRESHARK_UPPER_PDU, WTAP_MAX_PACKET_SIZE, - FALSE, shb_hdr, idb_inf, NULL, &err); + /* Use a random name for the temporary import buffer */ + exp_pdu_tap_data->wdh = wtap_dump_open_tempfile_ng(&tmpname, "Wireshark_PDU_", + WTAP_FILE_TYPE_SUBTYPE_PCAPNG, + WTAP_ENCAP_WIRESHARK_UPPER_PDU, WTAP_MAX_PACKET_SIZE, + FALSE, shb_hdr, idb_inf, NULL, &err); + capfile_name = g_strdup(tmpname); if (exp_pdu_tap_data->wdh == NULL) { - open_failure_alert_box(capfile_name, err, TRUE); + open_failure_alert_box(capfile_name ? capfile_name : "temporary file", err, TRUE); goto end; } - /* Run the tap */ cf_retap_packets(&cfile); |