5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * Richard Sharpe, 13-Feb-1999, added support for initializing structures
10 * needed by dissect routines
11 * Jeff Foster, 2001/03/12, added support tabbed hex display windowss
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include <gdk/gdkkeysyms.h>
44 #ifdef NEED_STRERROR_H
45 #include "wsutil/strerror.h"
51 #include "wsutil/wsgetopt.h"
54 #ifdef _WIN32 /* Needed for console I/O */
59 #ifdef HAVE_LIBPORTAUDIO
60 #include <portaudio.h>
61 #endif /* HAVE_LIBPORTAUDIO */
63 #include <epan/epan.h>
64 #include <epan/filesystem.h>
65 #include <wsutil/privileges.h>
66 #include <epan/epan_dissect.h>
67 #include <epan/timestamp.h>
68 #include <epan/packet.h>
69 #include <epan/plugins.h>
70 #include <epan/dfilter/dfilter.h>
71 #include <epan/strutil.h>
72 #include <epan/addr_resolv.h>
73 #include <epan/emem.h>
74 #include <epan/ex-opt.h>
75 #include <epan/funnel.h>
76 #include <epan/expert.h>
77 #include <epan/frequency-utils.h>
78 #include <epan/prefs.h>
79 #include <epan/prefs-int.h>
81 #include <epan/stat_cmd_args.h>
83 #include <epan/emem.h>
84 #include <epan/column.h>
86 /* general (not GTK specific) */
88 #include "../summary.h"
89 #include "../filters.h"
90 #include "../disabled_protos.h"
92 #include "../color_filters.h"
94 #include "../simple_dialog.h"
95 #include "../register.h"
96 #include "../ringbuffer.h"
97 #include "../ui_util.h"
99 #include "../clopts_common.h"
100 #include "../console_io.h"
101 #include "../cmdarg_err.h"
102 #include "../version_info.h"
103 #include "../merge.h"
104 #include "../alert_box.h"
106 #include <wsutil/file_util.h>
109 #include "../capture_ui_utils.h"
110 #include "../capture-pcap-util.h"
111 #include "../capture_ifinfo.h"
112 #include "../capture.h"
113 #include "../capture_sync.h"
117 #include "../capture-wpcap.h"
118 #include "../capture_wpcap_packet.h"
119 #include <tchar.h> /* Needed for Unicode */
120 #include <commctrl.h>
124 #include "gtk/file_dlg.h"
125 #include "gtk/gtkglobals.h"
126 #include "gtk/color_utils.h"
127 #include "gtk/gui_utils.h"
128 #include "gtk/color_dlg.h"
129 #include "gtk/filter_dlg.h"
130 #include "gtk/uat_gui.h"
132 #include "gtk/main.h"
133 #include "gtk/main_airpcap_toolbar.h"
134 #include "gtk/main_filter_toolbar.h"
135 #include "gtk/menus.h"
136 #include "gtk/main_packet_list.h"
137 #include "gtk/main_statusbar.h"
138 #include "gtk/main_statusbar_private.h"
139 #include "gtk/main_toolbar.h"
140 #include "gtk/main_welcome.h"
141 #include "gtk/drag_and_drop.h"
142 #include "gtk/capture_file_dlg.h"
143 #include "gtk/main_proto_draw.h"
144 #include "gtk/keys.h"
145 #include "gtk/packet_win.h"
146 #include "gtk/stock_icons.h"
147 #include "gtk/find_dlg.h"
148 #include "gtk/recent.h"
149 #include "gtk/follow_tcp.h"
150 #include "gtk/font_utils.h"
151 #include "gtk/about_dlg.h"
152 #include "gtk/help_dlg.h"
153 #include "gtk/decode_as_dlg.h"
154 #include "gtk/webbrowser.h"
155 #include "gtk/capture_dlg.h"
156 #include "gtk/capture_if_dlg.h"
157 #include "gtk/tap_dfilter_dlg.h"
158 #include "gtk/prefs_column.h"
159 #include "gtk/prefs_dlg.h"
160 #include "gtk/proto_help.h"
163 #include "../image/wsicon16.xpm"
164 #include "../image/wsicon32.xpm"
165 #include "../image/wsicon48.xpm"
166 #include "../image/wsicon64.xpm"
167 #include "../image/wsiconcap16.xpm"
168 #include "../image/wsiconcap32.xpm"
169 #include "../image/wsiconcap48.xpm"
174 #include "airpcap_loader.h"
175 #include "airpcap_dlg.h"
176 #include "airpcap_gui_utils.h"
180 #include <epan/crypt/airpdcap_ws.h>
183 #ifdef NEW_PACKET_LIST
184 #include "gtk/new_packet_list.h"
187 #ifdef HAVE_GTKOSXAPPLICATION
188 #include <igemacintegration/gtkosxapplication.h>
192 * Files under personal and global preferences directories in which
193 * GTK settings for Wireshark are stored.
195 #define RC_FILE "gtkrc"
199 /* "exported" main widgets */
200 GtkWidget *top_level = NULL, *pkt_scrollw, *tree_view_gbl, *byte_nb_ptr_gbl;
202 /* placement widgets (can be a bit confusing, because of the many layout possibilities */
203 static GtkWidget *main_vbox, *main_pane_v1, *main_pane_v2, *main_pane_h1, *main_pane_h2;
204 static GtkWidget *main_first_pane, *main_second_pane;
206 /* internally used widgets */
207 static GtkWidget *menubar, *main_tb, *filter_tb, *tv_scrollw, *statusbar, *welcome_pane;
210 GtkWidget *airpcap_tb;
211 int airpcap_dll_ret_val = -1;
214 GString *comp_info_str, *runtime_info_str;
215 gboolean have_capture_file = FALSE; /* XXX - is there an equivalent in cfile? */
217 guint tap_update_timer_id;
220 static gboolean has_console; /* TRUE if app has console */
221 static void destroy_console(void);
222 static gboolean stdin_capture = FALSE; /* Don't grab stdin & stdout if TRUE */
224 static void console_log_handler(const char *log_domain,
225 GLogLevelFlags log_level, const char *message, gpointer user_data);
228 capture_options global_capture_opts;
232 static void create_main_window(gint, gint, gint, e_prefs*);
233 static void show_main_window(gboolean);
234 static void file_quit_answered_cb(gpointer dialog, gint btn, gpointer data);
235 static void main_save_window_geometry(GtkWidget *widget);
238 /* Match selected byte pattern */
240 match_selected_cb_do(gpointer data, int action, gchar *text)
242 GtkWidget *filter_te;
243 char *cur_filter, *new_filter;
245 if ((!text) || (0 == strlen(text))) {
246 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not acquire information to build a filter!\nTry expanding or choosing another item.");
251 filter_te = g_object_get_data(G_OBJECT(data), E_DFILTER_TE_KEY);
254 cur_filter = gtk_editable_get_chars(GTK_EDITABLE(filter_te), 0, -1);
256 switch (action&MATCH_SELECTED_MASK) {
258 case MATCH_SELECTED_REPLACE:
259 new_filter = g_strdup(text);
262 case MATCH_SELECTED_AND:
263 if ((!cur_filter) || (0 == strlen(cur_filter)))
264 new_filter = g_strdup(text);
266 new_filter = g_strconcat("(", cur_filter, ") && (", text, ")", NULL);
269 case MATCH_SELECTED_OR:
270 if ((!cur_filter) || (0 == strlen(cur_filter)))
271 new_filter = g_strdup(text);
273 new_filter = g_strconcat("(", cur_filter, ") || (", text, ")", NULL);
276 case MATCH_SELECTED_NOT:
277 new_filter = g_strconcat("!(", text, ")", NULL);
280 case MATCH_SELECTED_AND_NOT:
281 if ((!cur_filter) || (0 == strlen(cur_filter)))
282 new_filter = g_strconcat("!(", text, ")", NULL);
284 new_filter = g_strconcat("(", cur_filter, ") && !(", text, ")", NULL);
287 case MATCH_SELECTED_OR_NOT:
288 if ((!cur_filter) || (0 == strlen(cur_filter)))
289 new_filter = g_strconcat("!(", text, ")", NULL);
291 new_filter = g_strconcat("(", cur_filter, ") || !(", text, ")", NULL);
295 g_assert_not_reached();
300 /* Free up the copy we got of the old filter text. */
303 /* Don't change the current display filter if we only want to copy the filter */
304 if (action&MATCH_SELECTED_COPY_ONLY) {
305 GString *gtk_text_str = g_string_new("");
306 g_string_append(gtk_text_str, new_filter);
307 copy_to_clipboard(gtk_text_str);
308 g_string_free(gtk_text_str, TRUE);
310 /* create a new one and set the display filter entry accordingly */
311 gtk_entry_set_text(GTK_ENTRY(filter_te), new_filter);
313 /* Run the display filter so it goes in effect. */
314 if (action&MATCH_SELECTED_APPLY_NOW)
315 main_filter_packets(&cfile, new_filter, FALSE);
318 /* Free up the new filter text. */
323 match_selected_ptree_cb(GtkWidget *w, gpointer data, MATCH_SELECTED_E action)
327 if (cfile.finfo_selected) {
328 filter = proto_construct_match_selected_string(cfile.finfo_selected,
330 match_selected_cb_do((data ? data : w), action, filter);
335 colorize_selected_ptree_cb(GtkWidget *w _U_, gpointer data _U_, guint8 filt_nr)
339 if (cfile.finfo_selected) {
340 filter = proto_construct_match_selected_string(cfile.finfo_selected,
342 if ((!filter) || (0 == strlen(filter))) {
343 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
344 "Could not acquire information to build a filter!\n"
345 "Try expanding or choosing another item.");
350 color_display_with_filter(filter);
353 color_filters_reset_tmp();
355 color_filters_set_tmp(filt_nr,filter, FALSE);
357 cf_colorize_packets(&cfile);
363 static void selected_ptree_info_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
365 gchar *selected_proto_url;
366 gchar *proto_abbrev = data;
371 if (cfile.finfo_selected) {
372 /* open wiki page using the protocol abbreviation */
373 selected_proto_url = g_strdup_printf("http://wiki.wireshark.org/Protocols/%s", proto_abbrev);
374 browser_open_url(selected_proto_url);
375 g_free(selected_proto_url);
378 case(ESD_BTN_CANCEL):
381 g_assert_not_reached();
387 selected_ptree_info_cb(GtkWidget *widget _U_, gpointer data _U_)
390 const gchar *proto_abbrev;
394 if (cfile.finfo_selected) {
395 /* convert selected field to protocol abbreviation */
396 /* XXX - could this conversion be simplified? */
397 field_id = cfile.finfo_selected->hfinfo->id;
398 /* if the selected field isn't a protocol, get it's parent */
399 if(!proto_registrar_is_protocol(field_id)) {
400 field_id = proto_registrar_get_parent(cfile.finfo_selected->hfinfo->id);
403 proto_abbrev = proto_registrar_get_abbrev(field_id);
405 if (!proto_is_private(field_id)) {
406 /* ask the user if the wiki page really should be opened */
407 dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_OK_CANCEL,
408 "%sOpen Wireshark Wiki page of protocol \"%s\"?%s\n"
410 "This will open the \"%s\" related Wireshark Wiki page in your Web browser.\n"
412 "The Wireshark Wiki is a collaborative approach to provide information "
413 "about Wireshark in several ways (not limited to protocol specifics).\n"
415 "This Wiki is new, so the page of the selected protocol "
416 "may not exist and/or may not contain valuable information.\n"
418 "As everyone can edit the Wiki and add new content (or extend existing), "
419 "you are encouraged to add information if you can.\n"
421 "Hint 1: If you are new to wiki editing, try out editing the Sandbox first!\n"
423 "Hint 2: If you want to add a new protocol page, you should use the ProtocolTemplate, "
424 "which will save you a lot of editing and will give a consistent look over the pages.",
425 simple_dialog_primary_start(), proto_abbrev, simple_dialog_primary_end(), proto_abbrev);
426 simple_dialog_set_cb(dialog, selected_ptree_info_answered_cb, (gpointer)proto_abbrev);
428 /* appologize to the user that the wiki page cannot be opened */
429 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
430 "%sCan't open Wireshark Wiki page of protocol \"%s\"%s\n"
432 "This would open the \"%s\" related Wireshark Wiki page in your Web browser.\n"
434 "Since this is a private protocol, such information is not available in "
435 "a public wiki. Therefore this wiki entry is blocked.\n"
437 "Sorry for the inconvenience.\n",
438 simple_dialog_primary_start(), proto_abbrev, simple_dialog_primary_end(), proto_abbrev);
443 static void selected_ptree_ref_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
445 gchar *selected_proto_url;
446 gchar *proto_abbrev = data;
450 if (cfile.finfo_selected) {
451 /* open reference page using the protocol abbreviation */
452 selected_proto_url = g_strdup_printf("http://www.wireshark.org/docs/dfref/%c/%s", proto_abbrev[0], proto_abbrev);
453 browser_open_url(selected_proto_url);
454 g_free(selected_proto_url);
457 case(ESD_BTN_CANCEL):
460 g_assert_not_reached();
465 selected_ptree_ref_cb(GtkWidget *widget _U_, gpointer data _U_)
468 const gchar *proto_abbrev;
472 if (cfile.finfo_selected) {
473 /* convert selected field to protocol abbreviation */
474 /* XXX - could this conversion be simplified? */
475 field_id = cfile.finfo_selected->hfinfo->id;
476 /* if the selected field isn't a protocol, get it's parent */
477 if(!proto_registrar_is_protocol(field_id)) {
478 field_id = proto_registrar_get_parent(cfile.finfo_selected->hfinfo->id);
481 proto_abbrev = proto_registrar_get_abbrev(field_id);
483 if (!proto_is_private(field_id)) {
484 /* ask the user if the wiki page really should be opened */
485 dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_OK_CANCEL,
486 "%sOpen Wireshark filter reference page of protocol \"%s\"?%s\n"
488 "This will open the \"%s\" related Wireshark filter reference page in your Web browser.\n"
490 simple_dialog_primary_start(), proto_abbrev, simple_dialog_primary_end(), proto_abbrev);
491 simple_dialog_set_cb(dialog, selected_ptree_ref_answered_cb, (gpointer)proto_abbrev);
493 /* appologize to the user that the wiki page cannot be opened */
494 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
495 "%sCan't open Wireshark filter reference page of protocol \"%s\"%s\n"
497 "This would open the \"%s\" related Wireshark filter reference page in your Web browser.\n"
499 "Since this is a private protocol, such information is not available on "
500 "a public website. Therefore this filter entry is blocked.\n"
502 "Sorry for the inconvenience.\n",
503 simple_dialog_primary_start(), proto_abbrev, simple_dialog_primary_end(), proto_abbrev);
509 is_address_column (gint column)
511 if (((cfile.cinfo.col_fmt[column] == COL_DEF_SRC) ||
512 (cfile.cinfo.col_fmt[column] == COL_RES_SRC) ||
513 (cfile.cinfo.col_fmt[column] == COL_DEF_DST) ||
514 (cfile.cinfo.col_fmt[column] == COL_RES_DST)) &&
515 strlen(cfile.cinfo.col_expr.col_expr_val[column]))
524 get_ip_address_list_from_packet_list_row(gpointer data)
526 gint row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_ROW_KEY));
527 #ifdef NEW_PACKET_LIST
528 gint column = new_packet_list_get_column_id (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_COL_KEY)));
530 gint column = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_COL_KEY));
534 GList *addr_list = NULL;
538 #ifdef NEW_PACKET_LIST
539 fdata = (frame_data *) new_packet_list_get_row_data(row);
541 fdata = (frame_data *) packet_list_get_row_data(row);
547 if (!cf_read_frame (&cfile, fdata, &err, &err_info))
549 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
550 cf_read_error_message(err, err_info), cfile.filename);
554 epan_dissect_init(&edt, FALSE, FALSE);
555 col_custom_prime_edt(&edt, &cfile.cinfo);
557 epan_dissect_run(&edt, &cfile.pseudo_header, cfile.pd, fdata, &cfile.cinfo);
558 epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
560 /* First check selected column */
561 if (is_address_column (column)) {
562 addr_list = g_list_append (addr_list, se_strdup_printf("%s", cfile.cinfo.col_expr.col_expr_val[column]));
565 for (col = 0; col < cfile.cinfo.num_cols; col++) {
566 /* Then check all columns except the selected */
567 if ((col != column) && (is_address_column (col))) {
568 addr_list = g_list_append (addr_list, se_strdup_printf("%s", cfile.cinfo.col_expr.col_expr_val[col]));
572 epan_dissect_cleanup(&edt);
579 get_filter_from_packet_list_row_and_column(gpointer data)
581 gint row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_ROW_KEY));
582 #ifdef NEW_PACKET_LIST
583 gint column = new_packet_list_get_column_id (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_COL_KEY)));
585 gint column = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_COL_KEY));
592 #ifdef NEW_PACKET_LIST
593 fdata = (frame_data *) new_packet_list_get_row_data(row);
595 fdata = (frame_data *) packet_list_get_row_data(row);
601 if (!cf_read_frame(&cfile, fdata, &err, &err_info)) {
602 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
603 cf_read_error_message(err, err_info), cfile.filename);
606 /* proto tree, visible. We need a proto tree if there's custom columns */
607 epan_dissect_init(&edt, have_custom_cols(&cfile.cinfo), FALSE);
608 col_custom_prime_edt(&edt, &cfile.cinfo);
610 epan_dissect_run(&edt, &cfile.pseudo_header, cfile.pd, fdata,
612 epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
614 if (strlen(cfile.cinfo.col_expr.col_expr[column]) != 0 &&
615 strlen(cfile.cinfo.col_expr.col_expr_val[column]) != 0) {
616 /* leak a little but safer than ep_ here */
617 if (cfile.cinfo.col_fmt[column] == COL_CUSTOM) {
618 header_field_info *hfi = proto_registrar_get_byname(cfile.cinfo.col_custom_field[column]);
619 if (hfi->parent == -1) {
621 buf = se_strdup(cfile.cinfo.col_expr.col_expr[column]);
622 } else if (hfi->type == FT_STRING) {
623 /* Custom string, add quotes */
624 buf = se_strdup_printf("%s == \"%s\"", cfile.cinfo.col_expr.col_expr[column],
625 cfile.cinfo.col_expr.col_expr_val[column]);
629 buf = se_strdup_printf("%s == %s", cfile.cinfo.col_expr.col_expr[column],
630 cfile.cinfo.col_expr.col_expr_val[column]);
634 epan_dissect_cleanup(&edt);
641 match_selected_plist_cb(GtkWidget *w _U_, gpointer data, MATCH_SELECTED_E action)
643 match_selected_cb_do(data,
645 get_filter_from_packet_list_row_and_column(data));
648 /* This function allows users to right click in the details window and copy the text
649 * information to the operating systems clipboard.
651 * We first check to see if a string representation is setup in the tree and then
652 * read the string. If not available then we try to grab the value. If all else
653 * fails we display a message to the user to indicate the copy could not be completed.
656 copy_selected_plist_cb(GtkWidget *w _U_, gpointer data _U_, COPY_SELECTED_E action)
658 GString *gtk_text_str = g_string_new("");
659 char labelstring[256];
660 char *stringpointer = labelstring;
664 case COPY_SELECTED_DESCRIPTION:
665 if (cfile.finfo_selected->rep->representation != 0) {
666 g_string_append(gtk_text_str, cfile.finfo_selected->rep->representation);
669 case COPY_SELECTED_FIELDNAME:
670 if (cfile.finfo_selected->hfinfo->abbrev != 0) {
671 g_string_append(gtk_text_str, cfile.finfo_selected->hfinfo->abbrev);
674 case COPY_SELECTED_VALUE:
675 if (cfile.edt !=0 ) {
676 g_string_append(gtk_text_str,
677 get_node_field_value(cfile.finfo_selected, cfile.edt));
684 if (gtk_text_str->len == 0) {
685 /* If no representation then... Try to read the value */
686 proto_item_fill_label(cfile.finfo_selected, stringpointer);
687 g_string_append(gtk_text_str, stringpointer);
690 if (gtk_text_str->len == 0) {
691 /* Could not get item so display error msg */
692 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not acquire information to copy, try expanding or choosing another item");
694 /* Copy string to clipboard */
695 copy_to_clipboard(gtk_text_str);
697 g_string_free(gtk_text_str, TRUE); /* Free the memory */
701 /* mark as reference time frame */
703 set_frame_reftime(gboolean set, frame_data *frame, gint row) {
707 frame->flags.ref_time=1;
709 frame->flags.ref_time=0;
711 cf_reftime_packets(&cfile);
712 #ifdef NEW_PACKET_LIST
713 if (!frame->flags.ref_time && !frame->flags.passed_dfilter) {
714 new_packet_list_freeze();
715 cfile.displayed_count--;
716 new_packet_list_recreate_visible_rows();
717 new_packet_list_thaw();
719 new_packet_list_queue_draw();
724 static void reftime_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
728 timestamp_set_type(TS_RELATIVE);
729 recent.gui_time_format = TS_RELATIVE;
730 #ifdef NEW_PACKET_LIST
731 cf_timestamp_auto_precision(&cfile);
732 new_packet_list_queue_draw();
734 cf_change_time_formats(&cfile);
740 g_assert_not_reached();
743 if (cfile.current_frame) {
744 set_frame_reftime(!cfile.current_frame->flags.ref_time,
745 cfile.current_frame, cfile.current_row);
751 reftime_frame_cb(GtkWidget *w _U_, gpointer data _U_, REFTIME_ACTION_E action)
753 static GtkWidget *reftime_dialog = NULL;
757 if (cfile.current_frame) {
758 if(recent.gui_time_format != TS_RELATIVE && cfile.current_frame->flags.ref_time==0) {
759 reftime_dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO,
760 "%sSwitch to the appropriate Time Display Format?%s\n\n"
761 "Time References don't work well with the currently selected Time Display Format.\n\n"
762 "Do you want to switch to \"Seconds Since Beginning of Capture\" now?",
763 simple_dialog_primary_start(), simple_dialog_primary_end());
764 simple_dialog_set_cb(reftime_dialog, reftime_answered_cb, NULL);
766 set_frame_reftime(!cfile.current_frame->flags.ref_time,
767 cfile.current_frame, cfile.current_row);
771 case REFTIME_FIND_NEXT:
772 find_previous_next_frame_with_filter("frame.ref_time", FALSE);
774 case REFTIME_FIND_PREV:
775 find_previous_next_frame_with_filter("frame.ref_time", TRUE);
781 find_next_mark_cb(GtkWidget *w _U_, gpointer data _U_, int action _U_)
783 find_previous_next_frame_with_filter("frame.marked == TRUE", FALSE);
787 find_prev_mark_cb(GtkWidget *w _U_, gpointer data _U_, int action _U_)
789 find_previous_next_frame_with_filter("frame.marked == TRUE", TRUE);
793 tree_view_selection_changed_cb(GtkTreeSelection *sel, gpointer user_data _U_)
796 gchar *help_str = NULL;
797 gchar len_str[2+10+1+5+1]; /* ", {N} bytes\0",
799 gboolean has_blurb = FALSE;
800 guint length = 0, byte_len;
801 GtkWidget *byte_view;
802 const guint8 *byte_data;
807 /* if nothing is selected */
808 if (!gtk_tree_selection_get_selected(sel, &model, &iter))
811 * Which byte view is displaying the current protocol tree
814 byte_view = get_notebook_bv_ptr(byte_nb_ptr_gbl);
815 if (byte_view == NULL)
818 byte_data = get_byte_view_data_and_length(byte_view, &byte_len);
819 if (byte_data == NULL)
822 cf_unselect_field(&cfile);
823 packet_hex_print(byte_view, byte_data,
824 cfile.current_frame, NULL, byte_len);
825 proto_help_menu_modify(sel, &cfile);
828 gtk_tree_model_get(model, &iter, 1, &finfo, -1);
831 set_notebook_page(byte_nb_ptr_gbl, finfo->ds_tvb);
833 byte_view = get_notebook_bv_ptr(byte_nb_ptr_gbl);
834 byte_data = get_byte_view_data_and_length(byte_view, &byte_len);
835 g_assert(byte_data != NULL);
837 cfile.finfo_selected = finfo;
838 set_menus_for_selected_tree_row(&cfile);
841 if (finfo->hfinfo->blurb != NULL &&
842 finfo->hfinfo->blurb[0] != '\0') {
844 length = (guint) strlen(finfo->hfinfo->blurb);
846 length = (guint) strlen(finfo->hfinfo->name);
848 finfo_length = finfo->length + finfo->appendix_length;
850 if (finfo_length == 0) {
852 } else if (finfo_length == 1) {
853 g_strlcpy (len_str, ", 1 byte", sizeof len_str);
855 g_snprintf (len_str, sizeof len_str, ", %d bytes", finfo_length);
857 statusbar_pop_field_msg(); /* get rid of current help msg */
859 help_str = g_strdup_printf(" %s (%s)%s",
860 (has_blurb) ? finfo->hfinfo->blurb : finfo->hfinfo->name,
861 finfo->hfinfo->abbrev, len_str);
862 statusbar_push_field_msg(help_str);
866 * Don't show anything if the field name is zero-length;
867 * the pseudo-field for "proto_tree_add_text()" is such
868 * a field, and we don't want "Text (text)" showing up
869 * on the status line if you've selected such a field.
871 * XXX - there are zero-length fields for which we *do*
872 * want to show the field name.
874 * XXX - perhaps the name and abbrev field should be null
875 * pointers rather than null strings for that pseudo-field,
876 * but we'd have to add checks for null pointers in some
877 * places if we did that.
879 * Or perhaps protocol tree items added with
880 * "proto_tree_add_text()" should have -1 as the field index,
881 * with no pseudo-field being used, but that might also
882 * require special checks for -1 to be added.
884 statusbar_push_field_msg("");
887 packet_hex_print(byte_view, byte_data, cfile.current_frame, finfo,
889 proto_help_menu_modify(sel, &cfile);
892 void collapse_all_cb(GtkWidget *widget _U_, gpointer data _U_) {
894 collapse_all_tree(cfile.edt->tree, tree_view_gbl);
897 void expand_all_cb(GtkWidget *widget _U_, gpointer data _U_) {
899 expand_all_tree(cfile.edt->tree, tree_view_gbl);
902 void apply_as_custom_column_cb (GtkWidget *widget _U_, gpointer data _U_)
904 if (cfile.finfo_selected) {
905 column_prefs_add_custom(COL_CUSTOM, cfile.finfo_selected->hfinfo->name,
906 cfile.finfo_selected->hfinfo->abbrev);
907 /* Recreate the packet list according to new preferences */
908 #ifdef NEW_PACKET_LIST
909 new_packet_list_recreate ();
911 packet_list_recreate ();
913 if (!prefs.gui_use_pref_save) {
916 cfile.cinfo.columns_changed = FALSE; /* Reset value */
920 void expand_tree_cb(GtkWidget *widget _U_, gpointer data _U_) {
923 path = tree_find_by_field_info(GTK_TREE_VIEW(tree_view_gbl), cfile.finfo_selected);
925 /* the mouse position is at an entry, expand that one */
926 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view_gbl), path, TRUE);
927 gtk_tree_path_free(path);
931 void resolve_name_cb(GtkWidget *widget _U_, gpointer data _U_) {
932 if (cfile.edt->tree) {
933 guint32 tmp = g_resolv_flags;
934 g_resolv_flags = RESOLV_ALL;
935 proto_tree_draw(cfile.edt->tree, tree_view_gbl);
936 g_resolv_flags = tmp;
941 main_set_for_capture_file(gboolean have_capture_file_in)
943 have_capture_file = have_capture_file_in;
945 main_widgets_show_or_hide();
951 /* get the current geometry, before writing it to disk */
952 main_save_window_geometry(top_level);
954 /* write user's recent file to disk
955 * It is no problem to write this file, even if we do not quit */
956 write_profile_recent();
959 /* XXX - should we check whether the capture file is an
960 unsaved temporary file for a live capture and, if so,
961 pop up a "do you want to exit without saving the capture
962 file?" dialog, and then just return, leaving said dialog
963 box to forcibly quit if the user clicks "OK"?
965 If so, note that this should be done in a subroutine that
966 returns TRUE if we do so, and FALSE otherwise, and if it
967 returns TRUE we should return TRUE without nuking anything.
969 Note that, if we do that, we might also want to check if
970 an "Update list of packets in real time" capture is in
971 progress and, if so, ask whether they want to terminate
972 the capture and discard it, and return TRUE, before nuking
973 any child capture, if they say they don't want to do so. */
976 /* Nuke any child capture in progress. */
977 capture_kill_child(&global_capture_opts);
980 /* Are we in the middle of reading a capture? */
981 if (cfile.state == FILE_READ_IN_PROGRESS) {
982 /* Yes, so we can't just close the file and quit, as
983 that may yank the rug out from under the read in
984 progress; instead, just set the state to
985 "FILE_READ_ABORTED" and return - the code doing the read
986 will check for that and, if it sees that, will clean
988 cfile.state = FILE_READ_ABORTED;
990 /* Say that the window should *not* be deleted;
991 that'll be done by the code that cleans up. */
994 /* Close any capture file we have open; on some OSes, you
995 can't unlink a temporary capture file if you have it
997 "cf_close()" will unlink it after closing it if
998 it's a temporary file.
1000 We do this here, rather than after the main loop returns,
1001 as, after the main loop returns, the main window may have
1002 been destroyed (if this is called due to a "destroy"
1003 even on the main window rather than due to the user
1004 selecting a menu item), and there may be a crash
1005 or other problem when "cf_close()" tries to
1006 clean up stuff in the main window.
1008 XXX - is there a better place to put this?
1009 Or should we have a routine that *just* closes the
1010 capture file, and doesn't do anything with the UI,
1011 which we'd call here, and another routine that
1012 calls that routine and also cleans up the UI, which
1013 we'd call elsewhere? */
1016 /* Exit by leaving the main loop, so that any quit functions
1017 we registered get called. */
1020 /* Say that the window should be deleted. */
1026 main_window_delete_event_cb(GtkWidget *widget _U_, GdkEvent *event _U_, gpointer data _U_)
1030 if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
1031 gtk_window_present(GTK_WINDOW(top_level));
1032 /* user didn't saved his current file, ask him */
1033 dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL,
1034 "%sSave capture file before program quit?%s\n\n"
1035 "If you quit the program without saving, your capture data will be discarded.",
1036 simple_dialog_primary_start(), simple_dialog_primary_end());
1037 simple_dialog_set_cb(dialog, file_quit_answered_cb, NULL);
1040 /* unchanged file, just exit */
1041 /* "main_do_quit()" indicates whether the main window should be deleted. */
1042 return main_do_quit();
1048 main_pane_load_window_geometry(void)
1050 if (recent.has_gui_geometry_main_upper_pane && recent.gui_geometry_main_upper_pane)
1051 gtk_paned_set_position(GTK_PANED(main_first_pane), recent.gui_geometry_main_upper_pane);
1052 if (recent.has_gui_geometry_main_lower_pane && recent.gui_geometry_main_lower_pane) {
1053 gtk_paned_set_position(GTK_PANED(main_second_pane), recent.gui_geometry_main_lower_pane);
1059 main_load_window_geometry(GtkWidget *widget)
1061 window_geometry_t geom;
1063 geom.set_pos = prefs.gui_geometry_save_position;
1064 geom.x = recent.gui_geometry_main_x;
1065 geom.y = recent.gui_geometry_main_y;
1066 geom.set_size = prefs.gui_geometry_save_size;
1067 if (recent.gui_geometry_main_width > 0 &&
1068 recent.gui_geometry_main_height > 0) {
1069 geom.width = recent.gui_geometry_main_width;
1070 geom.height = recent.gui_geometry_main_height;
1071 geom.set_maximized = prefs.gui_geometry_save_maximized;
1073 /* We assume this means the width and height weren't set in
1074 the "recent" file (or that there is no "recent" file),
1075 and weren't set to a default value, so we don't set the
1076 size. (The "recent" file code rejects non-positive width
1077 and height values.) */
1078 geom.set_size = FALSE;
1080 geom.maximized = recent.gui_geometry_main_maximized;
1082 window_set_geometry(widget, &geom);
1084 main_pane_load_window_geometry();
1085 statusbar_load_window_geometry();
1090 main_save_window_geometry(GtkWidget *widget)
1092 window_geometry_t geom;
1094 window_get_geometry(widget, &geom);
1096 if (prefs.gui_geometry_save_position) {
1097 recent.gui_geometry_main_x = geom.x;
1098 recent.gui_geometry_main_y = geom.y;
1101 if (prefs.gui_geometry_save_size) {
1102 recent.gui_geometry_main_width = geom.width;
1103 recent.gui_geometry_main_height = geom.height;
1106 if(prefs.gui_geometry_save_maximized) {
1107 recent.gui_geometry_main_maximized = geom.maximized;
1110 recent.gui_geometry_main_upper_pane = gtk_paned_get_position(GTK_PANED(main_first_pane));
1111 recent.gui_geometry_main_lower_pane = gtk_paned_get_position(GTK_PANED(main_second_pane));
1112 statusbar_save_window_geometry();
1115 static void file_quit_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
1119 /* save file first */
1120 file_save_as_cmd(after_save_exit, NULL);
1122 case(ESD_BTN_QUIT_DONT_SAVE):
1125 case(ESD_BTN_CANCEL):
1128 g_assert_not_reached();
1133 file_quit_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
1137 if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
1138 /* user didn't saved his current file, ask him */
1139 dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL,
1140 "%sSave capture file before program quit?%s\n\n"
1141 "If you quit the program without saving, your capture data will be discarded.",
1142 simple_dialog_primary_start(), simple_dialog_primary_end());
1143 simple_dialog_set_cb(dialog, file_quit_answered_cb, NULL);
1145 /* unchanged file, just exit */
1151 print_usage(gboolean print_ver) {
1161 fprintf(output, "Wireshark " VERSION "%s\n"
1162 "Interactively dump and analyze network traffic.\n"
1163 "See http://www.wireshark.org for more information.\n"
1166 wireshark_svnversion, get_copyright_info());
1170 fprintf(output, "\n");
1171 fprintf(output, "Usage: wireshark [options] ... [ <infile> ]\n");
1172 fprintf(output, "\n");
1175 fprintf(output, "Capture interface:\n");
1176 fprintf(output, " -i <interface> name or idx of interface (def: first non-loopback)\n");
1177 fprintf(output, " -f <capture filter> packet filter in libpcap filter syntax\n");
1178 fprintf(output, " -s <snaplen> packet snapshot length (def: 65535)\n");
1179 fprintf(output, " -p don't capture in promiscuous mode\n");
1180 fprintf(output, " -k start capturing immediately (def: do nothing)\n");
1181 fprintf(output, " -Q quit Wireshark after capturing\n");
1182 fprintf(output, " -S update packet display when new packets are captured\n");
1183 fprintf(output, " -l turn on automatic scrolling while -S is in use\n");
1184 #if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
1185 fprintf(output, " -B <buffer size> size of kernel buffer (def: 1MB)\n");
1187 fprintf(output, " -y <link type> link layer type (def: first appropriate)\n");
1188 fprintf(output, " -D print list of interfaces and exit\n");
1189 fprintf(output, " -L print list of link-layer types of iface and exit\n");
1190 fprintf(output, "\n");
1191 fprintf(output, "Capture stop conditions:\n");
1192 fprintf(output, " -c <packet count> stop after n packets (def: infinite)\n");
1193 fprintf(output, " -a <autostop cond.> ... duration:NUM - stop after NUM seconds\n");
1194 fprintf(output, " filesize:NUM - stop this file after NUM KB\n");
1195 fprintf(output, " files:NUM - stop after NUM files\n");
1196 /*fprintf(output, "\n");*/
1197 fprintf(output, "Capture output:\n");
1198 fprintf(output, " -b <ringbuffer opt.> ... duration:NUM - switch to next file after NUM secs\n");
1199 fprintf(output, " filesize:NUM - switch to next file after NUM KB\n");
1200 fprintf(output, " files:NUM - ringbuffer: replace after NUM files\n");
1201 #endif /* HAVE_LIBPCAP */
1203 /*fprintf(output, "\n");*/
1204 fprintf(output, "Input file:\n");
1205 fprintf(output, " -r <infile> set the filename to read from (no pipes or stdin!)\n");
1207 fprintf(output, "\n");
1208 fprintf(output, "Processing:\n");
1209 fprintf(output, " -R <read filter> packet filter in Wireshark display filter syntax\n");
1210 fprintf(output, " -n disable all name resolutions (def: all enabled)\n");
1211 fprintf(output, " -N <name resolve flags> enable specific name resolution(s): \"mntC\"\n");
1213 fprintf(output, "\n");
1214 fprintf(output, "User interface:\n");
1215 fprintf(output, " -C <config profile> start with specified configuration profile\n");
1216 fprintf(output, " -g <packet number> go to specified packet number after \"-r\"\n");
1217 fprintf(output, " -J <jump filter> jump to the first packet matching the (display) filter\n");
1218 fprintf(output, " -j search backwards for a matching packet after \"-J\"\n");
1219 fprintf(output, " -m <font> set the font name used for most text\n");
1220 fprintf(output, " -t ad|a|r|d|dd|e output format of time stamps (def: r: rel. to first)\n");
1221 fprintf(output, " -u s|hms output format of seconds (def: s: seconds)\n");
1222 fprintf(output, " -X <key>:<value> eXtension options, see man page for details\n");
1223 fprintf(output, " -z <statistics> show various statistics, see man page for details\n");
1225 fprintf(output, "\n");
1226 fprintf(output, "Output:\n");
1227 fprintf(output, " -w <outfile|-> set the output filename (or '-' for stdout)\n");
1229 fprintf(output, "\n");
1230 fprintf(output, "Miscellaneous:\n");
1231 fprintf(output, " -h display this help and exit\n");
1232 fprintf(output, " -v display version info and exit\n");
1233 fprintf(output, " -P <key>:<path> persconf:path - personal configuration files\n");
1234 fprintf(output, " persdata:path - personal data files\n");
1235 fprintf(output, " -o <name>:<value> ... override preference or recent setting\n");
1236 fprintf(output, " -K <keytab> keytab file to use for kerberos decryption\n");
1238 fprintf(output, " --display=DISPLAY X display to use\n");
1253 printf(PACKAGE " " VERSION "%s\n"
1260 wireshark_svnversion, get_copyright_info(), comp_info_str->str,
1261 runtime_info_str->str);
1269 * Print to the standard error. On Windows, create a console for the
1270 * standard error to show up on, if necessary.
1271 * XXX - pop this up in a window of some sort on UNIX+X11 if the controlling
1272 * terminal isn't the standard error?
1275 vfprintf_stderr(const char *fmt, va_list ap)
1280 vfprintf(stderr, fmt, ap);
1284 fprintf_stderr(const char *fmt, ...)
1289 vfprintf_stderr(fmt, ap);
1294 * Report an error in command-line arguments.
1295 * Creates a console on Windows.
1298 cmdarg_err(const char *fmt, ...)
1302 fprintf_stderr("wireshark: ");
1304 vfprintf_stderr(fmt, ap);
1306 fprintf_stderr("\n");
1310 * Report additional information for an error in command-line arguments.
1311 * Creates a console on Windows.
1312 * XXX - pop this up in a window of some sort on UNIX+X11 if the controlling
1313 * terminal isn't the standard error?
1316 cmdarg_err_cont(const char *fmt, ...)
1321 vfprintf_stderr(fmt, ap);
1322 fprintf_stderr("\n");
1326 #if defined(_WIN32) || ! defined USE_THREADS
1328 Once every 3 seconds we get a callback here which we use to update
1329 the tap extensions. Since Gtk1 is single threaded we dont have to
1330 worry about any locking or critical regions.
1333 tap_update_cb(gpointer data _U_)
1335 draw_tap_listeners(FALSE);
1339 /* Restart the tap update display timer with new configured interval */
1340 void reset_tap_update_timer(void)
1342 g_source_remove(tap_update_timer_id);
1343 tap_update_timer_id = g_timeout_add(prefs.tap_update_interval, tap_update_cb, NULL);
1348 /* if these three functions are copied to gtk1 Wireshark, since gtk1 does not
1349 use threads all update_thread_mutex can be dropped and protect/unprotect
1350 would just be empty functions.
1352 This allows gtk2-rpcstat.c and friends to be copied unmodified to
1353 gtk1-wireshark and it will just work.
1355 static GStaticMutex update_thread_mutex = G_STATIC_MUTEX_INIT;
1357 update_thread(gpointer data _U_)
1361 g_get_current_time(&tv1);
1362 g_static_mutex_lock(&update_thread_mutex);
1363 gdk_threads_enter();
1364 draw_tap_listeners(FALSE);
1365 gdk_threads_leave();
1366 g_static_mutex_unlock(&update_thread_mutex);
1368 g_get_current_time(&tv2);
1370 /* Assuming it took less than configured time to update tap listeners... */
1371 if( (tv1.tv_sec * 1000000 + tv1.tv_usec + prefs.tap_update_interval * 1000) >
1372 (tv2.tv_sec * 1000000 + tv2.tv_usec) ){
1373 /* Wait for remainder of configured time */
1374 g_usleep((tv1.tv_sec * 1000000 + tv1.tv_usec + prefs.tap_update_interval * 1000) -
1375 (tv2.tv_sec * 1000000 + tv2.tv_usec));
1382 protect_thread_critical_region(void)
1384 #if !defined(_WIN32) && defined USE_THREADS
1385 g_static_mutex_lock(&update_thread_mutex);
1389 unprotect_thread_critical_region(void)
1391 #if !defined(_WIN32) && defined USE_THREADS
1392 g_static_mutex_unlock(&update_thread_mutex);
1397 * Periodically process outstanding hostname lookups. If we have new items,
1398 * redraw the packet list and tree view.
1402 resolv_update_cb(gpointer data _U_)
1404 /* Anything new show up? */
1405 if (host_name_lookup_process(NULL)) {
1406 if (pkt_scrollw->window)
1407 gdk_window_invalidate_rect(pkt_scrollw->window, NULL, TRUE);
1408 if (tv_scrollw->window)
1409 gdk_window_invalidate_rect(tv_scrollw->window, NULL, TRUE);
1412 /* Always check. Even if we don't do async lookups we could still get
1413 passive updates, e.g. from DNS packets. */
1418 /* Set the file name in the name for the main window and in the name for the main window's icon. */
1420 set_display_filename(capture_file *cf)
1424 if (!cf->is_tempfile && cf->filename) {
1425 /* Add this filename to the list of recent files in the "Recent Files" submenu */
1426 add_menu_recent_capture_file(cf->filename);
1430 win_name = g_strdup_printf("%s - Wireshark", cf_get_display_name(cf));
1431 set_main_window_name(win_name);
1435 GtkWidget *close_dlg = NULL;
1438 priv_warning_dialog_cb(gpointer dialog, gint btn _U_, gpointer data _U_)
1440 recent.privs_warn_if_elevated = !simple_dialog_check_get(dialog);
1445 npf_warning_dialog_cb(gpointer dialog, gint btn _U_, gpointer data _U_)
1447 recent.privs_warn_if_no_npf = !simple_dialog_check_get(dialog);
1452 main_cf_cb_file_closing(capture_file *cf)
1455 /* if we have more than 10000 packets, show a splash screen while closing */
1456 /* XXX - don't know a better way to decide whether to show or not,
1457 * as most of the time is spend in a single eth_clist_clear function,
1458 * so we can't use a progress bar here! */
1459 if(cf->count > 10000) {
1460 close_dlg = simple_dialog(ESD_TYPE_STOP, ESD_BTN_NONE,
1461 "%sClosing file!%s\n\nPlease wait ...",
1462 simple_dialog_primary_start(),
1463 simple_dialog_primary_end());
1464 gtk_window_set_position(GTK_WINDOW(close_dlg), GTK_WIN_POS_CENTER_ON_PARENT);
1467 /* Destroy all windows, which refer to the
1468 capture file we're closing. */
1469 destroy_packet_wins();
1470 file_save_as_destroy();
1472 /* Restore the standard title bar message. */
1473 set_main_window_name("The Wireshark Network Analyzer");
1475 /* Disable all menu items that make sense only if you have a capture. */
1476 set_menus_for_capture_file(NULL);
1477 set_menus_for_captured_packets(FALSE);
1478 set_menus_for_selected_packet(cf);
1479 set_menus_for_capture_in_progress(FALSE);
1480 set_capture_if_dialog_for_capture_in_progress(FALSE);
1481 set_menus_for_selected_tree_row(cf);
1483 /* Set up main window for no capture file. */
1484 main_set_for_capture_file(FALSE);
1486 main_window_update();
1490 main_cf_cb_file_closed(capture_file *cf _U_)
1492 if(close_dlg != NULL) {
1493 splash_destroy(close_dlg);
1500 main_cf_cb_file_read_started(capture_file *cf _U_)
1502 tap_dfilter_dlg_update();
1504 /* Set up main window for a capture file. */
1505 main_set_for_capture_file(TRUE);
1509 main_cf_cb_file_read_finished(capture_file *cf)
1511 set_display_filename(cf);
1513 /* Enable menu items that make sense if you have a capture file you've
1514 finished reading. */
1515 set_menus_for_capture_file(cf);
1517 /* Enable menu items that make sense if you have some captured packets. */
1518 set_menus_for_captured_packets(TRUE);
1522 static GList *icon_list_create(
1523 const char **icon16_xpm,
1524 const char **icon32_xpm,
1525 const char **icon48_xpm,
1526 const char **icon64_xpm)
1528 GList *icon_list = NULL;
1529 GdkPixbuf * pixbuf16;
1530 GdkPixbuf * pixbuf32;
1531 GdkPixbuf * pixbuf48;
1532 GdkPixbuf * pixbuf64;
1535 if(icon16_xpm != NULL) {
1536 pixbuf16 = gdk_pixbuf_new_from_xpm_data(icon16_xpm);
1538 icon_list = g_list_append(icon_list, pixbuf16);
1541 if(icon32_xpm != NULL) {
1542 pixbuf32 = gdk_pixbuf_new_from_xpm_data(icon32_xpm);
1544 icon_list = g_list_append(icon_list, pixbuf32);
1547 if(icon48_xpm != NULL) {
1548 pixbuf48 = gdk_pixbuf_new_from_xpm_data(icon48_xpm);
1550 icon_list = g_list_append(icon_list, pixbuf48);
1553 if(icon64_xpm != NULL) {
1554 pixbuf64 = gdk_pixbuf_new_from_xpm_data(icon64_xpm);
1556 icon_list = g_list_append(icon_list, pixbuf64);
1563 main_capture_set_main_window_title(capture_options *capture_opts)
1565 GString *title = g_string_new("");
1567 g_string_append(title, "Capturing ");
1568 if(capture_opts->iface) {
1569 g_string_append_printf(title, "from %s ", cf_get_tempfile_source(capture_opts->cf));
1571 g_string_append(title, "- Wireshark");
1573 set_main_window_name(title->str);
1574 g_string_free(title, TRUE);
1578 main_capture_cb_capture_prepared(capture_options *capture_opts)
1580 static GList *icon_list = NULL;
1582 main_capture_set_main_window_title(capture_opts);
1584 if(icon_list == NULL) {
1585 icon_list = icon_list_create(wsiconcap16_xpm, wsiconcap32_xpm, wsiconcap48_xpm, NULL);
1587 gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
1589 /* Disable menu items that make no sense if you're currently running
1591 set_menus_for_capture_in_progress(TRUE);
1592 set_capture_if_dialog_for_capture_in_progress(TRUE);
1594 /* Don't set up main window for a capture file. */
1595 main_set_for_capture_file(FALSE);
1599 main_capture_cb_capture_update_started(capture_options *capture_opts)
1601 /* We've done this in "prepared" above, but it will be cleared while
1602 switching to the next multiple file. */
1603 main_capture_set_main_window_title(capture_opts);
1605 set_menus_for_capture_in_progress(TRUE);
1606 set_capture_if_dialog_for_capture_in_progress(TRUE);
1608 /* Enable menu items that make sense if you have some captured
1609 packets (yes, I know, we don't have any *yet*). */
1610 set_menus_for_captured_packets(TRUE);
1612 /* Set up main window for a capture file. */
1613 main_set_for_capture_file(TRUE);
1617 main_capture_cb_capture_update_finished(capture_options *capture_opts)
1619 capture_file *cf = capture_opts->cf;
1620 static GList *icon_list = NULL;
1622 set_display_filename(cf);
1624 /* Enable menu items that make sense if you're not currently running
1626 set_menus_for_capture_in_progress(FALSE);
1627 set_capture_if_dialog_for_capture_in_progress(FALSE);
1629 /* Enable menu items that make sense if you have a capture file
1630 you've finished reading. */
1631 set_menus_for_capture_file(cf);
1633 /* Set up main window for a capture file. */
1634 main_set_for_capture_file(TRUE);
1636 if(icon_list == NULL) {
1637 icon_list = icon_list_create(wsicon16_xpm, wsicon32_xpm, wsicon48_xpm, wsicon64_xpm);
1639 gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
1641 if(global_capture_opts.quit_after_cap) {
1642 /* command line asked us to quit after the capture */
1643 /* don't pop up a dialog to ask for unsaved files etc. */
1649 main_capture_cb_capture_fixed_started(capture_options *capture_opts _U_)
1651 /* Don't set up main window for a capture file. */
1652 main_set_for_capture_file(FALSE);
1656 main_capture_cb_capture_fixed_finished(capture_options *capture_opts _U_)
1659 capture_file *cf = capture_opts->cf;
1661 static GList *icon_list = NULL;
1663 /*set_display_filename(cf);*/
1665 /* Enable menu items that make sense if you're not currently running
1667 set_menus_for_capture_in_progress(FALSE);
1668 set_capture_if_dialog_for_capture_in_progress(FALSE);
1670 /* Restore the standard title bar message */
1671 /* (just in case we have trouble opening the capture file). */
1672 set_main_window_name("The Wireshark Network Analyzer");
1674 if(icon_list == NULL) {
1675 icon_list = icon_list_create(wsicon16_xpm, wsicon32_xpm, wsicon48_xpm, wsicon64_xpm);
1677 gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
1679 /* We don't have loaded the capture file, this will be done later.
1680 * For now we still have simply a blank screen. */
1682 if(global_capture_opts.quit_after_cap) {
1683 /* command line asked us to quit after the capture */
1684 /* don't pop up a dialog to ask for unsaved files etc. */
1689 #endif /* HAVE_LIBPCAP */
1692 main_cf_cb_packet_selected(gpointer data)
1694 capture_file *cf = data;
1696 /* Display the GUI protocol tree and packet bytes.
1697 XXX - why do we dump core if we call "proto_tree_draw()"
1698 before calling "add_byte_views()"? */
1699 add_main_byte_views(cf->edt);
1700 main_proto_tree_draw(cf->edt->tree);
1702 /* The user is searching for a string in the data or a hex value,
1703 * highlight the field that is found in the tree and hex displays. */
1704 if((cfile.string || cfile.hex) && cfile.search_pos != 0) {
1705 highlight_field(cf->edt->tvb, cfile.search_pos,
1706 (GtkTreeView *)tree_view_gbl, cf->edt->tree);
1707 cfile.search_pos = 0; /* Reset the position */
1710 /* A packet is selected. */
1711 set_menus_for_selected_packet(cf);
1715 main_cf_cb_packet_unselected(capture_file *cf)
1717 /* Clear out the display of that packet. */
1718 clear_tree_and_hex_views();
1720 /* No packet is selected. */
1721 set_menus_for_selected_packet(cf);
1725 main_cf_cb_field_unselected(capture_file *cf)
1727 set_menus_for_selected_tree_row(cf);
1731 main_cf_cb_file_save_reload_finished(gpointer data _U_)
1733 set_display_filename(&cfile);
1734 set_menus_for_capture_file(&cfile);
1738 main_cf_callback(gint event, gpointer data, gpointer user_data _U_)
1741 case(cf_cb_file_closing):
1742 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Closing");
1743 main_cf_cb_file_closing(data);
1745 case(cf_cb_file_closed):
1746 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Closed");
1747 main_cf_cb_file_closed(data);
1749 case(cf_cb_file_read_started):
1750 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Read started");
1751 main_cf_cb_file_read_started(data);
1753 case(cf_cb_file_read_finished):
1754 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Read finished");
1755 main_cf_cb_file_read_finished(data);
1757 case(cf_cb_packet_selected):
1758 main_cf_cb_packet_selected(data);
1760 case(cf_cb_packet_unselected):
1761 main_cf_cb_packet_unselected(data);
1763 case(cf_cb_field_unselected):
1764 main_cf_cb_field_unselected(data);
1766 case(cf_cb_file_save_started):
1767 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Save started");
1769 case(cf_cb_file_save_finished):
1770 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Save finished");
1772 case(cf_cb_file_save_reload_finished):
1773 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Reload finished");
1774 main_cf_cb_file_save_reload_finished(data);
1776 case(cf_cb_file_save_failed):
1777 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Save failed");
1780 g_warning("main_cf_callback: event %u unknown", event);
1781 g_assert_not_reached();
1787 main_capture_callback(gint event, capture_options *capture_opts, gpointer user_data _U_)
1789 #ifdef HAVE_GTKOSXAPPLICATION
1790 GtkOSXApplication *theApp;
1793 case(capture_cb_capture_prepared):
1794 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture prepared");
1795 main_capture_cb_capture_prepared(capture_opts);
1797 case(capture_cb_capture_update_started):
1798 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update started");
1799 main_capture_cb_capture_update_started(capture_opts);
1800 #ifdef HAVE_GTKOSXAPPLICATION
1801 theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
1802 gtk_osxapplication_set_dock_icon_pixbuf(theApp,gdk_pixbuf_new_from_xpm_data(wsiconcap48_xpm));
1805 case(capture_cb_capture_update_continue):
1806 /*g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update continue");*/
1808 case(capture_cb_capture_update_finished):
1809 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update finished");
1810 main_capture_cb_capture_update_finished(capture_opts);
1812 case(capture_cb_capture_fixed_started):
1813 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed started");
1814 main_capture_cb_capture_fixed_started(capture_opts);
1816 case(capture_cb_capture_fixed_continue):
1817 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed continue");
1819 case(capture_cb_capture_fixed_finished):
1820 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed finished");
1821 main_capture_cb_capture_fixed_finished(capture_opts);
1823 case(capture_cb_capture_stopping):
1824 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture stopping");
1825 /* Beware: this state won't be called, if the capture child
1826 * closes the capturing on it's own! */
1827 #ifdef HAVE_GTKOSXAPPLICATION
1828 theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
1829 gtk_osxapplication_set_dock_icon_pixbuf(theApp,gdk_pixbuf_new_from_xpm_data(wsicon64_xpm));
1833 g_warning("main_capture_callback: event %u unknown", event);
1834 g_assert_not_reached();
1840 get_gui_compiled_info(GString *str)
1842 epan_get_compiled_version_info(str);
1844 g_string_append(str, ", ");
1845 #ifdef HAVE_LIBPORTAUDIO
1846 #ifdef PORTAUDIO_API_1
1847 g_string_append(str, "with PortAudio <= V18");
1848 #else /* PORTAUDIO_API_1 */
1849 g_string_append(str, "with ");
1850 g_string_append(str, Pa_GetVersionText());
1851 #endif /* PORTAUDIO_API_1 */
1852 #else /* HAVE_LIBPORTAUDIO */
1853 g_string_append(str, "without PortAudio");
1854 #endif /* HAVE_LIBPORTAUDIO */
1856 g_string_append(str, ", ");
1858 get_compiled_airpcap_version(str);
1860 g_string_append(str, "without AirPcap");
1862 #ifndef NEW_PACKET_LIST
1863 g_string_append(str, ", with old_packet_list");
1868 get_gui_runtime_info(GString *str)
1870 epan_get_runtime_version_info(str);
1873 g_string_append(str, ", ");
1874 get_runtime_airpcap_version(str);
1878 g_string_append(str, ", ");
1879 u3_runtime_info(str);
1884 read_configuration_files(char **gdp_path, char **dp_path)
1886 int gpf_open_errno, gpf_read_errno;
1887 int cf_open_errno, df_open_errno;
1888 int gdp_open_errno, gdp_read_errno;
1889 int dp_open_errno, dp_read_errno;
1890 char *gpf_path, *pf_path;
1891 char *cf_path, *df_path;
1892 int pf_open_errno, pf_read_errno;
1895 /* Read the preference files. */
1896 prefs_p = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path,
1897 &pf_open_errno, &pf_read_errno, &pf_path);
1899 if (gpf_path != NULL) {
1900 if (gpf_open_errno != 0) {
1901 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
1902 "Could not open global preferences file\n\"%s\": %s.", gpf_path,
1903 strerror(gpf_open_errno));
1905 if (gpf_read_errno != 0) {
1906 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
1907 "I/O error reading global preferences file\n\"%s\": %s.", gpf_path,
1908 strerror(gpf_read_errno));
1911 if (pf_path != NULL) {
1912 if (pf_open_errno != 0) {
1913 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
1914 "Could not open your preferences file\n\"%s\": %s.", pf_path,
1915 strerror(pf_open_errno));
1917 if (pf_read_errno != 0) {
1918 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
1919 "I/O error reading your preferences file\n\"%s\": %s.", pf_path,
1920 strerror(pf_read_errno));
1927 /* if the user wants a console to be always there, well, we should open one for him */
1928 if (prefs_p->gui_console_open == console_open_always) {
1933 /* Read the capture filter file. */
1934 read_filter_list(CFILTER_LIST, &cf_path, &cf_open_errno);
1935 if (cf_path != NULL) {
1936 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
1937 "Could not open your capture filter file\n\"%s\": %s.", cf_path,
1938 strerror(cf_open_errno));
1942 /* Read the display filter file. */
1943 read_filter_list(DFILTER_LIST, &df_path, &df_open_errno);
1944 if (df_path != NULL) {
1945 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
1946 "Could not open your display filter file\n\"%s\": %s.", df_path,
1947 strerror(df_open_errno));
1951 /* Read the disabled protocols file. */
1952 read_disabled_protos_list(gdp_path, &gdp_open_errno, &gdp_read_errno,
1953 dp_path, &dp_open_errno, &dp_read_errno);
1954 if (*gdp_path != NULL) {
1955 if (gdp_open_errno != 0) {
1956 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
1957 "Could not open global disabled protocols file\n\"%s\": %s.",
1958 *gdp_path, strerror(gdp_open_errno));
1960 if (gdp_read_errno != 0) {
1961 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
1962 "I/O error reading global disabled protocols file\n\"%s\": %s.",
1963 *gdp_path, strerror(gdp_read_errno));
1968 if (*dp_path != NULL) {
1969 if (dp_open_errno != 0) {
1970 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
1971 "Could not open your disabled protocols file\n\"%s\": %s.", *dp_path,
1972 strerror(dp_open_errno));
1974 if (dp_read_errno != 0) {
1975 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
1976 "I/O error reading your disabled protocols file\n\"%s\": %s.", *dp_path,
1977 strerror(dp_read_errno));
1986 /* Check if there's something important to tell the user during startup.
1987 * We want to do this *after* showing the main window so that any windows
1988 * we pop up will be above the main window.
1992 check_and_warn_user_startup(gchar *cf_name)
1994 check_and_warn_user_startup(gchar *cf_name _U_)
1997 gchar *cur_user, *cur_group;
1998 gpointer priv_warning_dialog;
2000 /* Tell the user not to run as root. */
2001 if (running_with_special_privs() && recent.privs_warn_if_elevated) {
2002 cur_user = get_cur_username();
2003 cur_group = get_cur_groupname();
2004 priv_warning_dialog = simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
2005 "Running as user \"%s\" and group \"%s\".\n"
2006 "This could be dangerous.", cur_user, cur_group);
2009 simple_dialog_check_set(priv_warning_dialog, "Don't show this message again.");
2010 simple_dialog_set_cb(priv_warning_dialog, priv_warning_dialog_cb, NULL);
2014 /* Warn the user if npf.sys isn't loaded. */
2015 if (!stdin_capture && !cf_name && !npf_sys_is_running() && recent.privs_warn_if_no_npf && get_os_major_version() >= 6) {
2016 priv_warning_dialog = simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
2017 "The NPF driver isn't running. You may have trouble\n"
2018 "capturing or listing interfaces.");
2019 simple_dialog_check_set(priv_warning_dialog, "Don't show this message again.");
2020 simple_dialog_set_cb(priv_warning_dialog, npf_warning_dialog_cb, NULL);
2027 /* And now our feature presentation... [ fade to music ] */
2029 main(int argc, char *argv[])
2031 char *init_progfile_dir_error;
2034 gboolean arg_error = FALSE;
2036 extern int info_update_freq; /* Found in about_dlg.c. */
2037 const gchar *filter;
2045 char *gdp_path, *dp_path;
2048 gboolean start_capture = FALSE;
2049 gboolean list_link_layer_types = FALSE;
2053 gboolean capture_option_specified = FALSE;
2060 gint pl_size = 280, tv_size = 95, bv_size = 75;
2061 gchar *rc_file, *cf_name = NULL, *rfilter = NULL, *jfilter = NULL;
2062 dfilter_t *rfcode = NULL;
2063 gboolean rfilter_parse_failed = FALSE;
2066 GtkWidget *splash_win = NULL;
2067 GLogLevelFlags log_flags;
2068 guint go_to_packet = 0;
2069 gboolean jump_backwards = FALSE, saved_bw = FALSE;
2070 dfilter_t *jump_to_filter = NULL;
2073 #ifdef HAVE_GTKOSXAPPLICATION
2074 GtkOSXApplication *theApp;
2078 #if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
2079 #define OPTSTRING_B "B:"
2081 #define OPTSTRING_B ""
2082 #endif /* _WIN32 or HAVE_PCAP_CREATE */
2083 #else /* HAVE_LIBPCAP */
2084 #define OPTSTRING_B ""
2085 #endif /* HAVE_LIBPCAP */
2087 #ifdef HAVE_PCAP_CREATE
2088 #define OPTSTRING_I "I"
2090 #define OPTSTRING_I ""
2093 #define OPTSTRING "a:b:" OPTSTRING_B "c:C:Df:g:Hhi:" OPTSTRING_I "jJ:kK:lLm:nN:o:P:pQr:R:Ss:t:u:vw:X:y:z:"
2095 static const char optstring[] = OPTSTRING;
2098 * Get credential information for later use, and drop privileges
2099 * before doing anything else.
2100 * Let the user know if anything happened.
2102 get_credential_info();
2103 relinquish_special_privs_perm();
2106 * Attempt to get the pathname of the executable file.
2108 init_progfile_dir_error = init_progfile_dir(argv[0], main);
2110 /* initialize the funnel mini-api */
2111 initialize_funnel_ops();
2113 #ifdef HAVE_AIRPDCAP
2114 AirPDcapInitContext(&airpdcap_ctx);
2118 /* Load wpcap if possible. Do this before collecting the run-time version information */
2121 /* ... and also load the packet.dll from wpcap */
2122 wpcap_packet_load();
2125 /* Load the airpcap.dll. This must also be done before collecting
2126 * run-time version information. */
2127 airpcap_dll_ret_val = load_airpcap();
2129 switch (airpcap_dll_ret_val) {
2130 case AIRPCAP_DLL_OK:
2131 /* load the airpcap interfaces */
2132 airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
2134 if (airpcap_if_list == NULL || g_list_length(airpcap_if_list) == 0){
2135 if (err == CANT_GET_AIRPCAP_INTERFACE_LIST && err_str != NULL) {
2136 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", "Failed to open Airpcap Adapters!");
2139 airpcap_if_active = NULL;
2143 /* select the first ad default (THIS SHOULD BE CHANGED) */
2144 airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
2149 * XXX - Maybe we need to warn the user if one of the following happens???
2151 case AIRPCAP_DLL_OLD:
2152 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DLL_OLD\n");
2155 case AIRPCAP_DLL_ERROR:
2156 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DLL_ERROR\n");
2159 case AIRPCAP_DLL_NOT_FOUND:
2160 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DDL_NOT_FOUND\n");
2164 #endif /* HAVE_AIRPCAP */
2166 /* Start windows sockets */
2167 WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
2170 profile_store_persconffiles (TRUE);
2172 /* Assemble the compile-time version information string */
2173 comp_info_str = g_string_new("Compiled ");
2175 g_string_append(comp_info_str, "with ");
2176 g_string_append_printf(comp_info_str,
2177 #ifdef GTK_MAJOR_VERSION
2178 "GTK+ %d.%d.%d", GTK_MAJOR_VERSION, GTK_MINOR_VERSION,
2181 "GTK+ (version unknown)");
2183 g_string_append(comp_info_str, ", ");
2185 get_compiled_version_info(comp_info_str, get_gui_compiled_info);
2187 /* Assemble the run-time version information string */
2188 runtime_info_str = g_string_new("Running ");
2189 get_runtime_version_info(runtime_info_str, get_gui_runtime_info);
2191 /* Read the profile independent recent file. We have to do this here so we can */
2192 /* set the profile before it can be set from the command line parameterts */
2193 recent_read_static(&rf_path, &rf_open_errno);
2194 if (rf_path != NULL && rf_open_errno != 0) {
2195 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
2196 "Could not open common recent file\n\"%s\": %s.",
2197 rf_path, strerror(rf_open_errno));
2200 /* "pre-scan" the command line parameters, if we have "console only"
2201 parameters. We do this so we don't start GTK+ if we're only showing
2202 command-line help or version information.
2204 XXX - this pre-scan is done before we start GTK+, so we haven't
2205 run gtk_init() on the arguments. That means that GTK+ arguments
2206 have not been removed from the argument list; those arguments
2207 begin with "--", and will be treated as an error by getopt().
2209 We thus ignore errors - *and* set "opterr" to 0 to suppress the
2212 optind_initial = optind;
2213 while ((opt = getopt(argc, argv, optstring)) != -1) {
2215 case 'C': /* Configuration Profile */
2216 if (profile_exists (optarg)) {
2217 set_profile_name (optarg);
2219 cmdarg_err("Configuration Profile \"%s\" does not exist", optarg);
2223 case 'h': /* Print help and exit */
2229 if (strcmp(optarg, "-") == 0)
2230 stdin_capture = TRUE;
2233 case 'P': /* Path settings - change these before the Preferences and alike are processed */
2234 status = filesystem_opt(opt, optarg);
2236 cmdarg_err("-P flag \"%s\" failed (hint: is it quoted and existing?)", optarg);
2240 case 'v': /* Show version and exit */
2246 * Extension command line options have to be processed before
2247 * we call epan_init() as they are supposed to be used by dissectors
2248 * or taps very early in the registration process.
2252 case '?': /* Ignore errors - the "real" scan will catch them. */
2257 /* Init the "Open file" dialog directory */
2258 /* (do this after the path settings are processed) */
2260 /* Read the profile dependent (static part) of the recent file. */
2261 /* Only the static part of it will be read, as we don't have the gui now to fill the */
2262 /* recent lists which is done in the dynamic part. */
2263 /* We have to do this already here, so command line parameters can overwrite these values. */
2264 recent_read_profile_static(&rf_path, &rf_open_errno);
2265 if (rf_path != NULL && rf_open_errno != 0) {
2266 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
2267 "Could not open recent file\n\"%s\": %s.",
2268 rf_path, strerror(rf_open_errno));
2271 if (recent.gui_fileopen_remembered_dir &&
2272 test_for_directory(recent.gui_fileopen_remembered_dir) == EISDIR) {
2273 set_last_open_dir(recent.gui_fileopen_remembered_dir);
2275 set_last_open_dir(get_persdatafile_dir());
2278 /* Set getopt index back to initial value, so it will start with the
2279 first command line parameter again. Also reset opterr to 1, so that
2280 error messages are printed by getopt().
2282 XXX - this seems to work on most platforms, but time will tell.
2283 The Single UNIX Specification says "The getopt() function need
2284 not be reentrant", so this isn't guaranteed to work. The Mac
2285 OS X 10.4[.x] getopt() man page says
2287 In order to use getopt() to evaluate multiple sets of arguments, or to
2288 evaluate a single set of arguments multiple times, the variable optreset
2289 must be set to 1 before the second and each additional set of calls to
2290 getopt(), and the variable optind must be reinitialized.
2294 The optreset variable was added to make it possible to call the getopt()
2295 function multiple times. This is an extension to the IEEE Std 1003.2
2296 (``POSIX.2'') specification.
2298 which I think comes from one of the other BSDs.
2300 XXX - if we want to control all the command-line option errors, so
2301 that we can display them where we choose (e.g., in a window), we'd
2302 want to leave opterr as 0, and produce our own messages using optopt.
2303 We'd have to check the value of optopt to see if it's a valid option
2304 letter, in which case *presumably* the error is "this option requires
2305 an argument but none was specified", or not a valid option letter,
2306 in which case *presumably* the error is "this option isn't valid".
2307 Some versions of getopt() let you supply a option string beginning
2308 with ':', which means that getopt() will return ':' rather than '?'
2309 for "this option requires an argument but none was specified", but
2311 optind = optind_initial;
2314 /* Set the current locale according to the program environment.
2315 * We haven't localized anything, but some GTK widgets are localized
2316 * (the file selection dialogue, for example).
2317 * This also sets the C-language locale to the native environment. */
2320 /* Let GTK get its args (will need an X server, so do this after command line only commands handled) */
2321 gtk_init (&argc, &argv);
2323 cf_callback_add(main_cf_callback, NULL);
2325 capture_callback_add(main_capture_callback, NULL);
2327 cf_callback_add(statusbar_cf_callback, NULL);
2329 capture_callback_add(statusbar_capture_callback, NULL);
2332 /* Arrange that if we have no console window, and a GLib message logging
2333 routine is called to log a message, we pop up a console window.
2335 We do that by inserting our own handler for all messages logged
2336 to the default domain; that handler pops up a console if necessary,
2337 and then calls the default handler. */
2339 /* We might want to have component specific log levels later ... */
2343 G_LOG_LEVEL_CRITICAL|
2344 G_LOG_LEVEL_WARNING|
2345 G_LOG_LEVEL_MESSAGE|
2348 G_LOG_FLAG_FATAL|G_LOG_FLAG_RECURSION;
2350 g_log_set_handler(NULL,
2352 console_log_handler, NULL /* user_data */);
2353 g_log_set_handler(LOG_DOMAIN_MAIN,
2355 console_log_handler, NULL /* user_data */);
2358 g_log_set_handler(LOG_DOMAIN_CAPTURE,
2360 console_log_handler, NULL /* user_data */);
2361 g_log_set_handler(LOG_DOMAIN_CAPTURE_CHILD,
2363 console_log_handler, NULL /* user_data */);
2365 /* Set the initial values in the capture options. This might be overwritten
2366 by preference settings and then again by the command line parameters. */
2367 capture_opts_init(&global_capture_opts, &cfile);
2369 global_capture_opts.snaplen = MIN_PACKET_SIZE;
2370 global_capture_opts.has_ring_num_files = TRUE;
2373 /* Initialize whatever we need to allocate colors for GTK+ */
2376 /* Non-blank filter means we're remote. Throttle splash screen and resolution updates. */
2377 filter = get_conn_cfilter();
2378 if ( *filter != '\0' ) {
2379 info_update_freq = 1000; /* Milliseconds */
2382 /* We won't come till here, if we had a "console only" command line parameter. */
2383 splash_win = splash_new("Loading Wireshark ...");
2384 if (init_progfile_dir_error != NULL) {
2385 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
2386 "Can't get pathname of Wireshark: %s.\n"
2387 "It won't be possible to capture traffic.\n"
2388 "Report this to the Wireshark developers.",
2389 init_progfile_dir_error);
2390 g_free(init_progfile_dir_error);
2393 splash_update(RA_DISSECTORS, NULL, (gpointer)splash_win);
2395 /* Register all dissectors; we must do this before checking for the
2396 "-G" flag, as the "-G" flag dumps information registered by the
2397 dissectors, and we must do it before we read the preferences, in
2398 case any dissectors register preferences. */
2399 epan_init(register_all_protocols,register_all_protocol_handoffs,
2400 splash_update, (gpointer) splash_win,
2401 failure_alert_box,open_failure_alert_box,read_failure_alert_box,
2402 write_failure_alert_box);
2404 splash_update(RA_LISTENERS, NULL, (gpointer)splash_win);
2406 /* Register all tap listeners; we do this before we parse the arguments,
2407 as the "-z" argument can specify a registered tap. */
2409 /* we register the plugin taps before the other taps because
2410 stats_tree taps plugins will be registered as tap listeners
2411 by stats_tree_stat.c and need to registered before that */
2414 register_all_plugin_tap_listeners();
2417 register_all_tap_listeners();
2419 splash_update(RA_PREFERENCES, NULL, (gpointer)splash_win);
2421 /* Now register the preferences for any non-dissector modules.
2422 We must do that before we read the preferences as well. */
2423 prefs_register_modules();
2425 prefs_p = read_configuration_files (&gdp_path, &dp_path);
2427 /* multithread support currently doesn't seem to work in win32 gtk2.0.6 */
2428 #if !defined(_WIN32) && defined(G_THREADS_ENABLED) && defined USE_THREADS
2431 g_thread_init(NULL);
2433 ut=g_thread_create(update_thread, NULL, FALSE, NULL);
2434 g_thread_set_priority(ut, G_THREAD_PRIORITY_LOW);
2436 #else /* !_WIN32 && G_THREADS_ENABLED && USE_THREADS */
2437 /* this is to keep tap extensions updating once every 3 seconds */
2438 tap_update_timer_id = g_timeout_add(prefs_p->tap_update_interval, tap_update_cb, NULL);
2439 #endif /* !_WIN32 && G_THREADS_ENABLED && USE_THREADS */
2441 splash_update(RA_CONFIGURATION, NULL, (gpointer)splash_win);
2443 cap_file_init(&cfile);
2445 /* Fill in capture options with values from the preferences */
2446 prefs_to_capture_opts();
2448 /* Now get our args */
2449 while ((opt = getopt(argc, argv, optstring)) != -1) {
2451 /*** capture option specific ***/
2452 case 'a': /* autostop criteria */
2453 case 'b': /* Ringbuffer option */
2454 case 'c': /* Capture xxx packets */
2455 case 'f': /* capture filter */
2456 case 'k': /* Start capture immediately */
2457 case 'H': /* Hide capture info dialog box */
2458 case 'i': /* Use interface xxx */
2459 case 'p': /* Don't capture in promiscuous mode */
2460 #ifdef HAVE_PCAP_CREATE
2461 case 'I': /* Capture in monitor mode, if available */
2463 case 'Q': /* Quit after capture (just capture to file) */
2464 case 's': /* Set the snapshot (capture) length */
2465 case 'S': /* "Sync" mode: used for following file ala tail -f */
2466 case 'w': /* Write to capture file xxx */
2467 case 'y': /* Set the pcap data link type */
2468 #if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
2469 case 'B': /* Buffer size */
2470 #endif /* _WIN32 or HAVE_PCAP_CREATE */
2472 status = capture_opts_add_opt(&global_capture_opts, opt, optarg,
2478 capture_option_specified = TRUE;
2483 #if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
2484 case 'K': /* Kerberos keytab file */
2485 read_keytab_file(optarg);
2489 /*** all non capture option specific ***/
2491 /* Configuration profile settings were already processed just ignore them this time*/
2493 case 'D': /* Print a list of capture devices and exit */
2495 if_list = capture_interface_list(&err, &err_str);
2496 if (if_list == NULL) {
2498 case CANT_GET_INTERFACE_LIST:
2499 cmdarg_err("%s", err_str);
2503 case NO_INTERFACES_FOUND:
2504 cmdarg_err("There are no interfaces on which a capture can be done");
2509 capture_opts_print_interfaces(if_list);
2510 free_interface_list(if_list);
2513 capture_option_specified = TRUE;
2517 case 'j': /* Search backwards for a matching packet from filter in option J */
2518 jump_backwards = TRUE;
2520 case 'g': /* Go to packet with the given packet number */
2521 go_to_packet = get_positive_int(optarg, "go to packet");
2523 case 'J': /* Jump to the first packet which matches the filter criteria */
2526 case 'l': /* Automatic scrolling in live capture mode */
2528 auto_scroll_live = TRUE;
2530 capture_option_specified = TRUE;
2534 case 'L': /* Print list of link-layer types and exit */
2536 list_link_layer_types = TRUE;
2538 capture_option_specified = TRUE;
2542 case 'm': /* Fixed-width font for the display */
2543 g_free(prefs_p->gui_font_name);
2544 prefs_p->gui_font_name = g_strdup(optarg);
2546 case 'n': /* No name resolution */
2547 g_resolv_flags = RESOLV_NONE;
2549 case 'N': /* Select what types of addresses/port #s to resolve */
2550 if (g_resolv_flags == RESOLV_ALL)
2551 g_resolv_flags = RESOLV_NONE;
2552 badopt = string_to_name_resolve(optarg, &g_resolv_flags);
2553 if (badopt != '\0') {
2554 cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'",
2559 case 'o': /* Override preference from command line */
2560 switch (prefs_set_pref(optarg)) {
2563 case PREFS_SET_SYNTAX_ERR:
2564 cmdarg_err("Invalid -o flag \"%s\"", optarg);
2567 case PREFS_SET_NO_SUCH_PREF:
2568 /* not a preference, might be a recent setting */
2569 switch (recent_set_arg(optarg)) {
2572 case PREFS_SET_SYNTAX_ERR:
2573 /* shouldn't happen, checked already above */
2574 cmdarg_err("Invalid -o flag \"%s\"", optarg);
2577 case PREFS_SET_NO_SUCH_PREF:
2578 case PREFS_SET_OBSOLETE:
2579 cmdarg_err("-o flag \"%s\" specifies unknown preference/recent value",
2584 g_assert_not_reached();
2587 case PREFS_SET_OBSOLETE:
2588 cmdarg_err("-o flag \"%s\" specifies obsolete preference",
2593 g_assert_not_reached();
2597 /* Path settings were already processed just ignore them this time*/
2599 case 'r': /* Read capture file xxx */
2600 /* We may set "last_open_dir" to "cf_name", and if we change
2601 "last_open_dir" later, we free the old value, so we have to
2602 set "cf_name" to something that's been allocated. */
2603 #if defined _WIN32 && GLIB_CHECK_VERSION(2,6,0)
2604 /* since GLib 2.6, we need to convert filenames to utf8 for Win32 */
2605 cf_name = g_locale_to_utf8(optarg, -1, NULL, NULL, NULL);
2607 cf_name = g_strdup(optarg);
2610 case 'R': /* Read file filter */
2613 case 't': /* Time stamp type */
2614 if (strcmp(optarg, "r") == 0)
2615 timestamp_set_type(TS_RELATIVE);
2616 else if (strcmp(optarg, "a") == 0)
2617 timestamp_set_type(TS_ABSOLUTE);
2618 else if (strcmp(optarg, "ad") == 0)
2619 timestamp_set_type(TS_ABSOLUTE_WITH_DATE);
2620 else if (strcmp(optarg, "d") == 0)
2621 timestamp_set_type(TS_DELTA);
2622 else if (strcmp(optarg, "dd") == 0)
2623 timestamp_set_type(TS_DELTA_DIS);
2624 else if (strcmp(optarg, "e") == 0)
2625 timestamp_set_type(TS_EPOCH);
2627 cmdarg_err("Invalid time stamp type \"%s\"", optarg);
2628 cmdarg_err_cont("It must be \"r\" for relative, \"a\" for absolute,");
2629 cmdarg_err_cont("\"ad\" for absolute with date, or \"d\" for delta.");
2633 case 'u': /* Seconds type */
2634 if (strcmp(optarg, "s") == 0)
2635 timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
2636 else if (strcmp(optarg, "hms") == 0)
2637 timestamp_set_seconds_type(TS_SECONDS_HOUR_MIN_SEC);
2639 cmdarg_err("Invalid seconds type \"%s\"", optarg);
2640 cmdarg_err_cont("It must be \"s\" for seconds or \"hms\" for hours, minutes and seconds.");
2645 /* ext ops were already processed just ignore them this time*/
2648 /* We won't call the init function for the stat this soon
2649 as it would disallow MATE's fields (which are registered
2650 by the preferences set callback) from being used as
2651 part of a tap filter. Instead, we just add the argument
2652 to a list of stat arguments. */
2653 if (!process_stat_cmd_arg(optarg)) {
2654 cmdarg_err("Invalid -z argument.");
2655 cmdarg_err_cont(" -z argument must be one of :");
2656 list_stat_cmd_args();
2661 case '?': /* Bad flag - print usage message */
2669 if (cf_name != NULL) {
2671 * Input file name specified with "-r" *and* specified as a regular
2672 * command-line argument.
2674 cmdarg_err("File name specified both with -r and regular argument");
2678 * Input file name not specified with "-r", and a command-line argument
2679 * was specified; treat it as the input file name.
2681 * Yes, this is different from tshark, where non-flag command-line
2682 * arguments are a filter, but this works better on GUI desktops
2683 * where a command can be specified to be run to open a particular
2684 * file - yes, you could have "-r" as the last part of the command,
2685 * but that's a bit ugly.
2687 #if defined _WIN32 && GLIB_CHECK_VERSION(2,6,0)
2688 /* since GLib 2.6, we need to convert filenames to utf8 for Win32 */
2689 cf_name = g_locale_to_utf8(argv[0], -1, NULL, NULL, NULL);
2691 cf_name = g_strdup(argv[0]);
2702 * Extra command line arguments were specified; complain.
2704 cmdarg_err("Invalid argument: %s", argv[0]);
2709 #ifndef HAVE_LIBPCAP
2710 if (capture_option_specified) {
2711 cmdarg_err("This version of Wireshark was not built with support for capturing packets.");
2719 if (start_capture && list_link_layer_types) {
2720 /* Specifying *both* is bogus. */
2721 cmdarg_err("You can't specify both -L and a live capture.");
2725 if (list_link_layer_types) {
2726 /* We're supposed to list the link-layer types for an interface;
2727 did the user also specify a capture file to be read? */
2729 /* Yes - that's bogus. */
2730 cmdarg_err("You can't specify -L and a capture file to be read.");
2733 /* No - did they specify a ring buffer option? */
2734 if (global_capture_opts.multi_files_on) {
2735 cmdarg_err("Ring buffer requested, but a capture isn't being done.");
2739 /* We're supposed to do a live capture; did the user also specify
2740 a capture file to be read? */
2741 if (start_capture && cf_name) {
2742 /* Yes - that's bogus. */
2743 cmdarg_err("You can't specify both a live capture and a capture file to be read.");
2747 /* No - was the ring buffer option specified and, if so, does it make
2749 if (global_capture_opts.multi_files_on) {
2750 /* Ring buffer works only under certain conditions:
2751 a) ring buffer does not work with temporary files;
2752 b) real_time_mode and multi_files_on are mutually exclusive -
2753 real_time_mode takes precedence;
2754 c) it makes no sense to enable the ring buffer if the maximum
2755 file size is set to "infinite". */
2756 if (global_capture_opts.save_file == NULL) {
2757 cmdarg_err("Ring buffer requested, but capture isn't being saved to a permanent file.");
2758 global_capture_opts.multi_files_on = FALSE;
2760 /* if (global_capture_opts.real_time_mode) {
2761 cmdarg_err("Ring buffer requested, but an \"Update list of packets in real time\" capture is being done.");
2762 global_capture_opts.multi_files_on = FALSE;
2764 if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_duration) {
2765 cmdarg_err("Ring buffer requested, but no maximum capture file size or duration were specified.");
2766 /* XXX - this must be redesigned as the conditions changed */
2767 /* global_capture_opts.multi_files_on = FALSE;*/
2772 if (start_capture || list_link_layer_types) {
2773 /* Did the user specify an interface to use? */
2774 if (!capture_opts_trim_iface(&global_capture_opts,
2775 (prefs_p->capture_device) ? get_if_name(prefs_p->capture_device) : NULL)) {
2780 if (list_link_layer_types) {
2781 /* Get the list of link-layer types for the capture device. */
2782 if_capabilities_t *caps;
2784 caps = capture_get_if_capabilities(global_capture_opts.iface,
2785 global_capture_opts.monitor_mode,
2788 cmdarg_err("%s", err_str);
2792 if (caps->data_link_types == NULL) {
2793 cmdarg_err("The capture device \"%s\" has no data link types.", global_capture_opts.iface);
2796 capture_opts_print_if_capabilities(caps, global_capture_opts.monitor_mode);
2797 free_if_capabilities(caps);
2801 capture_opts_trim_snaplen(&global_capture_opts, MIN_PACKET_SIZE);
2802 capture_opts_trim_ring_num_files(&global_capture_opts);
2803 #endif /* HAVE_LIBPCAP */
2805 /* Notify all registered modules that have had any of their preferences
2806 changed either from one of the preferences file or from the command
2807 line that their preferences have changed. */
2810 /* disabled protocols as per configuration file */
2811 if (gdp_path == NULL && dp_path == NULL) {
2812 set_disabled_protos_list();
2815 build_column_format_array(&cfile.cinfo, prefs_p->num_cols, TRUE);
2817 /* read in rc file from global and personal configuration paths. */
2818 rc_file = get_datafile_path(RC_FILE);
2819 gtk_rc_parse(rc_file);
2821 rc_file = get_persconffile_path(RC_FILE, FALSE, FALSE);
2822 gtk_rc_parse(rc_file);
2829 /* close the splash screen, as we are going to open the main window now */
2830 splash_destroy(splash_win);
2832 /************************************************************************/
2833 /* Everything is prepared now, preferences and command line was read in */
2835 /* Pop up the main window. */
2836 create_main_window(pl_size, tv_size, bv_size, prefs_p);
2838 /* Read the dynamic part of the recent file, as we have the gui now ready for it. */
2839 recent_read_dynamic(&rf_path, &rf_open_errno);
2840 if (rf_path != NULL && rf_open_errno != 0) {
2841 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
2842 "Could not open recent file\n\"%s\": %s.",
2843 rf_path, strerror(rf_open_errno));
2846 color_filters_enable(recent.packet_list_colorize);
2848 /* rearrange all the widgets as we now have all recent settings ready for this */
2849 main_widgets_rearrange();
2851 /* Fill in column titles. This must be done after the top level window
2854 XXX - is that still true, with fixed-width columns? */
2855 #ifndef NEW_PACKET_LIST
2856 packet_list_set_column_titles();
2859 menu_recent_read_finished();
2861 menu_auto_scroll_live_changed(auto_scroll_live);
2864 switch (user_font_apply()) {
2867 case FA_FONT_NOT_RESIZEABLE:
2868 /* "user_font_apply()" popped up an alert box. */
2869 /* turn off zooming - font can't be resized */
2870 case FA_FONT_NOT_AVAILABLE:
2871 /* XXX - did we successfully load the un-zoomed version earlier?
2872 If so, this *probably* means the font is available, but not at
2873 this particular zoom level, but perhaps some other failure
2874 occurred; I'm not sure you can determine which is the case,
2876 /* turn off zooming - zoom level is unavailable */
2878 /* in any other case than FA_SUCCESS, turn off zooming */
2879 recent.gui_zoom_level = 0;
2880 /* XXX: would it be a good idea to disable zooming (insensitive GUI)? */
2883 dnd_init(top_level);
2885 color_filters_init();
2888 /* the window can be sized only, if it's not already shown, so do it now! */
2889 main_load_window_geometry(top_level);
2891 g_timeout_add(info_update_freq, resolv_update_cb, NULL);
2894 /* If we were given the name of a capture file, read it in now;
2895 we defer it until now, so that, if we can't open it, and pop
2896 up an alert box, the alert box is more likely to come up on
2897 top of the main window - but before the preference-file-error
2898 alert box, so, if we get one of those, it's more likely to come
2901 show_main_window(TRUE);
2902 check_and_warn_user_startup(cf_name);
2903 if (rfilter != NULL) {
2904 if (!dfilter_compile(rfilter, &rfcode)) {
2905 bad_dfilter_alert_box(rfilter);
2906 rfilter_parse_failed = TRUE;
2909 if (!rfilter_parse_failed) {
2910 if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
2911 /* "cf_open()" succeeded, so it closed the previous
2912 capture file, and thus destroyed any previous read filter
2913 attached to "cf". */
2915 cfile.rfcode = rfcode;
2916 /* Open stat windows; we do so after creating the main window,
2917 to avoid GTK warnings, and after successfully opening the
2918 capture file, so we know we have something to compute stats
2919 on, and after registering all dissectors, so that MATE will
2920 have registered its field array and we can have a tap filter
2921 with one of MATE's late-registered fields as part of the
2923 start_requested_stats();
2925 /* Read the capture file. */
2926 switch (cf_read(&cfile, FALSE)) {
2930 /* Just because we got an error, that doesn't mean we were unable
2931 to read any of the file; we handle what we could get from the
2933 /* if the user told us to jump to a specific packet, do it now */
2934 if(go_to_packet != 0) {
2935 /* Jump to the specified frame number, kept for backward
2937 cf_goto_frame(&cfile, go_to_packet);
2938 } else if (jfilter != NULL) {
2939 /* try to compile given filter */
2940 if (!dfilter_compile(jfilter, &jump_to_filter)) {
2941 bad_dfilter_alert_box(jfilter);
2944 /* Filter ok, jump to the first packet matching the filter
2945 conditions. Default search direction is forward, but if
2946 option d was given, search backwards */
2947 saved_bw = cfile.sbackward;
2948 cfile.sbackward = jump_backwards;
2949 cf_find_packet_dfilter(&cfile, jump_to_filter);
2950 cfile.sbackward = saved_bw;
2955 case CF_READ_ABORTED:
2960 /* Save the name of the containing directory specified in the
2961 path name, if any; we can write over cf_name, which is a
2962 good thing, given that "get_dirname()" does write over its
2964 s = get_dirname(cf_name);
2965 set_last_open_dir(s);
2970 dfilter_free(rfcode);
2971 cfile.rfcode = NULL;
2972 show_main_window(FALSE);
2973 /* Don't call check_and_warn_user_startup(): we did it above */
2974 set_menus_for_capture_in_progress(FALSE);
2975 set_capture_if_dialog_for_capture_in_progress(FALSE);
2980 if (start_capture) {
2981 if (global_capture_opts.save_file != NULL) {
2982 /* Save the directory name for future file dialogs. */
2983 /* (get_dirname overwrites filename) */
2984 s = get_dirname(g_strdup(global_capture_opts.save_file));
2985 set_last_open_dir(s);
2988 /* "-k" was specified; start a capture. */
2989 show_main_window(TRUE);
2990 check_and_warn_user_startup(cf_name);
2991 if (capture_start(&global_capture_opts)) {
2992 /* The capture started. Open stat windows; we do so after creating
2993 the main window, to avoid GTK warnings, and after successfully
2994 opening the capture file, so we know we have something to compute
2995 stats on, and after registering all dissectors, so that MATE will
2996 have registered its field array and we can have a tap filter with
2997 one of MATE's late-registered fields as part of the filter. */
2998 start_requested_stats();
3002 show_main_window(FALSE);
3003 check_and_warn_user_startup(cf_name);
3004 set_menus_for_capture_in_progress(FALSE);
3005 set_capture_if_dialog_for_capture_in_progress(FALSE);
3008 /* if the user didn't supplied a capture filter, use the one to filter out remote connections like SSH */
3009 if (!start_capture && strlen(global_capture_opts.cfilter) == 0) {
3010 g_free(global_capture_opts.cfilter);
3011 global_capture_opts.cfilter = g_strdup(get_conn_cfilter());
3013 #else /* HAVE_LIBPCAP */
3014 show_main_window(FALSE);
3015 check_and_warn_user_startup(cf_name);
3016 set_menus_for_capture_in_progress(FALSE);
3017 set_capture_if_dialog_for_capture_in_progress(FALSE);
3018 #endif /* HAVE_LIBPCAP */
3021 /* register our pid if we are being run from a U3 device */
3024 profile_store_persconffiles (FALSE);
3026 #ifdef HAVE_GTKOSXAPPLICATION
3027 theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
3028 gtk_osxapplication_set_dock_icon_pixbuf(theApp,gdk_pixbuf_new_from_xpm_data(wsicon64_xpm));
3029 gtk_osxapplication_ready(theApp);
3032 g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "Wireshark is up and ready to go");
3034 /* we'll enter the GTK loop now and hand the control over to GTK ... */
3036 /* ... back from GTK, we're going down now! */
3038 /* deregister our pid */
3039 u3_deregister_pid();
3043 #ifdef HAVE_AIRPDCAP
3044 AirPDcapDestroyContext(&airpdcap_ctx);
3048 /* hide the (unresponsive) main window, while asking the user to close the console window */
3049 gtk_widget_hide(top_level);
3051 #ifdef HAVE_GTKOSXAPPLICATION
3052 g_object_unref(theApp);
3055 /* Shutdown windows sockets */
3058 /* For some unknown reason, the "atexit()" call in "create_console()"
3059 doesn't arrange that "destroy_console()" be called when we exit,
3060 so we call it here if a console was created. */
3069 /* We build this as a GUI subsystem application on Win32, so
3070 "WinMain()", not "main()", gets called.
3072 Hack shamelessly stolen from the Win32 port of the GIMP. */
3074 #define _stdcall __attribute__((stdcall))
3078 WinMain (struct HINSTANCE__ *hInstance,
3079 struct HINSTANCE__ *hPrevInstance,
3083 INITCOMMONCONTROLSEX comm_ctrl;
3085 /* Initialize our controls. Required for native Windows file dialogs. */
3086 memset (&comm_ctrl, 0, sizeof(comm_ctrl));
3087 comm_ctrl.dwSize = sizeof(comm_ctrl);
3088 /* Includes the animate, header, hot key, list view, progress bar,
3089 * status bar, tab, tooltip, toolbar, trackbar, tree view, and
3092 comm_ctrl.dwICC = ICC_WIN95_CLASSES;
3093 InitCommonControlsEx(&comm_ctrl);
3095 /* RichEd20.DLL is needed for filter entries. */
3096 LoadLibrary(_T("riched20.dll"));
3098 has_console = FALSE;
3099 return main (__argc, __argv);
3102 /* The code to create and desstroy console windows should not be necessary,
3103 at least as I read the GLib source code, as it looks as if GLib is, on
3104 Win32, *supposed* to create a console window into which to display its
3107 That doesn't happen, however. I suspect there's something completely
3108 broken about that code in GLib-for-Win32, and that it may be related
3109 to the breakage that forces us to just call "printf()" on the message
3110 rather than passing the message on to "g_log_default_handler()"
3111 (which is the routine that does the aforementioned non-functional
3112 console window creation). */
3115 * If this application has no console window to which its standard output
3116 * would go, create one.
3119 create_console(void)
3121 if (stdin_capture) {
3122 /* We've been handed "-i -". Don't mess with stdio. */
3127 /* We have no console to which to print the version string, so
3128 create one and make it the standard input, output, and error. */
3129 if (!AllocConsole())
3130 return; /* couldn't create console */
3132 ws_freopen("CONIN$", "r", stdin);
3133 ws_freopen("CONOUT$", "w", stdout);
3134 ws_freopen("CONOUT$", "w", stderr);
3136 /* Well, we have a console now. */
3139 /* Now register "destroy_console()" as a routine to be called just
3140 before the application exits, so that we can destroy the console
3141 after the user has typed a key (so that the console doesn't just
3142 disappear out from under them, giving the user no chance to see
3143 the message(s) we put in there). */
3144 atexit(destroy_console);
3146 SetConsoleTitle(_T("Wireshark Debug Console"));
3151 destroy_console(void)
3154 printf("\n\nPress any key to exit\n");
3163 console_log_handler(const char *log_domain, GLogLevelFlags log_level,
3164 const char *message, gpointer user_data _U_)
3171 /* ignore log message, if log_level isn't interesting based
3172 upon the console log preferences.
3173 If the preferences haven't been loaded loaded yet, display the
3176 The default console_log_level preference value is such that only
3177 ERROR, CRITICAL and WARNING level messages are processed;
3178 MESSAGE, INFO and DEBUG level messages are ignored. */
3179 if((log_level & G_LOG_LEVEL_MASK & prefs.console_log_level) == 0 &&
3180 prefs.console_log_level != 0) {
3185 if (prefs.gui_console_open != console_open_never || log_level & G_LOG_LEVEL_ERROR) {
3186 /* the user wants a console or the application will terminate immediately */
3190 /* For some unknown reason, the above doesn't appear to actually cause
3191 anything to be sent to the standard output, so we'll just splat the
3192 message out directly, just to make sure it gets out. */
3194 switch(log_level & G_LOG_LEVEL_MASK) {
3195 case G_LOG_LEVEL_ERROR:
3198 case G_LOG_LEVEL_CRITICAL:
3201 case G_LOG_LEVEL_WARNING:
3204 case G_LOG_LEVEL_MESSAGE:
3207 case G_LOG_LEVEL_INFO:
3210 case G_LOG_LEVEL_DEBUG:
3214 fprintf(stderr, "unknown log_level %u\n", log_level);
3216 g_assert_not_reached();
3219 /* create a "timestamp" */
3221 today = localtime(&curr);
3223 fprintf(stderr, "%02u:%02u:%02u %8s %s %s\n",
3224 today->tm_hour, today->tm_min, today->tm_sec,
3225 log_domain != NULL ? log_domain : "",
3228 if(log_level & G_LOG_LEVEL_ERROR) {
3229 /* wait for a key press before the following error handler will terminate the program
3230 this way the user at least can read the error message */
3231 printf("\n\nPress any key to exit\n");
3235 /* XXX - on UN*X, should we just use g_log_default_handler()?
3236 We want the error messages to go to the standard output;
3237 on Mac OS X, that will cause them to show up in various
3238 per-user logs accessible through Console (details depend
3239 on whether you're running 10.0 through 10.4 or running
3240 10.5 and later), and, on other UN*X desktop environments,
3241 if they don't show up in some form of console log, that's
3242 a deficiency in that desktop environment. (Too bad
3243 Windows doesn't set the standard output and error for
3244 GUI apps to something that shows up in such a log.) */
3245 g_log_default_handler(log_domain, log_level, message, user_data);
3252 * Helper for main_widgets_rearrange()
3254 static void foreach_remove_a_child(GtkWidget *widget, gpointer data) {
3255 gtk_container_remove(GTK_CONTAINER(data), widget);
3258 static GtkWidget *main_widget_layout(gint layout_content)
3260 switch(layout_content) {
3261 case(layout_pane_content_none):
3263 case(layout_pane_content_plist):
3265 case(layout_pane_content_pdetails):
3267 case(layout_pane_content_pbytes):
3268 return byte_nb_ptr_gbl;
3270 g_assert_not_reached();
3277 * Rearrange the main window widgets
3279 void main_widgets_rearrange(void) {
3280 GtkWidget *first_pane_widget1, *first_pane_widget2;
3281 GtkWidget *second_pane_widget1, *second_pane_widget2;
3282 gboolean split_top_left;
3284 /* be a bit faster */
3285 gtk_widget_hide(main_vbox);
3287 /* be sure we don't lose a widget while rearranging */
3288 g_object_ref(G_OBJECT(menubar));
3289 g_object_ref(G_OBJECT(main_tb));
3290 g_object_ref(G_OBJECT(filter_tb));
3292 g_object_ref(G_OBJECT(airpcap_tb));
3294 g_object_ref(G_OBJECT(pkt_scrollw));
3295 g_object_ref(G_OBJECT(tv_scrollw));
3296 g_object_ref(G_OBJECT(byte_nb_ptr_gbl));
3297 g_object_ref(G_OBJECT(statusbar));
3298 g_object_ref(G_OBJECT(main_pane_v1));
3299 g_object_ref(G_OBJECT(main_pane_v2));
3300 g_object_ref(G_OBJECT(main_pane_h1));
3301 g_object_ref(G_OBJECT(main_pane_h2));
3302 g_object_ref(G_OBJECT(welcome_pane));
3304 /* empty all containers participating */
3305 gtk_container_foreach(GTK_CONTAINER(main_vbox), foreach_remove_a_child, main_vbox);
3306 gtk_container_foreach(GTK_CONTAINER(main_pane_v1), foreach_remove_a_child, main_pane_v1);
3307 gtk_container_foreach(GTK_CONTAINER(main_pane_v2), foreach_remove_a_child, main_pane_v2);
3308 gtk_container_foreach(GTK_CONTAINER(main_pane_h1), foreach_remove_a_child, main_pane_h1);
3309 gtk_container_foreach(GTK_CONTAINER(main_pane_h2), foreach_remove_a_child, main_pane_h2);
3311 statusbar_widgets_emptying(statusbar);
3313 /* add the menubar always at the top */
3314 gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0);
3317 gtk_box_pack_start(GTK_BOX(main_vbox), main_tb, FALSE, TRUE, 0);
3319 /* filter toolbar in toolbar area */
3320 if (!prefs.filter_toolbar_show_in_statusbar) {
3321 gtk_box_pack_start(GTK_BOX(main_vbox), filter_tb, FALSE, TRUE, 1);
3325 /* airpcap toolbar */
3326 gtk_box_pack_start(GTK_BOX(main_vbox), airpcap_tb, FALSE, TRUE, 1);
3329 /* fill the main layout panes */
3330 switch(prefs.gui_layout_type) {
3331 case(layout_type_5):
3332 main_first_pane = main_pane_v1;
3333 main_second_pane = main_pane_v2;
3334 split_top_left = FALSE;
3336 case(layout_type_2):
3337 main_first_pane = main_pane_v1;
3338 main_second_pane = main_pane_h1;
3339 split_top_left = FALSE;
3341 case(layout_type_1):
3342 main_first_pane = main_pane_v1;
3343 main_second_pane = main_pane_h1;
3344 split_top_left = TRUE;
3346 case(layout_type_4):
3347 main_first_pane = main_pane_h1;
3348 main_second_pane = main_pane_v1;
3349 split_top_left = FALSE;
3351 case(layout_type_3):
3352 main_first_pane = main_pane_h1;
3353 main_second_pane = main_pane_v1;
3354 split_top_left = TRUE;
3356 case(layout_type_6):
3357 main_first_pane = main_pane_h1;
3358 main_second_pane = main_pane_h2;
3359 split_top_left = FALSE;
3362 main_first_pane = NULL;
3363 main_second_pane = NULL;
3364 split_top_left = FALSE;
3365 g_assert_not_reached();
3367 if (split_top_left) {
3368 first_pane_widget1 = main_second_pane;
3369 second_pane_widget1 = main_widget_layout(prefs.gui_layout_content_1);
3370 second_pane_widget2 = main_widget_layout(prefs.gui_layout_content_2);
3371 first_pane_widget2 = main_widget_layout(prefs.gui_layout_content_3);
3373 first_pane_widget1 = main_widget_layout(prefs.gui_layout_content_1);
3374 first_pane_widget2 = main_second_pane;
3375 second_pane_widget1 = main_widget_layout(prefs.gui_layout_content_2);
3376 second_pane_widget2 = main_widget_layout(prefs.gui_layout_content_3);
3378 if (first_pane_widget1 != NULL)
3379 gtk_paned_add1(GTK_PANED(main_first_pane), first_pane_widget1);
3380 if (first_pane_widget2 != NULL)
3381 gtk_paned_add2(GTK_PANED(main_first_pane), first_pane_widget2);
3382 if (second_pane_widget1 != NULL)
3383 gtk_paned_pack1(GTK_PANED(main_second_pane), second_pane_widget1, TRUE, TRUE);
3384 if (second_pane_widget2 != NULL)
3385 gtk_paned_pack2(GTK_PANED(main_second_pane), second_pane_widget2, FALSE, FALSE);
3387 gtk_container_add(GTK_CONTAINER(main_vbox), main_first_pane);
3390 gtk_box_pack_start(GTK_BOX(main_vbox), welcome_pane, TRUE, TRUE, 0);
3393 gtk_box_pack_start(GTK_BOX(main_vbox), statusbar, FALSE, TRUE, 0);
3395 /* filter toolbar in statusbar hbox */
3396 if (prefs.filter_toolbar_show_in_statusbar) {
3397 gtk_box_pack_start(GTK_BOX(statusbar), filter_tb, FALSE, TRUE, 1);
3401 /* airpcap toolbar */
3402 gtk_box_pack_start(GTK_BOX(main_vbox), airpcap_tb, FALSE, TRUE, 1);
3405 /* statusbar widgets */
3406 statusbar_widgets_pack(statusbar);
3408 /* hide widgets on users recent settings */
3409 main_widgets_show_or_hide();
3411 gtk_widget_show(main_vbox);
3415 is_widget_visible(GtkWidget *widget, gpointer data)
3417 gboolean *is_visible = data;
3420 if (GTK_WIDGET_VISIBLE(widget))
3427 main_widgets_show_or_hide(void)
3429 gboolean main_second_pane_show;
3431 if (recent.main_toolbar_show) {
3432 gtk_widget_show(main_tb);
3434 gtk_widget_hide(main_tb);
3437 statusbar_widgets_show_or_hide(statusbar);
3439 if (recent.filter_toolbar_show) {
3440 gtk_widget_show(filter_tb);
3442 gtk_widget_hide(filter_tb);
3446 if (recent.airpcap_toolbar_show) {
3447 gtk_widget_show(airpcap_tb);
3449 gtk_widget_hide(airpcap_tb);
3453 if (recent.packet_list_show && have_capture_file) {
3454 gtk_widget_show(pkt_scrollw);
3456 gtk_widget_hide(pkt_scrollw);
3459 if (recent.tree_view_show && have_capture_file) {
3460 gtk_widget_show(tv_scrollw);
3462 gtk_widget_hide(tv_scrollw);
3465 if (recent.byte_view_show && have_capture_file) {
3466 gtk_widget_show(byte_nb_ptr_gbl);
3468 gtk_widget_hide(byte_nb_ptr_gbl);
3471 if (have_capture_file) {
3472 gtk_widget_show(main_first_pane);
3474 gtk_widget_hide(main_first_pane);
3478 * Is anything in "main_second_pane" visible?
3479 * If so, show it, otherwise hide it.
3481 main_second_pane_show = FALSE;
3482 gtk_container_foreach(GTK_CONTAINER(main_second_pane), is_widget_visible,
3483 &main_second_pane_show);
3484 if (main_second_pane_show) {
3485 gtk_widget_show(main_second_pane);
3487 gtk_widget_hide(main_second_pane);
3490 if (!have_capture_file) {
3492 gtk_widget_show(welcome_pane);
3495 gtk_widget_hide(welcome_pane);
3498 /* workaround for bug in GtkCList to ensure packet list scrollbar is updated */
3499 #ifndef NEW_PACKET_LIST
3500 packet_list_freeze ();
3501 packet_list_thaw ();
3506 /* called, when the window state changes (minimized, maximized, ...) */
3508 window_state_event_cb (GtkWidget *widget _U_,
3512 GdkWindowState new_window_state = ((GdkEventWindowState*)event)->new_window_state;
3514 if( (event->type) == (GDK_WINDOW_STATE)) {
3515 if(!(new_window_state & GDK_WINDOW_STATE_ICONIFIED)) {
3516 /* we might have dialogs popped up while we where iconified,
3518 display_queued_messages();
3526 #define NO_SHIFT_MOD_MASK (GDK_MODIFIER_MASK & ~(GDK_SHIFT_MASK|GDK_MOD2_MASK|GDK_LOCK_MASK))
3528 top_level_key_pressed_cb(GtkWidget *w _U_, GdkEventKey *event, gpointer user_data _U_)
3530 if (event->keyval == GDK_F8) {
3531 #ifdef NEW_PACKET_LIST
3532 new_packet_list_next();
3537 } else if (event->keyval == GDK_F7) {
3538 #ifdef NEW_PACKET_LIST
3539 new_packet_list_prev();
3544 } else if (event->state & NO_SHIFT_MOD_MASK) {
3545 return FALSE; /* Skip control, alt, and other modifiers */
3547 * A comment in gdkkeysyms.h says that it's autogenerated from
3548 * freedesktop.org/x.org's keysymdef.h. Although the GDK docs
3549 * don't explicitly say so, isprint() should work as expected
3552 } else if (isascii(event->keyval) && isprint(event->keyval)) {
3553 /* Forward the keypress on to the display filter entry */
3554 if (main_display_filter_widget && !gtk_widget_is_focus(main_display_filter_widget)) {
3555 gtk_window_set_focus(GTK_WINDOW(top_level), main_display_filter_widget);
3556 gtk_editable_set_position(GTK_EDITABLE(main_display_filter_widget), -1);
3564 create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs_p)
3566 GtkAccelGroup *accel;
3569 /* use user-defined title if preference is set */
3570 title = create_user_window_title("The Wireshark Network Analyzer");
3573 top_level = window_new(GTK_WINDOW_TOPLEVEL, title);
3576 gtk_widget_set_name(top_level, "main window");
3577 g_signal_connect(top_level, "delete_event", G_CALLBACK(main_window_delete_event_cb),
3579 g_signal_connect(GTK_OBJECT(top_level), "window_state_event",
3580 G_CALLBACK(window_state_event_cb), NULL);
3581 g_signal_connect(GTK_OBJECT(top_level), "key-press-event",
3582 G_CALLBACK(top_level_key_pressed_cb), NULL );
3584 /* Vertical container for menu bar, toolbar(s), paned windows and progress/info box */
3585 main_vbox = gtk_vbox_new(FALSE, 1);
3586 gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 1);
3587 gtk_container_add(GTK_CONTAINER(top_level), main_vbox);
3588 gtk_widget_show(main_vbox);
3591 menubar = main_menu_new(&accel);
3593 #if defined(HAVE_IGE_MAC_INTEGRATION) || defined (HAVE_GTKOSXAPPLICATION)
3594 /* Mac OS X native menus are created and displayed by main_menu_new() */
3595 if(!prefs_p->gui_macosx_style) {
3597 gtk_window_add_accel_group(GTK_WINDOW(top_level), accel);
3598 gtk_widget_show(menubar);
3599 #if defined(HAVE_IGE_MAC_INTEGRATION) || defined(HAVE_GTKOSXAPPLICATION)
3604 main_tb = toolbar_new();
3605 gtk_widget_show (main_tb);
3607 /* Filter toolbar */
3608 filter_tb = filter_toolbar_new();
3611 #ifdef NEW_PACKET_LIST
3612 pkt_scrollw = new_packet_list_create();
3613 gtk_widget_set_size_request(pkt_scrollw, -1, pl_size);
3614 gtk_widget_show_all(pkt_scrollw);
3616 pkt_scrollw = packet_list_new(prefs_p);
3617 gtk_widget_set_size_request(packet_list, -1, pl_size);
3618 gtk_widget_show(pkt_scrollw);
3622 tv_scrollw = main_tree_view_new(prefs_p, &tree_view_gbl);
3623 gtk_widget_set_size_request(tv_scrollw, -1, tv_size);
3624 gtk_widget_show(tv_scrollw);
3626 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view_gbl)),
3627 "changed", G_CALLBACK(tree_view_selection_changed_cb), NULL);
3628 g_signal_connect(tree_view_gbl, "button_press_event", G_CALLBACK(popup_menu_handler),
3629 g_object_get_data(G_OBJECT(popup_menu_object), PM_TREE_VIEW_KEY));
3630 gtk_widget_show(tree_view_gbl);
3633 byte_nb_ptr_gbl = byte_view_new();
3634 gtk_widget_set_size_request(byte_nb_ptr_gbl, -1, bv_size);
3635 gtk_widget_show(byte_nb_ptr_gbl);
3637 g_signal_connect(byte_nb_ptr_gbl, "button_press_event", G_CALLBACK(popup_menu_handler),
3638 g_object_get_data(G_OBJECT(popup_menu_object), PM_BYTES_VIEW_KEY));
3640 /* Panes for the packet list, tree, and byte view */
3641 main_pane_v1 = gtk_vpaned_new();
3642 gtk_widget_show(main_pane_v1);
3643 main_pane_v2 = gtk_vpaned_new();
3644 gtk_widget_show(main_pane_v2);
3645 main_pane_h1 = gtk_hpaned_new();
3646 gtk_widget_show(main_pane_h1);
3647 main_pane_h2 = gtk_hpaned_new();
3648 gtk_widget_show(main_pane_h2);
3650 airpcap_tb = airpcap_toolbar_new();
3651 gtk_widget_show(airpcap_tb);
3654 statusbar = statusbar_new();
3655 gtk_widget_show(statusbar);
3657 /* Pane for the welcome screen */
3658 welcome_pane = welcome_new();
3659 gtk_widget_show(welcome_pane);
3663 show_main_window(gboolean doing_work)
3665 main_set_for_capture_file(doing_work);
3667 /*** we have finished all init things, show the main window ***/
3668 gtk_widget_show(top_level);
3670 /* the window can be maximized only, if it's visible, so do it after show! */
3671 main_load_window_geometry(top_level);
3673 /* process all pending GUI events before continue */
3674 while (gtk_events_pending()) gtk_main_iteration();
3676 /* Pop up any queued-up alert boxes. */
3677 display_queued_messages();
3679 /* Move the main window to the front, in case it isn't already there */
3680 gdk_window_raise(top_level->window);
3683 airpcap_toolbar_show(airpcap_tb);
3684 #endif /* HAVE_AIRPCAP */
3687 /* Fill in capture options with values from the preferences */
3689 prefs_to_capture_opts(void)
3692 /* Set promiscuous mode from the preferences setting. */
3693 /* the same applies to other preferences settings as well. */
3694 global_capture_opts.promisc_mode = prefs.capture_prom_mode;
3695 global_capture_opts.use_pcapng = prefs.capture_pcap_ng;
3696 global_capture_opts.show_info = prefs.capture_show_info;
3697 global_capture_opts.real_time_mode = prefs.capture_real_time;
3698 auto_scroll_live = prefs.capture_auto_scroll;
3699 #endif /* HAVE_LIBPCAP */
3701 /* Set the name resolution code's flags from the preferences. */
3702 g_resolv_flags = prefs.name_resolve;
3706 /* Change configuration profile */
3707 void change_configuration_profile (const gchar *profile_name)
3709 char *gdp_path, *dp_path;
3713 /* First check if profile exists */
3714 if (!profile_exists(profile_name)) {
3718 /* Get the current geometry, before writing it to disk */
3719 main_save_window_geometry(top_level);
3721 if (profile_exists(get_profile_name())) {
3722 /* Write recent file for profile we are leaving, if it still exists */
3723 write_profile_recent();
3726 /* Set profile name and update the status bar */
3727 set_profile_name (profile_name);
3728 profile_bar_update ();
3730 /* Reset current preferences and apply the new */
3734 (void) read_configuration_files (&gdp_path, &dp_path);
3736 recent_read_profile_static(&rf_path, &rf_open_errno);
3737 if (rf_path != NULL && rf_open_errno != 0) {
3738 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
3739 "Could not open common recent file\n\"%s\": %s.",
3740 rf_path, strerror(rf_open_errno));
3742 if (recent.gui_fileopen_remembered_dir &&
3743 test_for_directory(recent.gui_fileopen_remembered_dir) == EISDIR) {
3744 set_last_open_dir(recent.gui_fileopen_remembered_dir);
3746 timestamp_set_type (recent.gui_time_format);
3747 timestamp_set_seconds_type (recent.gui_seconds_format);
3748 color_filters_enable(recent.packet_list_colorize);
3750 prefs_to_capture_opts();
3753 /* Update window view and redraw the toolbar */
3754 update_main_window_name();
3755 toolbar_redraw_all();
3757 /* Enable all protocols and disable from the disabled list */
3759 if (gdp_path == NULL && dp_path == NULL) {
3760 set_disabled_protos_list();
3763 /* Reload color filters */
3764 color_filters_reload();
3766 /* Reload list of interfaces on welcome page */
3767 welcome_if_panel_reload();
3769 /* Recreate the packet list according to new preferences */
3770 #ifdef NEW_PACKET_LIST
3771 new_packet_list_recreate ();
3773 packet_list_recreate ();
3775 cfile.cinfo.columns_changed = FALSE; /* Reset value */
3778 /* Update menus with new recent values */
3779 menu_recent_read_finished();
3781 /* Reload pane geometry, must be done after recreating the list */
3782 main_pane_load_window_geometry();
3785 /** redissect packets and update UI */
3786 void redissect_packets(void)
3788 cf_redissect_packets(&cfile);
3789 status_expert_update();