void capture_stop(capture_session *cap_session) { g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Stop ..."); capture_callback_invoke(capture_cb_capture_stopping, cap_session); /* stop the capture child gracefully */ sync_pipe_stop(cap_session); }
/** * Start a capture. * * @return TRUE if the capture starts successfully, FALSE otherwise. */ gboolean capture_start(capture_options *capture_opts, capture_session *cap_session) { gboolean ret; guint i; GString *source = g_string_new(""); cap_session->state = CAPTURE_PREPARING; g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start ..."); #ifdef _WIN32 if (capture_opts->ifaces->len < 2) { #else if (capture_opts->ifaces->len < 4) { #endif for (i = 0; i < capture_opts->ifaces->len; i++) { interface_options interface_opts; interface_opts = g_array_index(capture_opts->ifaces, interface_options, i); if (i > 0) { if (capture_opts->ifaces->len > 2) { g_string_append_printf(source, ","); } g_string_append_printf(source, " "); if (i == capture_opts->ifaces->len - 1) { g_string_append_printf(source, "and "); } } g_string_append_printf(source, "%s", get_iface_description_for_interface(capture_opts, i)); if ((interface_opts.cfilter != NULL) && (strlen(interface_opts.cfilter) > 0)) { g_string_append_printf(source, " (%s)", interface_opts.cfilter); } } } else { g_string_append_printf(source, "%u interfaces", capture_opts->ifaces->len); } 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); if(!ret) { if(capture_opts->save_file != NULL) { g_free(capture_opts->save_file); capture_opts->save_file = NULL; } g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start failed!"); cap_session->state = CAPTURE_STOPPED; } else { /* the capture child might not respond shortly after bringing it up */ /* (for example: it will block if no input arrives from an input capture pipe (e.g. mkfifo)) */ /* to prevent problems, bring the main GUI into "capture mode" right after a successful */ /* spawn/exec of the capture child, without waiting for any response from it */ capture_callback_invoke(capture_cb_capture_prepared, cap_session); if(capture_opts->show_info) capture_info_open(cap_session); } return ret; } void capture_stop(capture_session *cap_session) { g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Stop ..."); capture_callback_invoke(capture_cb_capture_stopping, cap_session); /* stop the capture child gracefully */ sync_pipe_stop(cap_session); }