aboutsummaryrefslogtreecommitdiffstats
path: root/tshark.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2006-08-21 23:28:19 +0000
committerGuy Harris <guy@alum.mit.edu>2006-08-21 23:28:19 +0000
commitfde1140905548ed81cdfaa0959194a373df0b27d (patch)
tree8a582bbb444a991cbaa4240cf078a73c0bc0add3 /tshark.c
parenta9469ccb31581ef5598ea5293e12d0141a98a222 (diff)
Initialize the cfilter field of a capture_opts structure to a null
pointer, so we can determine whether a capture filter has been set or not. Use that to check in TShark whether the user specified a filter with "-f" or not, rather than using the no-longer-set "capture_filter_specified" variable. Also, check for multiple "-f" options. If no capture filter is specified, use a null string, to work around broken versions of Linux libpcap. svn path=/trunk/; revision=18989
Diffstat (limited to 'tshark.c')
-rw-r--r--tshark.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/tshark.c b/tshark.c
index 0973870fee..ddb5bce457 100644
--- a/tshark.c
+++ b/tshark.c
@@ -677,7 +677,6 @@ main(int argc, char *argv[])
int dp_open_errno, dp_read_errno;
int err;
#ifdef HAVE_LIBPCAP
- gboolean capture_filter_specified = FALSE;
gboolean list_link_layer_types = FALSE;
gboolean start_capture = FALSE;
#else
@@ -1079,7 +1078,7 @@ main(int argc, char *argv[])
default:
case '?': /* Bad flag - print usage message */
switch(optopt) {
- case'F':
+ case 'F':
list_capture_types();
break;
default:
@@ -1104,7 +1103,7 @@ main(int argc, char *argv[])
rfilter = get_args_as_string(argc, argv, optind);
} else {
#ifdef HAVE_LIBPCAP
- if (capture_filter_specified) {
+ if (capture_opts.cfilter != NULL) {
cmdarg_err("Capture filters were specified both with \"-f\""
" and with additional command-line arguments");
exit(1);
@@ -1148,7 +1147,7 @@ main(int argc, char *argv[])
support in capture files we read). */
#ifdef HAVE_LIBPCAP
if (cf_name != NULL) {
- if (capture_filter_specified) {
+ if (capture_opts.cfilter != NULL) {
cmdarg_err("Only read filters, not capture filters, "
"can be specified when reading a capture file.");
exit(1);
@@ -1562,6 +1561,14 @@ capture(void)
*/
relinquish_special_privs_perm();
+ /*
+ * Some older Linux versions of libpcap don't work right without
+ * a capture filter; if none was specified, use an empty string.
+ * (Yes, that's a libpcap bug, and has been fixed for a while.)
+ */
+ if (capture_opts.cfilter == NULL)
+ capture_opts.cfilter = g_strdup("");
+
/* init the input filter from the network interface (capture pipe will do nothing) */
switch (capture_loop_init_filter(ld.pcap_h, ld.from_cap_pipe, capture_opts.iface, capture_opts.cfilter)) {