get main_window_update out of the way... pass an update_cb to the capture_sync stuff

... as per the XXX comment removed from tshark.c this was a mess to keep the linker
happy... I couldn't!

I did this without even understanding whether calling main_window_update was realy
necessary in most cases. I guess nothing or more specific update cbs would be best.


svn path=/trunk/; revision=50188
This commit is contained in:
Luis Ontanon 2013-06-27 17:10:50 +00:00
parent b450609a55
commit 0bdc0efc46
17 changed files with 90 additions and 80 deletions

View File

@ -130,7 +130,7 @@ capture_callback_remove(capture_callback_t func)
* @return TRUE if the capture starts successfully, FALSE otherwise. * @return TRUE if the capture starts successfully, FALSE otherwise.
*/ */
gboolean 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; gboolean ret;
guint i; guint i;
@ -168,7 +168,7 @@ capture_start(capture_options *capture_opts, capture_session *cap_session)
cf_set_tempfile_source((capture_file *)cap_session->cf, source->str); cf_set_tempfile_source((capture_file *)cap_session->cf, source->str);
g_string_free(source, TRUE); g_string_free(source, TRUE);
/* try to start the capture child process */ /* 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(!ret) {
if(capture_opts->save_file != NULL) { if(capture_opts->save_file != NULL) {
g_free(capture_opts->save_file); g_free(capture_opts->save_file);
@ -660,7 +660,7 @@ capture_input_closed(capture_session *cap_session, gchar *msg)
/* close the currently loaded capture file */ /* close the currently loaded capture file */
cf_close((capture_file *)cap_session->cf); 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 { } else {
/* We're not doing a capture any more, so we don't have a save file. */ /* We're not doing a capture any more, so we don't have a save file. */
g_free(capture_opts->save_file); g_free(capture_opts->save_file);
@ -696,7 +696,7 @@ capture_stat_start(capture_options *capture_opts) {
* mechanism, so opening all the devices and presenting packet * mechanism, so opening all the devices and presenting packet
* counts might not always be a good idea. * 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 = (if_stat_cache_t *)g_malloc(sizeof(if_stat_cache_t));
sc->stat_fd = stat_fd; sc->stat_fd = stat_fd;
sc->fork_child = fork_child; sc->fork_child = fork_child;

View File

@ -66,7 +66,7 @@ capture_callback_remove(capture_callback_t func);
* @return TRUE if the capture starts successfully, FALSE otherwise. * @return TRUE if the capture starts successfully, FALSE otherwise.
*/ */
extern gboolean extern 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));
/** Stop a capture session (usually from a menu item). */ /** Stop a capture session (usually from a menu item). */
extern void extern void

View File

