diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-06-24 13:48:40 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-06-24 20:49:06 +0000 |
commit | 0fb9369a5ed3381c1c243c2f34a66f3061712c4b (patch) | |
tree | 5d4fc23ab512393a967b9940b85ba2090058a6bf /tshark.c | |
parent | deda668e4c162c6d22e837f8d5265679a3b38216 (diff) | |
download | wireshark-0fb9369a5ed3381c1c243c2f34a66f3061712c4b.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>
Diffstat (limited to 'tshark.c')
-rw-r--r-- | tshark.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -188,6 +188,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); @@ -1322,8 +1327,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': @@ -2077,7 +2090,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) { |