Get rid of has_cfilter to simplify the handling of multiple interfaces.
authorMichael Tüxen <tuexen@fh-muenster.de>
Tue, 31 May 2011 14:49:21 +0000 (14:49 -0000)
committerMichael Tüxen <tuexen@fh-muenster.de>
Tue, 31 May 2011 14:49:21 +0000 (14:49 -0000)
svn path=/trunk/; revision=37478

capture_opts.c
capture_opts.h
dumpcap.c
gtk/main.c
tshark.c

index 5770211544f201fbd1e2a41105450b0372d537b2..e558723ddf91f7921bfce659badbb146bfe3f70d 100644 (file)
@@ -56,13 +56,13 @@ void
 capture_opts_init(capture_options *capture_opts, void *cf)
 {
   capture_opts->cf                              = cf;
-  capture_opts->cfilter                         = g_strdup("");     /* No capture filter string specified */
+  capture_opts->cfilter                         = NULL;            /* No capture filter string specified */
   capture_opts->iface                           = NULL;             /* Default is "pick the first interface" */
   capture_opts->iface_descr                     = NULL;
   capture_opts->ifaces                          = g_array_new(FALSE, FALSE, sizeof(interface_options));
   capture_opts->default_options.name            = NULL;
   capture_opts->default_options.descr           = NULL;
-  capture_opts->default_options.cfilter         = g_strdup("");
+  capture_opts->default_options.cfilter         = NULL;
   capture_opts->default_options.snaplen         = WTAP_MAX_PACKET_SIZE;
   capture_opts->default_options.linktype        = -1;
   capture_opts->default_options.promisc_mode    = TRUE;
@@ -658,7 +658,6 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_
         capture_opts->autostop_packets = get_positive_int(optarg_str_p, "packet count");
         break;
     case 'f':        /* capture filter */
-        capture_opts->has_cfilter = TRUE;
         g_free(capture_opts->cfilter);
         capture_opts->cfilter = g_strdup(optarg_str_p);
         if (capture_opts->ifaces->len > 0) {
index 8eda37b2b26782cd01298417b16362ba997ce595..fc020cb3461ad06de516da7e989080d336a9c1d0 100644 (file)
@@ -105,7 +105,6 @@ typedef struct interface_options_tag {
 typedef struct capture_options_tag {
     /* general */
     void     *cf;                   /**< handle to cfile (note: untyped handle) */
-    gboolean has_cfilter;           /**< TRUE if capture filter specified on command line */
     gchar    *cfilter;              /**< Capture filter string
                                       *< XXX: Can finally be be removed.
                                       *<      Replaced by interface_options.cfilter */
index 9467ab54e197e508f2a322b904c040b756bbd9d4..2ca9becbb6c99f6fc9d4935f807bbaa39b32734b 100644 (file)
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -2518,7 +2518,7 @@ capture_loop_init_output(capture_options *capture_opts, loop_data *ld, char *err
                 }
                 successful = libpcap_write_interface_description_block(ld->pdh,
                                                                        interface_opts.name,
-                                                                       interface_opts.cfilter,
+                                                                       interface_opts.cfilter?interface_opts.cfilter:"",
                                                                        pcap_opts->linktype,
                                                                        pcap_opts->snaplen,
                                                                        &ld->bytes_written,
@@ -2947,7 +2947,7 @@ do_file_switch_or_stop(capture_options *capture_opts,
                     pcap_opts = g_array_index(global_ld.pcaps, pcap_options *, i);
                     successful = libpcap_write_interface_description_block(global_ld.pdh,
                                                                            interface_opts.name,
-                                                                           interface_opts.cfilter,
+                                                                           interface_opts.cfilter?interface_opts.cfilter:"",
                                                                            pcap_opts->linktype,
                                                                            pcap_opts->snaplen,
                                                                            &(global_ld.bytes_written),
index 36c915ce0d1b26d67e00cfce0daf155c51b9585d..28e11e41040b3651491dbcc1118314c2053b8b13 100644 (file)
@@ -2956,8 +2956,7 @@ main(int argc, char *argv[])
     }
 
     /* if the user didn't supplied a capture filter, use the one to filter out remote connections like SSH */
-    if (!start_capture && strlen(global_capture_opts.cfilter) == 0) {
-      g_free(global_capture_opts.cfilter);
+    if (!start_capture && !global_capture_opts.cfilter) {
       global_capture_opts.cfilter = g_strdup(get_conn_cfilter());
     }
 #else /* HAVE_LIBPCAP */
index 2e55338c61034f9e08eba5b57bd055bf066b4275..76df7f16f80a73086a5466043b8ba3ac04d97fe4 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -1386,12 +1386,11 @@ main(int argc, char *argv[])
       rfilter = get_args_as_string(argc, argv, optind);
     } else {
 #ifdef HAVE_LIBPCAP
-      if (global_capture_opts.has_cfilter) {
+      if (global_capture_opts.cfilter) {
         cmdarg_err("Capture filters were specified both with \"-f\""
             " and with additional command-line arguments");
         return 1;
       }
-      global_capture_opts.has_cfilter = TRUE;
       global_capture_opts.cfilter = get_args_as_string(argc, argv, optind);
 #else
       capture_option_specified = TRUE;
@@ -1438,7 +1437,7 @@ main(int argc, char *argv[])
      support in capture files we read). */
 #ifdef HAVE_LIBPCAP
   if (cf_name != NULL) {
-    if (global_capture_opts.has_cfilter) {
+    if (global_capture_opts.cfilter) {
       cmdarg_err("Only read filters, not capture filters, "
           "can be specified when reading a capture file.");
       return 1;