@ -105,7 +105,7 @@ static void append_remote_list(GList *iflist)
/* XXX - We parse simple text output to get our interface list. Should /* XXX - We parse simple text output to get our interface list. Should
* we use "real" data serialization instead, e.g. via XML? */ * we use "real" data serialization instead, e.g. via XML? */
GList * GList *
capture_interface_list(int *err, char **err_str) capture_interface_list(int *err, char **err_str, void (*update_cb)(void))
{ {
int ret; int ret;
GList *if_list = NULL; GList *if_list = NULL;
@ -119,7 +119,7 @@ capture_interface_list(int *err, char **err_str)
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List ..."); g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List ...");
/* Try to get our interface list */ /* Try to get our interface list */
ret = sync_interface_list_open(&data, &primary_msg, &secondary_msg); ret = sync_interface_list_open(&data, &primary_msg, &secondary_msg, update_cb);
if (ret != 0) { if (ret != 0) {
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List failed!"); g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List failed!");
if (err_str) { if (err_str) {
@ -206,7 +206,7 @@ capture_interface_list(int *err, char **err_str)
* we use "real" data serialization instead, e.g. via XML? */ * we use "real" data serialization instead, e.g. via XML? */
if_capabilities_t * if_capabilities_t *
capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode, capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode,
char **err_str) char **err_str, void (*update_cb)(void))
{ {
if_capabilities_t *caps; if_capabilities_t *caps;
GList *linktype_list = NULL; GList *linktype_list = NULL;
@ -219,7 +219,7 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode,
/* Try to get our interface list */ /* Try to get our interface list */
err = sync_if_capabilities_open(ifname, monitor_mode, &data, err = sync_if_capabilities_open(ifname, monitor_mode, &data,
&primary_msg, &secondary_msg); &primary_msg, &secondary_msg, update_cb);
if (err != 0) { if (err != 0) {
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface Capabilities failed!"); g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface Capabilities failed!");
if (err_str) { if (err_str) {

View File

@ -77,7 +77,7 @@ typedef struct {
/** /**
* Fetch the interface list from a child process. * Fetch the interface list from a child process.
*/ */
extern GList *capture_interface_list(int *err, char **err_str); extern GList *capture_interface_list(int *err, char **err_str, void (*update_cb)(void));
/* Error values from "get_interface_list()/capture_interface_list()". */ /* Error values from "get_interface_list()/capture_interface_list()". */
#define CANT_GET_INTERFACE_LIST 1 /* error getting list */ #define CANT_GET_INTERFACE_LIST 1 /* error getting list */
@ -110,7 +110,7 @@ typedef struct {
*/ */
extern if_capabilities_t * extern if_capabilities_t *
capture_get_if_capabilities(const char *devname, gboolean monitor_mode, capture_get_if_capabilities(const char *devname, gboolean monitor_mode,
char **err_str); char **err_str, void (*update_cb)(void));
void free_if_capabilities(if_capabilities_t *caps); void free_if_capabilities(if_capabilities_t *caps);

View File

@ -334,7 +334,7 @@ init_pipe_args(int *argc) {
#define ARGV_NUMBER_LEN 24 #define ARGV_NUMBER_LEN 24
/* a new capture run: start a new dumpcap task and hand over parameters through command line */ /* a new capture run: start a new dumpcap task and hand over parameters through command line */
gboolean gboolean
sync_pipe_start(capture_options *capture_opts, capture_session *cap_session) sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, void (*update_cb)(void))
{ {
char ssnap[ARGV_NUMBER_LEN]; char ssnap[ARGV_NUMBER_LEN];
char scount[ARGV_NUMBER_LEN]; char scount[ARGV_NUMBER_LEN];
@ -687,7 +687,7 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session)
cap_session->capture_opts = capture_opts; cap_session->capture_opts = capture_opts;
/* we might wait for a moment till child is ready, so update screen now */ /* we might wait for a moment till child is ready, so update screen now */
main_window_update(); if (update_cb) update_cb();
/* We were able to set up to read the capture file; /* We were able to set up to read the capture file;
arrange that our callback be called whenever it's possible arrange that our callback be called whenever it's possible
@ -718,7 +718,7 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session)
#define PIPE_BUF_SIZE 5120 #define PIPE_BUF_SIZE 5120
static int static int
sync_pipe_open_command(char** argv, int *data_read_fd, sync_pipe_open_command(char** argv, int *data_read_fd,
int *message_read_fd, int *fork_child, gchar **msg) int *message_read_fd, int *fork_child, gchar **msg, void(*update_cb)(void))
{ {
enum PIPES { PIPE_READ, PIPE_WRITE }; /* Constants 0 and 1 for PIPE_READ and PIPE_WRITE */ enum PIPES { PIPE_READ, PIPE_WRITE }; /* Constants 0 and 1 for PIPE_READ and PIPE_WRITE */
#ifdef _WIN32 #ifdef _WIN32
@ -912,7 +912,7 @@ sync_pipe_open_command(char** argv, int *data_read_fd,
} }
/* we might wait for a moment till child is ready, so update screen now */ /* we might wait for a moment till child is ready, so update screen now */
main_window_update(); if (update_cb) update_cb();
return 0; return 0;
} }
@ -957,7 +957,7 @@ sync_pipe_close_command(int *data_read_fd, int *message_read_fd,
#define PIPE_BUF_SIZE 5120 #define PIPE_BUF_SIZE 5120
static int static int
sync_pipe_run_command_actual(char** argv, gchar **data, gchar **primary_msg, sync_pipe_run_command_actual(char** argv, gchar **data, gchar **primary_msg,
gchar **secondary_msg) gchar **secondary_msg, void(*update_cb)(void))
{ {
gchar *msg; gchar *msg;
int data_pipe_read_fd, sync_pipe_read_fd, fork_child, ret; int data_pipe_read_fd, sync_pipe_read_fd, fork_child, ret;
@ -974,7 +974,7 @@ sync_pipe_run_command_actual(char** argv, gchar **data, gchar **primary_msg,
ssize_t count; ssize_t count;
ret = sync_pipe_open_command(argv, &data_pipe_read_fd, &sync_pipe_read_fd, ret = sync_pipe_open_command(argv, &data_pipe_read_fd, &sync_pipe_read_fd,
&fork_child, &msg); &fork_child, &msg, update_cb);
if (ret == -1) { if (ret == -1) {
*primary_msg = msg; *primary_msg = msg;
*secondary_msg = NULL; *secondary_msg = NULL;
@ -1133,7 +1133,7 @@ sync_pipe_run_command_actual(char** argv, gchar **data, gchar **primary_msg,
*/ */
static int static int
sync_pipe_run_command(char** argv, gchar **data, gchar **primary_msg, sync_pipe_run_command(char** argv, gchar **data, gchar **primary_msg,
gchar **secondary_msg) gchar **secondary_msg, void (*update_cb)(void))
{ {
int ret, i; int ret, i;
GTimeVal start_time; GTimeVal start_time;
@ -1151,7 +1151,7 @@ sync_pipe_run_command(char** argv, gchar **data, gchar **primary_msg,
} }
} }
/* do the actual sync pipe run command */ /* do the actual sync pipe run command */
ret=sync_pipe_run_command_actual(argv, data, primary_msg, secondary_msg); ret=sync_pipe_run_command_actual(argv, data, primary_msg, secondary_msg, update_cb);
if(logging_enabled){ if(logging_enabled){
g_get_current_time(&end_time); g_get_current_time(&end_time);
@ -1168,7 +1168,7 @@ sync_pipe_run_command(char** argv, gchar **data, gchar **primary_msg,
int int
sync_interface_set_80211_chan(const gchar *iface, const char *freq, const gchar *type, sync_interface_set_80211_chan(const gchar *iface, const char *freq, const gchar *type,
gchar **data, gchar **primary_msg, gchar **data, gchar **primary_msg,
gchar **secondary_msg) gchar **secondary_msg, void (*update_cb)(void))
{ {
int argc, ret; int argc, ret;
char **argv; char **argv;
@ -1207,7 +1207,7 @@ sync_interface_set_80211_chan(const gchar *iface, const char *freq, const gchar
argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE); argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE);
#endif #endif
ret = sync_pipe_run_command(argv, data, primary_msg, secondary_msg); ret = sync_pipe_run_command(argv, data, primary_msg, secondary_msg, update_cb);
g_free(opt); g_free(opt);
return ret; return ret;
} }
@ -1226,7 +1226,7 @@ sync_interface_set_80211_chan(const gchar *iface, const char *freq, const gchar
*/ */
int int
sync_interface_list_open(gchar **data, gchar **primary_msg, sync_interface_list_open(gchar **data, gchar **primary_msg,
gchar **secondary_msg) gchar **secondary_msg, void (*update_cb)(void))
{ {
int argc; int argc;
char **argv; char **argv;
@ -1236,7 +1236,7 @@ sync_interface_list_open(gchar **data, gchar **primary_msg,
argv = init_pipe_args(&argc); argv = init_pipe_args(&argc);
if (!argv) { if (!argv) {
*primary_msg = g_strdup("We don't know where to find dumpcap."); *primary_msg = g_strdup("We don't know where to find dumpcap..");
*secondary_msg = NULL; *secondary_msg = NULL;
*data = NULL; *data = NULL;
return -1; return -1;
@ -1250,7 +1250,7 @@ sync_interface_list_open(gchar **data, gchar **primary_msg,
argv = sync_pipe_add_arg(argv, &argc, "-Z"); argv = sync_pipe_add_arg(argv, &argc, "-Z");
argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE); argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE);
#endif #endif
return sync_pipe_run_command(argv, data, primary_msg, secondary_msg); return sync_pipe_run_command(argv, data, primary_msg, secondary_msg, update_cb);
} }
/* /*
@ -1268,7 +1268,7 @@ sync_interface_list_open(gchar **data, gchar **primary_msg,
int int
sync_if_capabilities_open(const gchar *ifname, gboolean monitor_mode, sync_if_capabilities_open(const gchar *ifname, gboolean monitor_mode,
gchar **data, gchar **primary_msg, gchar **data, gchar **primary_msg,
gchar **secondary_msg) gchar **secondary_msg, void (*update_cb)(void))
{ {
int argc; int argc;
char **argv; char **argv;
@ -1296,7 +1296,7 @@ sync_if_capabilities_open(const gchar *ifname, gboolean monitor_mode,
argv = sync_pipe_add_arg(argv, &argc, "-Z"); argv = sync_pipe_add_arg(argv, &argc, "-Z");
argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE); argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE);
#endif #endif
return sync_pipe_run_command(argv, data, primary_msg, secondary_msg); return sync_pipe_run_command(argv, data, primary_msg, secondary_msg, update_cb);
} }
/* /*
@ -1306,7 +1306,7 @@ sync_if_capabilities_open(const gchar *ifname, gboolean monitor_mode,
* that must be g_free()d, and -1 will be returned. * that must be g_free()d, and -1 will be returned.
*/ */
int int
sync_interface_stats_open(int *data_read_fd, int *fork_child, gchar **msg) sync_interface_stats_open(int *data_read_fd, int *fork_child, gchar **msg, void (*update_cb)(void))
{ {
int argc; int argc;
char **argv; char **argv;
@ -1338,7 +1338,7 @@ sync_interface_stats_open(int *data_read_fd, int *fork_child, gchar **msg)
argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE); argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE);
#endif #endif
ret = sync_pipe_open_command(argv, data_read_fd, &message_read_fd, ret = sync_pipe_open_command(argv, data_read_fd, &message_read_fd,
fork_child, msg); fork_child, msg, update_cb);
if (ret == -1) if (ret == -1)
return -1; return -1;

View File

@ -47,7 +47,7 @@
* @return TRUE if a capture could be started, FALSE if not * @return TRUE if a capture could be started, FALSE if not
*/ */
extern gboolean extern gboolean
sync_pipe_start(capture_options *capture_opts, capture_session *cap_session); sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, void(*update_cb)(void));
/** User wants to stop capturing, gracefully close the capture child */ /** User wants to stop capturing, gracefully close the capture child */
extern void extern void
@ -61,22 +61,22 @@ sync_pipe_kill(int fork_child);
extern int extern int
sync_interface_set_80211_chan(const gchar *iface, const char *freq, const gchar *type, sync_interface_set_80211_chan(const gchar *iface, const char *freq, const gchar *type,
gchar **data, gchar **primary_msg, gchar **data, gchar **primary_msg,
gchar **secondary_msg); gchar **secondary_msg, void (*update_cb)(void));
/** Get an interface list using dumpcap */ /** Get an interface list using dumpcap */
extern int extern int
sync_interface_list_open(gchar **data, gchar **primary_msg, sync_interface_list_open(gchar **data, gchar **primary_msg,
gchar **secondary_msg); gchar **secondary_msg, void (*update_cb)(void));
/** Get interface capabilities using dumpcap */ /** Get interface capabilities using dumpcap */
extern int extern int
sync_if_capabilities_open(const gchar *ifname, gboolean monitor_mode, sync_if_capabilities_open(const gchar *ifname, gboolean monitor_mode,
gchar **data, gchar **primary_msg, gchar **data, gchar **primary_msg,
gchar **secondary_msg); gchar **secondary_msg, void (*update_cb)(void));
/** Start getting interface statistics using dumpcap. */ /** Start getting interface statistics using dumpcap. */
extern int extern int
sync_interface_stats_open(int *read_fd, int *fork_child, gchar **msg); sync_interface_stats_open(int *read_fd, int *fork_child, gchar **msg, void (*update_cb)(void));
/** Stop gathering statistics. */ /** Stop gathering statistics. */
extern int extern int

View File

@ -290,7 +290,7 @@ get_interface_descriptive_name(const char *if_name)
/* No, we don't have a user-supplied description; did we get /* No, we don't have a user-supplied description; did we get
one from the OS or libpcap? */ one from the OS or libpcap? */
descr = NULL; descr = NULL;
if_list = capture_interface_list(&err, NULL); if_list = capture_interface_list(&err, NULL, NULL);
if (if_list != NULL) { if (if_list != NULL) {
if_entry = if_list; if_entry = if_list;
do { do {

View File

@ -232,12 +232,14 @@ typedef enum {
STATE_EXPECT_DATA, STATE_EXPECT_DATA,
STATE_READ_DATA STATE_READ_DATA
} cap_pipe_state_t; } cap_pipe_state_t;
typedef enum { typedef enum {
PIPOK, PIPOK,
PIPEOF, PIPEOF,
PIPERR, PIPERR,
PIPNEXIST PIPNEXIST
} cap_pipe_err_t; } cap_pipe_err_t;
typedef struct _pcap_options { typedef struct _pcap_options {
guint32 received; guint32 received;
guint32 dropped; guint32 dropped;
@ -309,6 +311,7 @@ typedef struct _pcap_queue_element {
*/ */
static const char please_report[] = static const char please_report[] =
"Please report this to the Wireshark developers.\n" "Please report this to the Wireshark developers.\n"
"http://bugs.wireshark.org/\n"
"(This is not a crash; please do not report it as such.)"; "(This is not a crash; please do not report it as such.)";
/* /*
@ -929,7 +932,7 @@ show_filter_code(capture_options *capture_opts)
#endif #endif
if (capture_child) { if (capture_child) {
/* Let our parent know we succeeded. */ /* Let our parent know we succeeded. */
pipe_write_block(2, SP_SUCCESS, NULL); pipe_write_block(2, SP_SUCCESS, NULL); ///
} }
return TRUE; return TRUE;
} }
@ -949,7 +952,7 @@ show_filter_code(capture_options *capture_opts)
* just call get_interface_list(). * just call get_interface_list().
*/ */
GList * GList *
capture_interface_list(int *err, char **err_str) capture_interface_list(int *err, char **err_str, void(*update_cb)(void) _U_)
{ {
return get_interface_list(err, err_str); return get_interface_list(err, err_str);
} }
@ -1288,7 +1291,7 @@ print_machine_readable_interfaces(GList *if_list)
if (capture_child) { if (capture_child) {
/* Let our parent know we succeeded. */ /* Let our parent know we succeeded. */
pipe_write_block(2, SP_SUCCESS, NULL); pipe_write_block(2, SP_SUCCESS, NULL); ///
} }
i = 1; /* Interface id number */ i = 1; /* Interface id number */
@ -1366,7 +1369,7 @@ print_machine_readable_if_capabilities(if_capabilities_t *caps)
if (capture_child) { if (capture_child) {
/* Let our parent know we succeeded. */ /* Let our parent know we succeeded. */
pipe_write_block(2, SP_SUCCESS, NULL); pipe_write_block(2, SP_SUCCESS, NULL); ///
} }
if (caps->can_set_rfmon) if (caps->can_set_rfmon)
@ -1442,7 +1445,7 @@ print_statistics_loop(gboolean machine_readable)
if (capture_child) { if (capture_child) {
/* Let our parent know we succeeded. */ /* Let our parent know we succeeded. */
pipe_write_block(2, SP_SUCCESS, NULL); pipe_write_block(2, SP_SUCCESS, NULL); ///
} }
if (!machine_readable) { if (!machine_readable) {
@ -4104,7 +4107,7 @@ set_80211_channel(const char *iface, const char *opt)
} }
if (capture_child) if (capture_child)
pipe_write_block(2, SP_SUCCESS, NULL); pipe_write_block(2, SP_SUCCESS, NULL); ///
ret = 0; ret = 0;
out: out:
@ -4661,7 +4664,7 @@ main(int argc, char *argv[])
int err; int err;
gchar *err_str; gchar *err_str;
if_list = capture_interface_list(&err, &err_str); if_list = capture_interface_list(&err, &err_str,NULL);
if (if_list == NULL) { if (if_list == NULL) {
switch (err) { switch (err) {
case CANT_GET_INTERFACE_LIST: case CANT_GET_INTERFACE_LIST:
@ -4928,7 +4931,7 @@ report_packet_count(unsigned int packet_count)
if (capture_child) { if (capture_child) {
g_snprintf(tmp, sizeof(tmp), "%u", packet_count); g_snprintf(tmp, sizeof(tmp), "%u", packet_count);
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Packets: %s", tmp); g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Packets: %s", tmp);
pipe_write_block(2, SP_PACKET_COUNT, tmp); pipe_write_block(2, SP_PACKET_COUNT, tmp); ///
} else { } else {
count += packet_count; count += packet_count;
fprintf(stderr, "\rPackets: %u ", count); fprintf(stderr, "\rPackets: %u ", count);
@ -4942,7 +4945,7 @@ report_new_capture_file(const char *filename)
{ {
if (capture_child) { if (capture_child) {
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "File: %s", filename); g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "File: %s", filename);
pipe_write_block(2, SP_FILE, filename); pipe_write_block(2, SP_FILE, filename); ///
} else { } else {
#ifdef SIGINFO #ifdef SIGINFO
/* /*
@ -4981,7 +4984,7 @@ report_cfilter_error(capture_options *capture_opts, guint i, const char *errmsg)
if (capture_child) { if (capture_child) {
g_snprintf(tmp, sizeof(tmp), "%u:%s", i, errmsg); g_snprintf(tmp, sizeof(tmp), "%u:%s", i, errmsg);
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Capture filter error: %s", errmsg); g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Capture filter error: %s", errmsg);
pipe_write_block(2, SP_BAD_FILTER, tmp); pipe_write_block(2, SP_BAD_FILTER, tmp); ///
} else { } else {
/* /*
* clopts_step_invalid_capfilter in test/suite-clopts.sh MUST match * clopts_step_invalid_capfilter in test/suite-clopts.sh MUST match
@ -5027,7 +5030,7 @@ report_packet_drops(guint32 received, guint32 pcap_drops, guint32 drops, guint32
"Packets received/dropped on interface %s: %u/%u (pcap:%u/dumpcap:%u/flushed:%u)", "Packets received/dropped on interface %s: %u/%u (pcap:%u/dumpcap:%u/flushed:%u)",
name, received, total_drops, pcap_drops, drops, flushed); name, received, total_drops, pcap_drops, drops, flushed);
/* XXX: Need to provide interface id, changes to consumers required. */ /* XXX: Need to provide interface id, changes to consumers required. */
pipe_write_block(2, SP_DROPS, tmp); pipe_write_block(2, SP_DROPS, tmp); ///
} else { } else {
fprintf(stderr, fprintf(stderr,
"Packets received/dropped on interface '%s': %u/%u (pcap:%u/dumpcap:%u/flushed:%u) (%.1f%%)\n", "Packets received/dropped on interface '%s': %u/%u (pcap:%u/dumpcap:%u/flushed:%u) (%.1f%%)\n",
@ -5087,6 +5090,10 @@ signal_pipe_check_running(void)
} }
#endif #endif
/* /*
* Editor modelines - http://www.wireshark.org/tools/modelines.html * Editor modelines - http://www.wireshark.org/tools/modelines.html
* *

View File

@ -1245,7 +1245,7 @@ main(int argc, char *argv[])
#endif #endif
case 'D': /* Print a list of capture devices and exit */ case 'D': /* Print a list of capture devices and exit */
#ifdef HAVE_LIBPCAP #ifdef HAVE_LIBPCAP
if_list = capture_interface_list(&err, &err_str); if_list = capture_interface_list(&err, &err_str,NULL);
if (if_list == NULL) { if (if_list == NULL) {
switch (err) { switch (err) {
case CANT_GET_INTERFACE_LIST: case CANT_GET_INTERFACE_LIST:
@ -1959,7 +1959,7 @@ main(int argc, char *argv[])
if_capabilities_t *caps; if_capabilities_t *caps;
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i); interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
caps = capture_get_if_capabilities(interface_opts.name, interface_opts.monitor_mode, &err_str); caps = capture_get_if_capabilities(interface_opts.name, interface_opts.monitor_mode, &err_str, NULL);
if (caps == NULL) { if (caps == NULL) {
cmdarg_err("%s", err_str); cmdarg_err("%s", err_str);
g_free(err_str); g_free(err_str);
@ -2274,7 +2274,7 @@ capture(void)
fflush(stderr); fflush(stderr);
g_string_free(str, TRUE); g_string_free(str, TRUE);
ret = sync_pipe_start(&global_capture_opts, &global_capture_session); ret = sync_pipe_start(&global_capture_opts, &global_capture_session, NULL);
if (!ret) if (!ret)
return FALSE; return FALSE;
@ -2341,13 +2341,6 @@ capture(void)
return TRUE; return TRUE;
} }
/* XXX - move the call to main_window_update() out of capture_sync.c */
/* dummy for capture_sync.c to make linker happy */
void main_window_update(void)
{
}
/* capture child detected an error */ /* capture child detected an error */
void void
capture_input_error_message(capture_session *cap_session _U_, char *error_msg, char *secondary_error_msg) capture_input_error_message(capture_session *cap_session _U_, char *error_msg, char *secondary_error_msg)

View File

@ -5298,7 +5298,7 @@ capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
this capture. */ this capture. */
collect_ifaces(&global_capture_opts); collect_ifaces(&global_capture_opts);
if (capture_start(&global_capture_opts, &global_capture_session)) { if (capture_start(&global_capture_opts, &global_capture_session, main_window_update)) {
/* The capture succeeded, which means the capture filter syntax is /* The capture succeeded, which means the capture filter syntax is
valid; add this capture filter to the recent capture filter list. */ valid; add this capture filter to the recent capture filter list. */
for (i = 0; i < global_capture_opts.ifaces->len; i++) { for (i = 0; i < global_capture_opts.ifaces->len; i++) {
@ -5796,7 +5796,7 @@ capture_prep_monitor_changed_cb(GtkWidget *monitor, gpointer argp _U_)
if_string = g_strdup(device.name); if_string = g_strdup(device.name);
monitor_mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(monitor)); monitor_mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(monitor));
caps = capture_get_if_capabilities(if_string, monitor_mode, NULL); caps = capture_get_if_capabilities(if_string, monitor_mode, NULL, main_window_update);
if (caps != NULL) { if (caps != NULL) {
g_signal_handlers_disconnect_by_func(linktype_combo_box, G_CALLBACK(select_link_type_cb), NULL ); g_signal_handlers_disconnect_by_func(linktype_combo_box, G_CALLBACK(select_link_type_cb), NULL );
@ -6020,7 +6020,7 @@ void
refresh_local_interface_lists(void) refresh_local_interface_lists(void)
{ {
/* Reload the local interface list. */ /* Reload the local interface list. */
scan_local_interfaces(); scan_local_interfaces(main_window_update);
/* If there's an interfaces dialog up, refresh it. */ /* If there's an interfaces dialog up, refresh it. */
if (interfaces_dialog_window_present()) if (interfaces_dialog_window_present())

View File

@ -2293,7 +2293,7 @@ main(int argc, char *argv[])
break; break;
case 'D': /* Print a list of capture devices and exit */ case 'D': /* Print a list of capture devices and exit */
#ifdef HAVE_LIBPCAP #ifdef HAVE_LIBPCAP
if_list = capture_interface_list(&err, &err_str); if_list = capture_interface_list(&err, &err_str,main_window_update);
if (if_list == NULL) { if (if_list == NULL) {
switch (err) { switch (err) {
case CANT_GET_INTERFACE_LIST: case CANT_GET_INTERFACE_LIST:
@ -2800,7 +2800,7 @@ main(int argc, char *argv[])
} }
#ifdef HAVE_LIBPCAP #ifdef HAVE_LIBPCAP
fill_in_local_interfaces(); fill_in_local_interfaces(main_window_update);
if (start_capture && list_link_layer_types) { if (start_capture && list_link_layer_types) {
/* Specifying *both* is bogus. */ /* Specifying *both* is bogus. */
cmdarg_err("You can't specify both -L and a live capture."); cmdarg_err("You can't specify both -L and a live capture.");
@ -2870,7 +2870,7 @@ main(int argc, char *argv[])
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
if (device.selected) { if (device.selected) {
#if defined(HAVE_PCAP_CREATE) #if defined(HAVE_PCAP_CREATE)
caps = capture_get_if_capabilities(device.name, device.monitor_mode_supported, &err_str); caps = capture_get_if_capabilities(device.name, device.monitor_mode_supported, &err_str, main_window_update);
#else #else
caps = capture_get_if_capabilities(device.name, FALSE, &err_str); caps = capture_get_if_capabilities(device.name, FALSE, &err_str);
#endif #endif
@ -3133,7 +3133,7 @@ main(int argc, char *argv[])
to use for this capture. */ to use for this capture. */
if (global_capture_opts.ifaces->len == 0) if (global_capture_opts.ifaces->len == 0)
collect_ifaces(&global_capture_opts); collect_ifaces(&global_capture_opts);
if (capture_start(&global_capture_opts, &global_capture_session)) { if (capture_start(&global_capture_opts, &global_capture_session,main_window_update)) {
/* The capture started. Open stat windows; we do so after creating /* The capture started. Open stat windows; we do so after creating
the main window, to avoid GTK warnings, and after successfully the main window, to avoid GTK warnings, and after successfully
opening the capture file, so we know we have something to compute opening the capture file, so we know we have something to compute

View File

@ -43,6 +43,7 @@
#include "ui/recent.h" #include "ui/recent.h"
#include "ui/gtk/old-gtk-compat.h" #include "ui/gtk/old-gtk-compat.h"
#include "ui/ui_util.h"
#include "ui/gtk/main_80211_toolbar.h" #include "ui/gtk/main_80211_toolbar.h"
#include <ws80211_utils.h> #include <ws80211_utils.h>
@ -175,7 +176,7 @@ tb80211_do_set_channel(char *iface, int freq, int type)
freq_s = g_strdup_printf("%d", freq); freq_s = g_strdup_printf("%d", freq);
type_s = ws80211_chan_type_to_str(type); type_s = ws80211_chan_type_to_str(type);
ret = sync_interface_set_80211_chan(iface, freq_s, type_s, ret = sync_interface_set_80211_chan(iface, freq_s, type_s,
&data, &primary_msg, &secondary_msg); &data, &primary_msg, &secondary_msg, main_window_update);
/* Parse the error msg */ /* Parse the error msg */
if (ret && primary_msg) { if (ret && primary_msg) {

View File

@ -47,6 +47,7 @@
#include "ui/recent.h" #include "ui/recent.h"
#include "ui/simple_dialog.h" #include "ui/simple_dialog.h"
#include "ui/utf8_entities.h" #include "ui/utf8_entities.h"
#include "ui/ui_util.h"
#include "ui/gtk/gui_utils.h" #include "ui/gtk/gui_utils.h"
#include "ui/gtk/color_utils.h" #include "ui/gtk/color_utils.h"
@ -1068,7 +1069,7 @@ static void fill_capture_box(void)
/* run capture_interface_list(), not to get the interfaces, but to detect /* run capture_interface_list(), not to get the interfaces, but to detect
* any errors, if there is an error, display an appropriate message in the gui */ * any errors, if there is an error, display an appropriate message in the gui */
capture_interface_list(&error, &err_str); capture_interface_list(&error, &err_str,main_window_update);
switch (error) { switch (error) {
case CANT_GET_INTERFACE_LIST: case CANT_GET_INTERFACE_LIST:
@ -1297,7 +1298,7 @@ welcome_new(void)
g_object_set_data(G_OBJECT(welcome_hb), CAPTURE_VIEW, topic_capture_to_fill); g_object_set_data(G_OBJECT(welcome_hb), CAPTURE_VIEW, topic_capture_to_fill);
#ifdef HAVE_LIBPCAP #ifdef HAVE_LIBPCAP
fill_in_local_interfaces(); fill_in_local_interfaces(main_window_update);
fill_capture_box(); fill_capture_box();
/* capture help topic */ /* capture help topic */

View File

@ -37,6 +37,7 @@
#include "ui/capture_globals.h" #include "ui/capture_globals.h"
#include "ui/iface_lists.h" #include "ui/iface_lists.h"
#include "ui/simple_dialog.h" #include "ui/simple_dialog.h"
#include "ui/ui_util.h"
#include "ui/gtk/prefs_capture.h" #include "ui/gtk/prefs_capture.h"
#include "ui/gtk/prefs_dlg.h" #include "ui/gtk/prefs_dlg.h"
@ -160,7 +161,7 @@ capture_prefs_show(void)
/* /*
* XXX - what if we can't get the list? * XXX - what if we can't get the list?
*/ */
if_list = capture_interface_list(&err, NULL); if_list = capture_interface_list(&err, NULL, main_window_update);
combo_list = build_capture_combo_list(if_list, FALSE); combo_list = build_capture_combo_list(if_list, FALSE);
free_interface_list(if_list); free_interface_list(if_list);
if (combo_list != NULL) { if (combo_list != NULL) {
@ -1076,7 +1077,7 @@ ifopts_description_to_val (const char *if_name, gboolean monitor_mode, const cha
if_capabilities_t *caps; if_capabilities_t *caps;
int dlt = -1; int dlt = -1;
caps = capture_get_if_capabilities(if_name, monitor_mode, NULL); caps = capture_get_if_capabilities(if_name, monitor_mode, NULL, main_window_update);
if (caps != NULL) { if (caps != NULL) {
if (caps->data_link_types != NULL) { if (caps->data_link_types != NULL) {
GList *lt_entry; GList *lt_entry;
@ -1186,9 +1187,9 @@ ifopts_edit_ifsel_cb(GtkTreeSelection *selection _U_,
* to the interface capabilities of the selected interface * to the interface capabilities of the selected interface
*/ */
#ifdef HAVE_PCAP_CREATE #ifdef HAVE_PCAP_CREATE
caps = capture_get_if_capabilities(if_name, monitor_mode, NULL); caps = capture_get_if_capabilities(if_name, monitor_mode, NULL, main_window_update);
#else #else
caps = capture_get_if_capabilities(if_name, FALSE, NULL); caps = capture_get_if_capabilities(if_name, FALSE, NULL, main_window_update);
#endif #endif
if (caps != NULL) { if (caps != NULL) {
#ifdef HAVE_PCAP_CREATE #ifdef HAVE_PCAP_CREATE
@ -1304,7 +1305,7 @@ ifopts_edit_monitor_changed_cb(GtkToggleButton *tbt, gpointer udata)
gtk_list_store_set (list_store, &list_iter, gtk_list_store_set (list_store, &list_iter,
DEF_MONITOR_MODE_COLUMN, monitor_mode, DEF_MONITOR_MODE_COLUMN, monitor_mode,
-1); -1);
caps = capture_get_if_capabilities(if_name, monitor_mode, NULL); caps = capture_get_if_capabilities(if_name, monitor_mode, NULL, main_window_update);
#else #else
/* no monitor-mode support */ /* no monitor-mode support */
caps = capture_get_if_capabilities(if_name, FALSE, NULL); caps = capture_get_if_capabilities(if_name, FALSE, NULL);
@ -1620,7 +1621,7 @@ ifopts_options_add(GtkListStore *list_store, if_info_t *if_info)
#ifdef HAVE_PCAP_CREATE #ifdef HAVE_PCAP_CREATE
/* get default monitor mode setting */ /* get default monitor mode setting */
monitor_mode = prefs_capture_device_monitor_mode(if_info->name); monitor_mode = prefs_capture_device_monitor_mode(if_info->name);
caps = capture_get_if_capabilities(if_info->name, monitor_mode, NULL); caps = capture_get_if_capabilities(if_info->name, monitor_mode, NULL, main_window_update);
#else #else
/* no monitor-mode support */ /* no monitor-mode support */
caps = capture_get_if_capabilities(if_info->name, FALSE, NULL); caps = capture_get_if_capabilities(if_info->name, FALSE, NULL);
@ -1774,7 +1775,7 @@ ifopts_if_liststore_add(void)
int err; int err;
gchar *err_str; gchar *err_str;
if_list = capture_interface_list(&err, &err_str); /* if_list = ptr to first element of list (or NULL) */ if_list = capture_interface_list(&err, &err_str, main_window_update); /* if_list = ptr to first element of list (or NULL) */
if (if_list == NULL) { if (if_list == NULL) {
if (err != NO_INTERFACES_FOUND) { if (err != NO_INTERFACES_FOUND) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str); simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);

View File

@ -74,6 +74,9 @@
#endif /* HAVE_LIBPORTAUDIO */ #endif /* HAVE_LIBPORTAUDIO */
#define DUMP_PTR1(p) printf("#=> %p\n",p)
#define DUMP_PTR2(p) printf("==> %p\n",p)
const char *voip_call_state_name[8]={ const char *voip_call_state_name[8]={
"", "",
"CALL SETUP", "CALL SETUP",
@ -1526,7 +1529,8 @@ q931_calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, co
/* remove this LRQ/LCF call entry because we have found the Setup that match them */ /* remove this LRQ/LCF call entry because we have found the Setup that match them */
g_free(tmp_listinfo->from_identity); g_free(tmp_listinfo->from_identity);
g_free(tmp_listinfo->to_identity); g_free(tmp_listinfo->to_identity);
g_free(tmp2_h323info->guid); DUMP_PTR2(tmp2_h323info->guid);
g_free(tmp2_h323info->guid);
list2 = g_list_first(tmp2_h323info->h245_list); list2 = g_list_first(tmp2_h323info->h245_list);
while (list2) while (list2)
@ -1745,6 +1749,7 @@ static void add_h245_Address(h323_calls_info_t *h323info, h245_address_t *h245_
static void free_h225_info(gpointer p) { static void free_h225_info(gpointer p) {
h323_calls_info_t *tmp_h323info = (h323_calls_info_t *)p; h323_calls_info_t *tmp_h323info = (h323_calls_info_t *)p;
DUMP_PTR2(tmp_h323info->guid);
g_free(tmp_h323info->guid); g_free(tmp_h323info->guid);
if (tmp_h323info->h245_list) { if (tmp_h323info->h245_list) {
@ -1843,6 +1848,8 @@ H225calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, con
tmp_h323info = (h323_calls_info_t *)callsinfo->prot_info; tmp_h323info = (h323_calls_info_t *)callsinfo->prot_info;
g_assert(tmp_h323info != NULL); g_assert(tmp_h323info != NULL);
tmp_h323info->guid = (e_guid_t *)g_memdup(&pi->guid, sizeof pi->guid); tmp_h323info->guid = (e_guid_t *)g_memdup(&pi->guid, sizeof pi->guid);
DUMP_PTR1(tmp_h323info->guid);
tmp_h323info->h225SetupAddr.type = AT_NONE; tmp_h323info->h225SetupAddr.type = AT_NONE;
tmp_h323info->h225SetupAddr.len = 0; tmp_h323info->h225SetupAddr.len = 0;
tmp_h323info->h245_list = NULL; tmp_h323info->h245_list = NULL;

View File

@ -63,7 +63,7 @@ if_list_comparator_alph(const void *first_arg, const void *second_arg)
* those interfaces. * those interfaces.
*/ */
void void
scan_local_interfaces(void) scan_local_interfaces(void (*update_cb)(void))
{ {
GList *if_entry, *lt_entry, *if_list; GList *if_entry, *lt_entry, *if_list;
if_info_t *if_info, *temp; if_info_t *if_info, *temp;
@ -94,7 +94,7 @@ scan_local_interfaces(void)
} }
/* Scan through the list and build a list of strings to display. */ /* Scan through the list and build a list of strings to display. */
if_list = capture_interface_list(&err, NULL); if_list = capture_interface_list(&err, NULL, update_cb);
count = 0; count = 0;
for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) { for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) {
if_info = (if_info_t *)if_entry->data; if_info = (if_info_t *)if_entry->data;
@ -160,7 +160,7 @@ scan_local_interfaces(void)
} }
device.type = if_info->type; device.type = if_info->type;
monitor_mode = prefs_capture_device_monitor_mode(if_info->name); monitor_mode = prefs_capture_device_monitor_mode(if_info->name);
caps = capture_get_if_capabilities(if_info->name, monitor_mode, NULL); caps = capture_get_if_capabilities(if_info->name, monitor_mode, NULL, update_cb);
for (; (curr_addr = g_slist_nth(if_info->addrs, ips)) != NULL; ips++) { for (; (curr_addr = g_slist_nth(if_info->addrs, ips)) != NULL; ips++) {
temp_addr = (if_addr_t *)g_malloc0(sizeof(if_addr_t)); temp_addr = (if_addr_t *)g_malloc0(sizeof(if_addr_t));
if (ips != 0) { if (ips != 0) {
@ -347,7 +347,7 @@ scan_local_interfaces(void)
* record how long it takes in the info log. * record how long it takes in the info log.
*/ */
void void
fill_in_local_interfaces(void) fill_in_local_interfaces(void(*update_cb)(void))
{ {
GTimeVal start_time; GTimeVal start_time;
GTimeVal end_time; GTimeVal end_time;
@ -360,7 +360,7 @@ fill_in_local_interfaces(void)
if (!initialized) { if (!initialized) {
/* do the actual work */ /* do the actual work */
scan_local_interfaces(); scan_local_interfaces(update_cb);
initialized = TRUE; initialized = TRUE;
} }
/* log how long it took */ /* log how long it took */

View File

@ -41,12 +41,12 @@ extern gint if_list_comparator_alph(const void *first_arg, const void *second_ar
* Get the global interface list. Generate it if we haven't * Get the global interface list. Generate it if we haven't
* done so already. * done so already.
*/ */
extern void fill_in_local_interfaces(void); extern void fill_in_local_interfaces(void(*update_cb)(void));
/* /*
* Update the global interface list. * Update the global interface list.
*/ */
extern void scan_local_interfaces(void); extern void scan_local_interfaces(void (*update_cb)(void));
extern void hide_interface(gchar* new_hide); extern void hide_interface(gchar* new_hide);
#endif /* HAVE_LIBPCAP */ #endif /* HAVE_LIBPCAP */