diff options
-rw-r--r-- | capture_sync.c | 47 | ||||
-rw-r--r-- | capture_sync.h | 6 | ||||
-rw-r--r-- | ui/gtk/main_80211_toolbar.c | 3 |
3 files changed, 53 insertions, 3 deletions
diff --git a/capture_sync.c b/capture_sync.c index 100990c551..c99f8e5f1e 100644 --- a/capture_sync.c +++ b/capture_sync.c @@ -1112,6 +1112,53 @@ sync_pipe_run_command(const char** argv, gchar **data, gchar **primary_msg, return ret; } +int +sync_interface_set_80211_chan(gchar *iface, char *freq, gchar *type, + gchar **data, gchar **primary_msg, + gchar **secondary_msg) +{ + int argc, ret; + const char **argv; + gchar *opt; + + argv = init_pipe_args(&argc); + + if (!argv) { + *primary_msg = g_strdup("We don't know where to find dumpcap."); + *secondary_msg = NULL; + *data = NULL; + return -1; + } + + argv = sync_pipe_add_arg(argv, &argc, "-i"); + argv = sync_pipe_add_arg(argv, &argc, iface); + + if (type) + opt = g_strdup_printf("%s,%s", freq, type); + else + opt = g_strdup_printf("%s", freq); + + if (!opt) { + *primary_msg = g_strdup("Out of mem."); + *secondary_msg = NULL; + *data = NULL; + return -1; + } + + argv = sync_pipe_add_arg(argv, &argc, "-k"); + argv = sync_pipe_add_arg(argv, &argc, opt); + +#ifndef DEBUG_CHILD + /* Run dumpcap in capture child mode */ + argv = sync_pipe_add_arg(argv, &argc, "-Z"); + argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE); +#endif + + ret = sync_pipe_run_command(argv, data, primary_msg, secondary_msg); + g_free(opt); + return ret; +} + /* * Get the list of interfaces using dumpcap. * diff --git a/capture_sync.h b/capture_sync.h index d38e2ddd77..cb146dab96 100644 --- a/capture_sync.h +++ b/capture_sync.h @@ -57,6 +57,12 @@ sync_pipe_stop(capture_options *capture_opts); extern void sync_pipe_kill(int fork_child); +/** Set wireless channel using dumpcap */ +extern int +sync_interface_set_80211_chan(gchar *iface, char *freq, gchar *type, + gchar **data, gchar **primary_msg, + gchar **secondary_msg); + /** Get an interface list using dumpcap */ extern int sync_interface_list_open(gchar **data, gchar **primary_msg, diff --git a/ui/gtk/main_80211_toolbar.c b/ui/gtk/main_80211_toolbar.c index 4e5c822f5f..ca72af01b0 100644 --- a/ui/gtk/main_80211_toolbar.c +++ b/ui/gtk/main_80211_toolbar.c @@ -166,7 +166,6 @@ int get_selected_channel_type(void) static int tb80211_do_set_channel(char *iface, int freq, int type) { -#if 0 gchar *freq_s, *type_s; gchar *data, *primary_msg, *secondary_msg; int ret; @@ -185,8 +184,6 @@ tb80211_do_set_channel(char *iface, int freq, int type) g_free(secondary_msg); g_free(freq_s); return ret; -#endif - return -1;; } /* Called on freq and type combo box change. */ |