Remove a no-longer-used variable.
[metze/wireshark/wip.git] / dumpcap.c
index d2dfecabeef8c8a473dc09a68b140841973f69fc..875d15b63a4d502bf5a698452bf3143b74326285 100644 (file)
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -82,7 +82,6 @@
 
 #include "ringbuffer.h"
 #include "clopts_common.h"
-#include "console_io.h"
 #include "cmdarg_err.h"
 #include "version_info.h"
 
 #include "sync_pipe.h"
 
 #include "capture_opts.h"
+#include "capture_session.h"
 #include "capture_ifinfo.h"
 #include "capture_sync.h"
 
 #include "conditions.h"
 #include "capture_stop_conditions.h"
 
-#include "tempfile.h"
+#include "wsutil/tempfile.h"
 #include "log.h"
 #include "wsutil/file_util.h"
 
@@ -147,8 +147,8 @@ FILE *debug_log;   /* for logging debug messages to  */
 static GAsyncQueue *pcap_queue;
 static gint64 pcap_queue_bytes;
 static gint64 pcap_queue_packets;
-static gint64 pcap_queue_byte_limit = 1024 * 1024;
-static gint64 pcap_queue_packet_limit = 1000;
+static gint64 pcap_queue_byte_limit = 0;
+static gint64 pcap_queue_packet_limit = 0;
 
 static gboolean capture_child = FALSE; /* FALSE: standalone call, TRUE: this is an Wireshark capture child */
 #ifdef _WIN32
@@ -226,9 +226,24 @@ typedef enum {
     INITFILTER_OTHER_ERROR
 } initfilter_status_t;
 
