aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorGraeme Lunt <graeme.lunt@smhs.co.uk>2007-01-13 12:59:27 +0000
committerGraeme Lunt <graeme.lunt@smhs.co.uk>2007-01-13 12:59:27 +0000
commit2fd7d2c62078813f44e78f0b4b9f8b0e6e5928fb (patch)
tree8bc3e25bd6afc1b8eeb5ae59ab92988c18a6dcc8 /gtk
parent13a095e055798295514d723c15f72e8f2cd89a3e (diff)
New "decode as ..." feature for BER-encoded files (WTAP_FILE_BER).
A BER-encoded file can be dissected as one of a number of registered syntaxes (registered using register_ber_syntax_dissector()). Syntaxes may also be associated with OIDs (or other strings) using register_ber_oid_syntax(). A default syntax with which to dissect a BER-encoded file is determined from its filename (extension). For example, ".cer" and ".crt" files will be dissected as "Certificate". svn path=/trunk/; revision=20414
Diffstat (limited to 'gtk')
-rw-r--r--gtk/Makefile.common1
-rw-r--r--gtk/decode_as_ber.c165
-rw-r--r--gtk/decode_as_ber.h39
-rw-r--r--gtk/decode_as_dlg.c13
4 files changed, 217 insertions, 1 deletions
diff --git a/gtk/Makefile.common b/gtk/Makefile.common
index 280bc73ffa..260e4ea9a8 100644
--- a/gtk/Makefile.common
+++ b/gtk/Makefile.common
@@ -55,6 +55,7 @@ WIRESHARK_GTK_SRC = \
colors.c \
column_prefs.c \
conversations_table.c \
+ decode_as_ber.c \
decode_as_dlg.c \
decode_as_dcerpc.c \
dfilter_expr_dlg.c \
diff --git a/gtk/decode_as_ber.c b/gtk/decode_as_ber.c
new file mode 100644
index 0000000000..56d45d746c
--- /dev/null
+++ b/gtk/decode_as_ber.c
@@ -0,0 +1,165 @@
+/* decode_as_ber.c
+ *
+ * $Id$
+ *
+ * Routines to modify BER decoding on the fly.
+ *
+ * Copyright 2006 Graeme Lunt
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gtk/gtk.h>
+#include <string.h>
+
+#include "decode_as_dlg.h"
+#include "dlg_utils.h"
+#include "globals.h"
+#include "simple_dialog.h"
+#include <epan/packet.h>
+#include <epan/ipproto.h>
+#include "gui_utils.h"
+#include <epan/epan_dissect.h>
+#include "compat_macros.h"
+#include "decode_as_dcerpc.h"
+#include "decode_as_ber.h"
+
+#include <epan/dissectors/packet-ber.h>
+
+
+/**************************************************/
+/* Action routines for the "Decode As..." dialog */
+/* - called when the OK button pressed */
+/**************************************************/
+
+/*
+ * This routine is called when the user clicks the "OK" button in the
+ * "Decode As..." dialog window and the ASN.1 page is foremost.
+ * This routine takes care of making any changes requested to the ASN.1
+ * decoding.
+ *
+ * @param notebook_pg A pointer to the "ASN.1" notebook page.
+ */
+static void
+decode_ber(GtkWidget *notebook_pg)
+{
+ GtkWidget *list;
+ gchar *syntax;
+#if GTK_MAJOR_VERSION < 2
+ gint row;
+#else
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+#endif
+
+ syntax = NULL;
+ list = OBJECT_GET_DATA(notebook_pg, E_PAGE_LIST);
+
+ if (requested_action == E_DECODE_NO)
+#if GTK_MAJOR_VERSION < 2
+ gtk_clist_unselect_all(GTK_CLIST(list));
+#else
+ gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(list)));
+#endif
+
+#if GTK_MAJOR_VERSION < 2
+ if (!GTK_CLIST(list)->selection)
+ {
+ syntax = NULL;
+ } else {
+ row = GPOINTER_TO_INT(GTK_CLIST(list)->selection->data);
+ gtk_clist_get_text(GTK_CLIST(list), row, E_LIST_S_PROTO_NAME, &syntax);
+ }
+#else
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
+ if (gtk_tree_selection_get_selected(selection, &model, &iter) == FALSE)
+ {
+ syntax = NULL;
+ } else {
+ gtk_tree_model_get(model, &iter, E_LIST_S_PROTO_NAME, &syntax, -1);
+ }
+#endif
+
+ if ((syntax != NULL && strcmp(syntax, "(default)") == 0) ) {
+ ber_decode_as(NULL);
+ } else {
+ ber_decode_as(syntax);
+ }
+#if GTK_MAJOR_VERSION >= 2
+ if (syntax != NULL)
+ g_free(syntax);
+#endif
+
+}
+
+
+/**************************************************/
+/* Dialog setup */
+/**************************************************/
+
+
+/* add an interface to the list */
+static void
+decode_ber_add_to_list(gpointer key, gpointer value, gpointer user_data)
+{
+ decode_add_to_list("ASN.1", key, value, user_data);
+}
+
+
+/* add all interfaces to the list */
+static GtkWidget *
+decode_add_ber_menu (GtkWidget *page, const gchar *table_name _U_)
+{
+ GtkWidget *scrolled_window;
+ GtkWidget *list;
+
+ decode_list_menu_start(page, &list, &scrolled_window);
+
+ ber_decode_as_foreach(decode_ber_add_to_list, list);
+ decode_list_menu_finish(list);
+ return(scrolled_window);
+}
+
+
+/* add a BER page to the notebook */
+GtkWidget *
+decode_ber_add_page (packet_info *pinfo)
+{
+ GtkWidget *page_hb, *info_vb, *label, *scrolled_window;
+
+ /* create page content */
+ page_hb = gtk_hbox_new(FALSE, 5);
+ OBJECT_SET_DATA(page_hb, E_PAGE_ACTION, decode_ber);
+ OBJECT_SET_DATA(page_hb, E_PAGE_TABLE, "ASN.1");
+ OBJECT_SET_DATA(page_hb, E_PAGE_TITLE, "ASN.1");
+
+ info_vb = gtk_vbox_new(FALSE, 5);
+ gtk_box_pack_start(GTK_BOX(page_hb), info_vb, TRUE, TRUE, 0);
+
+ /* Always enabled */
+ label = gtk_label_new("Decode ASN.1 file as:");
+ gtk_box_pack_start(GTK_BOX(info_vb), label, TRUE, TRUE, 0);
+
+ scrolled_window = decode_add_ber_menu(page_hb, "ber" /*table_name*/);
+ gtk_box_pack_start(GTK_BOX(page_hb), scrolled_window, TRUE, TRUE, 0);
+ decode_dimmable = g_slist_prepend(decode_dimmable, scrolled_window);
+
+ return(page_hb);
+}
diff --git a/gtk/decode_as_ber.h b/gtk/decode_as_ber.h
new file mode 100644
index 0000000000..fb910cc07e
--- /dev/null
+++ b/gtk/decode_as_ber.h
@@ -0,0 +1,39 @@
+/* decode_as_ber.h
+ *
+ * $Id$
+ *
+ * Routines to modify BER decoding on the fly.
+ * Only internally used between decode_as_dlg and decode_as_ber
+ *
+ * Copyright 2006 Graeme Lunt
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __DECODE_AS_BER_H__
+#define __DECODE_AS_BER_H__
+
+/** @file
+ * "Decode As" / "User Specified Decodes" dialog box.
+ * @ingroup dialog_group
+ */
+
+#define E_PAGE_BER "notebook_page_ber" /* ber only */
+
+extern GtkWidget *
+decode_ber_add_page(packet_info *pinfo);
+
+#endif
diff --git a/gtk/decode_as_dlg.c b/gtk/decode_as_dlg.c
index 7d58887e0c..462061d720 100644
--- a/gtk/decode_as_dlg.c
+++ b/gtk/decode_as_dlg.c
@@ -39,6 +39,7 @@
#include <epan/epan_dissect.h>
#include "compat_macros.h"
#include "decode_as_dcerpc.h"
+#include "decode_as_ber.h"
#include "help_dlg.h"
#undef DEBUG
@@ -71,6 +72,8 @@ enum srcdst_type {
#define E_PAGE_DPORT "dport"
#define E_PAGE_SPORT "sport"
#define E_PAGE_PPID "ppid"
+#define E_PAGE_ASN1 "asn1"
+
/*
* Columns for a "Display" list
@@ -1770,7 +1773,8 @@ gboolean
decode_as_ok(void)
{
return cfile.edt->pi.ethertype || cfile.edt->pi.ipproto ||
- cfile.edt->pi.ptype == PT_TCP || cfile.edt->pi.ptype == PT_UDP;
+ cfile.edt->pi.ptype == PT_TCP || cfile.edt->pi.ptype == PT_UDP ||
+ cfile.cd_t == WTAP_FILE_BER;
}
@@ -1844,6 +1848,13 @@ decode_add_notebook (GtkWidget *format_hb)
OBJECT_SET_DATA(decode_w, E_PAGE_DCERPC, page);
}
+ if(cfile.cd_t == WTAP_FILE_BER) {
+ page = decode_ber_add_page(&cfile.edt->pi);
+ label = gtk_label_new("ASN.1");
+ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label);
+ OBJECT_SET_DATA(decode_w, E_PAGE_ASN1, page);
+ }
+
/* Select the last added page (selects first by default) */
/* Notebook must be visible for set_page to work. */
gtk_widget_show_all(notebook);