aboutsummaryrefslogtreecommitdiffstats
path: root/tshark.c
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2021-03-12 22:12:40 -0500
committerGuy Harris <gharris@sonic.net>2021-03-14 00:14:40 +0000
commitea60a57826624bcdf8f955af85af7130c8864018 (patch)
tree9b95bbeac945b3988827a4d5e9bfba9801687c61 /tshark.c
parent9bd144b8ea30a7345eca3c0cb590bc146f45f97c (diff)
tshark, export_pdu: Allow tshark to export PDUs to other file types
The export PDU API now allows writing to a different file type. tshark already has a -F flag for the output file type. If that option is given, respect it for export PDU. Also, rec.rec_header.packet_header.pkt_encap expects WTAP encapsulation types, not PCAP encapsulation types, so don't call wtap_wtap_encap_to_pcap_encap(), or else it won't actually write to pcap files, only pcapng (using the wrong sort of encap numbers eventually leads to WTAP_ENCAP_PER_PACKET, which we don't write to non-pcapng.)
Diffstat (limited to 'tshark.c')
-rw-r--r--tshark.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/tshark.c b/tshark.c
index da261ab4e2..6b9ac73382 100644
--- a/tshark.c
+++ b/tshark.c
@@ -759,7 +759,6 @@ main(int argc, char *argv[])
gchar *output_only = NULL;
gchar *volatile pdu_export_arg = NULL;
char *volatile exp_pdu_filename = NULL;
- int exp_pdu_file_type_subtype;
exp_pdu_t exp_pdu_tap_data;
const gchar* elastic_mapping_filter = NULL;
@@ -2066,18 +2065,17 @@ main(int argc, char *argv[])
}
/* Activate the export PDU tap */
- /* Write a pcapng file... */
- exp_pdu_file_type_subtype = wtap_pcapng_file_type_subtype();
- /* ...with this comment */
+ /* Write to our output file with this comment (if the type supports it,
+ * otherwise exp_pdu_open() will ignore the comment) */
comment = g_strdup_printf("Dump of PDUs from %s", cf_name);
exp_pdu_status = exp_pdu_open(&exp_pdu_tap_data,
- exp_pdu_file_type_subtype, exp_fd, comment,
+ out_file_type, exp_fd, comment,
&err, &err_info);
g_free(comment);
if (!exp_pdu_status) {
cfile_dump_open_failure_message("TShark", exp_pdu_filename,
err, err_info,
- exp_pdu_file_type_subtype);
+ out_file_type);
exit_status = INVALID_EXPORT;
goto clean_exit;
}