forked from osmocom/wireshark
add a state member to the capture_opts, and set it according to the capture engine
svn path=/trunk/; revision=14205
This commit is contained in:
parent
b979f69c0c
commit
4852c618d8
15
capture.c
15
capture.c
|
@ -82,6 +82,9 @@ capture_start(capture_options *capture_opts)
|
|||
/* close the currently loaded capture file */
|
||||
cf_close(capture_opts->cf);
|
||||
|
||||
g_assert(capture_opts->state == CAPTURE_STOPPED);
|
||||
capture_opts->state = CAPTURE_PREPARING;
|
||||
|
||||
/* try to start the capture child process */
|
||||
ret = sync_pipe_start(capture_opts, capture_opts->save_file == NULL);
|
||||
if(!ret) {
|
||||
|
@ -89,6 +92,8 @@ capture_start(capture_options *capture_opts)
|
|||
g_free(capture_opts->save_file);
|
||||
capture_opts->save_file = NULL;
|
||||
}
|
||||
|
||||
capture_opts->state = CAPTURE_STOPPED;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -209,6 +214,7 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
|
|||
int err;
|
||||
|
||||
|
||||
g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
|
||||
/*g_warning("New capture file: %s", new_file);*/
|
||||
|
||||
/* free the old filename */
|
||||
|
@ -251,6 +257,7 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
|
|||
cf_callback_invoke(cf_cb_live_capture_fixed_started, capture_opts);
|
||||
}
|
||||
|
||||
capture_opts->state = CAPTURE_RUNNING;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -299,8 +306,10 @@ capture_input_closed(capture_options *capture_opts)
|
|||
int err;
|
||||
|
||||
|
||||
/* if we have no file (happens if an error occured), do a fake start */
|
||||
if(capture_opts->save_file == NULL) {
|
||||
g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
|
||||
|
||||
/* if we didn't started the capture (happens if an error occured), do a fake start */
|
||||
if(capture_opts->state == CAPTURE_PREPARING) {
|
||||
if(capture_opts->real_time_mode) {
|
||||
cf_callback_invoke(cf_cb_live_capture_update_started, capture_opts);
|
||||
} else {
|
||||
|
@ -349,6 +358,8 @@ capture_input_closed(capture_options *capture_opts)
|
|||
}
|
||||
}
|
||||
|
||||
capture_opts->state = CAPTURE_STOPPED;
|
||||
|
||||
/* if we couldn't open a capture file, there's nothing more for us to do */
|
||||
if(capture_opts->save_file == NULL) {
|
||||
cf_close(capture_opts->cf);
|
||||
|
|
10
capture.h
10
capture.h
|
@ -34,6 +34,15 @@
|
|||
/** Name we give to the child process when doing a "-S" capture. */
|
||||
#define CHILD_NAME "ethereal-capture"
|
||||
|
||||
|
||||
/* Current state of capture engine. XXX - differentiate states */
|
||||
typedef enum {
|
||||
CAPTURE_STOPPED, /**< stopped */
|
||||
CAPTURE_PREPARING, /**< preparing, but still no response from capture child */
|
||||
CAPTURE_RUNNING /**< capture child signalled ok, capture is running now */
|
||||
} capture_state;
|
||||
|
||||
|
||||
/** Capture options coming from user interface */
|
||||
typedef struct capture_options_tag {
|
||||
/* general */
|
||||
|
@ -86,6 +95,7 @@ typedef struct capture_options_tag {
|
|||
#ifdef _WIN32
|
||||
int signal_pipe_fd; /**< the pipe to signal the child */
|
||||
#endif
|
||||
capture_state state; /**< current state of the capture engine */
|
||||
} capture_options;
|
||||
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ capture_opts_init(capture_options *capture_opts, void *cfile)
|
|||
#ifdef _WIN32
|
||||
capture_opts->signal_pipe_fd = -1;
|
||||
#endif
|
||||
capture_opts->state = CAPTURE_STOPPED;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue