2 * Routines for the capture interface dialog
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #include <sys/types.h>
40 #include <epan/prefs.h>
42 #include "../globals.h"
43 #include "../capture-pcap-util.h"
44 #include "../simple_dialog.h"
45 #include "../capture.h"
46 #include "../capture_errs.h"
47 #include "../capture_ui_utils.h"
48 #include "wsutil/file_util.h"
49 #include <wiretap/wtap.h>
52 #include "../capture-wpcap.h"
53 #include "gtk/capture_if_details_dlg_win32.h"
56 #include "gtk/stock_icons.h"
57 #include "gtk/capture_dlg.h"
58 #include "gtk/capture_if_dlg.h"
59 #include "gtk/recent.h"
60 #include "gtk/gui_utils.h"
61 #include "gtk/dlg_utils.h"
63 #include "gtk/main_toolbar.h"
64 #include "gtk/help_dlg.h"
66 #include "gtk/webbrowser.h"
67 #include "gtk/capture_globals.h"
68 #include "gtk/network_icons.h"
71 #include "../image/toolbar/capture_airpcap_16.xpm"
75 #include "../image/toolbar/capture_ethernet_16.xpm"
76 #include "../image/toolbar/modem_16.xpm"
79 #include "../image/toolbar/network_virtual_16.xpm"
81 /* new buttons to be used instead of labels for 'Capture','Prepare',' */
82 /*#include "../image/toolbar/capture_capture_16.xpm"*/
83 /*#include "../image/toolbar/capture_prepare_16.xpm"*/
84 /*#include "../image/toolbar/capture_details_16.xpm"*/
89 #include "airpcap_loader.h"
90 #include "airpcap_gui_utils.h"
91 #include "airpcap_dlg.h"
94 #define CAPTURE_IF_IP_ADDR_LABEL "capture_if_ip_addr_label"
95 #define CAPTURE_IF_SELECTED_IP_ADDR "capture_if_selected_ip_addr"
98 * Keep a static pointer to the current "Capture Interfaces" window, if
99 * any, so that if somebody tries to do "Capture:Start" while there's
100 * already a "Capture Interfaces" window up, we just pop up the existing
101 * one, rather than creating a new one.
103 static GtkWidget *cap_if_w;
105 GList *if_data = NULL;
114 * Timeout, in milliseconds, for reads from the stream of captured packets.
116 #define CAP_READ_TIMEOUT 250
119 /* the "runtime" data of one interface */
120 typedef struct if_dlg_data_s {
121 GtkWidget *device_lb;
126 GtkWidget *capture_bt;
127 GtkWidget *prepare_bt;
129 GtkWidget *details_bt;
131 guint32 last_packets;
137 /* start capture button was pressed */
139 capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
141 if_dlg_data_t *if_dlg_data = if_data;
144 airpcap_if_active = get_airpcap_if_from_name(airpcap_if_list, if_dlg_data->if_info.name);
145 airpcap_if_selected = airpcap_if_active;
148 g_free(global_capture_opts.iface);
149 g_free(global_capture_opts.iface_descr);
151 global_capture_opts.iface = g_strdup(if_dlg_data->device);
152 global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
154 /* XXX - remove this? */
155 if (global_capture_opts.save_file) {
156 g_free(global_capture_opts.save_file);
157 global_capture_opts.save_file = NULL;
160 /* stop capturing from all interfaces, we are going to do real work now ... */
161 window_destroy(cap_if_w);
163 capture_start_cb(NULL, NULL);
167 /* prepare capture button was pressed */
169 capture_prepare_cb(GtkWidget *prepare_bt _U_, gpointer if_data)
171 if_dlg_data_t *if_dlg_data = if_data;
173 g_free(global_capture_opts.iface);
174 g_free(global_capture_opts.iface_descr);
176 global_capture_opts.iface = g_strdup(if_dlg_data->device);
177 global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
179 /* stop capturing from all interfaces, we are going to do real work now ... */
180 window_destroy(cap_if_w);
182 capture_prep_cb(NULL, NULL);
187 /* capture details button was pressed */
189 capture_details_cb(GtkWidget *details_bt _U_, gpointer if_data)
191 if_dlg_data_t *if_dlg_data = if_data;
194 capture_if_details_open(if_dlg_data->device);
198 /* update a single interface */
200 update_if(if_dlg_data_t *if_dlg_data, if_stat_cache_t *sc)
202 struct pcap_stat stats;
208 * Note that some versions of libpcap, on some versions of UN*X,
209 * pcap_stats() returns the number of packets since the last
212 * That's a bug, and should be fixed; "pcap_stats()" is supposed
213 * to work the same way on all platforms.
216 if(capture_stats(sc, if_dlg_data->device, &stats)) {
217 diff = stats.ps_recv - if_dlg_data->last_packets;
218 if_dlg_data->last_packets = stats.ps_recv;
220 str = g_strdup_printf("%u", if_dlg_data->last_packets);
221 gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), str);
223 str = g_strdup_printf("%u", diff);
224 gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), str);
227 gtk_widget_set_sensitive(if_dlg_data->curr_lb, diff);
228 gtk_widget_set_sensitive(if_dlg_data->last_lb, diff);
230 gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), "error");
231 gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), "error");
236 /* update all interfaces */
238 update_all(gpointer data)
242 if_stat_cache_t *sc = data;
248 for(ifs = 0; (curr = g_list_nth(if_data, ifs)); ifs++) {
249 update_if(curr->data, sc);
255 gboolean g_capture_in_progress = FALSE;
257 /* a live capture has started or stopped */
259 set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
264 g_capture_in_progress = capture_in_progress;
267 gtk_widget_set_sensitive(stop_bt, capture_in_progress);
269 for(ifs = 0; (curr = g_list_nth(if_data, ifs)); ifs++) {
270 if_dlg_data_t *if_dlg_data = curr->data;
272 gtk_widget_set_sensitive(if_dlg_data->capture_bt, !capture_in_progress);
273 gtk_widget_set_sensitive(if_dlg_data->prepare_bt, !capture_in_progress);
279 /* the window was closed, cleanup things */
281 capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data)
285 if_stat_cache_t *sc = user_data;
287 g_source_remove(timer_id);
289 for(ifs = 0; (curr = g_list_nth(if_data, ifs)); ifs++) {
295 free_interface_list(if_list);
297 /* Note that we no longer have a "Capture Options" dialog box. */
300 capture_stat_stop(sc);
303 airpcap_set_toolbar_stop_capture(airpcap_if_active);
309 * Sorts the Interface List in alphabetical order
311 gint if_list_comparator_alph (const void *first_arg, const void *second_arg){
312 const if_info_t *first = first_arg, *second = second_arg;
314 if (first != NULL && first->description != NULL &&
315 second != NULL && second->description != NULL) {
316 return g_ascii_strcasecmp(first->description, second->description);
324 * Used to retrieve the interface icon.
325 * This is hideously platform-dependent.
327 GtkWidget * capture_get_if_icon(const if_info_t* if_info _U_)
331 * Much digging failed to reveal any obvious way to get something such
332 * as the SNMP MIB-II ifType value for an interface:
334 * http://www.iana.org/assignments/ianaiftype-mib
336 * by making some NDIS request.
338 if ( if_info->description && ( strstr(if_info->description,"generic dialup") != NULL ||
339 strstr(if_info->description,"PPP/SLIP") != NULL ) ) {
340 return xpm_to_widget(modem_16_xpm);
343 if ( if_info->description && ( strstr(if_info->description,"Wireless") != NULL ||
344 strstr(if_info->description,"802.11") != NULL || strstr(if_info->description,"AirPcap") != NULL ) ) {
345 return pixbuf_to_widget(network_wireless_pb_data);
348 if ( strstr(if_info->name,"airpcap") != NULL ) {
349 return pixbuf_to_widget(network_wireless_pb_data);
352 if ( if_info->description && strstr(if_info->description, "Bluetooth") != NULL ) {
353 return pixbuf_to_widget(network_bluetooth_pb_data);
355 #elif defined(__APPLE__)
357 * XXX - yes, fetching all the network addresses for an interface
358 * gets you an AF_LINK address, of type "struct sockaddr_dl", and,
359 * yes, that includes an SNMP MIB-II ifType value.
361 * However, it's IFT_ETHER, i.e. Ethernet, for AirPort interfaces,
362 * not IFT_IEEE80211 (which isn't defined in OS X in any case).
364 * Perhaps some other BSD-flavored OSes won't make this mistake;
365 * however, FreeBSD 7.0 and OpenBSD 4.2, at least, appear to have
366 * made the same mistake, at least for my Belkin ZyDAS stick.
368 * On Mac OS X, one might be able to get the information one wants from
371 if ( strcmp(if_info->name, "en1") == 0) {
372 return pixbuf_to_widget(network_wireless_pb_data);
376 * XXX - PPP devices have names beginning with "ppp" and an IFT_ of
377 * IFT_PPP, but they could be dial-up, or PPPoE, or mobile phone modem,
378 * or VPN, or... devices. One might have to dive into the bowels of
383 * XXX - there's currently no support for raw Bluetooth capture,
384 * and IP-over-Bluetooth devices just look like fake Ethernet
385 * devices. There's also Bluetooth modem support, but that'll
386 * probably just give you a device that looks like a PPP device.
388 #elif defined(__linux__)
390 * Look for /sys/class/net/{device}/wireless.
395 wireless_path = g_strdup_printf("/sys/class/net/%s/wireless", if_info->name);
396 if (wireless_path != NULL) {
397 if (ws_stat(wireless_path, &statb) == 0) {
398 g_free(wireless_path);
399 return pixbuf_to_widget(network_wireless_pb_data);
401 g_free(wireless_path);
407 * XXX - this is for raw Bluetooth capture; what about IP-over-Bluetooth
410 if ( strstr(if_info->name,"bluetooth") != NULL) {
411 return pixbuf_to_widget(network_bluetooth_pb_data);
417 if ( strstr(if_info->name,"usbmon") != NULL ) {
418 return pixbuf_to_widget(network_usb_pb_data);
423 * TODO: find a better icon!
424 * Bridge, NAT, or host-only interfaces on VMWare hosts have the name
425 * vmnet[0-9]+ or VMnet[0-9+ on Windows. Guests might use a native
426 * (LANCE or E1000) driver or the vmxnet driver. These devices have an
427 * IFT_ of IFT_ETHER, so we have to check the name.
429 if ( g_ascii_strncasecmp(if_info->name, "vmnet", 5) == 0) {
430 return xpm_to_widget(network_virtual_16_xpm);
433 if ( g_ascii_strncasecmp(if_info->name, "vmxnet", 6) == 0) {
434 return xpm_to_widget(network_virtual_16_xpm);
437 if ( if_info->description && strstr(if_info->description, "VMware") != NULL ) {
438 return xpm_to_widget(network_virtual_16_xpm);
441 return pixbuf_to_widget(network_wired_pb_data);
446 set_ip_addr_label(GSList *ip_addr_list, GtkWidget *ip_lb, guint selected_ip_addr)
450 const gchar *addr_str = NULL;
452 curr_ip = g_slist_nth(ip_addr_list, selected_ip_addr);
454 ip_addr = (if_addr_t *)curr_ip->data;
455 switch (ip_addr->type) {
458 addr_str = ip_to_str((guint8 *)&ip_addr->ip_addr.ip4_addr);
462 addr_str = ip6_to_str((struct e_in6_addr *)&ip_addr->ip_addr.ip6_addr);
466 g_assert_not_reached();
471 gtk_label_set_text(GTK_LABEL(ip_lb), addr_str);
473 gtk_label_set_text(GTK_LABEL(ip_lb), "unknown");
475 g_object_set_data(G_OBJECT(ip_lb), CAPTURE_IF_SELECTED_IP_ADDR, GINT_TO_POINTER(selected_ip_addr));
482 ip_label_enter_cb(GtkWidget *eb, GdkEventCrossing *event _U_, gpointer user_data _U_)
484 gtk_widget_set_state(eb, GTK_STATE_PRELIGHT);
491 ip_label_leave_cb(GtkWidget *eb, GdkEvent *event _U_, gpointer user_data _U_)
493 gtk_widget_set_state(eb, GTK_STATE_NORMAL);
500 ip_label_press_cb(GtkWidget *widget, GdkEvent *event _U_, gpointer data)
502 GtkWidget *ip_lb = g_object_get_data(G_OBJECT(widget), CAPTURE_IF_IP_ADDR_LABEL);
503 GSList *ip_addr_list = data;
504 guint selected_ip_addr = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(ip_lb), CAPTURE_IF_SELECTED_IP_ADDR));
506 /* Select next IP address */
508 if (g_slist_length(ip_addr_list) <= selected_ip_addr) {
509 /* Probably have the last one, start over again */
510 selected_ip_addr = 0;
513 set_ip_addr_label(ip_addr_list, ip_lb, selected_ip_addr);
520 /* start getting capture stats from all interfaces */
522 capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
532 GtkWidget *decryption_cb;
538 GtkTooltips *tooltips;
541 GtkRequisition requisition;
543 if_dlg_data_t *if_dlg_data;
547 GString *if_tool_str = g_string_new("");
548 const gchar *addr_str;
553 if (cap_if_w != NULL) {
554 /* There's already a "Capture Interfaces" dialog box; reactivate it. */
555 reactivate_window(cap_if_w);
560 /* Is WPcap loaded? */
564 detailed_err = cant_load_winpcap_err("Wireshark");
565 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", detailed_err);
566 g_free(detailed_err);
571 /* LOAD THE INTERFACES */
572 if_list = capture_interface_list(&err, &err_str);
573 if_list = g_list_sort (if_list, if_list_comparator_alph);
574 if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
575 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
581 /* LOAD AIRPCAP INTERFACES */
582 airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
583 if (airpcap_if_list == NULL)
584 airpcap_if_active = airpcap_if_selected = NULL;
586 decryption_cb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
587 update_decryption_mode_list(decryption_cb);
589 if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
591 /* XXX - Do we need to show an error here? */
592 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
597 /* If no airpcap interface is present, gray everything */
598 if (airpcap_if_active == NULL) {
599 if (airpcap_if_list == NULL) {
600 /*No airpcap device found */
601 airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
603 /* default adapter is not airpcap... or is airpcap but is not found*/
604 airpcap_set_toolbar_stop_capture(airpcap_if_active);
605 airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
609 airpcap_set_toolbar_start_capture(airpcap_if_active);
612 cap_if_w = dlg_window_new("Wireshark: Capture Interfaces"); /* transient_for top_level */
613 gtk_window_set_destroy_with_parent (GTK_WINDOW(cap_if_w), TRUE);
615 tooltips = gtk_tooltips_new();
617 main_sw = gtk_scrolled_window_new(NULL, NULL);
618 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(main_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
619 gtk_container_add(GTK_CONTAINER(cap_if_w), main_sw);
621 main_vb = gtk_vbox_new(FALSE, 0);
622 gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
623 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(main_sw), main_vb);
626 if_tb = gtk_table_new(1,9, FALSE);
627 gtk_table_set_row_spacings(GTK_TABLE(if_tb), 3);
628 gtk_table_set_col_spacings(GTK_TABLE(if_tb), 3);
629 gtk_box_pack_start(GTK_BOX(main_vb), if_tb, FALSE, FALSE, 0);
634 /* This is the icon column, used to display which kind of interface we have */
635 if_lb = gtk_label_new("");
636 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 0, 1, row, row+1);
640 * On Windows, device names are generally not meaningful - NT 5
641 * uses long blobs with GUIDs in them, for example - so we don't
642 * bother showing them.
644 if_lb = gtk_label_new("Device");
645 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 1, 2, row, row+1);
648 if_lb = gtk_label_new("Description");
649 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 2, 3, row, row+1);
651 if_lb = gtk_label_new(" IP ");
652 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 3, 4, row, row+1);
654 if_lb = gtk_label_new("Packets");
655 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 4, 5, row, row+1);
657 if_lb = gtk_label_new(" Packets/s ");
658 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 5, 6, row, row+1);
660 stop_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_STOP);
661 gtk_tooltips_set_tip(tooltips, stop_bt,
662 "Stop a running capture.", NULL);
664 gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 6, 9, row, row+1);
666 gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 6, 8, row, row+1);
668 g_signal_connect(stop_bt, "clicked", G_CALLBACK(capture_stop_cb), NULL);
671 gtk_widget_size_request(stop_bt, &requisition);
672 height += requisition.height + 15;
674 /* Start gathering statistics (using dumpcap) */
675 sc = capture_stat_start(if_list);
677 /* List the interfaces */
678 for(ifs = 0; (curr = g_list_nth(if_list, ifs)); ifs++) {
679 g_string_assign(if_tool_str, "");
680 if_info = curr->data;
682 /* Continue if capture device is hidden */
683 if (prefs_is_capture_device_hidden(if_info->name)) {
687 if_dlg_data = g_malloc0(sizeof(if_dlg_data_t));
688 if_dlg_data->if_info = *if_info;
690 /* Kind of adaptor (icon) */
692 if(get_airpcap_if_from_name(airpcap_if_list,if_info->name) != NULL)
693 icon = xpm_to_widget(capture_airpcap_16_xpm);
695 icon = capture_get_if_icon(if_info);
697 icon = capture_get_if_icon(if_info);
700 gtk_table_attach_defaults(GTK_TABLE(if_tb), icon, 0, 1, row, row+1);
703 if_dlg_data->device_lb = gtk_label_new(if_info->name);
704 if_dlg_data->device = if_info->name;
706 gtk_misc_set_alignment(GTK_MISC(if_dlg_data->device_lb), 0.0f, 0.5f);
707 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->device_lb, 1, 2, row, row+1);
709 g_string_append(if_tool_str, "Device: ");
710 g_string_append(if_tool_str, if_info->name);
711 g_string_append(if_tool_str, "\n");
714 user_descr = capture_dev_user_descr_find(if_info->name);
716 if_dlg_data->descr_lb = gtk_label_new(user_descr);
719 if (if_info->description)
720 if_dlg_data->descr_lb = gtk_label_new(if_info->description);
722 if_dlg_data->descr_lb = gtk_label_new("");
724 gtk_misc_set_alignment(GTK_MISC(if_dlg_data->descr_lb), 0.0f, 0.5f);
725 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->descr_lb, 2, 3, row, row+1);
727 if (if_info->description) {
728 g_string_append(if_tool_str, "Description: ");
729 g_string_append(if_tool_str, if_info->description);
730 g_string_append(if_tool_str, "\n");
734 /* Only one IP address will be shown, start with the first */
735 g_string_append(if_tool_str, "IP: ");
736 if_dlg_data->ip_lb = gtk_label_new("");
737 addr_str = set_ip_addr_label (if_info->ip_addr, if_dlg_data->ip_lb, 0);
739 gtk_widget_set_sensitive(if_dlg_data->ip_lb, TRUE);
740 g_string_append(if_tool_str, addr_str);
742 gtk_widget_set_sensitive(if_dlg_data->ip_lb, FALSE);
743 g_string_append(if_tool_str, "unknown");
745 eb = gtk_event_box_new ();
746 gtk_container_add(GTK_CONTAINER(eb), if_dlg_data->ip_lb);
747 gtk_table_attach_defaults(GTK_TABLE(if_tb), eb, 3, 4, row, row+1);
748 if (g_slist_length(if_info->ip_addr) > 1) {
749 /* More than one IP address, make it possible to toggle */
750 g_object_set_data(G_OBJECT(eb), CAPTURE_IF_IP_ADDR_LABEL, if_dlg_data->ip_lb);
751 g_signal_connect(eb, "enter-notify-event", G_CALLBACK(ip_label_enter_cb), NULL);
752 g_signal_connect(eb, "leave-notify-event", G_CALLBACK(ip_label_leave_cb), NULL);
753 g_signal_connect(eb, "button-press-event", G_CALLBACK(ip_label_press_cb), if_info->ip_addr);
755 g_string_append(if_tool_str, "\n");
758 if_dlg_data->curr_lb = gtk_label_new("-");
759 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->curr_lb, 4, 5, row, row+1);
762 if_dlg_data->last_lb = gtk_label_new("-");
763 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->last_lb, 5, 6, row, row+1);
766 if_dlg_data->capture_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_START);
767 g_signal_connect(if_dlg_data->capture_bt, "clicked", G_CALLBACK(capture_do_cb), if_dlg_data);
768 tmp_str = g_strdup_printf("Immediately start a capture from this interface:\n\n%s", if_tool_str->str);
769 gtk_tooltips_set_tip(tooltips, if_dlg_data->capture_bt,
772 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->capture_bt, 6, 7, row, row+1);
775 if_dlg_data->prepare_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_OPTIONS);
776 g_signal_connect(if_dlg_data->prepare_bt, "clicked", G_CALLBACK(capture_prepare_cb), if_dlg_data);
777 gtk_tooltips_set_tip(tooltips, if_dlg_data->prepare_bt,
778 "Open the capture options dialog with this interface selected.", NULL);
779 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->prepare_bt, 7, 8, row, row+1);
783 if_dlg_data->details_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_DETAILS);
784 gtk_tooltips_set_tip(tooltips, if_dlg_data->details_bt,
785 "Open the capture details dialog of this interface.", NULL);
786 gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->details_bt, 8, 9, row, row+1);
787 if (capture_if_has_details(if_dlg_data->device)) {
788 g_signal_connect(if_dlg_data->details_bt, "clicked", G_CALLBACK(capture_details_cb), if_dlg_data);
790 gtk_widget_set_sensitive(if_dlg_data->details_bt, FALSE);
794 if_data = g_list_append(if_data, if_dlg_data);
798 /* Lets add up 10 rows of interfaces, otherwise the window may become too high */
799 gtk_widget_size_request(GTK_WIDGET(if_dlg_data->prepare_bt), &requisition);
800 height += requisition.height;
804 g_string_free(if_tool_str, TRUE);
806 /* Button row: close and help button */
807 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
808 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
810 close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
811 window_set_cancel_button(cap_if_w, close_bt, window_cancel_button_cb);
812 gtk_tooltips_set_tip(tooltips, close_bt, "Close this window.", NULL);
814 help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
815 g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)(HELP_CAPTURE_INTERFACES_DIALOG));
817 gtk_widget_size_request(GTK_WIDGET(close_bt), &requisition);
818 /* height + static offset + what the GTK MS Windows Engine needs in addition per interface */
819 height += requisition.height + 20 + ifs;
820 gtk_window_set_default_size(GTK_WINDOW(cap_if_w), -1, height);
822 gtk_widget_grab_default(close_bt);
824 g_signal_connect(cap_if_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
825 g_signal_connect(cap_if_w, "destroy", G_CALLBACK(capture_if_destroy_cb), sc);
827 gtk_widget_show_all(cap_if_w);
828 window_present(cap_if_w);
830 set_capture_if_dialog_for_capture_in_progress(g_capture_in_progress);
832 /* update the interface list every 1000ms */
833 timer_id = g_timeout_add(1000, update_all, sc);
836 #else /* HAVE_LIBPCAP */
839 set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress _U_)
843 #endif /* HAVE_LIBPCAP */