2 * Copyright 2004, Irene Ruengeler <i.ruengeler [AT] fh-muenster.de>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include "epan/filesystem.h"
33 #include "simple_dialog.h"
34 #include "dlg_utils.h"
35 #include "gui_utils.h"
37 #include "compat_macros.h"
39 #include "sctp_stat.h"
40 /*#include "sctp_assoc_analyse.h"*/
43 static GtkWidget *sctp_error_dlg=NULL;
44 static GtkWidget *clist = NULL;
45 static GList *last_list = NULL;
46 static sctp_error_info_t* selected_packet = NULL;/* current selection */
47 /*static sctp_assoc_info_t* selected_assoc = NULL; */
51 typedef struct column_arrows {
54 GtkWidget *descend_pm;
64 static void add_to_clist(sctp_error_info_t* errinfo)
67 gchar *data[NUM_COLS];
68 gchar field[NUM_COLS][30];
70 for (i=0; i<NUM_COLS; i++)
73 /*printf("errinfo=%s\n",errinfo->chunk_info);*/
75 g_snprintf(field[0], 20, "%u", errinfo->frame_number);
76 g_snprintf(field[1], 20, "%s", errinfo->chunk_info);
77 g_snprintf(field[2], 20, "%s", errinfo->info_text);
79 added_row = gtk_clist_append(GTK_CLIST(clist), data);
81 /* set data pointer of last row to point to user data for that row */
82 gtk_clist_set_row_data(GTK_CLIST(clist), added_row, errinfo);
86 sctp_error_on_unselect(GtkButton *button _U_, gpointer user_data _U_)
88 gtk_clist_unselect_all(GTK_CLIST(clist));
91 static void sctp_error_dlg_update(GList *list)
95 if (sctp_error_dlg != NULL)
97 gtk_clist_clear(GTK_CLIST(clist));
102 add_to_clist((sctp_error_info_t*)(ilist->data));
103 ilist = g_list_next(ilist);
106 sctp_error_on_unselect(NULL, NULL);
112 sctp_error_on_select_row(GtkCList *clist, gint row,gint column _U_, GdkEventButton *event _U_, gpointer user_data _U_)
114 selected_packet = gtk_clist_get_row_data(GTK_CLIST(clist), row);
120 sctp_error_on_frame (GtkButton *button _U_, gpointer user_data _U_)
123 if (selected_packet==NULL)
127 cf_goto_frame(&cfile, selected_packet->frame_number);
132 sctp_error_on_close (GtkButton *button _U_, gpointer user_data _U_)
134 gtk_grab_remove(sctp_error_dlg);
135 gtk_widget_destroy(sctp_error_dlg);
139 gtk_sctperror_dlg(void)
141 GtkWidget *sctp_error_dlg_w;
143 GtkWidget *scrolledwindow1;
144 GtkWidget *hbuttonbox2;
145 GtkWidget *bt_unselect;
149 const gchar *titles[NUM_COLS] = {"Framenumber","Chunk Types", "Info"};
150 column_arrows *col_arrows;
152 GtkWidget *column_lb;
155 sctp_error_dlg_w = window_new (GTK_WINDOW_TOPLEVEL, "Wireshark: SCTP Associations");
156 gtk_window_set_position (GTK_WINDOW (sctp_error_dlg_w), GTK_WIN_POS_CENTER);
157 SIGNAL_CONNECT(sctp_error_dlg_w, "destroy", dlg_destroy,NULL);
159 /* Container for each row of widgets */
160 vbox1 = gtk_vbox_new(FALSE, 2);
161 gtk_container_border_width(GTK_CONTAINER(vbox1), 8);
162 gtk_container_add(GTK_CONTAINER(sctp_error_dlg_w), vbox1);
163 gtk_widget_show(vbox1);
165 scrolledwindow1 = scrolled_window_new (NULL, NULL);
166 gtk_widget_show (scrolledwindow1);
167 gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0);
169 clist = gtk_clist_new (NUM_COLS);
170 gtk_widget_show (clist);
171 gtk_container_add (GTK_CONTAINER (scrolledwindow1), clist);
172 WIDGET_SET_SIZE(clist, 500, 200);
174 gtk_clist_set_column_width (GTK_CLIST (clist), 0, 100);
175 gtk_clist_set_column_width (GTK_CLIST (clist), 1, 200);
176 gtk_clist_set_column_width (GTK_CLIST (clist), 2, 200);
178 gtk_clist_set_column_justification(GTK_CLIST(clist), 0, GTK_JUSTIFY_CENTER);
179 gtk_clist_set_column_justification(GTK_CLIST(clist), 1, GTK_JUSTIFY_LEFT);
180 gtk_clist_set_column_justification(GTK_CLIST(clist), 2, GTK_JUSTIFY_LEFT);
182 gtk_clist_column_titles_show (GTK_CLIST (clist));
184 gtk_clist_set_sort_column(GTK_CLIST(clist), 0);
185 gtk_clist_set_sort_type(GTK_CLIST(clist), GTK_SORT_ASCENDING);
187 gtk_widget_show(sctp_error_dlg_w);
189 col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) * NUM_COLS);
190 win_style = gtk_widget_get_style(scrolledwindow1);
192 for (i=0; i<NUM_COLS; i++) {
193 col_arrows[i].table = gtk_table_new(2, 2, FALSE);
194 gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
195 column_lb = gtk_label_new(titles[i]);
196 gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
197 gtk_widget_show(column_lb);
199 gtk_clist_set_column_widget(GTK_CLIST(clist), i, col_arrows[i].table);
200 gtk_widget_show(col_arrows[i].table);
204 hbuttonbox2 = gtk_hbutton_box_new ();
205 gtk_widget_show (hbuttonbox2);
206 gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox2, FALSE, FALSE, 0);
207 gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox2), 5);
208 gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox2), GTK_BUTTONBOX_SPREAD);
211 bt_unselect = gtk_button_new_with_label ("Unselect");
212 gtk_widget_show (bt_unselect);
213 gtk_container_add (GTK_CONTAINER (hbuttonbox2), bt_unselect);
215 bt_frame = gtk_button_new_with_label ("Go to Frame");
216 gtk_widget_show (bt_frame);
217 gtk_container_add (GTK_CONTAINER (hbuttonbox2), bt_frame);
219 bt_close = BUTTON_NEW_FROM_STOCK(GTK_STOCK_CLOSE);
220 gtk_widget_show (bt_close);
221 gtk_container_add (GTK_CONTAINER (hbuttonbox2), bt_close);
223 SIGNAL_CONNECT(sctp_error_dlg_w, "destroy", dlg_destroy, NULL);
224 SIGNAL_CONNECT(clist, "select_row", sctp_error_on_select_row, NULL);
225 SIGNAL_CONNECT(bt_unselect, "clicked", sctp_error_on_unselect, NULL);
226 SIGNAL_CONNECT(bt_frame, "clicked", sctp_error_on_frame, NULL);
227 SIGNAL_CONNECT(bt_close, "clicked", sctp_error_on_close, NULL);
229 sctp_error_dlg = sctp_error_dlg_w;
233 void sctp_error_dlg_show(sctp_assoc_info_t* assoc)
237 list =assoc->error_info_list;
240 if (sctp_error_dlg != NULL) {
241 /* There's already a dialog box; reactivate it. */
242 reactivate_window(sctp_error_dlg);
243 /* Another list since last call? */
244 if (list != last_list) {
245 sctp_error_dlg_update(list);
249 /* Create and show the dialog box */
251 sctp_error_dlg_update(list);
255 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,