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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <epan/packet.h>
30 #include <epan/epan_dissect.h>
31 #include <epan/dissectors/packet-ber.h>
33 #include "ui/gtk/decode_as_dlg.h"
34 #include "ui/gtk/dlg_utils.h"
35 #include "ui/gtk/gui_utils.h"
36 #include "ui/gtk/decode_as_dcerpc.h"
37 #include "ui/gtk/decode_as_ber.h"
40 /**************************************************/
41 /* Action routines for the "Decode As..." dialog */
42 /* - called when the OK button pressed */
43 /**************************************************/
46 * This routine is called when the user clicks the "OK" button in the
47 * "Decode As..." dialog window and the ASN.1 page is foremost.
48 * This routine takes care of making any changes requested to the ASN.1
51 * @param notebook_pg A pointer to the "ASN.1" notebook page.
54 decode_ber(GtkWidget
*notebook_pg
)
58 GtkTreeSelection
*selection
;
63 list
= (GtkWidget
*)g_object_get_data(G_OBJECT(notebook_pg
), E_PAGE_LIST
);
65 if (requested_action
== E_DECODE_NO
)
66 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(list
)));
68 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(list
));
69 if (gtk_tree_selection_get_selected(selection
, &model
, &iter
) == FALSE
)
73 gtk_tree_model_get(model
, &iter
, E_LIST_S_PROTO_NAME
, &syntax
, -1);
76 if ((syntax
!= NULL
&& strcmp(syntax
, "(default)") == 0) ) {
79 ber_decode_as(syntax
);
85 /**************************************************/
87 /**************************************************/
90 /* add an interface to the list */
92 decode_ber_add_to_list(gpointer key
, gpointer value
, gpointer user_data
)
94 decode_add_to_list("ASN.1", (gchar
*)key
, value
, user_data
);
98 /* add all interfaces to the list */
100 decode_add_ber_menu (GtkWidget
*page
, const gchar
*table_name _U_
)
102 GtkWidget
*scrolled_window
;
105 decode_list_menu_start(page
, &list
, &scrolled_window
);
107 ber_decode_as_foreach(decode_ber_add_to_list
, list
);
108 decode_list_menu_finish(list
);
109 return(scrolled_window
);
113 /* add a BER page to the notebook */
115 decode_ber_add_page (packet_info
*pinfo _U_
)
117 GtkWidget
*page_hb
, *info_vb
, *label
, *scrolled_window
;
119 /* create page content */
120 page_hb
= ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 5, FALSE
);
121 g_object_set_data(G_OBJECT(page_hb
), E_PAGE_ACTION
, decode_ber
);
122 g_object_set_data(G_OBJECT(page_hb
), E_PAGE_TABLE
, (gpointer
)"ASN.1");
123 g_object_set_data(G_OBJECT(page_hb
), E_PAGE_TITLE
, (gpointer
)"ASN.1");
125 info_vb
= ws_gtk_box_new(GTK_ORIENTATION_VERTICAL
, 5, FALSE
);
126 gtk_box_pack_start(GTK_BOX(page_hb
), info_vb
, TRUE
, TRUE
, 0);
129 label
= gtk_label_new("Decode ASN.1 file as:");
130 gtk_box_pack_start(GTK_BOX(info_vb
), label
, TRUE
, TRUE
, 0);
132 scrolled_window
= decode_add_ber_menu(page_hb
, "ber" /*table_name*/);
133 gtk_box_pack_start(GTK_BOX(page_hb
), scrolled_window
, TRUE
, TRUE
, 0);
134 decode_dimmable
= g_slist_prepend(decode_dimmable
, scrolled_window
);