diff options
author | Michal Labedzki <michal.labedzki@tieto.com> | 2014-01-18 15:20:02 +0100 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-02-25 17:43:13 +0000 |
commit | 579e7e19ce8e5f1a6e16b75f130ad4b001157ca5 (patch) | |
tree | 423547b0256e93647f98710cf14e15e112f7f73f /ui/gtk | |
parent | b6aae8d5c470aa681b70f33cad064dbb7045b3b7 (diff) |
Wireshark: Add option to choose format type of capture file
The best heuristic can fail, so add possibility to manually choose
capture file format type, so not correctly recognize file format can be
loaded in Wireshark.
On the other side now it is possible to open capture file
as file format to be dissected.
Change-Id: I5a9f662b32ff7e042f753a92eaaa86c6e41f400a
Reviewed-on: https://code.wireshark.org/review/16
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Evan Huus <eapache@gmail.com>
Tested-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'ui/gtk')
-rw-r--r-- | ui/gtk/capture_file_dlg.c | 31 | ||||
-rw-r--r-- | ui/gtk/drag_and_drop.c | 4 | ||||
-rw-r--r-- | ui/gtk/file_import_dlg.c | 2 | ||||
-rw-r--r-- | ui/gtk/fileset_dlg.c | 2 | ||||
-rw-r--r-- | ui/gtk/funnel_stat.c | 2 | ||||
-rw-r--r-- | ui/gtk/main.c | 4 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 4 |
7 files changed, 36 insertions, 13 deletions
diff --git a/ui/gtk/capture_file_dlg.c b/ui/gtk/capture_file_dlg.c index 9e852629f2..e79e8deced 100644 --- a/ui/gtk/capture_file_dlg.c +++ b/ui/gtk/capture_file_dlg.c @@ -139,7 +139,7 @@ preview_set_filename(GtkWidget *prev, const gchar *cf_name) return NULL; } - wth = wtap_open_offline(cf_name, &err, &err_info, TRUE); + wth = wtap_open_offline(cf_name, WTAP_TYPE_AUTO, &err, &err_info, TRUE); if (wth == NULL) { label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_FORMAT_KEY); if (err == WTAP_ERR_FILE_UNKNOWN_FORMAT) { @@ -474,11 +474,14 @@ preview_new(void) /* Open a file */ static gboolean -gtk_open_file(GtkWidget *w, GString *file_name, GString *display_filter) +gtk_open_file(GtkWidget *w, GString *file_name, gint *type, GString *display_filter) { GtkWidget *file_open_w; GtkWidget *main_hb, *main_vb, *filter_hbox, *filter_bt, *filter_te; GtkWidget *m_resolv_cb, *n_resolv_cb, *t_resolv_cb, *e_resolv_cb, *prev; + GtkWidget *format_type_co; + GtkCellRenderer *cell; + gint i; /* No Apply button, and "OK" just sets our text widget, it doesn't activate it (i.e., it doesn't cause us to try to open the file). */ @@ -542,6 +545,21 @@ gtk_open_file(GtkWidget *w, GString *file_name, GString *display_filter) gtk_box_pack_start(GTK_BOX(main_hb), main_vb, FALSE, FALSE, 0); gtk_widget_show(main_vb); + format_type_co = gtk_combo_box_text_new(); + cell = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(format_type_co), cell, TRUE); + + gtk_widget_set_tooltip_text(format_type_co, "Format type of capture file"); + gtk_box_pack_start(GTK_BOX(main_vb), format_type_co, FALSE, FALSE, 0); + + gtk_combo_box_text_append_text((GtkComboBoxText *) format_type_co, (const gchar *) "Automatic"); + for (i = 0; open_routines[i].name != NULL; i += 1) { + gtk_combo_box_text_append_text((GtkComboBoxText *) format_type_co, open_routines[i].name); + } + + gtk_combo_box_set_active((GtkComboBox *) format_type_co, 0); + gtk_widget_show(format_type_co); + /* Filter row */ filter_hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1, FALSE); gtk_container_set_border_width(GTK_CONTAINER(filter_hbox), 0); @@ -639,6 +657,8 @@ gtk_open_file(GtkWidget *w, GString *file_name, GString *display_filter) else gbl_resolv_flags.use_external_net_name_resolver = FALSE; + *type = gtk_combo_box_get_active((GtkComboBox *) format_type_co); + /* We've crossed the Rubicon; get rid of the file selection box. */ window_destroy(GTK_WIDGET(file_open_w)); @@ -666,6 +686,7 @@ file_open_cmd(capture_file *cf, GtkWidget *w _U_) GString *display_filter = g_string_new(""); dfilter_t *rfcode = NULL; int err; + int type = WTAP_TYPE_AUTO; /* * Loop until the user either selects a file or gives up. @@ -674,7 +695,7 @@ file_open_cmd(capture_file *cf, GtkWidget *w _U_) #ifdef USE_WIN32_FILE_DIALOGS if (win32_open_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)), file_name, display_filter)) { #else /* USE_WIN32_FILE_DIALOGS */ - if (gtk_open_file(top_level, file_name, display_filter)) { + if (gtk_open_file(top_level, file_name, &type, display_filter)) { #endif /* USE_WIN32_FILE_DIALOGS */ /* Only close the old file now that we know we want to open another one. */ @@ -690,7 +711,7 @@ file_open_cmd(capture_file *cf, GtkWidget *w _U_) } /* Try to open the capture file. */ - if (cf_open(&cfile, file_name->str, FALSE, &err) != CF_OK) { + if (cf_open(&cfile, file_name->str, type, FALSE, &err) != CF_OK) { /* We couldn't open it; don't dismiss the open dialog box, just leave it around so that the user can, after they dismiss the alert box popped up for the open error, @@ -971,7 +992,7 @@ file_merge_cmd(GtkWidget *w _U_) cf_close(&cfile); /* Try to open the merged capture file. */ - if (cf_open(&cfile, tmpname, TRUE /* temporary file */, &err) != CF_OK) { + if (cf_open(&cfile, tmpname, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) != CF_OK) { /* We couldn't open it; fail. */ if (rfcode != NULL) dfilter_free(rfcode); diff --git a/ui/gtk/drag_and_drop.c b/ui/gtk/drag_and_drop.c index 93e438a698..78db218385 100644 --- a/ui/gtk/drag_and_drop.c +++ b/ui/gtk/drag_and_drop.c @@ -204,7 +204,7 @@ dnd_open_file_cmd(gchar *cf_names_freeme) if (in_file_count == 1) { /* open and read the capture file (this will close an existing file) */ - if (cf_open(&cfile, in_filenames[0], FALSE, &err) == CF_OK) { + if (cf_open(&cfile, in_filenames[0], WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) { /* XXX - add this to the menu if the read fails? */ cf_read(&cfile, FALSE); add_menu_recent_capture_file(in_filenames[0]); @@ -219,7 +219,7 @@ dnd_open_file_cmd(gchar *cf_names_freeme) /* Merge succeeded; close the currently-open file and try to open the merged capture file. */ cf_close(&cfile); - if (cf_open(&cfile, tmpname, TRUE /* temporary file */, &err) == CF_OK) { + if (cf_open(&cfile, tmpname, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) == CF_OK) { g_free(tmpname); cf_read(&cfile, FALSE); } else { diff --git a/ui/gtk/file_import_dlg.c b/ui/gtk/file_import_dlg.c index 5ad8a80ce5..a59ac082c2 100644 --- a/ui/gtk/file_import_dlg.c +++ b/ui/gtk/file_import_dlg.c @@ -541,7 +541,7 @@ file_import_open(text_import_info_t *info) write_failure_alert_box(capfile_name, err); } - if (cf_open(&cfile, capfile_name, TRUE /* temporary file */, &err) != CF_OK) { + if (cf_open(&cfile, capfile_name, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) != CF_OK) { open_failure_alert_box(capfile_name, err, FALSE); goto end; } diff --git a/ui/gtk/fileset_dlg.c b/ui/gtk/fileset_dlg.c index fbfa866772..3123c226c4 100644 --- a/ui/gtk/fileset_dlg.c +++ b/ui/gtk/fileset_dlg.c @@ -79,7 +79,7 @@ fs_open_entry(fileset_entry *entry) /* close the old and open the new file */ cf_close(&cfile); - if (cf_open(&cfile, fname, FALSE, &err) == CF_OK) { + if (cf_open(&cfile, fname, WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) { cf_read(&cfile, FALSE); } diff --git a/ui/gtk/funnel_stat.c b/ui/gtk/funnel_stat.c index cc0cde0026..313a38a1a5 100644 --- a/ui/gtk/funnel_stat.c +++ b/ui/gtk/funnel_stat.c @@ -518,7 +518,7 @@ static gboolean funnel_open_file(const char* fname, const char* filter, const ch } - if (cf_open(&cfile, fname, FALSE, &err) != CF_OK) { + if (cf_open(&cfile, fname, WTAP_TYPE_AUTO, FALSE, &err) != CF_OK) { *err_str = g_strerror(err); if (rfcode != NULL) dfilter_free(rfcode); return FALSE; diff --git a/ui/gtk/main.c b/ui/gtk/main.c index a5e706dc9d..8748f0500f 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -2523,6 +2523,8 @@ main(int argc, char *argv[]) g_free(init_progfile_dir_error); } + init_open_routines(); + #ifdef HAVE_PLUGINS /* Register all the plugin types we have. */ epan_register_plugin_types(); /* Types known to libwireshark */ @@ -3088,7 +3090,7 @@ main(int argc, char *argv[]) } } if (!rfilter_parse_failed) { - if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) { + if (cf_open(&cfile, cf_name, WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) { /* "cf_open()" succeeded, so it closed the previous capture file, and thus destroyed any previous read filter attached to "cf". */ diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index e8b119e3b8..3d5f681001 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -4323,7 +4323,7 @@ menu_open_filename(gchar *cf_name) recent_files_list = (GList *)g_object_get_data(G_OBJECT(submenu_recent_files), "recent-files-list"); /* XXX: ask user to remove item, it's maybe only a temporary problem */ /* open and read the capture file (this will close an existing file) */ - if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) { + if (cf_open(&cfile, cf_name, WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) { cf_read(&cfile, FALSE); }else{ recent_files_list = remove_present_file_name(recent_files_list, cf_name); @@ -4351,7 +4351,7 @@ menu_open_recent_file_cmd(GtkAction *action) #endif /* open and read the capture file (this will close an existing file) */ - if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) { + if (cf_open(&cfile, cf_name, WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) { cf_read(&cfile, FALSE); } else { submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH); |