aboutsummaryrefslogtreecommitdiffstats
path: root/tshark.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-11-13 16:10:53 -0800
committerPeter Wu <peter@lekensteyn.nl>2018-11-16 02:18:26 +0000
commit4e17bd6229a09c149c4e0ac7e5a090febfc15c10 (patch)
tree3a389fbe89a5ee12abfe6d3ab1a770c830643d03 /tshark.c
parent658c30dc4b98c7afd1f0a7a5f8380a9399cbb082 (diff)
Use the dump parameters structure for non-pcapng-specific stuff.
Use it for all the per-file information, including the per-file link-layer type and the per-file snapshot length. Change-Id: Id75687c7faa6418a2bfcf7f8198206a9f95db629 Reviewed-on: https://code.wireshark.org/review/30616 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'tshark.c')
-rw-r--r--tshark.c54
1 files changed, 18 insertions, 36 deletions
diff --git a/tshark.c b/tshark.c
index 172764ad06..f7055c5aee 100644
--- a/tshark.c
+++ b/tshark.c
@@ -3087,8 +3087,6 @@ process_cap_file(capture_file *cf, char *save_file, int out_file_type,
gboolean out_file_name_res, int max_packet_count, gint64 max_byte_count)
{
gboolean success = TRUE;
- gint linktype;
- int snapshot_length;
wtap_dumper *pdh;
guint32 framenum;
int err = 0, err_pass1 = 0;
@@ -3096,52 +3094,36 @@ process_cap_file(capture_file *cf, char *save_file, int out_file_type,
gint64 data_offset;
gboolean filtering_tap_listeners;
guint tap_flags;
- wtapng_dump_params ng_params = WTAPNG_DUMP_PARAMS_INIT;
+ wtap_dump_params params = WTAP_DUMP_PARAMS_INIT;
wtap_rec rec;
Buffer buf;
epan_dissect_t *edt = NULL;
- char *shb_user_appl;
+ char *shb_user_appl;
wtap_rec_init(&rec);
if (save_file != NULL) {
/* Set up to write to the capture file. */
- snapshot_length = wtap_snapshot_length(cf->provider.wth);
- wtap_dump_params_init(&ng_params, cf->provider.wth);
- linktype = wtap_file_encap(cf->provider.wth);
+ wtap_dump_params_init(&params, cf->provider.wth);
/* If we don't have an application name add Tshark */
- if (wtap_block_get_string_option_value(g_array_index(ng_params.shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, &shb_user_appl) != WTAP_OPTTYPE_SUCCESS) {
+ if (wtap_block_get_string_option_value(g_array_index(params.shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, &shb_user_appl) != WTAP_OPTTYPE_SUCCESS) {
/* this is free'd by wtap_block_free() later */
- wtap_block_add_string_option_format(g_array_index(ng_params.shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, "TShark (Wireshark) %s", get_ws_vcs_version_info());
+ wtap_block_add_string_option_format(g_array_index(params.shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, "TShark (Wireshark) %s", get_ws_vcs_version_info());
}
- if (linktype != WTAP_ENCAP_PER_PACKET &&
- out_file_type == WTAP_FILE_TYPE_SUBTYPE_PCAP) {
- tshark_debug("tshark: writing PCAP format to %s", save_file);
- if (strcmp(save_file, "-") == 0) {
- /* Write to the standard output. */
- pdh = wtap_dump_open_stdout(out_file_type, linktype,
- snapshot_length, FALSE /* compressed */, NULL, &err);
- } else {
- pdh = wtap_dump_open(save_file, out_file_type, linktype,
- snapshot_length, FALSE /* compressed */, NULL, &err);
- }
- }
- else {
- tshark_debug("tshark: writing format type %d, to %s", out_file_type, save_file);
- if (strcmp(save_file, "-") == 0) {
- /* Write to the standard output. */
- pdh = wtap_dump_open_stdout(out_file_type, linktype,
- snapshot_length, FALSE /* compressed */, &ng_params, &err);
- } else {
- pdh = wtap_dump_open(save_file, out_file_type, linktype,
- snapshot_length, FALSE /* compressed */, &ng_params, &err);
- }
+ tshark_debug("tshark: writing format type %d, to %s", out_file_type, save_file);
+ if (strcmp(save_file, "-") == 0) {
+ /* Write to the standard output. */
+ pdh = wtap_dump_open_stdout(out_file_type, FALSE /* compressed */,
+ &params, &err);
+ } else {
+ pdh = wtap_dump_open(save_file, out_file_type, FALSE /* compressed */,
+ &params, &err);
}
- g_free(ng_params.idb_inf);
- ng_params.idb_inf = NULL;
+ g_free(params.idb_inf);
+ params.idb_inf = NULL;
if (pdh == NULL) {
/* We couldn't set up to write to the capture file. */
@@ -3307,7 +3289,7 @@ process_cap_file(capture_file *cf, char *save_file, int out_file_type,
err, err_info, framenum,
out_file_type);
wtap_dump_close(pdh, &err);
- wtap_dump_params_cleanup(&ng_params);
+ wtap_dump_params_cleanup(&params);
exit(2);
}
}
@@ -3392,7 +3374,7 @@ process_cap_file(capture_file *cf, char *save_file, int out_file_type,
cfile_write_failure_message("TShark", cf->filename, save_file,
err, err_info, framenum, out_file_type);
wtap_dump_close(pdh, &err);
- wtap_dump_params_cleanup(&ng_params);
+ wtap_dump_params_cleanup(&params);
exit(2);
}
}
@@ -3481,7 +3463,7 @@ out:
wtap_close(cf->provider.wth);
cf->provider.wth = NULL;
- wtap_dump_params_cleanup(&ng_params);
+ wtap_dump_params_cleanup(&params);
return success;
}