add missing functions (to complete/cleanup of interface):
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 3 Dec 2005 18:15:02 +0000 (18:15 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 3 Dec 2005 18:15:02 +0000 (18:15 +0000)
capture_input_drops
capture_input_error_message

and move the functionality from capture_sync.c to capture.c (just where it belongs)

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@16663 f5534014-38df-0310-8fa8-9805f1628bb7

capture.c
capture.h
capture_sync.c

index 2b6ab53779f33c4def3097757407129a68878431..8de503c8530b58d95f17e12a8abd065d288a1da4 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -255,6 +255,7 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
   /* free the old filename */
   if(capture_opts->save_file != NULL) {
     /* we start a new capture file, close the old one (if we had one before) */
+    /* (we can only have an open capture file in real_time_mode!) */
     if( ((capture_file *) capture_opts->cf)->state != FILE_CLOSED) {
         cf_callback_invoke(cf_cb_live_capture_update_finished, capture_opts->cf);
         cf_finish_tail(capture_opts->cf, &err);
@@ -308,9 +309,7 @@ capture_input_new_packets(capture_options *capture_opts, int to_read)
   g_assert(capture_opts->save_file);
 
   if(capture_opts->real_time_mode) {
-    /* Read from the capture file the number of records the child told us
-       it added.
-       XXX - do something if this fails? */
+    /* Read from the capture file the number of records the child told us it added. */
     switch (cf_continue_tail(capture_opts->cf, to_read, &err)) {
 
     case CF_READ_OK:
@@ -335,6 +334,34 @@ capture_input_new_packets(capture_options *capture_opts, int to_read)
 }
 
 
+/* Capture child told us, how many dropped packets it counted.
+ */
+void
+capture_input_drops(capture_options *capture_opts, int dropped)
+{
+  g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "%d packet%s dropped", dropped, plurality(dropped, "", "s"));
+
+  g_assert(capture_opts->state == CAPTURE_RUNNING);
+
+  cf_set_drops_known(capture_opts->cf, TRUE);
+  cf_set_drops(capture_opts->cf, dropped);
+}
+
+
+/* Capture child told us, that an error has occurred while starting the capture. */
+void
+capture_input_error_message(capture_options *capture_opts, char *error_message)
+{
+  g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Error message from child: \"%s\"", error_message);
+
+  g_assert(capture_opts->state == CAPTURE_PREPARING);
+
+  simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_message);
+
+  /* the capture child will close the sync_pipe, nothing to do for now */
+}
+
+
 /* capture child closed it's side ot the pipe, do the required cleanup */
 void
 capture_input_closed(capture_options *capture_opts)
index ce90327acb9ce41e0a995bc59047c5889d0e645a..14e27345f832371c4df06b7b5037458abc896996 100644 (file)
--- a/capture.h
+++ b/capture.h
@@ -139,6 +139,16 @@ extern gboolean capture_input_new_file(capture_options *capture_opts, gchar *new
  */
 extern void capture_input_new_packets(capture_options *capture_opts, int to_read);
 
+/**
+ * Capture child told us, how many dropped packets it counted.
+ */
+extern void capture_input_drops(capture_options *capture_opts, int dropped);
+
+/**
+ * Capture child told us, that an error has occurred while starting the capture.
+ */
+extern void capture_input_error_message(capture_options *capture_opts, char *error_message);
+
 /**
  * Capture child closed it's side ot the pipe, do the required cleanup.
  */
index 37189c46f4d162d49f2df8c0a30baea8280df199..888f4dbcebc29ca3f3b1aa71adc3d8cd9ca8b194 100644 (file)
@@ -621,14 +621,13 @@ sync_pipe_input_cb(gint source, gpointer user_data)
 
         /* We weren't able to open the new capture file; user has been
            alerted. Close the sync pipe. */
-        /* XXX - is it safe to close the pipe inside this callback? */
         eth_close(source);
 
         /* the child has send us a filename which we couldn't open.
            this probably means, the child is creating files faster than we can handle it.
            this should only be the case for very fast file switches
            we can't do much more than telling the child to stop
-           (this is the emergency brake if user e.g. wants to switch files every second) */
+           (this is the "emergency brake" if user e.g. wants to switch files every second) */
         sync_pipe_stop(capture_opts);
       }
       break;
@@ -638,14 +637,11 @@ sync_pipe_input_cb(gint source, gpointer user_data)
     capture_input_new_packets(capture_opts, nread);
     break;
   case SP_ERROR_MSG:
-    g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Error message from child: \"%s\"", buffer);
-    simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", buffer);
+    capture_input_error_message(capture_opts, buffer);
     /* the capture child will close the sync_pipe, nothing to do for now */
     break;
   case SP_DROPS:
-    g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "%d packet%s dropped", atoi(buffer), plurality(atoi(buffer), "", "s"));
-    cf_set_drops_known(capture_opts->cf, TRUE);
-    cf_set_drops(capture_opts->cf, atoi(buffer));
+    capture_input_drops(capture_opts, atoi(buffer));
     break;
   default:
       g_assert_not_reached();