aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorAlexis La Goutte <alexis.lagoutte@gmail.com>2013-12-17 13:06:11 +0000
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2013-12-17 13:06:11 +0000
commit3d6c71e90622e2032764e68d8dcbcf50a662f5ad (patch)
tree958debe4ecc9dcbebb4407ece4eaf3313ab298d6 /ui
parent2f3a943f0a09a9f75cb94a487d4b6f50df22317c (diff)
Fix indent (use 4 spaces) and add modelines
svn path=/trunk/; revision=54176
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk/main.c2632
1 files changed, 1322 insertions, 1310 deletions
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index 774d321dd5..48a7d230a3 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -810,11 +810,11 @@ tree_view_selection_changed_cb(GtkTreeSelection *sel, gpointer user_data _U_)
*/
byte_view = get_notebook_bv_ptr(byte_nb_ptr_gbl);
if (byte_view == NULL)
- return; /* none */
+ return; /* none */
byte_data = get_byte_view_data_and_length(byte_view, &byte_len);
if (byte_data == NULL)
- return; /* none */
+ return; /* none */
cf_unselect_field(&cfile);
packet_hex_print(byte_view, byte_data,
@@ -851,7 +851,7 @@ tree_view_selection_changed_cb(GtkTreeSelection *sel, gpointer user_data _U_)
} else {
g_snprintf (len_str, sizeof len_str, ", %d bytes", finfo_length);
}
- statusbar_pop_field_msg(); /* get rid of current help msg */
+ statusbar_pop_field_msg(); /* get rid of current help msg */
if (length) {
statusbar_push_field_msg(" %s (%s)%s",
(has_blurb) ? finfo->hfinfo->blurb : finfo->hfinfo->name,
@@ -1155,118 +1155,118 @@ file_quit_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
static void
print_usage(gboolean print_ver) {
- FILE *output;
+ FILE *output;
#ifdef _WIN32
- create_console();
+ create_console();
#endif
- if (print_ver) {
- output = stdout;
- fprintf(output, "Wireshark " VERSION "%s\n"
- "Interactively dump and analyze network traffic.\n"
- "See http://www.wireshark.org for more information.\n"
- "\n"
- "%s",
- wireshark_svnversion, get_copyright_info());
- } else {
- output = stderr;
- }
- fprintf(output, "\n");
- fprintf(output, "Usage: wireshark [options] ... [ <infile> ]\n");
- fprintf(output, "\n");
+ if (print_ver) {
+ output = stdout;
+ fprintf(output, "Wireshark " VERSION "%s\n"
+ "Interactively dump and analyze network traffic.\n"
+ "See http://www.wireshark.org for more information.\n"
+ "\n"
+ "%s",
+ wireshark_svnversion, get_copyright_info());
+ } else {
+ output = stderr;
+ }
+ fprintf(output, "\n");
+ fprintf(output, "Usage: wireshark [options] ... [ <infile> ]\n");
+ fprintf(output, "\n");
#ifdef HAVE_LIBPCAP
- fprintf(output, "Capture interface:\n");
- fprintf(output, " -i <interface> name or idx of interface (def: first non-loopback)\n");
- fprintf(output, " -f <capture filter> packet filter in libpcap filter syntax\n");
- fprintf(output, " -s <snaplen> packet snapshot length (def: 65535)\n");
- fprintf(output, " -p don't capture in promiscuous mode\n");
- fprintf(output, " -k start capturing immediately (def: do nothing)\n");
- fprintf(output, " -S update packet display when new packets are captured\n");
- fprintf(output, " -l turn on automatic scrolling while -S is in use\n");
+ fprintf(output, "Capture interface:\n");
+ fprintf(output, " -i <interface> name or idx of interface (def: first non-loopback)\n");
+ fprintf(output, " -f <capture filter> packet filter in libpcap filter syntax\n");
+ fprintf(output, " -s <snaplen> packet snapshot length (def: 65535)\n");
+ fprintf(output, " -p don't capture in promiscuous mode\n");
+ fprintf(output, " -k start capturing immediately (def: do nothing)\n");
+ fprintf(output, " -S update packet display when new packets are captured\n");
+ fprintf(output, " -l turn on automatic scrolling while -S is in use\n");
#ifdef HAVE_PCAP_CREATE
- fprintf(output, " -I capture in monitor mode, if available\n");
+ fprintf(output, " -I capture in monitor mode, if available\n");
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
- fprintf(output, " -B <buffer size> size of kernel buffer (def: %dMB)\n", DEFAULT_CAPTURE_BUFFER_SIZE);
-#endif
- fprintf(output, " -y <link type> link layer type (def: first appropriate)\n");
- fprintf(output, " -D print list of interfaces and exit\n");
- fprintf(output, " -L print list of link-layer types of iface and exit\n");
- fprintf(output, "\n");
- fprintf(output, "Capture stop conditions:\n");
- fprintf(output, " -c <packet count> stop after n packets (def: infinite)\n");
- fprintf(output, " -a <autostop cond.> ... duration:NUM - stop after NUM seconds\n");
- fprintf(output, " filesize:NUM - stop this file after NUM KB\n");
- fprintf(output, " files:NUM - stop after NUM files\n");
- /*fprintf(output, "\n");*/
- fprintf(output, "Capture output:\n");
- fprintf(output, " -b <ringbuffer opt.> ... duration:NUM - switch to next file after NUM secs\n");
- fprintf(output, " filesize:NUM - switch to next file after NUM KB\n");
- fprintf(output, " files:NUM - ringbuffer: replace after NUM files\n");
+ fprintf(output, " -B <buffer size> size of kernel buffer (def: %dMB)\n", DEFAULT_CAPTURE_BUFFER_SIZE);
+#endif
+ fprintf(output, " -y <link type> link layer type (def: first appropriate)\n");
+ fprintf(output, " -D print list of interfaces and exit\n");
+ fprintf(output, " -L print list of link-layer types of iface and exit\n");
+ fprintf(output, "\n");
+ fprintf(output, "Capture stop conditions:\n");
+ fprintf(output, " -c <packet count> stop after n packets (def: infinite)\n");
+ fprintf(output, " -a <autostop cond.> ... duration:NUM - stop after NUM seconds\n");
+ fprintf(output, " filesize:NUM - stop this file after NUM KB\n");
+ fprintf(output, " files:NUM - stop after NUM files\n");
+ /*fprintf(output, "\n");*/
+ fprintf(output, "Capture output:\n");
+ fprintf(output, " -b <ringbuffer opt.> ... duration:NUM - switch to next file after NUM secs\n");
+ fprintf(output, " filesize:NUM - switch to next file after NUM KB\n");
+ fprintf(output, " files:NUM - ringbuffer: replace after NUM files\n");
#endif /* HAVE_LIBPCAP */
#ifdef HAVE_PCAP_REMOTE
- fprintf(output, "RPCAP options:\n");
- fprintf(output, " -A <user>:<password> use RPCAP password authentication\n");
-#endif
- /*fprintf(output, "\n");*/
- fprintf(output, "Input file:\n");
- fprintf(output, " -r <infile> set the filename to read from (no pipes or stdin!)\n");
-
- fprintf(output, "\n");
- fprintf(output, "Processing:\n");
- fprintf(output, " -R <read filter> packet filter in Wireshark display filter syntax\n");
- fprintf(output, " -n disable all name resolutions (def: all enabled)\n");
- fprintf(output, " -N <name resolve flags> enable specific name resolution(s): \"mntC\"\n");
-
- fprintf(output, "\n");
- fprintf(output, "User interface:\n");
- fprintf(output, " -C <config profile> start with specified configuration profile\n");
- fprintf(output, " -Y <display filter> start with the given display filter\n");
- fprintf(output, " -g <packet number> go to specified packet number after \"-r\"\n");
- fprintf(output, " -J <jump filter> jump to the first packet matching the (display)\n");
- fprintf(output, " filter\n");
- fprintf(output, " -j search backwards for a matching packet after \"-J\"\n");
- fprintf(output, " -m <font> set the font name used for most text\n");
- fprintf(output, " -t a|ad|d|dd|e|r|u|ud output format of time stamps (def: r: rel. to first)\n");
- fprintf(output, " -u s|hms output format of seconds (def: s: seconds)\n");
- fprintf(output, " -X <key>:<value> eXtension options, see man page for details\n");
- fprintf(output, " -z <statistics> show various statistics, see man page for details\n");
-
- fprintf(output, "\n");
- fprintf(output, "Output:\n");
- fprintf(output, " -w <outfile|-> set the output filename (or '-' for stdout)\n");
-
- fprintf(output, "\n");
- fprintf(output, "Miscellaneous:\n");
- fprintf(output, " -h display this help and exit\n");
- fprintf(output, " -v display version info and exit\n");
- fprintf(output, " -P <key>:<path> persconf:path - personal configuration files\n");
- fprintf(output, " persdata:path - personal data files\n");
- fprintf(output, " -o <name>:<value> ... override preference or recent setting\n");
- fprintf(output, " -K <keytab> keytab file to use for kerberos decryption\n");
+ fprintf(output, "RPCAP options:\n");
+ fprintf(output, " -A <user>:<password> use RPCAP password authentication\n");
+#endif
+ /*fprintf(output, "\n");*/
+ fprintf(output, "Input file:\n");
+ fprintf(output, " -r <infile> set the filename to read from (no pipes or stdin!)\n");
+
+ fprintf(output, "\n");
+ fprintf(output, "Processing:\n");
+ fprintf(output, " -R <read filter> packet filter in Wireshark display filter syntax\n");
+ fprintf(output, " -n disable all name resolutions (def: all enabled)\n");
+ fprintf(output, " -N <name resolve flags> enable specific name resolution(s): \"mntC\"\n");
+
+ fprintf(output, "\n");
+ fprintf(output, "User interface:\n");
+ fprintf(output, " -C <config profile> start with specified configuration profile\n");
+ fprintf(output, " -Y <display filter> start with the given display filter\n");
+ fprintf(output, " -g <packet number> go to specified packet number after \"-r\"\n");
+ fprintf(output, " -J <jump filter> jump to the first packet matching the (display)\n");
+ fprintf(output, " filter\n");
+ fprintf(output, " -j search backwards for a matching packet after \"-J\"\n");
+ fprintf(output, " -m <font> set the font name used for most text\n");
+ fprintf(output, " -t a|ad|d|dd|e|r|u|ud output format of time stamps (def: r: rel. to first)\n");
+ fprintf(output, " -u s|hms output format of seconds (def: s: seconds)\n");
+ fprintf(output, " -X <key>:<value> eXtension options, see man page for details\n");
+ fprintf(output, " -z <statistics> show various statistics, see man page for details\n");
+
+ fprintf(output, "\n");
+ fprintf(output, "Output:\n");
+ fprintf(output, " -w <outfile|-> set the output filename (or '-' for stdout)\n");
+
+ fprintf(output, "\n");
+ fprintf(output, "Miscellaneous:\n");
+ fprintf(output, " -h display this help and exit\n");
+ fprintf(output, " -v display version info and exit\n");
+ fprintf(output, " -P <key>:<path> persconf:path - personal configuration files\n");
+ fprintf(output, " persdata:path - personal data files\n");
+ fprintf(output, " -o <name>:<value> ... override preference or recent setting\n");
+ fprintf(output, " -K <keytab> keytab file to use for kerberos decryption\n");
#ifndef _WIN32
- fprintf(output, " --display=DISPLAY X display to use\n");
+ fprintf(output, " --display=DISPLAY X display to use\n");
#endif
#ifdef _WIN32
- destroy_console();
+ destroy_console();
#endif
}
static void
show_version(void)
{
- printf(PACKAGE " " VERSION "%s\n"
- "\n"
- "%s"
- "\n"
- "%s"
- "\n"
- "%s",
- wireshark_svnversion, get_copyright_info(), comp_info_str->str,
- runtime_info_str->str);
+ printf(PACKAGE " " VERSION "%s\n"
+ "\n"
+ "%s"
+ "\n"
+ "%s"
+ "\n"
+ "%s",
+ wireshark_svnversion, get_copyright_info(), comp_info_str->str,
+ runtime_info_str->str);
}
/*
@@ -1276,16 +1276,16 @@ show_version(void)
void
cmdarg_err(const char *fmt, ...)
{
- va_list ap;
+ va_list ap;
#ifdef _WIN32
- create_console();
+ create_console();
#endif
- fprintf(stderr, "wireshark: ");
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- fprintf(stderr, "\n");
+ fprintf(stderr, "wireshark: ");
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
}
/*
@@ -1297,15 +1297,15 @@ cmdarg_err(const char *fmt, ...)
void
cmdarg_err_cont(const char *fmt, ...)
{
- va_list ap;
+ va_list ap;
#ifdef _WIN32
- create_console();
+ create_console();
#endif
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- va_end(ap);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
}
/*
@@ -1327,17 +1327,17 @@ tap_update_cb(gpointer data _U_)
static gboolean
resolv_update_cb(gpointer data _U_)
{
- /* Anything new show up? */
- if (host_name_lookup_process()) {
- if (gtk_widget_get_window(pkt_scrollw))
- gdk_window_invalidate_rect(gtk_widget_get_window(pkt_scrollw), NULL, TRUE);
- if (gtk_widget_get_window(tv_scrollw))
- gdk_window_invalidate_rect(gtk_widget_get_window(tv_scrollw), NULL, TRUE);
- }
+ /* Anything new show up? */
+ if (host_name_lookup_process()) {
+ if (gtk_widget_get_window(pkt_scrollw))
+ gdk_window_invalidate_rect(gtk_widget_get_window(pkt_scrollw), NULL, TRUE);
+ if (gtk_widget_get_window(tv_scrollw))
+ gdk_window_invalidate_rect(gtk_widget_get_window(tv_scrollw), NULL, TRUE);
+ }
- /* Always check. Even if we don't do async lookups we could still get
- passive updates, e.g. from DNS packets. */
- return TRUE;
+ /* Always check. Even if we don't do async lookups we could still get
+ passive updates, e.g. from DNS packets. */
+ return TRUE;
}
@@ -1348,9 +1348,9 @@ resolv_update_cb(gpointer data _U_)
void
main_update_for_unsaved_changes(capture_file *cf)
{
- set_titlebar_for_capture_file(cf);
- set_menus_for_capture_file(cf);
- set_toolbar_for_capture_file(cf);
+ set_titlebar_for_capture_file(cf);
+ set_menus_for_capture_file(cf);
+ set_toolbar_for_capture_file(cf);
}
#ifdef HAVE_LIBPCAP
@@ -1358,27 +1358,27 @@ void
main_auto_scroll_live_changed(gboolean auto_scroll_live_in)
{
/* Update menubar and toolbar */
- menu_auto_scroll_live_changed(auto_scroll_live_in);
- toolbar_auto_scroll_live_changed(auto_scroll_live_in);
+ menu_auto_scroll_live_changed(auto_scroll_live_in);
+ toolbar_auto_scroll_live_changed(auto_scroll_live_in);
- /* change auto scroll state */
- auto_scroll_live = auto_scroll_live_in;
+ /* change auto scroll state */
+ auto_scroll_live = auto_scroll_live_in;
}
#endif
void
main_colorize_changed(gboolean packet_list_colorize)
{
- /* Update menubar and toolbar */
- menu_colorize_changed(packet_list_colorize);
- toolbar_colorize_changed(packet_list_colorize);
-
- /* change colorization */
- if(packet_list_colorize != recent.packet_list_colorize) {
- recent.packet_list_colorize = packet_list_colorize;
- color_filters_enable(packet_list_colorize);
- packet_list_colorize_packets();
- }
+ /* Update menubar and toolbar */
+ menu_colorize_changed(packet_list_colorize);
+ toolbar_colorize_changed(packet_list_colorize);
+
+ /* change colorization */
+ if(packet_list_colorize != recent.packet_list_colorize) {
+ recent.packet_list_colorize = packet_list_colorize;
+ color_filters_enable(packet_list_colorize);
+ packet_list_colorize_packets();
+ }
}
static GtkWidget *close_dlg = NULL;
@@ -1412,8 +1412,8 @@ main_cf_cb_file_closing(capture_file *cf)
simple_dialog_primary_end());
gtk_window_set_position(GTK_WINDOW(close_dlg), GTK_WIN_POS_CENTER_ON_PARENT);
}
- /* Clear maunally resolved addresses */
- manually_resolve_cleanup();
+ /* Clear maunally resolved addresses */
+ manually_resolve_cleanup();
/* Destroy all windows that refer to the
capture file we're closing. */
destroy_packet_wins();
@@ -1441,20 +1441,20 @@ main_cf_cb_file_closing(capture_file *cf)
static void
main_cf_cb_file_closed(capture_file *cf _U_)
{
- if(close_dlg != NULL) {
- splash_destroy(close_dlg);
- close_dlg = NULL;
- }
+ if(close_dlg != NULL) {
+ splash_destroy(close_dlg);
+ close_dlg = NULL;
+ }
}
static void
main_cf_cb_file_read_started(capture_file *cf _U_)
{
- tap_param_dlg_update();
+ tap_param_dlg_update();
- /* Set up main window for a capture file. */
- main_set_for_capture_file(TRUE);
+ /* Set up main window for a capture file. */
+ main_set_for_capture_file(TRUE);
}
static void
@@ -1505,38 +1505,38 @@ static GList *icon_list_create(
const guint8 *icon48_pb,
const guint8 *icon64_pb)
{
- GList *icon_list = NULL;
- GdkPixbuf * pixbuf16;
- GdkPixbuf * pixbuf32;
- GdkPixbuf * pixbuf48;
- GdkPixbuf * pixbuf64;
+ GList *icon_list = NULL;
+ GdkPixbuf * pixbuf16;
+ GdkPixbuf * pixbuf32;
+ GdkPixbuf * pixbuf48;
+ GdkPixbuf * pixbuf64;
- if(icon16_pb != NULL) {
- pixbuf16 = gdk_pixbuf_new_from_inline(-1, icon16_pb, FALSE, NULL);
- g_assert(pixbuf16);
- icon_list = g_list_append(icon_list, pixbuf16);
+ if(icon16_pb != NULL) {
+ pixbuf16 = gdk_pixbuf_new_from_inline(-1, icon16_pb, FALSE, NULL);
+ g_assert(pixbuf16);
+ icon_list = g_list_append(icon_list, pixbuf16);
}
- if(icon32_pb != NULL) {
- pixbuf32 = gdk_pixbuf_new_from_inline(-1, icon32_pb, FALSE, NULL);
- g_assert(pixbuf32);
- icon_list = g_list_append(icon_list, pixbuf32);
- }
+ if(icon32_pb != NULL) {
+ pixbuf32 = gdk_pixbuf_new_from_inline(-1, icon32_pb, FALSE, NULL);
+ g_assert(pixbuf32);
+ icon_list = g_list_append(icon_list, pixbuf32);
+ }
- if(icon48_pb != NULL) {
- pixbuf48 = gdk_pixbuf_new_from_inline(-1, icon48_pb, FALSE, NULL);
- g_assert(pixbuf48);
- icon_list = g_list_append(icon_list, pixbuf48);
- }
+ if(icon48_pb != NULL) {
+ pixbuf48 = gdk_pixbuf_new_from_inline(-1, icon48_pb, FALSE, NULL);
+ g_assert(pixbuf48);
+ icon_list = g_list_append(icon_list, pixbuf48);
+ }
- if(icon64_pb != NULL) {
- pixbuf64 = gdk_pixbuf_new_from_inline(-1, icon64_pb, FALSE, NULL);
- g_assert(pixbuf64);
- icon_list = g_list_append(icon_list, pixbuf64);
- }
+ if(icon64_pb != NULL) {
+ pixbuf64 = gdk_pixbuf_new_from_inline(-1, icon64_pb, FALSE, NULL);
+ g_assert(pixbuf64);
+ icon_list = g_list_append(icon_list, pixbuf64);
+ }
- return icon_list;
+ return icon_list;
}
static void
@@ -1899,49 +1899,48 @@ main_capture_callback(gint event, capture_session *cap_session, gpointer user_da
static void
get_gtk_compiled_info(GString *str)
{
- g_string_append(str, "with ");
- g_string_append_printf(str,
+ g_string_append(str, "with ");
+ g_string_append_printf(str,
#ifdef GTK_MAJOR_VERSION
- "GTK+ %d.%d.%d", GTK_MAJOR_VERSION, GTK_MINOR_VERSION,
- GTK_MICRO_VERSION);
+ "GTK+ %d.%d.%d", GTK_MAJOR_VERSION, GTK_MINOR_VERSION,
+ GTK_MICRO_VERSION);
#else
- "GTK+ (version unknown)");
+ "GTK+ (version unknown)");
#endif
- g_string_append(str, ", ");
- /* Cairo */
- g_string_append(str, "with Cairo ");
- g_string_append(str, CAIRO_VERSION_STRING);
- g_string_append(str, ", ");
-
- /* Pango */
- g_string_append(str, "with Pango ");
- g_string_append(str, PANGO_VERSION_STRING);
- g_string_append(str, ", ");
+ g_string_append(str, ", ");
+ /* Cairo */
+ g_string_append(str, "with Cairo ");
+ g_string_append(str, CAIRO_VERSION_STRING);
+ g_string_append(str, ", ");
+ /* Pango */
+ g_string_append(str, "with Pango ");
+ g_string_append(str, PANGO_VERSION_STRING);
+ g_string_append(str, ", ");
}
static void
get_gui_compiled_info(GString *str)
{
- epan_get_compiled_version_info(str);
+ epan_get_compiled_version_info(str);
- g_string_append(str, ", ");
+ g_string_append(str, ", ");
#ifdef HAVE_LIBPORTAUDIO
#ifdef PORTAUDIO_API_1
- g_string_append(str, "with PortAudio <= V18");
+ g_string_append(str, "with PortAudio <= V18");
#else /* PORTAUDIO_API_1 */
- g_string_append(str, "with ");
- g_string_append(str, Pa_GetVersionText());
+ g_string_append(str, "with ");
+ g_string_append(str, Pa_GetVersionText());
#endif /* PORTAUDIO_API_1 */
#else /* HAVE_LIBPORTAUDIO */
- g_string_append(str, "without PortAudio");
+ g_string_append(str, "without PortAudio");
#endif /* HAVE_LIBPORTAUDIO */
- g_string_append(str, ", ");
+ g_string_append(str, ", ");
#ifdef HAVE_AIRPCAP
- get_compiled_airpcap_version(str);
-#else
+ get_compiled_airpcap_version(str);
+#e lse
g_string_append(str, "without AirPcap");
#endif
}
@@ -1949,123 +1948,123 @@ get_gui_compiled_info(GString *str)
static void
get_gui_runtime_info(GString *str)
{
- epan_get_runtime_version_info(str);
+ epan_get_runtime_version_info(str);
#ifdef HAVE_AIRPCAP
- g_string_append(str, ", ");
- get_runtime_airpcap_version(str);
+ g_string_append(str, ", ");
+ get_runtime_airpcap_version(str);
#endif
- if(u3_active()) {
- g_string_append(str, ", ");
- u3_runtime_info(str);
- }
+ if(u3_active()) {
+ g_string_append(str, ", ");
+ u3_runtime_info(str);
+ }
}
static e_prefs *
read_configuration_files(char **gdp_path, char **dp_path)
{
- int gpf_open_errno, gpf_read_errno;
- int cf_open_errno, df_open_errno;
- int gdp_open_errno, gdp_read_errno;
- int dp_open_errno, dp_read_errno;
- char *gpf_path, *pf_path;
- char *cf_path, *df_path;
- int pf_open_errno, pf_read_errno;
- e_prefs *prefs_p;
-
- /* load the decode as entries of this profile */
- load_decode_as_entries();
-
- /* Read the preference files. */
- prefs_p = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path,
- &pf_open_errno, &pf_read_errno, &pf_path);
-
- if (gpf_path != NULL) {
- if (gpf_open_errno != 0) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not open global preferences file\n\"%s\": %s.", gpf_path,
- g_strerror(gpf_open_errno));
- }
- if (gpf_read_errno != 0) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "I/O error reading global preferences file\n\"%s\": %s.", gpf_path,
- g_strerror(gpf_read_errno));
+ int gpf_open_errno, gpf_read_errno;
+ int cf_open_errno, df_open_errno;
+ int gdp_open_errno, gdp_read_errno;
+ int dp_open_errno, dp_read_errno;
+ char *gpf_path, *pf_path;
+ char *cf_path, *df_path;
+ int pf_open_errno, pf_read_errno;
+ e_prefs *prefs_p;
+
+ /* load the decode as entries of this profile */
+ load_decode_as_entries();
+
+ /* Read the preference files. */
+ prefs_p = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path,
+ &pf_open_errno, &pf_read_errno, &pf_path);
+
+ if (gpf_path != NULL) {
+ if (gpf_open_errno != 0) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "Could not open global preferences file\n\"%s\": %s.",
+ gpf_path, g_strerror(gpf_open_errno));
+ }
+ if (gpf_read_errno != 0) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "I/O error reading global preferences file\n\"%s\": %s.",
+ gpf_path, g_strerror(gpf_read_errno));
+ }
+ }
+ if (pf_path != NULL) {
+ if (pf_open_errno != 0) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "Could not open your preferences file\n\"%s\": %s.",
+ pf_path, g_strerror(pf_open_errno));
+ }
+ if (pf_read_errno != 0) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "I/O error reading your preferences file\n\"%s\": %s.",
+ pf_path, g_strerror(pf_read_errno));
+ }
+ g_free(pf_path);
+ pf_path = NULL;
}
- }
- if (pf_path != NULL) {
- if (pf_open_errno != 0) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not open your preferences file\n\"%s\": %s.", pf_path,
- g_strerror(pf_open_errno));
- }
- if (pf_read_errno != 0) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "I/O error reading your preferences file\n\"%s\": %s.", pf_path,
- g_strerror(pf_read_errno));
- }
- g_free(pf_path);
- pf_path = NULL;
- }
#ifdef _WIN32
- /* if the user wants a console to be always there, well, we should open one for him */
- if (prefs_p->gui_console_open == console_open_always) {
- create_console();
- }
+ /* if the user wants a console to be always there, well, we should open one for him */
+ if (prefs_p->gui_console_open == console_open_always) {
+ create_console();
+ }
#endif
- /* Read the capture filter file. */
- read_filter_list(CFILTER_LIST, &cf_path, &cf_open_errno);
- if (cf_path != NULL) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not open your capture filter file\n\"%s\": %s.", cf_path,
- g_strerror(cf_open_errno));
- g_free(cf_path);
- }
+ /* Read the capture filter file. */
+ read_filter_list(CFILTER_LIST, &cf_path, &cf_open_errno);
+ if (cf_path != NULL) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "Could not open your capture filter file\n\"%s\": %s.",
+ cf_path, g_strerror(cf_open_errno));
+ g_free(cf_path);
+ }
- /* Read the display filter file. */
- read_filter_list(DFILTER_LIST, &df_path, &df_open_errno);
- if (df_path != NULL) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not open your display filter file\n\"%s\": %s.", df_path,
- g_strerror(df_open_errno));
- g_free(df_path);
- }
+ /* Read the display filter file. */
+ read_filter_list(DFILTER_LIST, &df_path, &df_open_errno);
+ if (df_path != NULL) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "Could not open your display filter file\n\"%s\": %s.",
+ df_path, g_strerror(df_open_errno));
+ g_free(df_path);
+ }
- /* Read the disabled protocols file. */
- read_disabled_protos_list(gdp_path, &gdp_open_errno, &gdp_read_errno,
- dp_path, &dp_open_errno, &dp_read_errno);
- if (*gdp_path != NULL) {
- if (gdp_open_errno != 0) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not open global disabled protocols file\n\"%s\": %s.",
- *gdp_path, g_strerror(gdp_open_errno));
- }
- if (gdp_read_errno != 0) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "I/O error reading global disabled protocols file\n\"%s\": %s.",
- *gdp_path, g_strerror(gdp_read_errno));
- }
- g_free(*gdp_path);
- *gdp_path = NULL;
- }
- if (*dp_path != NULL) {
- if (dp_open_errno != 0) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not open your disabled protocols file\n\"%s\": %s.", *dp_path,
- g_strerror(dp_open_errno));
- }
- if (dp_read_errno != 0) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "I/O error reading your disabled protocols file\n\"%s\": %s.", *dp_path,
- g_strerror(dp_read_errno));
- }
- g_free(*dp_path);
- *dp_path = NULL;
- }
+ /* Read the disabled protocols file. */
+ read_disabled_protos_list(gdp_path, &gdp_open_errno, &gdp_read_errno,
+ dp_path, &dp_open_errno, &dp_read_errno);
+ if (*gdp_path != NULL) {
+ if (gdp_open_errno != 0) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "Could not open global disabled protocols file\n\"%s\": %s.",
+ *gdp_path, g_strerror(gdp_open_errno));
+ }
+ if (gdp_read_errno != 0) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "I/O error reading global disabled protocols file\n\"%s\": %s.",
+ *gdp_path, g_strerror(gdp_read_errno));
+ }
+ g_free(*gdp_path);
+ *gdp_path = NULL;
+ }
+ if (*dp_path != NULL) {
+ if (dp_open_errno != 0) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "Could not open your disabled protocols file\n\"%s\": %s.",
+ *dp_path, g_strerror(dp_open_errno));
+ }
+ if (dp_read_errno != 0) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "I/O error reading your disabled protocols file\n\"%s\": %s.",
+ *dp_path, g_strerror(dp_read_errno));
+ }
+ g_free(*dp_path);
+ *dp_path = NULL;
+ }
- return prefs_p;
+ return prefs_p;
}
/* Check if there's something important to tell the user during startup.
@@ -2079,87 +2078,86 @@ check_and_warn_user_startup(gchar *cf_name)
check_and_warn_user_startup(gchar *cf_name _U_)
#endif
{
- gchar *cur_user, *cur_group;
- gpointer priv_warning_dialog;
-
- /* Tell the user not to run as root. */
- if (running_with_special_privs() && recent.privs_warn_if_elevated) {
- cur_user = get_cur_username();
- cur_group = get_cur_groupname();
- priv_warning_dialog = simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Running as user \"%s\" and group \"%s\".\n"
- "This could be dangerous.\n\n"
- "If you're running Wireshark this way in order to perform live capture, "
- "you may want to be aware that there is a better way documented at\n"
- "http://wiki.wireshark.org/CaptureSetup/CapturePrivileges", cur_user, cur_group);
- g_free(cur_user);
- g_free(cur_group);
- simple_dialog_check_set(priv_warning_dialog, "Don't show this message again.");
- simple_dialog_set_cb(priv_warning_dialog, priv_warning_dialog_cb, NULL);
- }
+ gchar *cur_user, *cur_group;
+ gpointer priv_warning_dialog;
+
+ /* Tell the user not to run as root. */
+ if (running_with_special_privs() && recent.privs_warn_if_elevated) {
+ cur_user = get_cur_username();
+ cur_group = get_cur_groupname();
+ priv_warning_dialog = simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "Running as user \"%s\" and group \"%s\".\n"
+ "This could be dangerous.\n\n"
+ "If you're running Wireshark this way in order to perform live capture, "
+ "you may want to be aware that there is a better way documented at\n"
+ "http://wiki.wireshark.org/CaptureSetup/CapturePrivileges", cur_user, cur_group);
+ g_free(cur_user);
+ g_free(cur_group);
+ simple_dialog_check_set(priv_warning_dialog, "Don't show this message again.");
+ simple_dialog_set_cb(priv_warning_dialog, priv_warning_dialog_cb, NULL);
+ }
#ifdef _WIN32
- /* Warn the user if npf.sys isn't loaded. */
- if (!get_stdin_capture() && !cf_name && !npf_sys_is_running() && recent.privs_warn_if_no_npf && get_os_major_version() >= 6) {
- priv_warning_dialog = simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "The NPF driver isn't running. You may have trouble\n"
- "capturing or listing interfaces.");
- simple_dialog_check_set(priv_warning_dialog, "Don't show this message again.");
- simple_dialog_set_cb(priv_warning_dialog, npf_warning_dialog_cb, NULL);
- }
+ /* Warn the user if npf.sys isn't loaded. */
+ if (!get_stdin_capture() && !cf_name && !npf_sys_is_running() && recent.privs_warn_if_no_npf && get_os_major_version() >= 6) {
+ priv_warning_dialog = simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "The NPF driver isn't running. You may have trouble\n"
+ "capturing or listing interfaces.");
+ simple_dialog_check_set(priv_warning_dialog, "Don't show this message again.");
+ simple_dialog_set_cb(priv_warning_dialog, npf_warning_dialog_cb, NULL);
+ }
#endif
}
-
/* And now our feature presentation... [ fade to music ] */
int
main(int argc, char *argv[])
{
- char *init_progfile_dir_error;
- char *s;
- int opt;
- gboolean arg_error = FALSE;
+ char *init_progfile_dir_error;
+ char *s;
+ int opt;
+ gboolean arg_error = FALSE;
- extern int info_update_freq; /* Found in about_dlg.c. */
- const gchar *filter;
+ extern int info_update_freq; /* Found in about_dlg.c. */
+ const gchar *filter;
#ifdef _WIN32
- WSADATA wsaData;
+ WSADATA wsaData;
#endif /* _WIN32 */
- char *rf_path;
- int rf_open_errno;
- char *gdp_path, *dp_path;
- int err;
+ char *rf_path;
+ int rf_open_errno;
+ char *gdp_path, *dp_path;
+ int err;
#ifdef HAVE_LIBPCAP
- gboolean start_capture = FALSE;
- gboolean list_link_layer_types = FALSE;
- GList *if_list;
- gchar *err_str;
- int status;
+ gboolean start_capture = FALSE;
+ gboolean list_link_layer_types = FALSE;
+ GList *if_list;
+ gchar *err_str;
+ int status;
#else
- gboolean capture_option_specified = FALSE;
+ gboolean capture_option_specified = FALSE;
#ifdef _WIN32
#ifdef HAVE_AIRPCAP
- gchar *err_str;
-#endif
-#endif
-#endif
- gint pl_size = 280, tv_size = 95, bv_size = 75;
- gchar *rc_file, *cf_name = NULL, *rfilter = NULL, *dfilter = NULL, *jfilter = NULL;
- dfilter_t *rfcode = NULL;
- gboolean rfilter_parse_failed = FALSE;
- e_prefs *prefs_p;
- char badopt;
- GtkWidget *splash_win = NULL;
- GLogLevelFlags log_flags;
- guint go_to_packet = 0;
- search_direction jump_backwards = SD_FORWARD;
- dfilter_t *jump_to_filter = NULL;
- int optind_initial;
+ gchar *err_str;
+#endif
+#endif
+#endif
+ gint pl_size = 280, tv_size = 95, bv_size = 75;
+ gchar *rc_file, *cf_name = NULL, *rfilter = NULL, *dfilter = NULL, *jfilter = NULL;
+ dfilter_t *rfcode = NULL;
+ gboolean rfilter_parse_failed = FALSE;
+ e_prefs *prefs_p;
+ char badopt;
+ GtkWidget *splash_win = NULL;
+ GLogLevelFlags log_flags;
+ guint go_to_packet = 0;
+ search_direction jump_backwards = SD_FORWARD;
+ dfilter_t *jump_to_filter = NULL;
+ int optind_initial;
#ifdef HAVE_GTKOSXAPPLICATION
- GtkosxApplication *theApp;
+ GtkosxApplication *theApp;
#endif
#ifdef HAVE_LIBPCAP
@@ -2184,208 +2182,208 @@ main(int argc, char *argv[])
#define OPTSTRING "a:" OPTSTRING_A "b:" OPTSTRING_B "c:C:Df:g:Hhi:" OPTSTRING_I "jJ:kK:lLm:nN:o:P:pr:R:Ss:t:u:vw:X:y:Y:z:"
- static const char optstring[] = OPTSTRING;
+ static const char optstring[] = OPTSTRING;
- /* Set the C-language locale to the native environment. */
- setlocale(LC_ALL, "");
+ /* Set the C-language locale to the native environment. */
+ setlocale(LC_ALL, "");
#ifdef _WIN32
- arg_list_utf_16to8(argc, argv);
- create_app_running_mutex();
+ arg_list_utf_16to8(argc, argv);
+ create_app_running_mutex();
#endif /* _WIN32 */
- /*
- * Get credential information for later use, and drop privileges
- * before doing anything else.
- * Let the user know if anything happened.
- */
- init_process_policies();
- relinquish_special_privs_perm();
+ /*
+ * Get credential information for later use, and drop privileges
+ * before doing anything else.
+ * Let the user know if anything happened.
+ */
+ init_process_policies();
+ relinquish_special_privs_perm();
- /*
- * Attempt to get the pathname of the executable file.
- */
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ /*
+ * Attempt to get the pathname of the executable file.
+ */
+ init_progfile_dir_error = init_progfile_dir(argv[0], main);
- /* initialize the funnel mini-api */
- initialize_funnel_ops();
+ /* initialize the funnel mini-api */
+ initialize_funnel_ops();
- AirPDcapInitContext(&airpdcap_ctx);
+ AirPDcapInitContext(&airpdcap_ctx);
#ifdef _WIN32
- /* Load wpcap if possible. Do this before collecting the run-time version information */
- load_wpcap();
+ /* Load wpcap if possible. Do this before collecting the run-time version information */
+ load_wpcap();
- /* ... and also load the packet.dll from wpcap */
- wpcap_packet_load();
+ /* ... and also load the packet.dll from wpcap */
+ wpcap_packet_load();
#ifdef HAVE_AIRPCAP
- /* Load the airpcap.dll. This must also be done before collecting
- * run-time version information. */
- airpcap_dll_ret_val = load_airpcap();
-
- switch (airpcap_dll_ret_val) {
- case AIRPCAP_DLL_OK:
- /* load the airpcap interfaces */
- airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
-
- if (airpcap_if_list == NULL || g_list_length(airpcap_if_list) == 0){
- if (err == CANT_GET_AIRPCAP_INTERFACE_LIST && err_str != NULL) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", "Failed to open Airpcap Adapters.");
- g_free(err_str);
- }
- airpcap_if_active = NULL;
+ /* Load the airpcap.dll. This must also be done before collecting
+ * run-time version information. */
+ airpcap_dll_ret_val = load_airpcap();
+
+ switch (airpcap_dll_ret_val) {
+ case AIRPCAP_DLL_OK:
+ /* load the airpcap interfaces */
+ airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
+
+ if (airpcap_if_list == NULL || g_list_length(airpcap_if_list) == 0){
+ if (err == CANT_GET_AIRPCAP_INTERFACE_LIST && err_str != NULL) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", "Failed to open Airpcap Adapters.");
+ g_free(err_str);
+ }
+ airpcap_if_active = NULL;
- } else {
+ } else {
- /* select the first ad default (THIS SHOULD BE CHANGED) */
- airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
- }
- break;
+ /* select the first ad default (THIS SHOULD BE CHANGED) */
+ airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
+ }
+ break;
#if 0
- /*
- * XXX - Maybe we need to warn the user if one of the following happens???
- */
- case AIRPCAP_DLL_OLD:
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DLL_OLD\n");
- break;
+ /*
+ * XXX - Maybe we need to warn the user if one of the following happens???
+ */
+ case AIRPCAP_DLL_OLD:
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DLL_OLD\n");
+ break;
- case AIRPCAP_DLL_ERROR:
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DLL_ERROR\n");
- break;
+ case AIRPCAP_DLL_ERROR:
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DLL_ERROR\n");
+ break;
- case AIRPCAP_DLL_NOT_FOUND:
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DDL_NOT_FOUND\n");
- break;
+ case AIRPCAP_DLL_NOT_FOUND:
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DDL_NOT_FOUND\n");
+ break;
#endif
- }
+ }
#endif /* HAVE_AIRPCAP */
#endif /* _WIN32 */
- /* Assemble the compile-time version information string */
- comp_info_str = g_string_new("Compiled ");
+ /* Assemble the compile-time version information string */
+ comp_info_str = g_string_new("Compiled ");
- get_compiled_version_info(comp_info_str, get_gtk_compiled_info, get_gui_compiled_info);
+ get_compiled_version_info(comp_info_str, get_gtk_compiled_info, get_gui_compiled_info);
- /* Assemble the run-time version information string */
- runtime_info_str = g_string_new("Running ");
- get_runtime_version_info(runtime_info_str, get_gui_runtime_info);
+ /* Assemble the run-time version information string */
+ runtime_info_str = g_string_new("Running ");
+ get_runtime_version_info(runtime_info_str, get_gui_runtime_info);
#ifdef _WIN32
- ws_add_crash_info(PACKAGE " " VERSION "%s\n"
- "\n"
- "%s"
- "\n"
- "%s",
- wireshark_svnversion, comp_info_str->str, runtime_info_str->str);
-
- /* Start windows sockets */
- WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
-#endif /* _WIN32 */
+ ws_add_crash_info(PACKAGE " " VERSION "%s\n"
+ "\n"
+ "%s"
+ "\n"
+ "%s",
+ wireshark_svnversion, comp_info_str->str, runtime_info_str->str);
- profile_store_persconffiles (TRUE);
+ /* Start windows sockets */
+ WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
+#endif /* _WIN32 */
- /* Read the profile independent recent file. We have to do this here so we can */
- /* set the profile before it can be set from the command line parameterts */
- recent_read_static(&rf_path, &rf_open_errno);
- if (rf_path != NULL && rf_open_errno != 0) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not open common recent file\n\"%s\": %s.",
- rf_path, g_strerror(rf_open_errno));
- }
+ profile_store_persconffiles (TRUE);
- /* "pre-scan" the command line parameters, if we have "console only"
- parameters. We do this so we don't start GTK+ if we're only showing
- command-line help or version information.
-
- XXX - this pre-scan is done before we start GTK+, so we haven't
- run gtk_init() on the arguments. That means that GTK+ arguments
- have not been removed from the argument list; those arguments
- begin with "--", and will be treated as an error by getopt().
-
- We thus ignore errors - *and* set "opterr" to 0 to suppress the
- error messages. */
- opterr = 0;
- optind_initial = optind;
- while ((opt = getopt(argc, argv, optstring)) != -1) {
- switch (opt) {
- case 'C': /* Configuration Profile */
- if (profile_exists (optarg, FALSE)) {
- set_profile_name (optarg);
- } else {
- cmdarg_err("Configuration Profile \"%s\" does not exist", optarg);
- exit(1);
- }
- break;
- case 'D': /* Print a list of capture devices and exit */
+ /* Read the profile independent recent file. We have to do this here so we can */
+ /* set the profile before it can be set from the command line parameterts */
+ recent_read_static(&rf_path, &rf_open_errno);
+ if (rf_path != NULL && rf_open_errno != 0) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "Could not open common recent file\n\"%s\": %s.",
+ rf_path, g_strerror(rf_open_errno));
+ }
+
+ /* "pre-scan" the command line parameters, if we have "console only"
+ parameters. We do this so we don't start GTK+ if we're only showing
+ command-line help or version information.
+
+ XXX - this pre-scan is done before we start GTK+, so we haven't
+ run gtk_init() on the arguments. That means that GTK+ arguments
+ have not been removed from the argument list; those arguments
+ begin with "--", and will be treated as an error by getopt().
+
+ We thus ignore errors - *and* set "opterr" to 0 to suppress the
+ error messages. */
+ opterr = 0;
+ optind_initial = optind;
+ while ((opt = getopt(argc, argv, optstring)) != -1) {
+ switch (opt) {
+ case 'C': /* Configuration Profile */
+ if (profile_exists (optarg, FALSE)) {
+ set_profile_name (optarg);
+ } else {
+ cmdarg_err("Configuration Profile \"%s\" does not exist", optarg);
+ exit(1);
+ }
+ break;
+ case 'D': /* Print a list of capture devices and exit */
#ifdef HAVE_LIBPCAP
- if_list = capture_interface_list(&err, &err_str,main_window_update);
- if (if_list == NULL) {
- switch (err) {
- case CANT_GET_INTERFACE_LIST:
- case DONT_HAVE_PCAP:
- cmdarg_err("%s", err_str);
- g_free(err_str);
- break;
-
- case NO_INTERFACES_FOUND:
- cmdarg_err("There are no interfaces on which a capture can be done");
- break;
- }
- exit(2);
- }
+ if_list = capture_interface_list(&err, &err_str,main_window_update);
+ if (if_list == NULL) {
+ switch (err) {
+ case CANT_GET_INTERFACE_LIST:
+ case DONT_HAVE_PCAP:
+ cmdarg_err("%s", err_str);
+ g_free(err_str);
+ break;
+
+ case NO_INTERFACES_FOUND:
+ cmdarg_err("There are no interfaces on which a capture can be done");
+ break;
+ }
+ exit(2);
+ }
#ifdef _WIN32
- create_console();
+ create_console();
#endif /* _WIN32 */
- capture_opts_print_interfaces(if_list);
- free_interface_list(if_list);
+ capture_opts_print_interfaces(if_list);
+ free_interface_list(if_list);
#ifdef _WIN32
- destroy_console();
+ destroy_console();
#endif /* _WIN32 */
- exit(0);
+ exit(0);
#else /* HAVE_LIBPCAP */
- capture_option_specified = TRUE;
- arg_error = TRUE;
+ capture_option_specified = TRUE;
+ arg_error = TRUE;
#endif /* HAVE_LIBPCAP */
- break;
- case 'h': /* Print help and exit */
- print_usage(TRUE);
- exit(0);
- break;
+ break;
+ case 'h': /* Print help and exit */
+ print_usage(TRUE);
+ exit(0);
+ break;
#ifdef _WIN32
- case 'i':
- if (strcmp(optarg, "-") == 0)
- set_stdin_capture(TRUE);
- break;
-#endif
- case 'P': /* Personal file directory path settings - change these before the Preferences and alike are processed */
- if (!persfilepath_opt(opt, optarg)) {
- cmdarg_err("-P flag \"%s\" failed (hint: is it quoted and existing?)", optarg);
- exit(2);
- }
- break;
- case 'v': /* Show version and exit */
+ case 'i':
+ if (strcmp(optarg, "-") == 0)
+ set_stdin_capture(TRUE);
+ break;
+#endif
+ case 'P': /* Personal file directory path settings - change these before the Preferences and alike are processed */
+ if (!persfilepath_opt(opt, optarg)) {
+ cmdarg_err("-P flag \"%s\" failed (hint: is it quoted and existing?)", optarg);
+ exit(2);
+ }
+ break;
+ case 'v': /* Show version and exit */
#ifdef _WIN32
- create_console();
+ create_console();
#endif
- show_version();
+ show_version();
#ifdef _WIN32
- destroy_console();
-#endif
- exit(0);
- break;
- case 'X':
- /*
- * Extension command line options have to be processed before
- * we call epan_init() as they are supposed to be used by dissectors
- * or taps very early in the registration process.
- */
- ex_opt_add(optarg);
- break;
- case '?': /* Ignore errors - the "real" scan will catch them. */
- break;
+ destroy_console();
+#endif
+ exit(0);
+ break;
+ case 'X':
+ /*
+ * Extension command line options have to be processed before
+ * we call epan_init() as they are supposed to be used by dissectors
+ * or taps very early in the registration process.
+ */
+ ex_opt_add(optarg);
+ break;
+ case '?': /* Ignore errors - the "real" scan will catch them. */
+ break;
+ }
}
- }
/* Init the "Open file" dialog directory */
/* (do this after the path settings are processed) */
@@ -2397,8 +2395,8 @@ main(int argc, char *argv[])
recent_read_profile_static(&rf_path, &rf_open_errno);
if (rf_path != NULL && rf_open_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not open recent file\n\"%s\": %s.",
- rf_path, g_strerror(rf_open_errno));
+ "Could not open recent file\n\"%s\": %s.",
+ rf_path, g_strerror(rf_open_errno));
}
if (recent.gui_fileopen_remembered_dir &&
@@ -2408,877 +2406,878 @@ main(int argc, char *argv[])
set_last_open_dir(get_persdatafile_dir());
}
- /* Set getopt index back to initial value, so it will start with the
- first command line parameter again. Also reset opterr to 1, so that
- error messages are printed by getopt().
+ /* Set getopt index back to initial value, so it will start with the
+ first command line parameter again. Also reset opterr to 1, so that
+ error messages are printed by getopt().
- XXX - this seems to work on most platforms, but time will tell.
- The Single UNIX Specification says "The getopt() function need
- not be reentrant", so this isn't guaranteed to work. The Mac
- OS X 10.4[.x] getopt() man page says
+ XXX - this seems to work on most platforms, but time will tell.
+ The Single UNIX Specification says "The getopt() function need
+ not be reentrant", so this isn't guaranteed to work. The Mac
+ OS X 10.4[.x] getopt() man page says
- In order to use getopt() to evaluate multiple sets of arguments, or to
- evaluate a single set of arguments multiple times, the variable optreset
- must be set to 1 before the second and each additional set of calls to
- getopt(), and the variable optind must be reinitialized.
+ In order to use getopt() to evaluate multiple sets of arguments, or to
+ evaluate a single set of arguments multiple times, the variable optreset
+ must be set to 1 before the second and each additional set of calls to
+ getopt(), and the variable optind must be reinitialized.
...
- The optreset variable was added to make it possible to call the getopt()
- function multiple times. This is an extension to the IEEE Std 1003.2
- (``POSIX.2'') specification.
-
- which I think comes from one of the other BSDs.
-
- XXX - if we want to control all the command-line option errors, so
- that we can display them where we choose (e.g., in a window), we'd
- want to leave opterr as 0, and produce our own messages using optopt.
- We'd have to check the value of optopt to see if it's a valid option
- letter, in which case *presumably* the error is "this option requires
- an argument but none was specified", or not a valid option letter,
- in which case *presumably* the error is "this option isn't valid".
- Some versions of getopt() let you supply a option string beginning
- with ':', which means that getopt() will return ':' rather than '?'
- for "this option requires an argument but none was specified", but
- not all do. */
- optind = optind_initial;
- opterr = 1;
+ The optreset variable was added to make it possible to call the getopt()
+ function multiple times. This is an extension to the IEEE Std 1003.2
+ (``POSIX.2'') specification.
+
+ which I think comes from one of the other BSDs.
+
+ XXX - if we want to control all the command-line option errors, so
+ that we can display them where we choose (e.g., in a window), we'd
+ want to leave opterr as 0, and produce our own messages using optopt.
+ We'd have to check the value of optopt to see if it's a valid option
+ letter, in which case *presumably* the error is "this option requires
+ an argument but none was specified", or not a valid option letter,
+ in which case *presumably* the error is "this option isn't valid".
+ Some versions of getopt() let you supply a option string beginning
+ with ':', which means that getopt() will return ':' rather than '?'
+ for "this option requires an argument but none was specified", but
+ not all do. */
+ optind = optind_initial;
+ opterr = 1;
#if !GLIB_CHECK_VERSION(2,31,0)
- g_thread_init(NULL);
+ g_thread_init(NULL);
#endif
- /* Set the current locale according to the program environment.
- * We haven't localized anything, but some GTK widgets are localized
- * (the file selection dialogue, for example).
- * This also sets the C-language locale to the native environment. */
- setlocale (LC_ALL, "");
+ /* Set the current locale according to the program environment.
+ * We haven't localized anything, but some GTK widgets are localized
+ * (the file selection dialogue, for example).
+ * This also sets the C-language locale to the native environment. */
+ setlocale (LC_ALL, "");
- /* Let GTK get its args (will need an X server, so do this after command line only commands handled) */
- gtk_init (&argc, &argv);
+ /* Let GTK get its args (will need an X server, so do this after command line only commands handled) */
+ gtk_init (&argc, &argv);
- cf_callback_add(main_cf_callback, NULL);
+ cf_callback_add(main_cf_callback, NULL);
#ifdef HAVE_LIBPCAP
- capture_callback_add(main_capture_callback, NULL);
+ capture_callback_add(main_capture_callback, NULL);
#endif
- cf_callback_add(statusbar_cf_callback, NULL);
+ cf_callback_add(statusbar_cf_callback, NULL);
#ifdef HAVE_LIBPCAP
- capture_callback_add(statusbar_capture_callback, NULL);
+ capture_callback_add(statusbar_capture_callback, NULL);
#endif
- /* Arrange that if we have no console window, and a GLib message logging
- routine is called to log a message, we pop up a console window.
+ /* Arrange that if we have no console window, and a GLib message logging
+ routine is called to log a message, we pop up a console window.
- We do that by inserting our own handler for all messages logged
- to the default domain; that handler pops up a console if necessary,
- and then calls the default handler. */
+ We do that by inserting our own handler for all messages logged
+ to the default domain; that handler pops up a console if necessary,
+ and then calls the default handler. */
- /* We might want to have component specific log levels later ... */
+ /* We might want to have component specific log levels later ... */
- log_flags = (GLogLevelFlags)
- (G_LOG_LEVEL_ERROR|
- G_LOG_LEVEL_CRITICAL|
- G_LOG_LEVEL_WARNING|
- G_LOG_LEVEL_MESSAGE|
- G_LOG_LEVEL_INFO|
- G_LOG_LEVEL_DEBUG|
- G_LOG_FLAG_FATAL|G_LOG_FLAG_RECURSION);
+ log_flags = (GLogLevelFlags)
+ (G_LOG_LEVEL_ERROR|
+ G_LOG_LEVEL_CRITICAL|
+ G_LOG_LEVEL_WARNING|
+ G_LOG_LEVEL_MESSAGE|
+ G_LOG_LEVEL_INFO|
+ G_LOG_LEVEL_DEBUG|
+ G_LOG_FLAG_FATAL|
+ G_LOG_FLAG_RECURSION);
- g_log_set_handler(NULL,
- log_flags,
- console_log_handler, NULL /* user_data */);
- g_log_set_handler(LOG_DOMAIN_MAIN,
- log_flags,
- console_log_handler, NULL /* user_data */);
+ g_log_set_handler(NULL,
+ log_flags,
+ console_log_handler, NULL /* user_data */);
+ g_log_set_handler(LOG_DOMAIN_MAIN,
+ log_flags,
+ console_log_handler, NULL /* user_data */);
#ifdef HAVE_LIBPCAP
- g_log_set_handler(LOG_DOMAIN_CAPTURE,
- log_flags,
- console_log_handler, NULL /* user_data */);
+ g_log_set_handler(LOG_DOMAIN_CAPTURE,
+ log_flags,
+ console_log_handler, NULL /* user_data */);
g_log_set_handler(LOG_DOMAIN_CAPTURE_CHILD,
- log_flags,
- console_log_handler, NULL /* user_data */);
+ log_flags,
+ console_log_handler, NULL /* user_data */);
- /* Set the initial values in the capture options. This might be overwritten
- by preference settings and then again by the command line parameters. */
- capture_opts_init(&global_capture_opts);
+ /* Set the initial values in the capture options. This might be overwritten
+ by preference settings and then again by the command line parameters. */
+ capture_opts_init(&global_capture_opts);
- capture_session_init(&global_capture_session, (void *)&cfile);
+ capture_session_init(&global_capture_session, (void *)&cfile);
#endif
- init_report_err(failure_alert_box, open_failure_alert_box,
- read_failure_alert_box, write_failure_alert_box);
+ init_report_err(failure_alert_box, open_failure_alert_box,
+ read_failure_alert_box, write_failure_alert_box);
- /* Initialize whatever we need to allocate colors for GTK+ */
- colors_init();
+ /* Initialize whatever we need to allocate colors for GTK+ */
+ colors_init();
- /* Non-blank filter means we're remote. Throttle splash screen and resolution updates. */
- filter = get_conn_cfilter();
- if ( *filter != '\0' ) {
- info_update_freq = 1000; /* Milliseconds */
- }
+ /* Non-blank filter means we're remote. Throttle splash screen and resolution updates. */
+ filter = get_conn_cfilter();
+ if ( *filter != '\0' ) {
+ info_update_freq = 1000; /* Milliseconds */
+ }
- /* We won't come till here, if we had a "console only" command line parameter. */
- splash_win = splash_new("Loading Wireshark ...");
- if (init_progfile_dir_error != NULL) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Can't get pathname of Wireshark: %s.\n"
- "It won't be possible to capture traffic.\n"
- "Report this to the Wireshark developers.",
- init_progfile_dir_error);
- g_free(init_progfile_dir_error);
- }
+ /* We won't come till here, if we had a "console only" command line parameter. */
+ splash_win = splash_new("Loading Wireshark ...");
+ if (init_progfile_dir_error != NULL) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "Can't get pathname of Wireshark: %s.\n"
+ "It won't be possible to capture traffic.\n"
+ "Report this to the Wireshark developers.",
+ init_progfile_dir_error);
+ g_free(init_progfile_dir_error);
+ }
#ifdef HAVE_PLUGINS
- /* Register all the plugin types we have. */
- epan_register_plugin_types(); /* Types known to libwireshark */
- wtap_register_plugin_types(); /* Types known to libwiretap */
- codec_register_plugin_types(); /* Types known to libcodec */
+ /* Register all the plugin types we have. */
+ epan_register_plugin_types(); /* Types known to libwireshark */
+ wtap_register_plugin_types(); /* Types known to libwiretap */
+ codec_register_plugin_types(); /* Types known to libcodec */
- /* Scan for plugins. This does *not* call their registration routines;
- that's done later. */
- scan_plugins();
+ /* Scan for plugins. This does *not* call their registration routines;
+ that's done later. */
+ scan_plugins();
- /* Register all libwiretap plugin modules. */
- register_all_wiretap_modules();
+ /* Register all libwiretap plugin modules. */
+ register_all_wiretap_modules();
- /* Register all audio codec plugins. */
- register_all_codecs();
+ /* Register all audio codec plugins. */
+ register_all_codecs();
#endif
- splash_update(RA_DISSECTORS, NULL, (gpointer)splash_win);
+ splash_update(RA_DISSECTORS, NULL, (gpointer)splash_win);
- /* Register all dissectors; we must do this before checking for the
- "-G" flag, as the "-G" flag dumps information registered by the
- dissectors, and we must do it before we read the preferences, in
- case any dissectors register preferences. */
- epan_init(register_all_protocols,register_all_protocol_handoffs,
- splash_update, (gpointer) splash_win);
+ /* Register all dissectors; we must do this before checking for the
+ "-G" flag, as the "-G" flag dumps information registered by the
+ dissectors, and we must do it before we read the preferences, in
+ case any dissectors register preferences. */
+ epan_init(register_all_protocols,register_all_protocol_handoffs,
+ splash_update, (gpointer) splash_win);
- splash_update(RA_LISTENERS, NULL, (gpointer)splash_win);
+ splash_update(RA_LISTENERS, NULL, (gpointer)splash_win);
- /* Register all tap listeners; we do this before we parse the arguments,
- as the "-z" argument can specify a registered tap. */
+ /* Register all tap listeners; we do this before we parse the arguments,
+ as the "-z" argument can specify a registered tap. */
- /* we register the plugin taps before the other taps because
- stats_tree taps plugins will be registered as tap listeners
- by stats_tree_stat.c and need to registered before that */
+ /* we register the plugin taps before the other taps because
+ stats_tree taps plugins will be registered as tap listeners
+ by stats_tree_stat.c and need to registered before that */
#ifdef HAVE_PLUGINS
- register_all_plugin_tap_listeners();
+ register_all_plugin_tap_listeners();
#endif
- register_all_tap_listeners();
+ register_all_tap_listeners();
- splash_update(RA_PREFERENCES, NULL, (gpointer)splash_win);
+ splash_update(RA_PREFERENCES, NULL, (gpointer)splash_win);
- prefs_p = read_configuration_files (&gdp_path, &dp_path);
- /* Removed thread code:
- * http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=35027
- */
+ prefs_p = read_configuration_files (&gdp_path, &dp_path);
+ /* Removed thread code:
+ * http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=35027
+ */
- /* this is to keep tap extensions updating once every 3 seconds */
- tap_update_timer_id = g_timeout_add(prefs_p->tap_update_interval, tap_update_cb, NULL);
+ /* this is to keep tap extensions updating once every 3 seconds */
+ tap_update_timer_id = g_timeout_add(prefs_p->tap_update_interval, tap_update_cb, NULL);
- splash_update(RA_CONFIGURATION, NULL, (gpointer)splash_win);
- proto_help_init();
- cap_file_init(&cfile);
+ splash_update(RA_CONFIGURATION, NULL, (gpointer)splash_win);
+ proto_help_init();
+ cap_file_init(&cfile);
- /* Fill in capture options with values from the preferences */
- prefs_to_capture_opts();
+ /* Fill in capture options with values from the preferences */
+ prefs_to_capture_opts();
/*#ifdef HAVE_LIBPCAP
- fill_in_local_interfaces();
+ fill_in_local_interfaces();
#endif*/
- /* Now get our args */
- while ((opt = getopt(argc, argv, optstring)) != -1) {
- switch (opt) {
- /*** capture option specific ***/
- case 'a': /* autostop criteria */
- case 'b': /* Ringbuffer option */
- case 'c': /* Capture xxx packets */
- case 'f': /* capture filter */
- case 'k': /* Start capture immediately */
- case 'H': /* Hide capture info dialog box */
- case 'p': /* Don't capture in promiscuous mode */
- case 'i': /* Use interface x */
+ /* Now get our args */
+ while ((opt = getopt(argc, argv, optstring)) != -1) {
+ switch (opt) {
+ /*** capture option specific ***/
+ case 'a': /* autostop criteria */
+ case 'b': /* Ringbuffer option */
+ case 'c': /* Capture xxx packets */
+ case 'f': /* capture filter */
+ case 'k': /* Start capture immediately */
+ case 'H': /* Hide capture info dialog box */
+ case 'p': /* Don't capture in promiscuous mode */
+ case 'i': /* Use interface x */
#ifdef HAVE_PCAP_CREATE
- case 'I': /* Capture in monitor mode, if available */
+ case 'I': /* Capture in monitor mode, if available */
#endif
#ifdef HAVE_PCAP_REMOTE
- case 'A': /* Authentication */
+ case 'A': /* Authentication */
#endif
- case 's': /* Set the snapshot (capture) length */
- case 'S': /* "Sync" mode: used for following file ala tail -f */
- case 'w': /* Write to capture file xxx */
- case 'y': /* Set the pcap data link type */
+ case 's': /* Set the snapshot (capture) length */
+ case 'S': /* "Sync" mode: used for following file ala tail -f */
+ case 'w': /* Write to capture file xxx */
+ case 'y': /* Set the pcap data link type */
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
- case 'B': /* Buffer size */
+ case 'B': /* Buffer size */
#endif /* _WIN32 or HAVE_PCAP_CREATE */
#ifdef HAVE_LIBPCAP
- status = capture_opts_add_opt(&global_capture_opts, opt, optarg,
- &start_capture);
- if(status != 0) {
- exit(status);
- }
+ status = capture_opts_add_opt(&global_capture_opts, opt, optarg,
+ &start_capture);
+ if(status != 0) {
+ exit(status);
+ }
#else
- capture_option_specified = TRUE;
- arg_error = TRUE;
+ capture_option_specified = TRUE;
+ arg_error = TRUE;
#endif
- break;
+ break;
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
- case 'K': /* Kerberos keytab file */
- read_keytab_file(optarg);
- break;
-#endif
-
- /*** all non capture option specific ***/
- case 'C':
- /* Configuration profile settings were already processed just ignore them this time*/
- break;
- case 'j': /* Search backwards for a matching packet from filter in option J */
- jump_backwards = SD_BACKWARD;
- break;
- case 'g': /* Go to packet with the given packet number */
- go_to_packet = get_positive_int(optarg, "go to packet");
- break;
- case 'J': /* Jump to the first packet which matches the filter criteria */
- jfilter = optarg;
- break;
- case 'l': /* Automatic scrolling in live capture mode */
+ case 'K': /* Kerberos keytab file */
+ read_keytab_file(optarg);
+ break;
+#endif
+
+ /*** all non capture option specific ***/
+ case 'C':
+ /* Configuration profile settings were already processed just ignore them this time*/
+ break;
+ case 'j': /* Search backwards for a matching packet from filter in option J */
+ jump_backwards = SD_BACKWARD;
+ break;
+ case 'g': /* Go to packet with the given packet number */
+ go_to_packet = get_positive_int(optarg, "go to packet");
+ break;
+ case 'J': /* Jump to the first packet which matches the filter criteria */
+ jfilter = optarg;
+ break;
+ case 'l': /* Automatic scrolling in live capture mode */
#ifdef HAVE_LIBPCAP
- auto_scroll_live = TRUE;
+ auto_scroll_live = TRUE;
#else
- capture_option_specified = TRUE;
- arg_error = TRUE;
+ capture_option_specified = TRUE;
+ arg_error = TRUE;
#endif
- break;
- case 'L': /* Print list of link-layer types and exit */
+ break;
+ case 'L': /* Print list of link-layer types and exit */
#ifdef HAVE_LIBPCAP
- list_link_layer_types = TRUE;
+ list_link_layer_types = TRUE;
#else
- capture_option_specified = TRUE;
- arg_error = TRUE;
-#endif
- break;
- case 'm': /* Fixed-width font for the display */
- g_free(prefs_p->gui_gtk2_font_name);
- prefs_p->gui_gtk2_font_name = g_strdup(optarg);
- break;
- case 'n': /* No name resolution */
- gbl_resolv_flags.mac_name = FALSE;
- gbl_resolv_flags.network_name = FALSE;
- gbl_resolv_flags.transport_name = FALSE;
- gbl_resolv_flags.concurrent_dns = FALSE;
- break;
- case 'N': /* Select what types of addresses/port #s to resolve */
- badopt = string_to_name_resolve(optarg, &gbl_resolv_flags);
- if (badopt != '\0') {
- cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'",
- badopt);
- exit(1);
- }
- break;
- case 'o': /* Override preference from command line */
- switch (prefs_set_pref(optarg)) {
- case PREFS_SET_OK:
- break;
- case PREFS_SET_SYNTAX_ERR:
- cmdarg_err("Invalid -o flag \"%s\"", optarg);
- exit(1);
- break;
- case PREFS_SET_NO_SUCH_PREF:
- /* not a preference, might be a recent setting */
- switch (recent_set_arg(optarg)) {
- case PREFS_SET_OK:
- break;
- case PREFS_SET_SYNTAX_ERR:
- /* shouldn't happen, checked already above */
- cmdarg_err("Invalid -o flag \"%s\"", optarg);
- exit(1);
- break;
- case PREFS_SET_NO_SUCH_PREF:
- case PREFS_SET_OBSOLETE:
- cmdarg_err("-o flag \"%s\" specifies unknown preference/recent value",
- optarg);
- exit(1);
- break;
- default:
- g_assert_not_reached();
- }
- break;
- case PREFS_SET_OBSOLETE:
- cmdarg_err("-o flag \"%s\" specifies obsolete preference",
- optarg);
- exit(1);
- break;
- default:
- g_assert_not_reached();
- }
- break;
- case 'P':
- /* Path settings were already processed just ignore them this time*/
- break;
- case 'r': /* Read capture file xxx */
- /* We may set "last_open_dir" to "cf_name", and if we change
- "last_open_dir" later, we free the old value, so we have to
- set "cf_name" to something that's been allocated. */
- cf_name = g_strdup(optarg);
- break;
- case 'R': /* Read file filter */
- rfilter = optarg;
- break;
- case 't': /* Time stamp type */
- if (strcmp(optarg, "r") == 0)
- timestamp_set_type(TS_RELATIVE);
- else if (strcmp(optarg, "a") == 0)
- timestamp_set_type(TS_ABSOLUTE);
- else if (strcmp(optarg, "ad") == 0)
- timestamp_set_type(TS_ABSOLUTE_WITH_YMD);
- else if (strcmp(optarg, "adoy") == 0)
- timestamp_set_type(TS_ABSOLUTE_WITH_YDOY);
- else if (strcmp(optarg, "d") == 0)
- timestamp_set_type(TS_DELTA);
- else if (strcmp(optarg, "dd") == 0)
- timestamp_set_type(TS_DELTA_DIS);
- else if (strcmp(optarg, "e") == 0)
- timestamp_set_type(TS_EPOCH);
- else if (strcmp(optarg, "u") == 0)
- timestamp_set_type(TS_UTC);
- else if (strcmp(optarg, "ud") == 0)
- timestamp_set_type(TS_UTC_WITH_YMD);
- else if (strcmp(optarg, "udoy") == 0)
- timestamp_set_type(TS_UTC_WITH_YDOY);
- else {
- cmdarg_err("Invalid time stamp type \"%s\"", optarg);
- cmdarg_err_cont(
+ capture_option_specified = TRUE;
+ arg_error = TRUE;
+#endif
+ break;
+ case 'm': /* Fixed-width font for the display */
+ g_free(prefs_p->gui_gtk2_font_name);
+ prefs_p->gui_gtk2_font_name = g_strdup(optarg);
+ break;
+ case 'n': /* No name resolution */
+ gbl_resolv_flags.mac_name = FALSE;
+ gbl_resolv_flags.network_name = FALSE;
+ gbl_resolv_flags.transport_name = FALSE;
+ gbl_resolv_flags.concurrent_dns = FALSE;
+ break;
+ case 'N': /* Select what types of addresses/port #s to resolve */
+ badopt = string_to_name_resolve(optarg, &gbl_resolv_flags);
+ if (badopt != '\0') {
+ cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'",
+ badopt);
+ exit(1);
+ }
+ break;
+ case 'o': /* Override preference from command line */
+ switch (prefs_set_pref(optarg)) {
+ case PREFS_SET_OK:
+ break;
+ case PREFS_SET_SYNTAX_ERR:
+ cmdarg_err("Invalid -o flag \"%s\"", optarg);
+ exit(1);
+ break;
+ case PREFS_SET_NO_SUCH_PREF:
+ /* not a preference, might be a recent setting */
+ switch (recent_set_arg(optarg)) {
+ case PREFS_SET_OK:
+ break;
+ case PREFS_SET_SYNTAX_ERR:
+ /* shouldn't happen, checked already above */
+ cmdarg_err("Invalid -o flag \"%s\"", optarg);
+ exit(1);
+ break;
+ case PREFS_SET_NO_SUCH_PREF:
+ case PREFS_SET_OBSOLETE:
+ cmdarg_err("-o flag \"%s\" specifies unknown preference/recent value",
+ optarg);
+ exit(1);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+ break;
+ case PREFS_SET_OBSOLETE:
+ cmdarg_err("-o flag \"%s\" specifies obsolete preference",
+ optarg);
+ exit(1);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+ break;
+ case 'P':
+ /* Path settings were already processed just ignore them this time*/
+ break;
+ case 'r': /* Read capture file xxx */
+ /* We may set "last_open_dir" to "cf_name", and if we change
+ "last_open_dir" later, we free the old value, so we have to
+ set "cf_name" to something that's been allocated. */
+ cf_name = g_strdup(optarg);
+ break;
+ case 'R': /* Read file filter */
+ rfilter = optarg;
+ break;
+ case 't': /* Time stamp type */
+ if (strcmp(optarg, "r") == 0)
+ timestamp_set_type(TS_RELATIVE);
+ else if (strcmp(optarg, "a") == 0)
+ timestamp_set_type(TS_ABSOLUTE);
+ else if (strcmp(optarg, "ad") == 0)
+ timestamp_set_type(TS_ABSOLUTE_WITH_YMD);
+ else if (strcmp(optarg, "adoy") == 0)
+ timestamp_set_type(TS_ABSOLUTE_WITH_YDOY);
+ else if (strcmp(optarg, "d") == 0)
+ timestamp_set_type(TS_DELTA);
+ else if (strcmp(optarg, "dd") == 0)
+ timestamp_set_type(TS_DELTA_DIS);
+ else if (strcmp(optarg, "e") == 0)
+ timestamp_set_type(TS_EPOCH);
+ else if (strcmp(optarg, "u") == 0)
+ timestamp_set_type(TS_UTC);
+ else if (strcmp(optarg, "ud") == 0)
+ timestamp_set_type(TS_UTC_WITH_YMD);
+ else if (strcmp(optarg, "udoy") == 0)
+ timestamp_set_type(TS_UTC_WITH_YDOY);
+ else {
+ cmdarg_err("Invalid time stamp type \"%s\"", optarg);
+ cmdarg_err_cont(
"It must be \"a\" for absolute, \"ad\" for absolute with YYYY-MM-DD date,");
- cmdarg_err_cont(
+ cmdarg_err_cont(
"\"adoy\" for absolute with YYYY/DOY date, \"d\" for delta,");
- cmdarg_err_cont(
+ cmdarg_err_cont(
"\"dd\" for delta displayed, \"e\" for epoch, \"r\" for relative,");
- cmdarg_err_cont(
+ cmdarg_err_cont(
"\"u\" for absolute UTC, \"ud\" for absolute UTC with YYYY-MM-DD date,");
- cmdarg_err_cont(
+ cmdarg_err_cont(
"or \"udoy\" for absolute UTC with YYYY/DOY date.");
- exit(1);
- }
- break;
- case 'u': /* Seconds type */
- if (strcmp(optarg, "s") == 0)
- timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
- else if (strcmp(optarg, "hms") == 0)
- timestamp_set_seconds_type(TS_SECONDS_HOUR_MIN_SEC);
- else {
- cmdarg_err("Invalid seconds type \"%s\"", optarg);
- cmdarg_err_cont("It must be \"s\" for seconds or \"hms\" for hours, minutes and seconds.");
- exit(1);
- }
- break;
- case 'X':
- /* ext ops were already processed just ignore them this time*/
- break;
- case 'Y':
- dfilter = optarg;
- break;
- case 'z':
- /* We won't call the init function for the stat this soon
- as it would disallow MATE's fields (which are registered
- by the preferences set callback) from being used as
- part of a tap filter. Instead, we just add the argument
- to a list of stat arguments. */
- if (!process_stat_cmd_arg(optarg)) {
- cmdarg_err("Invalid -z argument.");
- cmdarg_err_cont(" -z argument must be one of :");
- list_stat_cmd_args();
- exit(1);
- }
- break;
- default:
- case '?': /* Bad flag - print usage message */
- arg_error = TRUE;
- break;
+ exit(1);
+ }
+ break;
+ case 'u': /* Seconds type */
+ if (strcmp(optarg, "s") == 0)
+ timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
+ else if (strcmp(optarg, "hms") == 0)
+ timestamp_set_seconds_type(TS_SECONDS_HOUR_MIN_SEC);
+ else {
+ cmdarg_err("Invalid seconds type \"%s\"", optarg);
+ cmdarg_err_cont(
+"It must be \"s\" for seconds or \"hms\" for hours, minutes and seconds.");
+ exit(1);
+ }
+ break;
+ case 'X':
+ /* ext ops were already processed just ignore them this time*/
+ break;
+ case 'Y':
+ dfilter = optarg;
+ break;
+ case 'z':
+ /* We won't call the init function for the stat this soon
+ as it would disallow MATE's fields (which are registered
+ by the preferences set callback) from being used as
+ part of a tap filter. Instead, we just add the argument
+ to a list of stat arguments. */
+ if (!process_stat_cmd_arg(optarg)) {
+ cmdarg_err("Invalid -z argument.");
+ cmdarg_err_cont(" -z argument must be one of :");
+ list_stat_cmd_args();
+ exit(1);
+ }
+ break;
+ default:
+ case '?': /* Bad flag - print usage message */
+ arg_error = TRUE;
+ break;
+ }
}
- }
- if (!arg_error) {
- argc -= optind;
- argv += optind;
- if (argc >= 1) {
- if (cf_name != NULL) {
- /*
- * Input file name specified with "-r" *and* specified as a regular
- * command-line argument.
- */
- cmdarg_err("File name specified both with -r and regular argument");
- arg_error = TRUE;
- } else {
- /*
- * Input file name not specified with "-r", and a command-line argument
- * was specified; treat it as the input file name.
- *
- * Yes, this is different from tshark, where non-flag command-line
- * arguments are a filter, but this works better on GUI desktops
- * where a command can be specified to be run to open a particular
- * file - yes, you could have "-r" as the last part of the command,
- * but that's a bit ugly.
- */
+ if (!arg_error) {
+ argc -= optind;
+ argv += optind;
+ if (argc >= 1) {
+ if (cf_name != NULL) {
+ /*
+ * Input file name specified with "-r" *and* specified as a regular
+ * command-line argument.
+ */
+ cmdarg_err("File name specified both with -r and regular argument");
+ arg_error = TRUE;
+ } else {
+ /*
+ * Input file name not specified with "-r", and a command-line argument
+ * was specified; treat it as the input file name.
+ *
+ * Yes, this is different from tshark, where non-flag command-line
+ * arguments are a filter, but this works better on GUI desktops
+ * where a command can be specified to be run to open a particular
+ * file - yes, you could have "-r" as the last part of the command,
+ * but that's a bit ugly.
+ */
#ifndef HAVE_GTKOSXAPPLICATION
- /*
- * For GTK+ Mac Integration, file name passed as free argument passed
- * through grag-and-drop and opened twice sometimes causing crashes.
- * Subject to report to GTK+ MAC.
- */
- cf_name = g_strdup(argv[0]);
+ /*
+ * For GTK+ Mac Integration, file name passed as free argument passed
+ * through grag-and-drop and opened twice sometimes causing crashes.
+ * Subject to report to GTK+ MAC.
+ */
+ cf_name = g_strdup(argv[0]);
#endif
- }
- argc--;
- argv++;
- }
+ }
+ argc--;
+ argv++;
+ }
- if (argc != 0) {
- /*
- * Extra command line arguments were specified; complain.
- */
- cmdarg_err("Invalid argument: %s", argv[0]);
- arg_error = TRUE;
+ if (argc != 0) {
+ /*
+ * Extra command line arguments were specified; complain.
+ */
+ cmdarg_err("Invalid argument: %s", argv[0]);
+ arg_error = TRUE;
+ }
}
- }
- if (arg_error) {
+
+ if (arg_error) {
#ifndef HAVE_LIBPCAP
- if (capture_option_specified) {
- cmdarg_err("This version of Wireshark was not built with support for capturing packets.");
- }
+ if (capture_option_specified) {
+ cmdarg_err("This version of Wireshark was not built with support for capturing packets.");
+ }
#endif
- print_usage(FALSE);
- exit(1);
- }
+ print_usage(FALSE);
+ exit(1);
+ }
#ifdef HAVE_LIBPCAP
- fill_in_local_interfaces(main_window_update);
- if (start_capture && list_link_layer_types) {
- /* Specifying *both* is bogus. */
- cmdarg_err("You can't specify both -L and a live capture.");
- exit(1);
- }
+ fill_in_local_interfaces(main_window_update);
+ if (start_capture && list_link_layer_types) {
+ /* Specifying *both* is bogus. */
+ cmdarg_err("You can't specify both -L and a live capture.");
+ exit(1);
+ }
+
+ if (list_link_layer_types) {
+ /* We're supposed to list the link-layer types for an interface;
+ did the user also specify a capture file to be read? */
+ if (cf_name) {
+ /* Yes - that's bogus. */
+ cmdarg_err("You can't specify -L and a capture file to be read.");
+ exit(1);
+ }
+ /* No - did they specify a ring buffer option? */
+ if (global_capture_opts.multi_files_on) {
+ cmdarg_err("Ring buffer requested, but a capture isn't being done.");
+ exit(1);
+ }
+ } else {
+ /* We're supposed to do a live capture; did the user also specify
+ a capture file to be read? */
+ if (start_capture && cf_name) {
+ /* Yes - that's bogus. */
+ cmdarg_err("You can't specify both a live capture and a capture file to be read.");
+ exit(1);
+ }
- if (list_link_layer_types) {
- /* We're supposed to list the link-layer types for an interface;
- did the user also specify a capture file to be read? */
- if (cf_name) {
- /* Yes - that's bogus. */
- cmdarg_err("You can't specify -L and a capture file to be read.");
- exit(1);
- }
- /* No - did they specify a ring buffer option? */
- if (global_capture_opts.multi_files_on) {
- cmdarg_err("Ring buffer requested, but a capture isn't being done.");
- exit(1);
- }
- } else {
- /* We're supposed to do a live capture; did the user also specify
- a capture file to be read? */
- if (start_capture && cf_name) {
- /* Yes - that's bogus. */
- cmdarg_err("You can't specify both a live capture and a capture file to be read.");
- exit(1);
- }
-
- /* No - was the ring buffer option specified and, if so, does it make
- sense? */
- if (global_capture_opts.multi_files_on) {
- /* Ring buffer works only under certain conditions:
- a) ring buffer does not work with temporary files;
- b) real_time_mode and multi_files_on are mutually exclusive -
- real_time_mode takes precedence;
- c) it makes no sense to enable the ring buffer if the maximum
- file size is set to "infinite". */
- if (global_capture_opts.save_file == NULL) {
- cmdarg_err("Ring buffer requested, but capture isn't being saved to a permanent file.");
- global_capture_opts.multi_files_on = FALSE;
- }
- if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_duration) {
- cmdarg_err("Ring buffer requested, but no maximum capture file size or duration were specified.");
- /* XXX - this must be redesigned as the conditions changed */
- }
+ /* No - was the ring buffer option specified and, if so, does it make
+ sense? */
+ if (global_capture_opts.multi_files_on) {
+ /* Ring buffer works only under certain conditions:
+ a) ring buffer does not work with temporary files;
+ b) real_time_mode and multi_files_on are mutually exclusive -
+ real_time_mode takes precedence;
+ c) it makes no sense to enable the ring buffer if the maximum
+ file size is set to "infinite". */
+ if (global_capture_opts.save_file == NULL) {
+ cmdarg_err("Ring buffer requested, but capture isn't being saved to a permanent file.");
+ global_capture_opts.multi_files_on = FALSE;
+ }
+ if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_duration) {
+ cmdarg_err("Ring buffer requested, but no maximum capture file size or duration were specified.");
+ /* XXX - this must be redesigned as the conditions changed */
+ }
+ }
}
- }
- if (start_capture || list_link_layer_types) {
- /* We're supposed to do a live capture or get a list of link-layer
- types for a live capture device; if the user didn't specify an
- interface to use, pick a default. */
- status = capture_opts_default_iface_if_necessary(&global_capture_opts,
+ if (start_capture || list_link_layer_types) {
+ /* We're supposed to do a live capture or get a list of link-layer
+ types for a live capture device; if the user didn't specify an
+ interface to use, pick a default. */
+ status = capture_opts_default_iface_if_necessary(&global_capture_opts,
((prefs_p->capture_device) && (*prefs_p->capture_device != '\0')) ? get_if_name(prefs_p->capture_device) : NULL);
- if (status != 0) {
- exit(status);
+ if (status != 0) {
+ exit(status);
+ }
}
- }
- if (list_link_layer_types) {
- /* Get the list of link-layer types for the capture devices. */
- if_capabilities_t *caps;
- guint i;
- interface_t device;
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
+ if (list_link_layer_types) {
+ /* Get the list of link-layer types for the capture devices. */
+ if_capabilities_t *caps;
+ guint i;
+ interface_t device;
+ for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (device.selected) {
+ device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
+ if (device.selected) {
#if defined(HAVE_PCAP_CREATE)
- caps = capture_get_if_capabilities(device.name, device.monitor_mode_supported, &err_str, main_window_update);
+ caps = capture_get_if_capabilities(device.name, device.monitor_mode_supported, &err_str, main_window_update);
#else
- caps = capture_get_if_capabilities(device.name, FALSE, &err_str,main_window_update);
+ caps = capture_get_if_capabilities(device.name, FALSE, &err_str,main_window_update);
#endif
- if (caps == NULL) {
- cmdarg_err("%s", err_str);
- g_free(err_str);
- exit(2);
- }
- if (caps->data_link_types == NULL) {
- cmdarg_err("The capture device \"%s\" has no data link types.", device.name);
- exit(2);
- }
+ if (caps == NULL) {
+ cmdarg_err("%s", err_str);
+ g_free(err_str);
+ exit(2);
+ }
+ if (caps->data_link_types == NULL) {
+ cmdarg_err("The capture device \"%s\" has no data link types.", device.name);
+ exit(2);
+ }
#ifdef _WIN32
- create_console();
+ create_console();
#endif /* _WIN32 */
#if defined(HAVE_PCAP_CREATE)
- capture_opts_print_if_capabilities(caps, device.name, device.monitor_mode_supported);
+ capture_opts_print_if_capabilities(caps, device.name, device.monitor_mode_supported);
#else
- capture_opts_print_if_capabilities(caps, device.name, FALSE);
+ capture_opts_print_if_capabilities(caps, device.name, FALSE);
#endif
#ifdef _WIN32
- destroy_console();
+ destroy_console();
#endif /* _WIN32 */
- free_if_capabilities(caps);
- }
+ free_if_capabilities(caps);
+ }
+ }
+ exit(0);
}
- exit(0);
- }
-
capture_opts_trim_snaplen(&global_capture_opts, MIN_PACKET_SIZE);
capture_opts_trim_ring_num_files(&global_capture_opts);
#endif /* HAVE_LIBPCAP */
- /* Notify all registered modules that have had any of their preferences
- changed either from one of the preferences file or from the command
- line that their preferences have changed. */
- prefs_apply_all();
+ /* Notify all registered modules that have had any of their preferences
+ changed either from one of the preferences file or from the command
+ line that their preferences have changed. */
+ prefs_apply_all();
#ifdef HAVE_LIBPCAP
- if ((global_capture_opts.num_selected == 0) &&
- ((prefs.capture_device != NULL) && (*prefs_p->capture_device != '\0'))) {
- guint i;
- interface_t device;
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (!device.hidden && strstr(prefs.capture_device, device.name) != NULL) {
+ if ((global_capture_opts.num_selected == 0) &&
+ ((prefs.capture_device != NULL) && (*prefs_p->capture_device != '\0'))) {
+ guint i;
+ interface_t device;
+ for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
+ device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
+ if (!device.hidden && strstr(prefs.capture_device, device.name) != NULL) {
+ device.selected = TRUE;
+ global_capture_opts.num_selected++;
+ global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
+ g_array_insert_val(global_capture_opts.all_ifaces, i, device);
+ break;
+ }
+ }
+ }
+ if (global_capture_opts.num_selected == 0 && global_capture_opts.all_ifaces->len == 1) {
+ interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, 0);
device.selected = TRUE;
global_capture_opts.num_selected++;
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
- g_array_insert_val(global_capture_opts.all_ifaces, i, device);
- break;
- }
+ global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, 0);
+ g_array_insert_val(global_capture_opts.all_ifaces, 0, device);
}
- }
- if (global_capture_opts.num_selected == 0 && global_capture_opts.all_ifaces->len == 1) {
- interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, 0);
- device.selected = TRUE;
- global_capture_opts.num_selected++;
- global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, 0);
- g_array_insert_val(global_capture_opts.all_ifaces, 0, device);
- }
#endif
- /* disabled protocols as per configuration file */
- if (gdp_path == NULL && dp_path == NULL) {
- set_disabled_protos_list();
- }
+ /* disabled protocols as per configuration file */
+ if (gdp_path == NULL && dp_path == NULL) {
+ set_disabled_protos_list();
+ }
- build_column_format_array(&cfile.cinfo, prefs_p->num_cols, TRUE);
+ build_column_format_array(&cfile.cinfo, prefs_p->num_cols, TRUE);
- /* read in rc file from global and personal configuration paths. */
- rc_file = get_datafile_path(RC_FILE);
+ /* read in rc file from global and personal configuration paths. */
+ rc_file = get_datafile_path(RC_FILE);
#if GTK_CHECK_VERSION(3,0,0)
- /* XXX resolve later */
+ /* XXX resolve later */
#else
- gtk_rc_parse(rc_file);
- g_free(rc_file);
- rc_file = get_persconffile_path(RC_FILE, FALSE);
- gtk_rc_parse(rc_file);
+ gtk_rc_parse(rc_file);
+ g_free(rc_file);
+ rc_file = get_persconffile_path(RC_FILE, FALSE);
+ gtk_rc_parse(rc_file);
#endif
- g_free(rc_file);
+ g_free(rc_file);
- font_init();
+ font_init();
- macros_init();
+ macros_init();
- stock_icons_init();
+ stock_icons_init();
- /* close the splash screen, as we are going to open the main window now */
- splash_destroy(splash_win);
+ /* close the splash screen, as we are going to open the main window now */
+ splash_destroy(splash_win);
- /************************************************************************/
- /* Everything is prepared now, preferences and command line was read in */
+ /************************************************************************/
+ /* Everything is prepared now, preferences and command line was read in */
- /* Pop up the main window. */
- create_main_window(pl_size, tv_size, bv_size, prefs_p);
+ /* Pop up the main window. */
+ create_main_window(pl_size, tv_size, bv_size, prefs_p);
- /* Read the dynamic part of the recent file, as we have the gui now ready for it. */
- recent_read_dynamic(&rf_path, &rf_open_errno);
- if (rf_path != NULL && rf_open_errno != 0) {
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not open recent file\n\"%s\": %s.",
- rf_path, g_strerror(rf_open_errno));
- }
+ /* Read the dynamic part of the recent file, as we have the gui now ready for it. */
+ recent_read_dynamic(&rf_path, &rf_open_errno);
+ if (rf_path != NULL && rf_open_errno != 0) {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+ "Could not open recent file\n\"%s\": %s.",
+ rf_path, g_strerror(rf_open_errno));
+ }
- color_filters_enable(recent.packet_list_colorize);
+ color_filters_enable(recent.packet_list_colorize);
- /* rearrange all the widgets as we now have all recent settings ready for this */
- main_widgets_rearrange();
+ /* rearrange all the widgets as we now have all recent settings ready for this */
+ main_widgets_rearrange();
- /* Fill in column titles. This must be done after the top level window
+ /* Fill in column titles. This must be done after the top level window
is displayed.
XXX - is that still true, with fixed-width columns? */
- menu_recent_read_finished();
+ menu_recent_read_finished();
#ifdef HAVE_LIBPCAP
- main_auto_scroll_live_changed(auto_scroll_live);
-#endif
-
- switch (user_font_apply()) {
- case FA_SUCCESS:
- break;
- case FA_FONT_NOT_RESIZEABLE:
- /* "user_font_apply()" popped up an alert box. */
- /* turn off zooming - font can't be resized */
- case FA_FONT_NOT_AVAILABLE:
- /* XXX - did we successfully load the un-zoomed version earlier?
- If so, this *probably* means the font is available, but not at
- this particular zoom level, but perhaps some other failure
- occurred; I'm not sure you can determine which is the case,
- however. */
- /* turn off zooming - zoom level is unavailable */
- default:
- /* in any other case than FA_SUCCESS, turn off zooming */
- recent.gui_zoom_level = 0;
- /* XXX: would it be a good idea to disable zooming (insensitive GUI)? */
- }
+ main_auto_scroll_live_changed(auto_scroll_live);
+#endif
+
+ switch (user_font_apply()) {
+ case FA_SUCCESS:
+ break;
+ case FA_FONT_NOT_RESIZEABLE:
+ /* "user_font_apply()" popped up an alert box. */
+ /* turn off zooming - font can't be resized */
+ case FA_FONT_NOT_AVAILABLE:
+ /* XXX - did we successfully load the un-zoomed version earlier?
+ If so, this *probably* means the font is available, but not at
+ this particular zoom level, but perhaps some other failure
+ occurred; I'm not sure you can determine which is the case,
+ however. */
+ /* turn off zooming - zoom level is unavailable */
+ default:
+ /* in any other case than FA_SUCCESS, turn off zooming */
+ recent.gui_zoom_level = 0;
+ /* XXX: would it be a good idea to disable zooming (insensitive GUI)? */
+ }
- dnd_init(top_level);
+ dnd_init(top_level);
- color_filters_init();
+ color_filters_init();
#ifdef HAVE_LIBPCAP
- capture_filter_init();
+ capture_filter_init();
#endif
- /* the window can be sized only, if it's not already shown, so do it now! */
- main_load_window_geometry(top_level);
+ /* the window can be sized only, if it's not already shown, so do it now! */
+ main_load_window_geometry(top_level);
- g_timeout_add(info_update_freq, resolv_update_cb, NULL);
+ g_timeout_add(info_update_freq, resolv_update_cb, NULL);
- /* If we were given the name of a capture file, read it in now;
+ /* If we were given the name of a capture file, read it in now;
we defer it until now, so that, if we can't open it, and pop
up an alert box, the alert box is more likely to come up on
top of the main window - but before the preference-file-error
alert box, so, if we get one of those, it's more likely to come
up on top of us. */
- if (cf_name) {
- show_main_window(TRUE);
- check_and_warn_user_startup(cf_name);
- if (rfilter != NULL) {
- if (!dfilter_compile(rfilter, &rfcode)) {
- bad_dfilter_alert_box(top_level, rfilter);
- rfilter_parse_failed = TRUE;
- }
- }
- if (!rfilter_parse_failed) {
- if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
- /* "cf_open()" succeeded, so it closed the previous
- capture file, and thus destroyed any previous read filter
- attached to "cf". */
-
- cfile.rfcode = rfcode;
- /* Open stat windows; we do so after creating the main window,
- to avoid GTK warnings, and after successfully opening the
- capture file, so we know we have something to compute stats
- on, and after registering all dissectors, so that MATE will
- have registered its field array and we can have a tap filter
- with one of MATE's late-registered fields as part of the
- filter. */
- start_requested_stats();
-
- /* Read the capture file. */
- switch (cf_read(&cfile, FALSE)) {
-
- case CF_READ_OK:
- case CF_READ_ERROR:
- /* Just because we got an error, that doesn't mean we were unable
- to read any of the file; we handle what we could get from the
- file. */
- /* if the user told us to jump to a specific packet, do it now */
- if(go_to_packet != 0) {
- /* Jump to the specified frame number, kept for backward
- compatibility. */
- cf_goto_frame(&cfile, go_to_packet);
- } else if (jfilter != NULL) {
- /* try to compile given filter */
- if (!dfilter_compile(jfilter, &jump_to_filter)) {
- bad_dfilter_alert_box(top_level, jfilter);
- } else {
- /* Filter ok, jump to the first packet matching the filter
- conditions. Default search direction is forward, but if
- option d was given, search backwards */
- cf_find_packet_dfilter(&cfile, jump_to_filter, jump_backwards);
+ if (cf_name) {
+ show_main_window(TRUE);
+ check_and_warn_user_startup(cf_name);
+ if (rfilter != NULL) {
+ if (!dfilter_compile(rfilter, &rfcode)) {
+ bad_dfilter_alert_box(top_level, rfilter);
+ rfilter_parse_failed = TRUE;
}
- }
- break;
-
- case CF_READ_ABORTED:
- /* Exit now. */
- exit(0);
- break;
}
+ if (!rfilter_parse_failed) {
+ if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
+ /* "cf_open()" succeeded, so it closed the previous
+ capture file, and thus destroyed any previous read filter
+ attached to "cf". */
+
+ cfile.rfcode = rfcode;
+ /* Open stat windows; we do so after creating the main window,
+ to avoid GTK warnings, and after successfully opening the
+ capture file, so we know we have something to compute stats
+ on, and after registering all dissectors, so that MATE will
+ have registered its field array and we can have a tap filter
+ with one of MATE's late-registered fields as part of the
+ filter. */
+ start_requested_stats();
+
+ /* Read the capture file. */
+ switch (cf_read(&cfile, FALSE)) {
+
+ case CF_READ_OK:
+ case CF_READ_ERROR:
+ /* Just because we got an error, that doesn't mean we were unable
+ to read any of the file; we handle what we could get from the
+ file. */
+ /* if the user told us to jump to a specific packet, do it now */
+ if(go_to_packet != 0) {
+ /* Jump to the specified frame number, kept for backward
+ compatibility. */
+ cf_goto_frame(&cfile, go_to_packet);
+ } else if (jfilter != NULL) {
+ /* try to compile given filter */
+ if (!dfilter_compile(jfilter, &jump_to_filter)) {
+ bad_dfilter_alert_box(top_level, jfilter);
+ } else {
+ /* Filter ok, jump to the first packet matching the filter
+ conditions. Default search direction is forward, but if
+ option d was given, search backwards */
+ cf_find_packet_dfilter(&cfile, jump_to_filter, jump_backwards);
+ }
+ }
+ break;
+
+ case CF_READ_ABORTED:
+ /* Exit now. */
+ exit(0);
+ break;
+ }
- /* If the filename is not the absolute path, prepend the current dir. This happens
- when wireshark is invoked from a cmd shell (e.g.,'wireshark -r file.pcap'). */
- if (!g_path_is_absolute(cf_name)) {
- char *old_cf_name = cf_name;
- char *pwd = g_get_current_dir();
- cf_name = g_strdup_printf("%s%s%s", pwd, G_DIR_SEPARATOR_S, cf_name);
- g_free(old_cf_name);
- g_free(pwd);
- }
+ /* If the filename is not the absolute path, prepend the current dir. This happens
+ when wireshark is invoked from a cmd shell (e.g.,'wireshark -r file.pcap'). */
+ if (!g_path_is_absolute(cf_name)) {
+ char *old_cf_name = cf_name;
+ char *pwd = g_get_current_dir();
+ cf_name = g_strdup_printf("%s%s%s", pwd, G_DIR_SEPARATOR_S, cf_name);
+ g_free(old_cf_name);
+ g_free(pwd);
+ }
- /* Save the name of the containing directory specified in the
- path name, if any; we can write over cf_name, which is a
- good thing, given that "get_dirname()" does write over its
- argument. */
- s = get_dirname(cf_name);
- set_last_open_dir(s);
- g_free(cf_name);
- cf_name = NULL;
- } else {
- if (rfcode != NULL)
- dfilter_free(rfcode);
- cfile.rfcode = NULL;
- show_main_window(FALSE);
- /* Don't call check_and_warn_user_startup(): we did it above */
- main_set_for_capture_in_progress(FALSE);
- set_capture_if_dialog_for_capture_in_progress(FALSE);
- }
- }
- } else {
-#ifdef HAVE_LIBPCAP
- if (start_capture) {
- if (global_capture_opts.save_file != NULL) {
- /* Save the directory name for future file dialogs. */
- /* (get_dirname overwrites filename) */
- s = get_dirname(g_strdup(global_capture_opts.save_file));
- set_last_open_dir(s);
- g_free(s);
- }
- /* "-k" was specified; start a capture. */
- show_main_window(FALSE);
- check_and_warn_user_startup(cf_name);
-
- /* If no user interfaces were specified on the command line,
- copy the list of selected interfaces to the set of interfaces
- to use for this capture. */
- if (global_capture_opts.ifaces->len == 0)
- collect_ifaces(&global_capture_opts);
- if (capture_start(&global_capture_opts, &global_capture_session,main_window_update)) {
- /* The capture started. Open stat windows; we do so after creating
- the main window, to avoid GTK warnings, and after successfully
- opening the capture file, so we know we have something to compute
- stats on, and after registering all dissectors, so that MATE will
- have registered its field array and we can have a tap filter with
- one of MATE's late-registered fields as part of the filter. */
- start_requested_stats();
- }
+ /* Save the name of the containing directory specified in the
+ path name, if any; we can write over cf_name, which is a
+ good thing, given that "get_dirname()" does write over its
+ argument. */
+ s = get_dirname(cf_name);
+ set_last_open_dir(s);
+ g_free(cf_name);
+ cf_name = NULL;
+ } else {
+ if (rfcode != NULL)
+ dfilter_free(rfcode);
+ cfile.rfcode = NULL;
+ show_main_window(FALSE);
+ /* Don't call check_and_warn_user_startup(): we did it above */
+ main_set_for_capture_in_progress(FALSE);
+ set_capture_if_dialog_for_capture_in_progress(FALSE);
+ }
+ }
} else {
- show_main_window(FALSE);
- check_and_warn_user_startup(cf_name);
- main_set_for_capture_in_progress(FALSE);
- set_capture_if_dialog_for_capture_in_progress(FALSE);
- }
-
+#ifdef HAVE_LIBPCAP
+ if (start_capture) {
+ if (global_capture_opts.save_file != NULL) {
+ /* Save the directory name for future file dialogs. */
+ /* (get_dirname overwrites filename) */
+ s = get_dirname(g_strdup(global_capture_opts.save_file));
+ set_last_open_dir(s);
+ g_free(s);
+ }
+ /* "-k" was specified; start a capture. */
+ show_main_window(FALSE);
+ check_and_warn_user_startup(cf_name);
+
+ /* If no user interfaces were specified on the command line,
+ copy the list of selected interfaces to the set of interfaces
+ to use for this capture. */
+ if (global_capture_opts.ifaces->len == 0)
+ collect_ifaces(&global_capture_opts);
+ if (capture_start(&global_capture_opts, &global_capture_session,main_window_update)) {
+ /* The capture started. Open stat windows; we do so after creating
+ the main window, to avoid GTK warnings, and after successfully
+ opening the capture file, so we know we have something to compute
+ stats on, and after registering all dissectors, so that MATE will
+ have registered its field array and we can have a tap filter with
+ one of MATE's late-registered fields as part of the filter. */
+ start_requested_stats();
+ }
+ } else {
+ show_main_window(FALSE);
+ check_and_warn_user_startup(cf_name);
+ main_set_for_capture_in_progress(FALSE);
+ set_capture_if_dialog_for_capture_in_progress(FALSE);
+ }
/* if the user didn't supply a capture filter, use the one to filter out remote connections like SSH */
- if (!start_capture && !global_capture_opts.default_options.cfilter) {
- global_capture_opts.default_options.cfilter = g_strdup(get_conn_cfilter());
- }
+ if (!start_capture && !global_capture_opts.default_options.cfilter) {
+ global_capture_opts.default_options.cfilter = g_strdup(get_conn_cfilter());
+ }
#else /* HAVE_LIBPCAP */
- show_main_window(FALSE);
- check_and_warn_user_startup(cf_name);
- main_set_for_capture_in_progress(FALSE);
- set_capture_if_dialog_for_capture_in_progress(FALSE);
+ show_main_window(FALSE);
+ check_and_warn_user_startup(cf_name);
+ main_set_for_capture_in_progress(FALSE);
+ set_capture_if_dialog_for_capture_in_progress(FALSE);
#endif /* HAVE_LIBPCAP */
- }
+ }
- if (dfilter) {
- GtkWidget *filter_te;
- filter_te = gtk_bin_get_child(GTK_BIN(g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY)));
- gtk_entry_set_text(GTK_ENTRY(filter_te), dfilter);
+ if (dfilter) {
+ GtkWidget *filter_te;
+ filter_te = gtk_bin_get_child(GTK_BIN(g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY)));
+ gtk_entry_set_text(GTK_ENTRY(filter_te), dfilter);
- /* Run the display filter so it goes in effect. */
- main_filter_packets(&cfile, dfilter, FALSE);
- }
+ /* Run the display filter so it goes in effect. */
+ main_filter_packets(&cfile, dfilter, FALSE);
+ }
- /* register our pid if we are being run from a U3 device */
- u3_register_pid();
+ /* register our pid if we are being run from a U3 device */
+ u3_register_pid();
- profile_store_persconffiles (FALSE);
+ profile_store_persconffiles (FALSE);
#ifdef HAVE_GTKOSXAPPLICATION
- theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
- gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsicon_64_pb_data, FALSE, NULL));
- gtkosx_application_ready(theApp);
+ theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
+ gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsicon_64_pb_data, FALSE, NULL));
+ gtkosx_application_ready(theApp);
#endif
- g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "Wireshark is up and ready to go");
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "Wireshark is up and ready to go");
#ifdef HAVE_LIBPCAP
- gtk_iface_mon_start();
+ gtk_iface_mon_start();
#endif
- software_update_init();
+ software_update_init();
- /* we'll enter the GTK loop now and hand the control over to GTK ... */
- gtk_main();
- /* ... back from GTK, we're going down now! */
+ /* we'll enter the GTK loop now and hand the control over to GTK ... */
+ gtk_main();
+ /* ... back from GTK, we're going down now! */
#ifdef HAVE_LIBPCAP
- gtk_iface_mon_stop();
+ gtk_iface_mon_stop();
#endif
- /* deregister our pid */
- u3_deregister_pid();
+ /* deregister our pid */
+ u3_deregister_pid();
- epan_cleanup();
+ epan_cleanup();
- AirPDcapDestroyContext(&airpdcap_ctx);
+ AirPDcapDestroyContext(&airpdcap_ctx);
#ifdef _WIN32
- /* hide the (unresponsive) main window, while asking the user to close the console window */
- gtk_widget_hide(top_level);
+ /* hide the (unresponsive) main window, while asking the user to close the console window */
+ gtk_widget_hide(top_level);
#ifdef HAVE_GTKOSXAPPLICATION
- g_object_unref(theApp);
+ g_object_unref(theApp);
#endif
- software_update_cleanup();
+ software_update_cleanup();
- /* Shutdown windows sockets */
- WSACleanup();
+ /* Shutdown windows sockets */
+ WSACleanup();
- /* For some unknown reason, the "atexit()" call in "create_console()"
- doesn't arrange that "destroy_console()" be called when we exit,
- so we call it here if a console was created. */
- destroy_console();
+ /* For some unknown reason, the "atexit()" call in "create_console()"
+ doesn't arrange that "destroy_console()" be called when we exit,
+ so we call it here if a console was created. */
+ destroy_console();
#endif
- exit(0);
+ exit(0);
}
#ifdef _WIN32
@@ -3297,30 +3296,30 @@ WinMain (struct HINSTANCE__ *hInstance,
char *lpszCmdLine,
int nCmdShow)
{
- INITCOMMONCONTROLSEX comm_ctrl;
-
- /*
- * Initialize our DLL search path. MUST be called before LoadLibrary
- * or g_module_open.
- */
- ws_init_dll_search_path();
+ INITCOMMONCONTROLSEX comm_ctrl;
- /* Initialize our controls. Required for native Windows file dialogs. */
- memset (&comm_ctrl, 0, sizeof(comm_ctrl));
- comm_ctrl.dwSize = sizeof(comm_ctrl);
- /* Includes the animate, header, hot key, list view, progress bar,
- * status bar, tab, tooltip, toolbar, trackbar, tree view, and
- * up-down controls
- */
- comm_ctrl.dwICC = ICC_WIN95_CLASSES;
- InitCommonControlsEx(&comm_ctrl);
+ /*
+ * Initialize our DLL search path. MUST be called before LoadLibrary
+ * or g_module_open.
+ */
+ ws_init_dll_search_path();
+
+ /* Initialize our controls. Required for native Windows file dialogs. */
+ memset (&comm_ctrl, 0, sizeof(comm_ctrl));
+ comm_ctrl.dwSize = sizeof(comm_ctrl);
+ /* Includes the animate, header, hot key, list view, progress bar,
+ * status bar, tab, tooltip, toolbar, trackbar, tree view, and
+ * up-down controls
+ */
+ comm_ctrl.dwICC = ICC_WIN95_CLASSES;
+ InitCommonControlsEx(&comm_ctrl);
- /* RichEd20.DLL is needed for filter entries. */
- ws_load_library("riched20.dll");
+ /* RichEd20.DLL is needed for filter entries. */
+ ws_load_library("riched20.dll");
- set_has_console(FALSE);
- set_console_wait(FALSE);
- return main (__argc, __argv);
+ set_has_console(FALSE);
+ set_console_wait(FALSE);
+ return main (__argc, __argv);
}
#endif /* _WIN32 */
@@ -3330,87 +3329,87 @@ static void
console_log_handler(const char *log_domain, GLogLevelFlags log_level,
const char *message, gpointer user_data _U_)
{
- time_t curr;
- struct tm *today;
- const char *level;
+ time_t curr;
+ struct tm *today;
+ const char *level;
- /* ignore log message, if log_level isn't interesting based
- upon the console log preferences.
- If the preferences haven't been loaded loaded yet, display the
- message anyway.
+ /* ignore log message, if log_level isn't interesting based
+ upon the console log preferences.
+ If the preferences haven't been loaded loaded yet, display the
+ message anyway.
- The default console_log_level preference value is such that only
- ERROR, CRITICAL and WARNING level messages are processed;
- MESSAGE, INFO and DEBUG level messages are ignored. */
- if((log_level & G_LOG_LEVEL_MASK & prefs.console_log_level) == 0 &&
- prefs.console_log_level != 0) {
- return;
- }
+ The default console_log_level preference value is such that only
+ ERROR, CRITICAL and WARNING level messages are processed;
+ MESSAGE, INFO and DEBUG level messages are ignored. */
+ if((log_level & G_LOG_LEVEL_MASK & prefs.console_log_level) == 0 &&
+ prefs.console_log_level != 0) {
+ return;
+ }
#ifdef _WIN32
- if (prefs.gui_console_open != console_open_never || log_level & G_LOG_LEVEL_ERROR) {
- /* the user wants a console or the application will terminate immediately */
- create_console();
- }
- if (get_has_console()) {
- /* For some unknown reason, the above doesn't appear to actually cause
- anything to be sent to the standard output, so we'll just splat the
- message out directly, just to make sure it gets out. */
-#endif
- switch(log_level & G_LOG_LEVEL_MASK) {
- case G_LOG_LEVEL_ERROR:
- level = "Err ";
- break;
- case G_LOG_LEVEL_CRITICAL:
- level = "Crit";
- break;
- case G_LOG_LEVEL_WARNING:
- level = "Warn";
- break;
- case G_LOG_LEVEL_MESSAGE:
- level = "Msg ";
- break;
- case G_LOG_LEVEL_INFO:
- level = "Info";
- break;
- case G_LOG_LEVEL_DEBUG:
- level = "Dbg ";
- break;
- default:
- fprintf(stderr, "unknown log_level %u\n", log_level);
- level = NULL;
- g_assert_not_reached();
+ if (prefs.gui_console_open != console_open_never || log_level & G_LOG_LEVEL_ERROR) {
+ /* the user wants a console or the application will terminate immediately */
+ create_console();
}
+ if (get_has_console()) {
+ /* For some unknown reason, the above doesn't appear to actually cause
+ anything to be sent to the standard output, so we'll just splat the
+ message out directly, just to make sure it gets out. */
+#endif
+ switch(log_level & G_LOG_LEVEL_MASK) {
+ case G_LOG_LEVEL_ERROR:
+ level = "Err ";
+ break;
+ case G_LOG_LEVEL_CRITICAL:
+ level = "Crit";
+ break;
+ case G_LOG_LEVEL_WARNING:
+ level = "Warn";
+ break;
+ case G_LOG_LEVEL_MESSAGE:
+ level = "Msg ";
+ break;
+ case G_LOG_LEVEL_INFO:
+ level = "Info";
+ break;
+ case G_LOG_LEVEL_DEBUG:
+ level = "Dbg ";
+ break;
+ default:
+ fprintf(stderr, "unknown log_level %u\n", log_level);
+ level = NULL;
+ g_assert_not_reached();
+ }
- /* create a "timestamp" */
- time(&curr);
- today = localtime(&curr);
+ /* create a "timestamp" */
+ time(&curr);
+ today = localtime(&curr);
- fprintf(stderr, "%02u:%02u:%02u %8s %s %s\n",
- today->tm_hour, today->tm_min, today->tm_sec,
- log_domain != NULL ? log_domain : "",
- level, message);
+ fprintf(stderr, "%02u:%02u:%02u %8s %s %s\n",
+ today->tm_hour, today->tm_min, today->tm_sec,
+ log_domain != NULL ? log_domain : "",
+ level, message);
#ifdef _WIN32
- if(log_level & G_LOG_LEVEL_ERROR) {
- /* wait for a key press before the following error handler will terminate the program
- this way the user at least can read the error message */
- printf("\n\nPress any key to exit\n");
- _getch();
+ if(log_level & G_LOG_LEVEL_ERROR) {
+ /* wait for a key press before the following error handler will terminate the program
+ this way the user at least can read the error message */
+ printf("\n\nPress any key to exit\n");
+ _getch();
+ }
+ } else {
+ /* XXX - on UN*X, should we just use g_log_default_handler()?
+ We want the error messages to go to the standard output;
+ on Mac OS X, that will cause them to show up in various
+ per-user logs accessible through Console (details depend
+ on whether you're running 10.0 through 10.4 or running
+ 10.5 and later), and, on other UN*X desktop environments,
+ if they don't show up in some form of console log, that's
+ a deficiency in that desktop environment. (Too bad
+ Windows doesn't set the standard output and error for
+ GUI apps to something that shows up in such a log.) */
+ g_log_default_handler(log_domain, log_level, message, user_data);
}
- } else {
- /* XXX - on UN*X, should we just use g_log_default_handler()?
- We want the error messages to go to the standard output;
- on Mac OS X, that will cause them to show up in various
- per-user logs accessible through Console (details depend
- on whether you're running 10.0 through 10.4 or running
- 10.5 and later), and, on other UN*X desktop environments,
- if they don't show up in some form of console log, that's
- a deficiency in that desktop environment. (Too bad
- Windows doesn't set the standard output and error for
- GUI apps to something that shows up in such a log.) */
- g_log_default_handler(log_domain, log_level, message, user_data);
- }
#endif
}
@@ -3725,7 +3724,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs_p
/* Vertical container for menu bar, toolbar(s), paned windows and progress/info box */
main_vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 1, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 0);
+ gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 0);
gtk_container_add(GTK_CONTAINER(top_level), main_vbox);
gtk_widget_show(main_vbox);
@@ -3803,25 +3802,25 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs_p
static void
show_main_window(gboolean doing_work)
{
- main_set_for_capture_file(doing_work);
+ main_set_for_capture_file(doing_work);
- /*** we have finished all init things, show the main window ***/
- gtk_widget_show(top_level);
+ /*** we have finished all init things, show the main window ***/
+ gtk_widget_show(top_level);
- /* the window can be maximized only, if it's visible, so do it after show! */
- main_load_window_geometry(top_level);
+ /* the window can be maximized only, if it's visible, so do it after show! */
+ main_load_window_geometry(top_level);
- /* process all pending GUI events before continue */
- while (gtk_events_pending()) gtk_main_iteration();
+ /* process all pending GUI events before continue */
+ while (gtk_events_pending()) gtk_main_iteration();
- /* Pop up any queued-up alert boxes. */
- display_queued_messages();
+ /* Pop up any queued-up alert boxes. */
+ display_queued_messages();
- /* Move the main window to the front, in case it isn't already there */
- gdk_window_raise(gtk_widget_get_window(top_level));
+ /* Move the main window to the front, in case it isn't already there */
+ gdk_window_raise(gtk_widget_get_window(top_level));
#ifdef HAVE_AIRPCAP
- airpcap_toolbar_show(wireless_tb);
+ airpcap_toolbar_show(wireless_tb);
#endif /* HAVE_AIRPCAP */
}
@@ -3944,3 +3943,16 @@ void redissect_packets(void)
cf_redissect_packets(&cfile);
status_expert_update();
}
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */