diff options
author | Gerald Combs <gerald@wireshark.org> | 2012-08-01 22:32:14 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2012-08-01 22:32:14 +0000 |
commit | bd855826a9b15000f8ebf5451b42360abbc4684f (patch) | |
tree | 585c4eb093bfa4bca7d05818d07e32df4236322e | |
parent | 51fd116d6d5f868839db80d43483f30671dfef0f (diff) | |
download | wireshark-bd855826a9b15000f8ebf5451b42360abbc4684f.tar.gz wireshark-bd855826a9b15000f8ebf5451b42360abbc4684f.tar.bz2 wireshark-bd855826a9b15000f8ebf5451b42360abbc4684f.zip |
Move the common parts of iface_lists.[ch] from ui/gtk/ to ui/. Leave the
GTK+-specific parts behind in capture_dlg.c.
svn path=/trunk/; revision=44196
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | ui/Makefile.common | 2 | ||||
-rw-r--r-- | ui/gtk/CMakeLists.txt | 1 | ||||
-rw-r--r-- | ui/gtk/Makefile.common | 2 | ||||
-rw-r--r-- | ui/gtk/capture_dlg.c | 47 | ||||
-rw-r--r-- | ui/gtk/capture_dlg.h | 12 | ||||
-rw-r--r-- | ui/gtk/gtk_iface_monitor.c | 4 | ||||
-rw-r--r-- | ui/gtk/main.c | 14 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 6 | ||||
-rw-r--r-- | ui/gtk/main_welcome.c | 4 | ||||
-rw-r--r-- | ui/gtk/prefs_capture.c | 2 | ||||
-rw-r--r-- | ui/iface_lists.c (renamed from ui/gtk/iface_lists.c) | 136 | ||||
-rw-r--r-- | ui/iface_lists.h (renamed from ui/gtk/iface_lists.h) | 14 |
13 files changed, 127 insertions, 118 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d98b8ecc51..db0ab5296d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -702,6 +702,7 @@ if( (BUILD_wireshark AND GTK_FOUND) OR (BUILD_qtshark AND QT_FOUND) ) tempfile.c u3.c ui/alert_box.c + ui/iface_lists.c ui/util.c ws80211_utils.c ${SHARK_COMMON_CAPTURE_SRC} diff --git a/ui/Makefile.common b/ui/Makefile.common index f220a34ba8..84e166b071 100644 --- a/ui/Makefile.common +++ b/ui/Makefile.common @@ -42,11 +42,13 @@ GENERATOR_FILES = WIRESHARK_UI_SRC = \ alert_box.c \ + iface_lists.c \ util.c noinst_HEADERS = \ alert_box.h \ last_open_dir.h \ + iface_lists.h \ main_statusbar.h \ progress_dlg.h \ recent.h \ diff --git a/ui/gtk/CMakeLists.txt b/ui/gtk/CMakeLists.txt index efc0bb4130..2cfdc469b3 100644 --- a/ui/gtk/CMakeLists.txt +++ b/ui/gtk/CMakeLists.txt @@ -71,7 +71,6 @@ set(WIRESHARK_GTK_SRC gui_utils.c help_dlg.c hostlist_table.c - iface_lists.c macros_dlg.c main.c main_80211_toolbar.c diff --git a/ui/gtk/Makefile.common b/ui/gtk/Makefile.common index 8b805b2612..d1126b787b 100644 --- a/ui/gtk/Makefile.common +++ b/ui/gtk/Makefile.common @@ -96,7 +96,6 @@ WIRESHARK_GTK_SRC = \ gui_utils.c \ help_dlg.c \ hostlist_table.c \ - iface_lists.c \ macros_dlg.c \ main.c \ main_80211_toolbar.c \ @@ -291,7 +290,6 @@ noinst_HEADERS = \ help_dlg.h \ hostlist_table.h \ iax2_analysis.h \ - iface_lists.h \ keys.h \ macros_dlg.h \ main.h \ diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c index d88a0b1b05..d6f7ab1b62 100644 --- a/ui/gtk/capture_dlg.c +++ b/ui/gtk/capture_dlg.c @@ -46,12 +46,12 @@ #include "../capture_ui_utils.h" #include "../ringbuffer.h" +#include "ui/iface_lists.h" #include "ui/recent.h" #include "ui/recent_utils.h" #include "ui/simple_dialog.h" #include "ui/gtk/main.h" -#include "ui/gtk/iface_lists.h" #include "ui/gtk/gui_utils.h" #include "ui/gtk/capture_dlg.h" #include "ui/gtk/filter_dlg.h" @@ -66,6 +66,7 @@ #include "ui/gtk/capture_if_dlg.h" #include "ui/gtk/main_welcome.h" #include "ui/gtk/network_icons.h" +#include "ui/gtk/main_80211_toolbar.h" #include "ui/gtk/keys.h" @@ -4182,7 +4183,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_) g_object_set_data(G_OBJECT(cap_open_w), E_CAP_M_RESOLVE_KEY, m_resolv_cb); g_object_set_data(G_OBJECT(cap_open_w), E_CAP_N_RESOLVE_KEY, n_resolv_cb); g_object_set_data(G_OBJECT(cap_open_w), E_CAP_T_RESOLVE_KEY, t_resolv_cb); - g_object_set_data(G_OBJECT(cap_open_w), E_CAP_E_RESOLVE_KEY, e_resolv_cb); + g_object_set_data(G_OBJECT(cap_open_w), E_CAP_E_RESOLVE_KEY, e_resolv_cb); /* Set the sensitivity of various widgets as per the settings of other widgets. */ @@ -4951,4 +4952,46 @@ gboolean capture_dlg_window_present(void) return (cap_open_w?TRUE:FALSE); } +/* + * Refresh everything visible that shows an interface list that + * includes local interfaces. + */ +void +refresh_local_interface_lists(void) +{ + /* Reload the local interface list. */ + scan_local_interfaces(); + + /* If there's an interfaces dialog up, refresh it. */ + if (interfaces_dialog_window_present()) + refresh_if_window(); + + /* If there's a capture options dialog up, refresh it. */ + if (capture_dlg_window_present()) + capture_dlg_refresh_if(); + + /* If the welcome screen is up, refresh its interface list. */ + if (get_welcome_window() != NULL) + welcome_if_panel_reload(); + + /* Refresh the 802.11 toolbar. */ + tb80211_refresh_interfaces(); +} + +/* + * Refresh everything visible that shows an interface list that + * includes non-local interfaces. + */ +void +refresh_non_local_interface_lists(void) +{ + /* If there's a capture options dialog up, refresh it. */ + if (capture_dlg_window_present()) + capture_dlg_refresh_if(); + + /* If the welcome screen is up, refresh its interface list. */ + if (get_welcome_window() != NULL) + welcome_if_panel_reload(); +} + #endif /* HAVE_LIBPCAP */ diff --git a/ui/gtk/capture_dlg.h b/ui/gtk/capture_dlg.h index ba6b3f0115..9efd48d5fe 100644 --- a/ui/gtk/capture_dlg.h +++ b/ui/gtk/capture_dlg.h @@ -114,4 +114,16 @@ options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *co void capture_dlg_refresh_if(void); +/* + * Refresh everything visible that shows an interface list that + * includes local interfaces. + */ +extern void refresh_local_interface_lists(void); + +/* + * Refresh everything visible that shows an interface list that + * includes non-local interfaces. + */ +extern void refresh_non_local_interface_lists(void); + #endif /* capture_dlg.h */ diff --git a/ui/gtk/gtk_iface_monitor.c b/ui/gtk/gtk_iface_monitor.c index bb64d7676a..99aaa4e95a 100644 --- a/ui/gtk/gtk_iface_monitor.c +++ b/ui/gtk/gtk_iface_monitor.c @@ -36,8 +36,10 @@ #include "capture_opts.h" -#include "ui/gtk/iface_lists.h" +#include "ui/iface_lists.h" + #include "ui/gtk/capture_globals.h" +#include "ui/gtk/capture_dlg.h" GIOChannel *iface_mon_channel; diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 1652b73cf0..22cb36830a 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -111,6 +111,10 @@ #include "ui/simple_dialog.h" #include "ui/ui_util.h" +#ifdef HAVE_LIBPCAP +#include "ui/iface_lists.h" +#endif + #include <wsutil/file_util.h> #ifdef HAVE_LIBPCAP @@ -173,10 +177,6 @@ #include "ui/gtk/new_packet_list.h" #include "ui/gtk/filter_expression_save_dlg.h" -#ifdef HAVE_LIBPCAP -#include "ui/gtk/iface_lists.h" -#endif - #include "ui/gtk/old-gtk-compat.h" #ifdef HAVE_LIBPCAP @@ -2588,7 +2588,7 @@ main(int argc, char *argv[]) prefs_to_capture_opts(); /*#ifdef HAVE_LIBPCAP - fill_in_local_interfaces(&global_capture_opts); + fill_in_local_interfaces(); #endif*/ /* Now get our args */ while ((opt = getopt(argc, argv, optstring)) != -1) { @@ -2831,9 +2831,9 @@ main(int argc, char *argv[]) print_usage(FALSE); exit(1); } - + #ifdef HAVE_LIBPCAP - fill_in_local_interfaces(&global_capture_opts); + fill_in_local_interfaces(); if (start_capture && list_link_layer_types) { /* Specifying *both* is bogus. */ cmdarg_err("You can't specify both -L and a live capture."); diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index 4a07ad6c35..fc992e968e 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -54,10 +54,11 @@ #include "../stat_menu.h" #include "../u3.h" -#include "ui/ui_util.h" +#include "ui/iface_lists.h" +#include "ui/main_statusbar.h" #include "ui/recent.h" #include "ui/simple_dialog.h" -#include "ui/main_statusbar.h" +#include "ui/ui_util.h" #include "ui/utf8_entities.h" #include "ui/gtk/about_dlg.h" @@ -97,7 +98,6 @@ #include "epan/dissectors/packet-ssl-utils.h" #include "ui/gtk/export_sslkeys.h" #include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/iface_lists.h" #include "ui/gtk/main.h" #include "ui/gtk/menus.h" #include "ui/gtk/main_menubar_private.h" diff --git a/ui/gtk/main_welcome.c b/ui/gtk/main_welcome.c index 246789d97f..2ea1595920 100644 --- a/ui/gtk/main_welcome.c +++ b/ui/gtk/main_welcome.c @@ -41,6 +41,7 @@ #include <wsutil/file_util.h> +#include "ui/iface_lists.h" #include "ui/recent.h" #include "ui/simple_dialog.h" #include "ui/utf8_entities.h" @@ -48,7 +49,6 @@ #include "ui/gtk/gui_utils.h" #include "ui/gtk/color_utils.h" #include "ui/gtk/gtkglobals.h" -#include "ui/gtk/iface_lists.h" #include "ui/gtk/main.h" #include "ui/gtk/menus.h" #include "ui/gtk/main_welcome.h" @@ -1267,7 +1267,7 @@ welcome_new(void) g_object_set_data(G_OBJECT(welcome_hb), CAPTURE_VIEW, topic_capture_to_fill); #ifdef HAVE_LIBPCAP - fill_in_local_interfaces(&global_capture_opts); + fill_in_local_interfaces(); fill_capture_box(); /* capture help topic */ diff --git a/ui/gtk/prefs_capture.c b/ui/gtk/prefs_capture.c index 9e8d147205..096725cef8 100644 --- a/ui/gtk/prefs_capture.c +++ b/ui/gtk/prefs_capture.c @@ -33,6 +33,7 @@ #include <epan/prefs.h> +#include "ui/iface_lists.h" #include "ui/simple_dialog.h" #include "../capture_ifinfo.h" #include "../capture_ui_utils.h" @@ -41,7 +42,6 @@ #include "ui/gtk/prefs_dlg.h" #include "ui/gtk/gui_utils.h" #include "ui/gtk/dlg_utils.h" -#include "ui/gtk/iface_lists.h" #include "ui/gtk/capture_globals.h" #include "ui/gtk/main_welcome.h" #include "ui/gtk/help_dlg.h" diff --git a/ui/gtk/iface_lists.c b/ui/iface_lists.c index 4db0acedb5..96d5cd915a 100644 --- a/ui/gtk/iface_lists.c +++ b/ui/iface_lists.c @@ -38,13 +38,15 @@ #include "../capture_ui_utils.h" +/* #include "ui/gtk/capture_dlg.h" #include "ui/gtk/capture_if_dlg.h" #include "ui/gtk/capture_globals.h" #include "ui/gtk/main_welcome.h" #include "ui/gtk/main_80211_toolbar.h" +*/ -#include "ui/gtk/iface_lists.h" +#include "ui/iface_lists.h" capture_options global_capture_opts; @@ -70,8 +72,8 @@ if_list_comparator_alph(const void *first_arg, const void *second_arg) * and set the list of "all interfaces" in *capture_opts to include * those interfaces. */ -static void -scan_local_interfaces(capture_options* capture_opts) +void +scan_local_interfaces(void) { GList *if_entry, *lt_entry, *if_list; if_info_t *if_info, *temp; @@ -90,13 +92,13 @@ scan_local_interfaces(capture_options* capture_opts) GString *ip_str; interface_options interface_opts; gboolean found = FALSE; - - if (capture_opts->all_ifaces->len > 0) { - for (i = (int)capture_opts->all_ifaces->len-1; i >= 0; i--) { - device = g_array_index(capture_opts->all_ifaces, interface_t, i); + + if (global_capture_opts.all_ifaces->len > 0) { + for (i = (int)global_capture_opts.all_ifaces->len-1; i >= 0; i--) { + device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); if (device.local) { - capture_opts->all_ifaces = g_array_remove_index(capture_opts->all_ifaces, i); + global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i); } } } @@ -145,7 +147,7 @@ scan_local_interfaces(capture_options* capture_opts) device.selected = FALSE; if (prefs_is_capture_device_hidden(if_info->name)) { device.hidden = TRUE; - } + } device.type = get_interface_type(if_info->name, if_info->description); cap_settings = capture_get_cap_settings(if_info->name); caps = capture_get_if_capabilities(if_info->name, cap_settings.monitor_mode, NULL); @@ -181,18 +183,18 @@ scan_local_interfaces(capture_options* capture_opts) #ifdef HAVE_PCAP_REMOTE device.local = TRUE; device.remote_opts.src_type = CAPTURE_IFLOCAL; - device.remote_opts.remote_host_opts.remote_host = g_strdup(capture_opts->default_options.remote_host); - device.remote_opts.remote_host_opts.remote_port = g_strdup(capture_opts->default_options.remote_port); - device.remote_opts.remote_host_opts.auth_type = capture_opts->default_options.auth_type; - device.remote_opts.remote_host_opts.auth_username = g_strdup(capture_opts->default_options.auth_username); - device.remote_opts.remote_host_opts.auth_password = g_strdup(capture_opts->default_options.auth_password); - device.remote_opts.remote_host_opts.datatx_udp = capture_opts->default_options.datatx_udp; - device.remote_opts.remote_host_opts.nocap_rpcap = capture_opts->default_options.nocap_rpcap; - device.remote_opts.remote_host_opts.nocap_local = capture_opts->default_options.nocap_local; + device.remote_opts.remote_host_opts.remote_host = g_strdup(global_capture_opts.default_options.remote_host); + device.remote_opts.remote_host_opts.remote_port = g_strdup(global_capture_opts.default_options.remote_port); + device.remote_opts.remote_host_opts.auth_type = global_capture_opts.default_options.auth_type; + device.remote_opts.remote_host_opts.auth_username = g_strdup(global_capture_opts.default_options.auth_username); + device.remote_opts.remote_host_opts.auth_password = g_strdup(global_capture_opts.default_options.auth_password); + device.remote_opts.remote_host_opts.datatx_udp = global_capture_opts.default_options.datatx_udp; + device.remote_opts.remote_host_opts.nocap_rpcap = global_capture_opts.default_options.nocap_rpcap; + device.remote_opts.remote_host_opts.nocap_local = global_capture_opts.default_options.nocap_local; #endif #ifdef HAVE_PCAP_SETSAMPLING - device.remote_opts.sampling_method = capture_opts->default_options.sampling_method; - device.remote_opts.sampling_param = capture_opts->default_options.sampling_param; + device.remote_opts.sampling_method = global_capture_opts.default_options.sampling_method; + device.remote_opts.sampling_param = global_capture_opts.default_options.sampling_param; #endif linktype_count = 0; device.links = NULL; @@ -200,7 +202,7 @@ scan_local_interfaces(capture_options* capture_opts) #if defined(HAVE_PCAP_CREATE) device.monitor_mode_enabled = cap_settings.monitor_mode; device.monitor_mode_supported = caps->can_set_rfmon; -#endif +#endif for (lt_entry = caps->data_link_types; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) { data_link_info = lt_entry->data; if (linktype_count == 0) { @@ -230,53 +232,53 @@ scan_local_interfaces(capture_options* capture_opts) device.local = TRUE; device.if_info = *temp; device.last_packets = 0; - device.pmode = capture_opts->default_options.promisc_mode; - device.has_snaplen = capture_opts->default_options.has_snaplen; - device.snaplen = capture_opts->default_options.snaplen; - device.cfilter = g_strdup(capture_opts->default_options.cfilter); + device.pmode = global_capture_opts.default_options.promisc_mode; + device.has_snaplen = global_capture_opts.default_options.has_snaplen; + device.snaplen = global_capture_opts.default_options.snaplen; + device.cfilter = g_strdup(global_capture_opts.default_options.cfilter); #if defined(_WIN32) || defined(HAVE_PCAP_CREATE) device.buffer = 1; #endif - - if (capture_opts->ifaces->len > 0) { - for (j = 0; j < capture_opts->ifaces->len; j++) { - interface_opts = g_array_index(capture_opts->ifaces, interface_options, j); - if (strcmp(interface_opts.name, device.name) == 0) { + + if (global_capture_opts.ifaces->len > 0) { + for (j = 0; j < global_capture_opts.ifaces->len; j++) { + interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, j); + if (strcmp(interface_opts.name, device.name) == 0) { #if defined(HAVE_PCAP_CREATE) device.buffer = interface_opts.buffer_size; device.monitor_mode_enabled = interface_opts.monitor_mode; #endif device.pmode = interface_opts.promisc_mode; device.has_snaplen = interface_opts.has_snaplen; - device.snaplen = interface_opts.snaplen; + device.snaplen = interface_opts.snaplen; device.cfilter = g_strdup(interface_opts.cfilter); device.active_dlt = interface_opts.linktype; device.selected = TRUE; - capture_opts->num_selected++; + global_capture_opts.num_selected++; break; } } } - if (capture_opts->all_ifaces->len <= count) { - g_array_append_val(capture_opts->all_ifaces, device); - count = capture_opts->all_ifaces->len; + if (global_capture_opts.all_ifaces->len <= count) { + g_array_append_val(global_capture_opts.all_ifaces, device); + count = global_capture_opts.all_ifaces->len; } else { - g_array_insert_val(capture_opts->all_ifaces, count, device); + g_array_insert_val(global_capture_opts.all_ifaces, count, device); } if (caps != NULL) { free_if_capabilities(caps); } - + g_string_free(ip_str, TRUE); count++; } free_interface_list(if_list); /* see whether there are additional interfaces in ifaces */ - for (j = 0; j < capture_opts->ifaces->len; j++) { - interface_opts = g_array_index(capture_opts->ifaces, interface_options, j); + for (j = 0; j < global_capture_opts.ifaces->len; j++) { + interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, j); found = FALSE; - for (i = 0; i < (int)capture_opts->all_ifaces->len; i++) { - device = g_array_index(capture_opts->all_ifaces, interface_t, i); + for (i = 0; i < (int)global_capture_opts.all_ifaces->len; i++) { + device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); if (strcmp(device.name, interface_opts.name) == 0) { found = TRUE; break; @@ -297,7 +299,7 @@ scan_local_interfaces(capture_options* capture_opts) #endif device.pmode = interface_opts.promisc_mode; device.has_snaplen = interface_opts.has_snaplen; - device.snaplen = interface_opts.snaplen; + device.snaplen = interface_opts.snaplen; device.cfilter = g_strdup(interface_opts.cfilter); device.active_dlt = interface_opts.linktype; device.addresses = NULL; @@ -311,8 +313,8 @@ scan_local_interfaces(capture_options* capture_opts) device.if_info.addrs = NULL; device.if_info.loopback = FALSE; - g_array_append_val(capture_opts->all_ifaces, device); - capture_opts->num_selected++; + g_array_append_val(global_capture_opts.all_ifaces, device); + global_capture_opts.num_selected++; } } } @@ -322,58 +324,16 @@ scan_local_interfaces(capture_options* capture_opts) * done so already. */ void -fill_in_local_interfaces(capture_options* capture_opts) +fill_in_local_interfaces(void) { static gboolean initialized = FALSE; if (!initialized) { - scan_local_interfaces(capture_opts); + scan_local_interfaces(); initialized = TRUE; } } -/* - * Refresh everything visible that shows an interface list that - * includes local interfaces. - */ -void -refresh_local_interface_lists(void) -{ - /* Reload the local interface list. */ - scan_local_interfaces(&global_capture_opts); - - /* If there's an interfaces dialog up, refresh it. */ - if (interfaces_dialog_window_present()) - refresh_if_window(); - - /* If there's a capture options dialog up, refresh it. */ - if (capture_dlg_window_present()) - capture_dlg_refresh_if(); - - /* If the welcome screen is up, refresh its interface list. */ - if (get_welcome_window() != NULL) - welcome_if_panel_reload(); - - /* Refresh the 802.11 toolbar. */ - tb80211_refresh_interfaces(); -} - -/* - * Refresh everything visible that shows an interface list that - * includes non-local interfaces. - */ -void -refresh_non_local_interface_lists(void) -{ - /* If there's a capture options dialog up, refresh it. */ - if (capture_dlg_window_present()) - capture_dlg_refresh_if(); - - /* If the welcome screen is up, refresh its interface list. */ - if (get_welcome_window() != NULL) - welcome_if_panel_reload(); -} - void hide_interface(gchar* new_hide) { @@ -400,7 +360,7 @@ hide_interface(gchar* new_hide) found = TRUE; break; } - } + } if (!found) { device.hidden = FALSE; } diff --git a/ui/gtk/iface_lists.h b/ui/iface_lists.h index ee955059f7..cd528f603b 100644 --- a/ui/gtk/iface_lists.h +++ b/ui/iface_lists.h @@ -37,22 +37,14 @@ 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 * done so already. */ -extern void fill_in_local_interfaces(capture_options* capture_opts); +extern void fill_in_local_interfaces(void); /* - * Refresh everything visible that shows an interface list that - * includes local interfaces. + * Update the global interface list. */ -extern void refresh_local_interface_lists(void); - -/* - * Refresh everything visible that shows an interface list that - * includes non-local interfaces. - */ -extern void refresh_non_local_interface_lists(void); +extern void scan_local_interfaces(void); extern void hide_interface(gchar* new_hide); #endif /* HAVE_LIBPCAP */ #endif /* __IFACE_LISTS_H__ */ - |