5 * Routines to modify BER decoding on the fly.
7 * Copyright 2006 Graeme Lunt
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include "decode_as_dlg.h"
32 #include "dlg_utils.h"
34 #include "simple_dialog.h"
35 #include <epan/packet.h>
36 #include <epan/ipproto.h>
37 #include "gui_utils.h"
38 #include <epan/epan_dissect.h>
39 #include "compat_macros.h"
40 #include "decode_as_dcerpc.h"
41 #include "decode_as_ber.h"
43 #include <epan/dissectors/packet-ber.h>
46 /**************************************************/
47 /* Action routines for the "Decode As..." dialog */
48 /* - called when the OK button pressed */
49 /**************************************************/
52 * This routine is called when the user clicks the "OK" button in the
53 * "Decode As..." dialog window and the ASN.1 page is foremost.
54 * This routine takes care of making any changes requested to the ASN.1
57 * @param notebook_pg A pointer to the "ASN.1" notebook page.
60 decode_ber(GtkWidget *notebook_pg)
64 #if GTK_MAJOR_VERSION < 2
67 GtkTreeSelection *selection;
73 list = OBJECT_GET_DATA(notebook_pg, E_PAGE_LIST);
75 if (requested_action == E_DECODE_NO)
76 #if GTK_MAJOR_VERSION < 2
77 gtk_clist_unselect_all(GTK_CLIST(list));
79 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(list)));
82 #if GTK_MAJOR_VERSION < 2
83 if (!GTK_CLIST(list)->selection)
87 row = GPOINTER_TO_INT(GTK_CLIST(list)->selection->data);
88 gtk_clist_get_text(GTK_CLIST(list), row, E_LIST_S_PROTO_NAME, &syntax);
91 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
92 if (gtk_tree_selection_get_selected(selection, &model, &iter) == FALSE)
96 gtk_tree_model_get(model, &iter, E_LIST_S_PROTO_NAME, &syntax, -1);
100 if ((syntax != NULL && strcmp(syntax, "(default)") == 0) ) {
103 ber_decode_as(syntax);
105 #if GTK_MAJOR_VERSION >= 2
113 /**************************************************/
115 /**************************************************/
118 /* add an interface to the list */
120 decode_ber_add_to_list(gpointer key, gpointer value, gpointer user_data)
122 decode_add_to_list("ASN.1", key, value, user_data);
126 /* add all interfaces to the list */
128 decode_add_ber_menu (GtkWidget *page, const gchar *table_name _U_)
130 GtkWidget *scrolled_window;
133 decode_list_menu_start(page, &list, &scrolled_window);
135 ber_decode_as_foreach(decode_ber_add_to_list, list);
136 decode_list_menu_finish(list);
137 return(scrolled_window);
141 /* add a BER page to the notebook */
143 decode_ber_add_page (packet_info *pinfo _U_)
145 GtkWidget *page_hb, *info_vb, *label, *scrolled_window;
147 /* create page content */
148 page_hb = gtk_hbox_new(FALSE, 5);
149 OBJECT_SET_DATA(page_hb, E_PAGE_ACTION, decode_ber);
150 OBJECT_SET_DATA(page_hb, E_PAGE_TABLE, "ASN.1");
151 OBJECT_SET_DATA(page_hb, E_PAGE_TITLE, "ASN.1");
153 info_vb = gtk_vbox_new(FALSE, 5);
154 gtk_box_pack_start(GTK_BOX(page_hb), info_vb, TRUE, TRUE, 0);
157 label = gtk_label_new("Decode ASN.1 file as:");
158 gtk_box_pack_start(GTK_BOX(info_vb), label, TRUE, TRUE, 0);
160 scrolled_window = decode_add_ber_menu(page_hb, "ber" /*table_name*/);
161 gtk_box_pack_start(GTK_BOX(page_hb), scrolled_window, TRUE, TRUE, 0);
162 decode_dimmable = g_slist_prepend(decode_dimmable, scrolled_window);