fix compilation for:
[obnox/wireshark/wip.git] / gtk / capture_if_dlg.c
1 /* capture_if_dlg.c
2  * Routines for the capture interface dialog
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #ifdef HAVE_LIBPCAP
30
31 #ifdef HAVE_SYS_WAIT_H
32 # include <sys/wait.h>
33 #endif
34
35
36 #include <gtk/gtk.h>
37
38 #include "globals.h"
39 #include "capture-pcap-util.h"
40
41 #ifdef _WIN32
42 #include "capture-wpcap.h"
43 #endif
44
45 #include "compat_macros.h"
46 #include "simple_dialog.h"
47 #include "capture.h"
48 #include "capture_dlg.h"
49 #include "capture_if_details_dlg.h"
50 #include "capture_errs.h"
51 #include "recent.h"
52 #include <epan/prefs.h>
53
54 #include "gui_utils.h"
55 #include "dlg_utils.h"
56
57 #include "main.h"
58 #include "wtap.h"
59 #include "help_dlg.h"
60 #include "toolbar.h"
61 #include "keys.h"
62
63 #include "webbrowser.h"
64
65 #ifdef HAVE_AIRPCAP
66 #include "../image/toolbar/capture_airpcap_16.xpm"
67 #endif
68 #include "../image/toolbar/capture_ethernet_16.xpm"
69
70 /* new buttons to be used instead of labels for 'Capture','Prepare',' */
71 #include "../image/toolbar/capture_capture_16.xpm"
72 #include "../image/toolbar/capture_prepare_16.xpm"
73 #include "../image/toolbar/capture_details_16.xpm"
74
75
76 #ifdef HAVE_AIRPCAP
77 #include <airpcap.h>
78 #include "airpcap_loader.h"
79 #include "airpcap_gui_utils.h"
80 #include "airpcap_dlg.h"
81 #endif
82
83 /*
84  * Keep a static pointer to the current "Capture Interfaces" window, if
85  * any, so that if somebody tries to do "Capture:Start" while there's
86  * already a "Capture Interfaces" window up, we just pop up the existing
87  * one, rather than creating a new one.
88  */
89 static GtkWidget *cap_if_w;
90 #ifdef HAVE_AIRPCAP
91 static GtkWidget *cap_air_w;
92 #endif
93
94 GList           *if_data = NULL;
95
96 guint           timer_id;
97
98 GtkWidget       *stop_bt;
99
100 GList           *if_list;
101
102 /*
103  * Timeout, in milliseconds, for reads from the stream of captured packets.
104  */
105 #define CAP_READ_TIMEOUT        250
106
107
108 /* the "runtime" data of one interface */
109 typedef struct if_dlg_data_s {
110     pcap_t      *pch;
111     GtkWidget   *device_lb;
112     GtkWidget   *descr_lb;
113     GtkWidget   *ip_lb;
114     GtkWidget   *curr_lb;
115     GtkWidget   *last_lb;
116     GtkWidget   *capture_bt;
117     GtkWidget   *prepare_bt;
118 #ifdef _WIN32
119     GtkWidget   *details_bt;
120 #endif
121     guint32     last_packets;
122     gchar       *device;
123 } if_dlg_data_t;
124
125 void update_if(if_dlg_data_t *if_dlg_data);
126
127
128 /* start capture button was pressed */
129 static void
130 capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
131 {
132   if_dlg_data_t *if_dlg_data = if_data;
133
134 #ifdef HAVE_AIRPCAP
135   airpcap_if_active = get_airpcap_if_from_description(airpcap_if_list, GTK_LABEL(if_dlg_data->descr_lb)->label);
136   airpcap_if_selected = airpcap_if_active;
137 #endif
138
139   if (capture_opts->iface)
140     g_free(capture_opts->iface);
141
142   capture_opts->iface = g_strdup(if_dlg_data->device);
143
144   /* XXX - remove this? */
145   if (capture_opts->save_file) {
146     g_free(capture_opts->save_file);
147     capture_opts->save_file = NULL;
148   }
149
150   /* stop capturing from all interfaces, we are going to do real work now ... */
151   window_destroy(cap_if_w);
152
153   capture_start_cb(NULL, NULL);
154 }
155
156
157 /* prepare capture button was pressed */
158 static void
159 capture_prepare_cb(GtkWidget *prepare_bt _U_, gpointer if_data)
160 {
161   if_dlg_data_t *if_dlg_data = if_data;
162
163   if (capture_opts->iface)
164     g_free(capture_opts->iface);
165
166   capture_opts->iface = g_strdup(if_dlg_data->device);
167
168   /* stop capturing from all interfaces, we are going to do real work now ... */
169   window_destroy(cap_if_w);
170
171   capture_prep_cb(NULL, NULL);
172 }
173
174
175 #ifdef _WIN32
176 /* capture details button was pressed */
177 static void
178 capture_details_cb(GtkWidget *details_bt _U_, gpointer if_data)
179 {
180   if_dlg_data_t *if_dlg_data = if_data;
181
182
183   capture_if_details_open(if_dlg_data->device);
184 }
185 #endif
186
187
188 /* open a single interface */
189 static void
190 open_if(gchar *name, if_dlg_data_t *if_dlg_data)
191 {
192   gchar       open_err_str[CAPTURE_PCAP_ERRBUF_SIZE];
193
194   /*
195    * XXX - on systems with BPF, the number of BPF devices limits the
196    * number of devices on which you can capture simultaneously.
197    *
198    * This means that
199    *
200    *    1) this might fail if you run out of BPF devices
201    *
202    * and
203    *
204    *    2) opening every interface could leave too few BPF devices
205    *       for *other* programs.
206    *
207    * It also means the system could end up getting a lot of traffic
208    * that it has to pass through the networking stack and capture
209    * mechanism, so opening all the devices and presenting packet
210    * counts might not always be a good idea.
211    */
212   if_dlg_data->pch = pcap_open_live(name,
213                        MIN_PACKET_SIZE,
214                        capture_opts->promisc_mode, CAP_READ_TIMEOUT,
215                        open_err_str);
216
217   if (if_dlg_data->pch != NULL) {
218     update_if(if_dlg_data);
219   } else {
220     printf("open_if: %s\n", open_err_str);
221     gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), "error");
222     gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), "error");
223   }
224 }
225
226 /* update a single interface */
227 void
228 update_if(if_dlg_data_t *if_dlg_data)
229 {
230   struct pcap_stat stats;
231   gchar *str;
232   guint diff;
233
234
235   /* pcap_stats() stats values differ on libpcap and winpcap!
236    * libpcap: returns the number of packets since pcap_open_live
237    * winpcap: returns the number of packets since the last pcap_stats call
238    * XXX - if that's true, that's a bug, and should be fixed; "pcap_stats()"
239    * is supposed to work the same way on all platforms, including Windows.
240    * Note that the WinPcap 3.0 documentation says "The values represent
241    * packet statistics from the start of the run to the time of the call."
242    * (Note also that some versions of libpcap, on some versions of UN*X,
243    * have the same bug.)
244    */
245   if (if_dlg_data->pch) {
246     if(pcap_stats(if_dlg_data->pch, &stats) >= 0) {
247 #ifdef _WIN32
248       diff = stats.ps_recv - if_dlg_data->last_packets;
249       if_dlg_data->last_packets = stats.ps_recv;
250 #else
251       diff = stats.ps_recv;
252       if_dlg_data->last_packets = stats.ps_recv + if_dlg_data->last_packets;
253 #endif
254
255       str = g_strdup_printf("%u", if_dlg_data->last_packets);
256       gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), str);
257       g_free(str);
258       str = g_strdup_printf("%u", diff);
259       gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), str);
260       g_free(str);
261
262       gtk_widget_set_sensitive(if_dlg_data->curr_lb, diff);
263       gtk_widget_set_sensitive(if_dlg_data->last_lb, diff);
264     } else {
265       gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), "error");
266       gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), "error");
267     }
268   }
269 }
270
271
272 /* close a single interface */
273 static void
274 close_if(if_dlg_data_t *if_dlg_data)
275 {
276     if(if_dlg_data->pch)
277         pcap_close(if_dlg_data->pch);
278 }
279
280
281
282 /* update all interfaces */
283 static gboolean
284 update_all(gpointer data)
285 {
286     GList *curr;
287     int ifs;
288
289
290     if(!cap_if_w) {
291         return FALSE;
292     }
293
294     for(ifs = 0; (curr = g_list_nth(data, ifs)); ifs++) {
295         update_if(curr->data);
296     }
297
298     return TRUE;
299 }
300
301
302 /* a live capture has started or stopped */
303 void
304 set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
305 {
306     GList *curr;
307     int ifs;
308
309     if(cap_if_w) {
310         gtk_widget_set_sensitive(stop_bt, capture_in_progress);
311
312         for(ifs = 0; (curr = g_list_nth(if_data, ifs)); ifs++) {
313             if_dlg_data_t *if_dlg_data = curr->data;
314
315             gtk_widget_set_sensitive(if_dlg_data->capture_bt, !capture_in_progress);
316             gtk_widget_set_sensitive(if_dlg_data->prepare_bt, !capture_in_progress);
317         }
318     }
319 }
320
321
322 /* the window was closed, cleanup things */
323 static void
324 capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
325 {
326     GList *curr;
327     int ifs;
328
329     gtk_timeout_remove(timer_id);
330
331     for(ifs = 0; (curr = g_list_nth(if_data, ifs)); ifs++) {
332         if_dlg_data_t *if_dlg_data = curr->data;
333
334         close_if(if_dlg_data);
335         g_free(curr->data);
336     }
337
338     if_data = NULL;
339
340     free_interface_list(if_list);
341
342     /* Note that we no longer have a "Capture Options" dialog box. */
343     cap_if_w = NULL;
344
345 #ifdef HAVE_AIRPCAP
346         airpcap_set_toolbar_stop_capture(airpcap_if_active);
347 #endif
348 }
349
350 GtkWidget*
351 combo_channel_new(void)
352 {
353           GtkWidget* channel_cb;
354           GList*     popdown;
355
356
357       channel_cb = gtk_combo_new();
358           gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cb)->entry), "1");
359
360           popdown = NULL;
361
362           popdown = g_list_append(popdown, "1");
363       popdown = g_list_append(popdown, "2");
364       popdown = g_list_append(popdown, "3");
365       popdown = g_list_append(popdown, "4");
366           popdown = g_list_append(popdown, "5");
367           popdown = g_list_append(popdown, "6");
368           popdown = g_list_append(popdown, "7");
369           popdown = g_list_append(popdown, "8");
370           popdown = g_list_append(popdown, "9");
371           popdown = g_list_append(popdown, "10");
372           popdown = g_list_append(popdown, "11");
373           popdown = g_list_append(popdown, "12");
374           popdown = g_list_append(popdown, "13");
375           popdown = g_list_append(popdown, "14");
376
377       gtk_combo_set_popdown_strings( GTK_COMBO(channel_cb), popdown) ;
378
379           #if GTK_MAJOR_VERSION < 2
380           gtk_widget_set_usize( GTK_WIDGET(channel_cb),
381                                   45,
382                                   10 );
383           #else
384           gtk_widget_set_size_request( GTK_WIDGET(channel_cb),
385                                   45,
386                                   10 );
387       #endif
388
389
390           return channel_cb;
391 }
392
393 /* start getting capture stats from all interfaces */
394 void
395 capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
396 {
397   GtkWidget     *main_vb,
398                                 *main_sw,
399                                 *bbox,
400                                 *close_bt,
401                                 *help_bt,
402                                 *icon;
403
404 #ifdef HAVE_AIRPCAP
405   GtkWidget             *decryption_cm;
406 #endif
407
408   GtkWidget     *if_tb;
409   GtkWidget     *if_lb;
410 #if GTK_MAJOR_VERSION < 2
411   GtkAccelGroup *accel_group;
412 #endif
413   GtkTooltips   *tooltips;
414   int           err;
415   char          err_str[CAPTURE_PCAP_ERRBUF_SIZE];
416   gchar         *cant_get_if_list_errstr;
417   GtkRequisition requisition;
418   int           row, height;
419   if_dlg_data_t *if_dlg_data;
420   int           ifs;
421   GList         *curr;
422   if_info_t     *if_info;
423   GSList        *curr_ip;
424   if_addr_t     *ip_addr;
425   GString       *if_tool_str = g_string_new("");
426   gchar         *tmp_str;
427
428   if (cap_if_w != NULL) {
429     /* There's already a "Capture Interfaces" dialog box; reactivate it. */
430     reactivate_window(cap_if_w);
431     return;
432   }
433
434 #ifdef _WIN32
435   /* Is WPcap loaded? */
436   if (!has_wpcap) {
437     char *detailed_err;
438
439     detailed_err = cant_load_winpcap_err("Wireshark");
440     simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", detailed_err);
441     g_free(detailed_err);
442     return;
443   }
444 #endif
445
446   /* LOAD THE INTERFACES */
447   if_list = get_interface_list(&err, err_str);
448   if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
449     cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
450     simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
451                   cant_get_if_list_errstr);
452     g_free(cant_get_if_list_errstr);
453     return;
454   }
455
456 #ifdef HAVE_AIRPCAP
457   /* LOAD AIRPCAP INTERFACES */
458         /* load the airpcap interfaces */
459         airpcap_if_list = get_airpcap_interface_list(&err, err_str);
460         if(airpcap_if_list == NULL) airpcap_if_active = airpcap_if_selected = NULL;
461
462         decryption_cm = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY);
463         update_decryption_mode_list(decryption_cm);
464
465         if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
466         cant_get_if_list_errstr = cant_get_airpcap_if_list_error_message(err_str);
467         simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
468                                   cant_get_if_list_errstr);
469         g_free(cant_get_if_list_errstr);
470         }
471
472         /* If no airpcap interface is present, gray everything */
473         if(airpcap_if_active == NULL)
474                 {
475                 if(airpcap_if_list == NULL)
476                         {
477                         /*No airpcap device found */
478                         airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
479                         }
480                 else
481                         {
482                         /* default adapter is not airpcap... or is airpcap but is not found*/
483                         airpcap_set_toolbar_stop_capture(airpcap_if_active);
484                         airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
485                         }
486                 }
487
488   airpcap_set_toolbar_start_capture(airpcap_if_active);
489 #endif
490
491   cap_if_w = window_new(GTK_WINDOW_TOPLEVEL, "Wireshark: Capture Interfaces");
492
493   tooltips = gtk_tooltips_new();
494
495 #if GTK_MAJOR_VERSION < 2
496   /* Accelerator group for the accelerators (or, as they're called in
497      Windows and, I think, in Motif, "mnemonics"; Alt+<key> is a mnemonic,
498      Ctrl+<key> is an accelerator). */
499   accel_group = gtk_accel_group_new();
500   gtk_window_add_accel_group(GTK_WINDOW(cap_if_w), accel_group);
501 #endif
502
503   main_sw = gtk_scrolled_window_new(NULL, NULL);
504   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(main_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
505   gtk_container_add(GTK_CONTAINER(cap_if_w), main_sw);
506
507   main_vb = gtk_vbox_new(FALSE, 0);
508   gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
509   gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(main_sw), main_vb);
510
511
512   if_tb = gtk_table_new(1,9, FALSE);
513   gtk_table_set_row_spacings(GTK_TABLE(if_tb), 3);
514   gtk_table_set_col_spacings(GTK_TABLE(if_tb), 3);
515   gtk_box_pack_start(GTK_BOX(main_vb), if_tb, FALSE, FALSE, 0);
516
517   row = 0;
518   height = 0;
519
520   /* This is the icon column, used to display which kind of interface we have */
521   if_lb = gtk_label_new("");
522   gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 0, 1, row, row+1);
523
524 #ifndef _WIN32
525   /*
526    * On Windows, device names are generally not meaningful - NT 5
527    * uses long blobs with GUIDs in them, for example - so we don't
528    * bother showing them.
529    */
530   if_lb = gtk_label_new("Device");
531   gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 1, 2, row, row+1);
532 #endif
533
534   if_lb = gtk_label_new("Description");
535   gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 2, 3, row, row+1);
536
537   if_lb = gtk_label_new(" IP ");
538   gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 3, 4, row, row+1);
539
540   if_lb = gtk_label_new("Packets");
541   gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 4, 5, row, row+1);
542
543   if_lb = gtk_label_new(" Packets/s ");
544   gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 5, 6, row, row+1);
545
546   stop_bt = BUTTON_NEW_FROM_STOCK(WIRESHARK_STOCK_CAPTURE_STOP);
547   gtk_tooltips_set_tip(tooltips, stop_bt,
548           "Stop a running capture.", NULL);
549 #ifdef _WIN32
550   gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 6, 9, row, row+1);
551 #else
552   gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 6, 8, row, row+1);
553 #endif
554   SIGNAL_CONNECT(stop_bt, "clicked", capture_stop_cb, NULL);
555
556   row++;
557   gtk_widget_size_request(stop_bt, &requisition);
558   height += requisition.height + 15;
559
560   for(ifs = 0; (curr = g_list_nth(if_list, ifs)); ifs++) {
561       g_string_assign(if_tool_str, "");
562       if_info = curr->data;
563       if_dlg_data = g_malloc0(sizeof(if_dlg_data_t));
564
565       /* Kind of adaptor (icon) */
566 #ifdef HAVE_AIRPCAP
567       if(get_airpcap_if_from_description(airpcap_if_list,if_info->description) != NULL)
568         icon = xpm_to_widget(capture_airpcap_16_xpm);
569       else
570         icon = xpm_to_widget(capture_ethernet_16_xpm);
571 #else
572       icon = xpm_to_widget(capture_ethernet_16_xpm);
573 #endif
574
575       gtk_table_attach_defaults(GTK_TABLE(if_tb), icon, 0, 1, row, row+1);
576
577       /* device name */
578       if_dlg_data->device_lb = gtk_label_new(if_info->name);
579       if_dlg_data->device = if_info->name;
580 #ifndef _WIN32
581       gtk_misc_set_alignment(GTK_MISC(if_dlg_data->device_lb), 0.0, 0.5);
582       gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->device_lb, 1, 2, row, row+1);
583 #endif
584       g_string_append(if_tool_str, "Device: ");
585       g_string_append(if_tool_str, if_info->name);
586       g_string_append(if_tool_str, "\n");
587
588       /* description */
589       if (if_info->description != NULL)
590         if_dlg_data->descr_lb = gtk_label_new(if_info->description);
591       else
592         if_dlg_data->descr_lb = gtk_label_new("");
593       gtk_misc_set_alignment(GTK_MISC(if_dlg_data->descr_lb), 0.0, 0.5);
594       gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->descr_lb, 2, 3, row, row+1);
595
596       if (if_info->description) {
597         g_string_append(if_tool_str, "Description: ");
598         g_string_append(if_tool_str, if_info->description);
599         g_string_append(if_tool_str, "\n");
600       }
601
602       /* IP address */
603       /* only the first IP address will be shown */
604       g_string_append(if_tool_str, "IP: ");
605       curr_ip = g_slist_nth(if_info->ip_addr, 0);
606       if(curr_ip) {
607         ip_addr = (if_addr_t *)curr_ip->data;
608         switch (ip_addr->type) {
609
610         case AT_IPv4:
611           tmp_str = ip_to_str((guint8 *)&ip_addr->ip_addr.ip4_addr);
612           break;
613
614         case AT_IPv6:
615           tmp_str = ip6_to_str((struct e_in6_addr *)&ip_addr->ip_addr.ip6_addr);
616           break;
617
618         default:
619           g_assert_not_reached();
620           tmp_str = NULL;
621         }
622         if_dlg_data->ip_lb = gtk_label_new(tmp_str);
623         gtk_widget_set_sensitive(if_dlg_data->ip_lb, TRUE);
624         g_string_append(if_tool_str, tmp_str);
625       } else {
626         if_dlg_data->ip_lb = gtk_label_new("unknown");
627         gtk_widget_set_sensitive(if_dlg_data->ip_lb, FALSE);
628         g_string_append(if_tool_str, "unknown");
629       }
630       gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->ip_lb, 3, 4, row, row+1);
631       g_string_append(if_tool_str, "\n");
632
633       /* packets */
634       if_dlg_data->curr_lb = gtk_label_new("-");
635       gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->curr_lb, 4, 5, row, row+1);
636
637       /* packets/s */
638       if_dlg_data->last_lb = gtk_label_new("-");
639       gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->last_lb, 5, 6, row, row+1);
640
641       /* capture button */
642       if_dlg_data->capture_bt = BUTTON_NEW_FROM_STOCK(WIRESHARK_STOCK_CAPTURE_START);
643           SIGNAL_CONNECT(if_dlg_data->capture_bt, "clicked", capture_do_cb, if_dlg_data);
644       tmp_str = g_strdup_printf("Immediately start a capture from this interface:\n\n%s", if_tool_str->str);
645       gtk_tooltips_set_tip(tooltips, if_dlg_data->capture_bt,
646           tmp_str, NULL);
647       g_free(tmp_str);
648       gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->capture_bt, 6, 7, row, row+1);
649
650       /* prepare button */
651       if_dlg_data->prepare_bt = BUTTON_NEW_FROM_STOCK(WIRESHARK_STOCK_CAPTURE_OPTIONS);
652       SIGNAL_CONNECT(if_dlg_data->prepare_bt, "clicked", capture_prepare_cb, if_dlg_data);
653       gtk_tooltips_set_tip(tooltips, if_dlg_data->prepare_bt,
654           "Open the capture options dialog with this interface selected.", NULL);
655       gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->prepare_bt, 7, 8, row, row+1);
656
657       /* details button */
658 #ifdef _WIN32
659       if_dlg_data->details_bt = BUTTON_NEW_FROM_STOCK(WIRESHARK_STOCK_CAPTURE_DETAILS);
660           SIGNAL_CONNECT(if_dlg_data->details_bt, "clicked", capture_details_cb, if_dlg_data);
661       gtk_tooltips_set_tip(tooltips, if_dlg_data->details_bt,
662           "Open the capture details dialog of this interface.", NULL);
663       gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->details_bt, 8, 9, row, row+1);
664 #endif
665
666       open_if(if_info->name, if_dlg_data);
667
668       if_data = g_list_append(if_data, if_dlg_data);
669
670       row++;
671       if (row <= 10) {
672           /* Lets add up 10 rows of interfaces, otherwise the window may become too high */
673           gtk_widget_size_request(GTK_WIDGET(if_dlg_data->prepare_bt), &requisition);
674           height += requisition.height;
675       }
676   }
677
678   g_string_free(if_tool_str, TRUE);
679
680   /* Button row: close button */
681   if(topic_available(HELP_CAPTURE_INTERFACES_DIALOG)) {
682     bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
683   } else {
684     bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
685   }
686   gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
687
688   close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
689   window_set_cancel_button(cap_if_w, close_bt, window_cancel_button_cb);
690   gtk_tooltips_set_tip(tooltips, close_bt, "Close this window.", NULL);
691
692   if(topic_available(HELP_CAPTURE_INTERFACES_DIALOG)) {
693     help_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_HELP);
694     SIGNAL_CONNECT(help_bt, "clicked", topic_cb, HELP_CAPTURE_INTERFACES_DIALOG);
695   }
696
697   gtk_widget_size_request(GTK_WIDGET(close_bt), &requisition);
698   /* height + static offset + what GTK-Wimp needs in addition per interface */
699   height += requisition.height + 20 + ifs;
700   gtk_window_set_default_size(GTK_WINDOW(cap_if_w), -1, height);
701
702   gtk_widget_grab_default(close_bt);
703
704   SIGNAL_CONNECT(cap_if_w, "delete_event", window_delete_event_cb, NULL);
705   SIGNAL_CONNECT(cap_if_w, "destroy", capture_if_destroy_cb, NULL);
706
707   gtk_widget_show_all(cap_if_w);
708   window_present(cap_if_w);
709
710   set_capture_if_dialog_for_capture_in_progress(is_capture_in_progress());
711
712     /* update the interface list every 1000ms */
713   timer_id = gtk_timeout_add(1000, update_all, if_data);
714 }
715
716
717 #endif /* HAVE_LIBPCAP */