+typedef enum {
+    STATE_EXPECT_REC_HDR,
+    STATE_READ_REC_HDR,
+    STATE_EXPECT_DATA,
+    STATE_READ_DATA
+} cap_pipe_state_t;
+
+typedef enum { 
+    PIPOK, 
+    PIPEOF, 
+    PIPERR, 
+    PIPNEXIST 
+} cap_pipe_err_t;
+
 typedef struct _pcap_options {
     guint32                      received;
     guint32                      dropped;
+    guint32                      flushed;
     pcap_t                      *pcap_h;
 #ifdef MUST_DO_SELECT
     int                          pcap_fd;                /**< pcap file descriptor */
@@ -258,13 +273,9 @@ typedef struct _pcap_options {
     size_t                       cap_pipe_bytes_to_read; /**< Used by cap_pipe_dispatch */
     size_t                       cap_pipe_bytes_read;    /**< Used by cap_pipe_dispatch */
 #endif
-    enum {
-        STATE_EXPECT_REC_HDR,
-        STATE_READ_REC_HDR,
-        STATE_EXPECT_DATA,
-        STATE_READ_DATA
-    } cap_pipe_state;
-    enum { PIPOK, PIPEOF, PIPERR, PIPNEXIST } cap_pipe_err;
+    cap_pipe_state_t cap_pipe_state;
+    cap_pipe_err_t cap_pipe_err;
+
 #if defined(_WIN32)
     GMutex                      *cap_pipe_read_mtx;
     GAsyncQueue                 *cap_pipe_pending_q, *cap_pipe_done_q;
@@ -300,6 +311,7 @@ typedef struct _pcap_queue_element {
  */
 static const char please_report[] =
     "Please report this to the Wireshark developers.\n"
+    "http://bugs.wireshark.org/\n"
     "(This is not a crash; please do not report it as such.)";
 
 /*
@@ -365,7 +377,7 @@ static void WS_MSVC_NORETURN exit_main(int err) G_GNUC_NORETURN;
 
 static void report_new_capture_file(const char *filename);
 static void report_packet_count(unsigned int packet_count);
-static void report_packet_drops(guint32 received, guint32 drops, gchar *name);
+static void report_packet_drops(guint32 received, guint32 pcap_drops, guint32 drops, guint32 flushed, gchar *name);
 static void report_capture_error(const char *error_msg, const char *secondary_error_msg);
 static void report_cfilter_error(capture_options *capture_opts, guint i, const char *errmsg);
 
@@ -452,7 +464,7 @@ print_usage(gboolean print_ver)
     fprintf(output, "  -I                       capture in monitor mode, if available\n");
 #endif
 #if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
-    fprintf(output, "  -B <buffer size>         size of kernel buffer (def: 1MB)\n");
+    fprintf(output, "  -B <buffer size>         size of kernel buffer in MB (def: %dMB)\n", DEFAULT_CAPTURE_BUFFER_SIZE);
 #endif
     fprintf(output, "  -y <link type>           link layer type (def: first appropriate)\n");
     fprintf(output, "  -D                       print list of interfaces and exit\n");
@@ -491,6 +503,8 @@ print_usage(gboolean print_ver)
     fprintf(output, "  -P                       use libpcap format instead of pcapng\n");
     fprintf(output, "\n");
     fprintf(output, "Miscellaneous:\n");
+    fprintf(output, "  -N <packet_limit>        maximum number of packets buffered within dumpcap\n");
+    fprintf(output, "  -C <byte_limit>          maximum number of bytes used for buffering packets within dumpcap\n");
     fprintf(output, "  -t                       use a separate thread per interface\n");
     fprintf(output, "  -q                       don't report packet capture counts\n");
     fprintf(output, "  -v                       print version information and exit\n");
@@ -515,26 +529,6 @@ show_version(GString *comp_info_str, GString *runtime_info_str)
         wireshark_svnversion, get_copyright_info(), comp_info_str->str, runtime_info_str->str);
 }
 
-/*
- * Print to the standard error.  This is a command-line tool, so there's
- * no need to pop up a console.
- */
-void
-vfprintf_stderr(const char *fmt, va_list ap)
-{
-    vfprintf(stderr, fmt, ap);
-}
-
-void
-fprintf_stderr(const char *fmt, ...)
-{
-    va_list ap;
-
-    va_start(ap, fmt);
-    vfprintf_stderr(fmt, ap);
-    va_end(ap);
-}
-
 /*
  * Report an error in command-line arguments.
  */
@@ -938,7 +932,7 @@ show_filter_code(capture_options *capture_opts)
 #endif
     if (capture_child) {
         /* Let our parent know we succeeded. */
-        pipe_write_block(2, SP_SUCCESS, NULL);
+        pipe_write_block(2, SP_SUCCESS, NULL); ///
     }
     return TRUE;
 }
@@ -958,7 +952,7 @@ show_filter_code(capture_options *capture_opts)
  * just call get_interface_list().
  */
 GList *
-capture_interface_list(int *err, char **err_str)
+capture_interface_list(int *err, char **err_str, void(*update_cb)(void) _U_)
 {
     return get_interface_list(err, err_str);
 }
@@ -1128,7 +1122,7 @@ get_if_capabilities(const char *devicename, gboolean monitor_mode
     /*
      * Allocate the interface capabilities structure.
      */
-    caps = g_malloc(sizeof *caps);
+    caps = (if_capabilities_t *)g_malloc(sizeof *caps);
 
     /*
      * WinPcap 4.1.2, and possibly earlier versions, have a bug
@@ -1297,14 +1291,14 @@ print_machine_readable_interfaces(GList *if_list)
 
     if (capture_child) {
         /* Let our parent know we succeeded. */
-        pipe_write_block(2, SP_SUCCESS, NULL);
+        pipe_write_block(2, SP_SUCCESS, NULL); ///
     }
 
     i = 1;  /* Interface id number */
     for (if_entry = g_list_first(if_list); if_entry != NULL;
          if_entry = g_list_next(if_entry)) {
         if_info = (if_info_t *)if_entry->data;
-        printf("%d. %s", i++, if_info->name);
+        printf("%d. %s\t", i++, if_info->name);
 
         /*
          * Print the contents of the if_entry struct in a parseable format.
@@ -1313,9 +1307,9 @@ print_machine_readable_interfaces(GList *if_list)
          */
         /* XXX - Make sure our description doesn't contain a tab */
         if (if_info->vendor_description != NULL)
-            printf("\t%s\t", if_info->vendor_description);
+            printf("%s\t", if_info->vendor_description);
         else
-            printf("\t\t");
+            printf("\t");
 
         /* XXX - Make sure our friendly name doesn't contain a tab */
         if (if_info->friendly_name != NULL)
@@ -1323,6 +1317,8 @@ print_machine_readable_interfaces(GList *if_list)
         else
             printf("\t");
 
+        printf("%u\t", if_info->type);
+
         for (addr = g_slist_nth(if_info->addrs, 0); addr != NULL;
                     addr = g_slist_next(addr)) {
             if (addr != g_slist_nth(if_info->addrs, 0))
@@ -1373,7 +1369,7 @@ print_machine_readable_if_capabilities(if_capabilities_t *caps)
 
     if (capture_child) {
         /* Let our parent know we succeeded. */
-        pipe_write_block(2, SP_SUCCESS, NULL);
+        pipe_write_block(2, SP_SUCCESS, NULL); ///
     }
 
     if (caps->can_set_rfmon)
@@ -1449,7 +1445,7 @@ print_statistics_loop(gboolean machine_readable)
 
     if (capture_child) {
         /* Let our parent know we succeeded. */
-        pipe_write_block(2, SP_SUCCESS, NULL);
+        pipe_write_block(2, SP_SUCCESS, NULL); ///
     }
 
     if (!machine_readable) {
@@ -2103,11 +2099,10 @@ cap_pipe_open_live(char *pipename,
 
     pcap_opts->from_cap_pipe = TRUE;
 
-    if ((pcap_opts->from_cap_socket)
-#ifndef _WIN32
-         || 1
+#ifdef _WIN32
+    if (pcap_opts->from_cap_socket)
 #endif
-         ) {
+    {
         /* read the pcap header */
         bytes_read = 0;
         while (bytes_read < sizeof magic) {
@@ -2194,11 +2189,10 @@ cap_pipe_open_live(char *pipename,
         goto error;
     }
 
-    if ((pcap_opts->from_cap_socket)
-#ifndef _WIN32
-         || 1
+#ifdef _WIN32
+    if (pcap_opts->from_cap_socket)
 #endif
-         ) {
+    {
         /* Read the rest of the header */
         bytes_read = 0;
         while (bytes_read < sizeof(struct pcap_hdr)) {
@@ -2310,11 +2304,10 @@ cap_pipe_dispatch(loop_data *ld, pcap_options *pcap_opts, guchar *data, char *er
         /* Fall through */
 
     case STATE_READ_REC_HDR:
-        if ((pcap_opts->from_cap_socket)
-#ifndef _WIN32
-           || 1
+#ifdef _WIN32
+        if (pcap_opts->from_cap_socket)
 #endif
-           ) {
+        {
             b = cap_pipe_read(pcap_opts->cap_pipe_fd, ((char *)&pcap_opts->cap_pipe_rechdr)+pcap_opts->cap_pipe_bytes_read,
                  pcap_opts->cap_pipe_bytes_to_read - pcap_opts->cap_pipe_bytes_read, pcap_opts->from_cap_socket);
             if (b <= 0) {
@@ -2370,11 +2363,10 @@ cap_pipe_dispatch(loop_data *ld, pcap_options *pcap_opts, guchar *data, char *er
         /* Fall through */
 
     case STATE_READ_DATA:
-        if ((pcap_opts->from_cap_socket)
-#ifndef _WIN32
-           || 1
+#ifdef _WIN32
+        if (pcap_opts->from_cap_socket)
 #endif
-           ) {
+        {
             b = cap_pipe_read(pcap_opts->cap_pipe_fd,
                               data+pcap_opts->cap_pipe_bytes_read,
                               pcap_opts->cap_pipe_bytes_to_read - pcap_opts->cap_pipe_bytes_read,
@@ -2397,7 +2389,7 @@ cap_pipe_dispatch(loop_data *ld, pcap_options *pcap_opts, guchar *data, char *er
             g_get_current_time(&wait_time);
             g_time_val_add(&wait_time, PIPE_READ_TIMEOUT);
             q_status = g_async_queue_timed_pop(pcap_opts->cap_pipe_done_q, &wait_time);
-#endif
+#endif /* GLIB_CHECK_VERSION(2,31,18) */
             if (pcap_opts->cap_pipe_err == PIPEOF) {
                 result = PD_PIPE_EOF;
                 break;
@@ -2409,7 +2401,7 @@ cap_pipe_dispatch(loop_data *ld, pcap_options *pcap_opts, guchar *data, char *er
                 return 0;
             }
         }
-#endif
+#endif /* _WIN32 */
         if (pcap_opts->cap_pipe_bytes_read < pcap_opts->cap_pipe_bytes_to_read)
             return 0;
         result = PD_DATA_READ;
@@ -2567,6 +2559,7 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
         }
         pcap_opts->received = 0;
         pcap_opts->dropped = 0;
+        pcap_opts->flushed = 0;
         pcap_opts->pcap_h = NULL;
 #ifdef MUST_DO_SELECT
         pcap_opts->pcap_fd = -1;
@@ -2592,7 +2585,7 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
 #endif
         pcap_opts->cap_pipe_bytes_to_read = 0;
         pcap_opts->cap_pipe_bytes_read = 0;
-        pcap_opts->cap_pipe_state = 0;
+        pcap_opts->cap_pipe_state = STATE_EXPECT_REC_HDR;
         pcap_opts->cap_pipe_err = PIPOK;
 #ifdef _WIN32
 #if GLIB_CHECK_VERSION(2,31,0)
@@ -2937,7 +2930,7 @@ capture_loop_close_output(capture_options *capture_opts, loop_data *ld, int *err
 
                     if (pcap_stats(pcap_opts->pcap_h, &stats) >= 0) {
                         isb_ifrecv = pcap_opts->received;
-                        isb_ifdrop = stats.ps_drop + pcap_opts->dropped;
+                        isb_ifdrop = stats.ps_drop + pcap_opts->dropped + pcap_opts->flushed;
                    } else {
                         isb_ifrecv = G_MAXUINT64;
                         isb_ifdrop = G_MAXUINT64;
@@ -3583,14 +3576,14 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
 #if GLIB_CHECK_VERSION(2,31,18)
 
             g_async_queue_lock(pcap_queue);
-            queue_element = g_async_queue_timeout_pop_unlocked(pcap_queue, WRITER_THREAD_TIMEOUT);
+            queue_element = (pcap_queue_element *)g_async_queue_timeout_pop_unlocked(pcap_queue, WRITER_THREAD_TIMEOUT);
 #else
             GTimeVal write_thread_time;
 
             g_get_current_time(&write_thread_time);
             g_time_val_add(&write_thread_time, WRITER_THREAD_TIMEOUT);
             g_async_queue_lock(pcap_queue);
-            queue_element = g_async_queue_timed_pop_unlocked(pcap_queue, &write_thread_time);
+            queue_element = (pcap_queue_element *)g_async_queue_timed_pop_unlocked(pcap_queue, &write_thread_time);
 #endif
             if (queue_element) {
                 pcap_queue_bytes -= queue_element->phdr.caplen;
@@ -3714,7 +3707,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
         }
         while (1) {
             g_async_queue_lock(pcap_queue);
-            queue_element = g_async_queue_try_pop_unlocked(pcap_queue);
+            queue_element = (pcap_queue_element *)g_async_queue_try_pop_unlocked(pcap_queue);
             if (queue_element) {
                 pcap_queue_bytes -= queue_element->phdr.caplen;
                 pcap_queue_packets -= 1;
@@ -3834,19 +3827,18 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
     /* get packet drop statistics from pcap */
     for (i = 0; i < capture_opts->ifaces->len; i++) {
         guint32 received;
-        guint32 dropped;
+        guint32 pcap_dropped = 0;
 
         pcap_opts = g_array_index(global_ld.pcaps, pcap_options *, i);
         interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
         received = pcap_opts->received;
-        dropped = pcap_opts->dropped;
         if (pcap_opts->pcap_h != NULL) {
             g_assert(!pcap_opts->from_cap_pipe);
             /* Get the capture statistics, so we know how many packets were dropped. */
             if (pcap_stats(pcap_opts->pcap_h, stats) >= 0) {
                 *stats_known = TRUE;
                 /* Let the parent process know. */
-                dropped += stats->ps_drop;
+                pcap_dropped += stats->ps_drop;
             } else {
                 g_snprintf(errmsg, sizeof(errmsg),
                            "Can't get packet-drop statistics: %s",
@@ -3854,7 +3846,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
                 report_capture_error(errmsg, please_report);
             }
         }
-        report_packet_drops(received, dropped, interface_opts.console_display_name);
+        report_packet_drops(received, pcap_dropped, pcap_opts->dropped, pcap_opts->flushed, interface_opts.console_display_name);
     }
 
     /* close the input file (pcap or capture pipe) */
@@ -3973,7 +3965,7 @@ capture_loop_write_packet_cb(u_char *pcap_opts_p, const struct pcap_pkthdr *phdr
        the "stop capturing" flag, ignore this packet, as we're not
        supposed to be saving any more packets. */
     if (!global_ld.go) {
-        pcap_opts->dropped++;
+        pcap_opts->flushed++;
         return;
     }
 
@@ -4030,7 +4022,7 @@ capture_loop_queue_packet_cb(u_char *pcap_opts_p, const struct pcap_pkthdr *phdr
        the "stop capturing" flag, ignore this packet, as we're not
        supposed to be saving any more packets. */
     if (!global_ld.go) {
-        pcap_opts->dropped++;
+        pcap_opts->flushed++;
         return;
     }
 
@@ -4049,8 +4041,8 @@ capture_loop_queue_packet_cb(u_char *pcap_opts_p, const struct pcap_pkthdr *phdr
     }
     memcpy(queue_element->pd, pd, phdr->caplen);
     g_async_queue_lock(pcap_queue);
-    if (((pcap_queue_byte_limit > 0) && (pcap_queue_bytes < pcap_queue_byte_limit)) &&
-        ((pcap_queue_packet_limit > 0) && (pcap_queue_packets < pcap_queue_packet_limit))) {
+    if (((pcap_queue_byte_limit == 0) || (pcap_queue_bytes < pcap_queue_byte_limit)) &&
+        ((pcap_queue_packet_limit == 0) || (pcap_queue_packets < pcap_queue_packet_limit))) {
         limit_reached = FALSE;
         g_async_queue_push_unlocked(pcap_queue, queue_element);
         pcap_queue_bytes += phdr->caplen;
@@ -4115,7 +4107,7 @@ set_80211_channel(const char *iface, const char *opt)
     }
 
     if (capture_child)
-        pipe_write_block(2, SP_SUCCESS, NULL);
+        pipe_write_block(2, SP_SUCCESS, NULL); ///
     ret = 0;
 
 out:
@@ -4177,9 +4169,8 @@ main(int argc, char *argv[])
 
 #ifdef _WIN32
     arg_list_utf_16to8(argc, argv);
-#endif /* _WIN32 */
+    create_app_running_mutex();
 
-#ifdef _WIN32
     /*
      * Initialize our DLL search path. MUST be called before LoadLibrary
      * or g_module_open.
@@ -4221,7 +4212,7 @@ main(int argc, char *argv[])
 #define OPTSTRING_d ""
 #endif
 
-#define OPTSTRING "a:" OPTSTRING_A "b:" OPTSTRING_B "c:" OPTSTRING_d "Df:ghi:" OPTSTRING_I "k:L" OPTSTRING_m "MnpPq" OPTSTRING_r "Ss:t" OPTSTRING_u "vw:y:Z:"
+#define OPTSTRING "a:" OPTSTRING_A "b:" OPTSTRING_B "C:c:" OPTSTRING_d "Df:ghi:" OPTSTRING_I "k:L" OPTSTRING_m "MN:npPq" OPTSTRING_r "Ss:t" OPTSTRING_u "vw:y:Z:"
 
 #ifdef DEBUG_CHILD_DUMPCAP
     if ((debug_log = ws_fopen("dumpcap_debug_log.tmp","w")) == NULL) {
@@ -4290,20 +4281,22 @@ main(int argc, char *argv[])
     }
 
     /* The default_log_handler will use stdout, which makes trouble in   */
-    /* capture child mode, as it uses stdout for it's sync_pipe.         */
+    /* capture child mode, as it uses stdout for its sync_pipe.          */
     /* So: the filtering is done in the console_log_handler and not here.*/
     /* We set the log handlers right up front to make sure that any log  */
     /* messages when running as child will be sent back to the parent    */
     /* with the correct format.                                          */
 
     log_flags =
+        (GLogLevelFlags)(
         G_LOG_LEVEL_ERROR|
         G_LOG_LEVEL_CRITICAL|
         G_LOG_LEVEL_WARNING|
         G_LOG_LEVEL_MESSAGE|
         G_LOG_LEVEL_INFO|
         G_LOG_LEVEL_DEBUG|
-        G_LOG_FLAG_FATAL|G_LOG_FLAG_RECURSION;
+        G_LOG_FLAG_FATAL|
+        G_LOG_FLAG_RECURSION);
 
     g_log_set_handler(NULL,
                       log_flags,
@@ -4462,13 +4455,16 @@ main(int argc, char *argv[])
 
     /* Set the initial values in the capture options. This might be overwritten
        by the command line parameters. */
-    capture_opts_init(&global_capture_opts, NULL);
+    capture_opts_init(&global_capture_opts);
 
     /* We always save to a file - if no file was specified, we save to a
        temporary file. */
     global_capture_opts.saving_to_file      = TRUE;
     global_capture_opts.has_ring_num_files  = TRUE;
 
+       /* Pass on capture_child mode for capture_opts */
+       global_capture_opts.capture_child = capture_child;
+
     /* Now get our args */
     while ((opt = getopt(argc, argv, OPTSTRING)) != -1) {
         switch (opt) {
@@ -4574,6 +4570,12 @@ main(int argc, char *argv[])
         case 'M':        /* For -D, -L, and -S, print machine-readable output */
             machine_readable = TRUE;
             break;
+        case 'C':
+            pcap_queue_byte_limit = get_positive_int(optarg, "byte_limit");
+            break;
+        case 'N':
+            pcap_queue_packet_limit = get_positive_int(optarg, "packet_limit");
+            break;
         default:
             cmdarg_err("Invalid Option: %s", argv[optind-1]);
             /* FALLTHROUGH */
@@ -4601,6 +4603,15 @@ main(int argc, char *argv[])
         }
     }
 
+    if ((pcap_queue_byte_limit > 0) || (pcap_queue_packet_limit > 0)) {
+        use_threads = TRUE;
+    }
+    if ((pcap_queue_byte_limit == 0) && (pcap_queue_packet_limit == 0)) {
+        /* Use some default if the user hasn't specified some */
+        /* XXX: Are these defaults good enough? */
+        pcap_queue_byte_limit = 1000 * 1000;
+        pcap_queue_packet_limit = 1000;
+    }
     if (arg_error) {
         print_usage(FALSE);
         exit_main(1);
@@ -4653,7 +4664,7 @@ main(int argc, char *argv[])
         int    err;
         gchar *err_str;
 
-        if_list = capture_interface_list(&err, &err_str);
+        if_list = capture_interface_list(&err, &err_str,NULL);
         if (if_list == NULL) {
             switch (err) {
             case CANT_GET_INTERFACE_LIST:
@@ -4712,7 +4723,7 @@ main(int argc, char *argv[])
      * "-L", "-d", and capturing act on a particular interface, so we have to
      * have an interface; if none was specified, pick a default.
      */
-    status = capture_opts_trim_iface(&global_capture_opts, NULL);
+    status = capture_opts_default_iface_if_necessary(&global_capture_opts, NULL);
     if (status != 0) {
         /* cmdarg_err() already called .... */
         exit_main(status);
@@ -4920,7 +4931,7 @@ report_packet_count(unsigned int packet_count)
     if (capture_child) {
         g_snprintf(tmp, sizeof(tmp), "%u", packet_count);
         g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Packets: %s", tmp);
-        pipe_write_block(2, SP_PACKET_COUNT, tmp);
+        pipe_write_block(2, SP_PACKET_COUNT, tmp); ///
     } else {
         count += packet_count;
         fprintf(stderr, "\rPackets: %u ", count);
@@ -4934,7 +4945,7 @@ report_new_capture_file(const char *filename)
 {
     if (capture_child) {
         g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "File: %s", filename);
-        pipe_write_block(2, SP_FILE, filename);
+        pipe_write_block(2, SP_FILE, filename); ///
     } else {
 #ifdef SIGINFO
         /*
@@ -4973,7 +4984,7 @@ report_cfilter_error(capture_options *capture_opts, guint i, const char *errmsg)
         if (capture_child) {
             g_snprintf(tmp, sizeof(tmp), "%u:%s", i, errmsg);
             g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Capture filter error: %s", errmsg);
-            pipe_write_block(2, SP_BAD_FILTER, tmp);
+            pipe_write_block(2, SP_BAD_FILTER, tmp); ///
         } else {
             /*
              * clopts_step_invalid_capfilter in test/suite-clopts.sh MUST match
@@ -5007,23 +5018,24 @@ report_capture_error(const char *error_msg, const char *secondary_error_msg)
 }
 
 static void
-report_packet_drops(guint32 received, guint32 drops, gchar *name)
+report_packet_drops(guint32 received, guint32 pcap_drops, guint32 drops, guint32 flushed, gchar *name)
 {
     char tmp[SP_DECISIZE+1+1];
+    guint32 total_drops = pcap_drops + drops + flushed;
 
-    g_snprintf(tmp, sizeof(tmp), "%u", drops);
+    g_snprintf(tmp, sizeof(tmp), "%u", total_drops);
 
     if (capture_child) {
         g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
-            "Packets received/dropped on interface %s: %u/%u",
-            name, received, drops);
+            "Packets received/dropped on interface %s: %u/%u (pcap:%u/dumpcap:%u/flushed:%u)",
+            name, received, total_drops, pcap_drops, drops, flushed);
         /* XXX: Need to provide interface id, changes to consumers required. */
-        pipe_write_block(2, SP_DROPS, tmp);
+        pipe_write_block(2, SP_DROPS, tmp); ///
     } else {
         fprintf(stderr,
-            "Packets received/dropped on interface '%s': %u/%u (%.1f%%)\n",
-            name, received, drops,
-            received ? 100.0 * received / (received + drops) : 0.0);
+            "Packets received/dropped on interface '%s': %u/%u (pcap:%u/dumpcap:%u/flushed:%u) (%.1f%%)\n",
+            name, received, total_drops, pcap_drops, drops, flushed,
+            received ? 100.0 * received / (received + total_drops) : 0.0);
         /* stderr could be line buffered */
         fflush(stderr);
     }
@@ -5078,6 +5090,10 @@ signal_pipe_check_running(void)
 }
 #endif
 
+
+
+
+
 /*
  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
  *