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 */
|
/* close the currently loaded capture file */
|
||||||
cf_close(capture_opts->cf);
|
cf_close(capture_opts->cf);
|
||||||
|
|
||||||
|
g_assert(capture_opts->state == CAPTURE_STOPPED);
|
||||||
|
capture_opts->state = CAPTURE_PREPARING;
|
||||||
|
|
||||||
/* try to start the capture child process */
|
/* try to start the capture child process */
|
||||||
ret = sync_pipe_start(capture_opts, capture_opts->save_file == NULL);
|
ret = sync_pipe_start(capture_opts, capture_opts->save_file == NULL);
|
||||||
if(!ret) {
|
if(!ret) {
|
||||||
|
@ -89,6 +92,8 @@ capture_start(capture_options *capture_opts)
|
||||||
g_free(capture_opts->save_file);
|
g_free(capture_opts->save_file);
|
||||||
capture_opts->save_file = NULL;
|
capture_opts->save_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
capture_opts->state = CAPTURE_STOPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -209,6 +214,7 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
|
||||||
|
g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
|
||||||
/*g_warning("New capture file: %s", new_file);*/
|
/*g_warning("New capture file: %s", new_file);*/
|
||||||
|
|
||||||
/* free the old filename */
|
/* 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);
|
cf_callback_invoke(cf_cb_live_capture_fixed_started, capture_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
capture_opts->state = CAPTURE_RUNNING;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -299,8 +306,10 @@ capture_input_closed(capture_options *capture_opts)
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
|
||||||
/* if we have no file (happens if an error occured), do a fake start */
|
g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
|
||||||
if(capture_opts->save_file == NULL) {
|
|
||||||
|
/* 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) {
|
if(capture_opts->real_time_mode) {
|
||||||
cf_callback_invoke(cf_cb_live_capture_update_started, capture_opts);
|
cf_callback_invoke(cf_cb_live_capture_update_started, capture_opts);
|
||||||
} else {
|
} 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 we couldn't open a capture file, there's nothing more for us to do */
|
||||||
if(capture_opts->save_file == NULL) {
|
if(capture_opts->save_file == NULL) {
|
||||||
cf_close(capture_opts->cf);
|
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. */
|
/** Name we give to the child process when doing a "-S" capture. */
|
||||||
#define CHILD_NAME "ethereal-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 */
|
/** Capture options coming from user interface */
|
||||||
typedef struct capture_options_tag {
|
typedef struct capture_options_tag {
|
||||||
/* general */
|
/* general */
|
||||||
|
@ -86,6 +95,7 @@ typedef struct capture_options_tag {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int signal_pipe_fd; /**< the pipe to signal the child */
|
int signal_pipe_fd; /**< the pipe to signal the child */
|
||||||
#endif
|
#endif
|
||||||
|
capture_state state; /**< current state of the capture engine */
|
||||||
} capture_options;
|
} capture_options;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ capture_opts_init(capture_options *capture_opts, void *cfile)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
capture_opts->signal_pipe_fd = -1;
|
capture_opts->signal_pipe_fd = -1;
|
||||||
#endif
|
#endif
|
||||||
|
capture_opts->state = CAPTURE_STOPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue