sec_vt_header: dissect call_id
[metze/wireshark/wip.git] / capture.c
index ae940a2d69319191cd8d3e023bf435e2f67e466f..9477919d2aad85c6528fca43d2c8862e8cc2e1b0 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -31,6 +31,7 @@
 #endif
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <glib.h>
@@ -130,7 +131,7 @@ capture_callback_remove(capture_callback_t func)
  * @return TRUE if the capture starts successfully, FALSE otherwise.
  */
 gboolean
-capture_start(capture_options *capture_opts, capture_session *cap_session)
+capture_start(capture_options *capture_opts, capture_session *cap_session, void(*update_cb)(void))
 {
   gboolean ret;
   guint i;
@@ -168,7 +169,7 @@ capture_start(capture_options *capture_opts, capture_session *cap_session)
   cf_set_tempfile_source((capture_file *)cap_session->cf, source->str);
   g_string_free(source, TRUE);
   /* try to start the capture child process */
-  ret = sync_pipe_start(capture_opts, cap_session);
+  ret = sync_pipe_start(capture_opts, cap_session, update_cb);
   if(!ret) {
       if(capture_opts->save_file != NULL) {
           g_free(capture_opts->save_file);
@@ -361,7 +362,7 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
   /* if we are in real-time mode, open the new file now */
   if(capture_opts->real_time_mode) {
     /* Attempt to open the capture file and set up to read from it. */
-    switch(cf_start_tail((capture_file *)cap_session->cf, capture_opts->save_file, is_tempfile, &err)) {
+    switch(cf_open((capture_file *)cap_session->cf, capture_opts->save_file, is_tempfile, &err)) {
     case CF_OK:
       break;
     case CF_ERROR:
@@ -646,6 +647,13 @@ capture_input_closed(capture_session *cap_session, gchar *msg)
 
     ws_unlink(capture_opts->save_file);
 
+    /* If we have a ring buffer, the original save file has been overwritten
+       with the "ring filename".  Restore it before starting again */
+    if ((capture_opts->multi_files_on) && (capture_opts->orig_save_file != NULL)) {
+      g_free(capture_opts->save_file);
+      capture_opts->save_file = g_strdup(capture_opts->orig_save_file);
+    }
+
     /* if it was a tempfile, throw away the old filename (so it will become a tempfile again) */
     if(cf_is_tempfile((capture_file *)cap_session->cf)) {
       g_free(capture_opts->save_file);
@@ -660,7 +668,7 @@ capture_input_closed(capture_session *cap_session, gchar *msg)
     /* close the currently loaded capture file */
     cf_close((capture_file *)cap_session->cf);
 
-    capture_start(capture_opts, cap_session);
+    capture_start(capture_opts, cap_session,NULL); /*XXX is this NULL ok or we need an update_cb???*/
   } else {
     /* We're not doing a capture any more, so we don't have a save file. */
     g_free(capture_opts->save_file);
@@ -696,7 +704,7 @@ capture_stat_start(capture_options *capture_opts) {
    * mechanism, so opening all the devices and presenting packet
    * counts might not always be a good idea.
    */
-  if (sync_interface_stats_open(&stat_fd, &fork_child, &msg) == 0) {
+  if (sync_interface_stats_open(&stat_fd, &fork_child, &msg, NULL) == 0) {
     sc = (if_stat_cache_t *)g_malloc(sizeof(if_stat_cache_t));
     sc->stat_fd = stat_fd;
     sc->fork_child = fork_child;