summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-06-24 13:48:40 -0700
committerGuy Harris <guy@alum.mit.edu>2014-06-24 20:49:30 +0000
commit25d39ca3bc59cb757d0096afd1bda5cad104574a (patch)
tree66a73b0fd6a7246eff6ce00e75048a079928efaa
parentc7874f7d8c046beaa75a45f14b991a1adf62f31d (diff)
downloadwireshark-25d39ca3bc59cb757d0096afd1bda5cad104574a.tar.gz
Support -w even if we're not built with pcap.
You can, for example, do tshark -r file1 -Y filter -w file2 to read a file, apply a read filter, and write the packets that match the filter to another file even if you can't capture traffic. Change-Id: Ifd5e1d5c0e745edef5e98ec4babc720bfbcee6d9 Reviewed-on: https://code.wireshark.org/review/2627 Reviewed-by: Guy Harris <guy@alum.mit.edu> (cherry picked from commit 0fb9369a5ed3381c1c243c2f34a66f3061712c4b) Reviewed-on: https://code.wireshark.org/review/2628
-rw-r--r--tshark.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/tshark.c b/tshark.c
index 539792cd74..4d5895d308 100644
--- a/tshark.c
+++ b/tshark.c
@@ -181,6 +181,11 @@ static void capture_cleanup(int);
static void report_counts_siginfo(int);
#endif /* SIGINFO */
#endif /* _WIN32 */
+
+#else /* HAVE_LIBPCAP */
+
+static char *output_file_name;
+
#endif /* HAVE_LIBPCAP */
static int load_cap_file(capture_file *, char *, int, gboolean, int, gint64);
@@ -1319,8 +1324,16 @@ main(int argc, char *argv[])
return status;
}
#else
- capture_option_specified = TRUE;
- arg_error = TRUE;
+ if (opt == 'w') {
+ /*
+ * Output file name, if we're reading a file and writing to another
+ * file.
+ */
+ output_file_name = optarg;
+ } else {
+ capture_option_specified = TRUE;
+ arg_error = TRUE;
+ }
#endif
break;
case 'C':
@@ -2074,7 +2087,7 @@ main(int argc, char *argv[])
global_capture_opts.has_autostop_packets ? global_capture_opts.autostop_packets : 0,
global_capture_opts.has_autostop_filesize ? global_capture_opts.autostop_filesize : 0);
#else
- err = load_cap_file(&cfile, NULL, out_file_type, out_file_name_res, 0, 0);
+ err = load_cap_file(&cfile, output_file_name, out_file_type, out_file_name_res, 0, 0);
#endif
}
CATCH(OutOfMemoryError) {