2 * Routines for GSM MAP Statictics summary window
4 * Copyright 2004, Michael Lum <mlum [AT] telostech.com>
5 * In association with Telos Technology Inc.
7 * Modified from summary_dlg.c
11 * Ethereal - Network traffic analyzer
12 * By Gerald Combs <gerald@ethereal.com>
13 * Copyright 1998 Gerald Combs
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #include "epan/packet_info.h"
39 #include "epan/epan.h"
40 #include "epan/value_string.h"
41 #include "stat_menu.h"
45 #include "dlg_utils.h"
47 #include "compat_macros.h"
50 #include <epan/dissectors/packet-gsm_map.h>
51 #include "gsm_map_stat.h"
53 #define SUM_STR_MAX 1024
57 add_string_to_box(gchar *str, GtkWidget *box)
60 lb = gtk_label_new(str);
61 gtk_misc_set_alignment(GTK_MISC(lb), 0.0, 0.5);
62 gtk_box_pack_start(GTK_BOX(box), lb,FALSE,FALSE, 0);
68 gsm_map_stat_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_)
70 summary_tally summary;
71 GtkWidget *sum_open_w,
72 *main_vb, *file_fr, *data_fr, *file_box,
73 *data_box, *bbox, *close_bt,
74 *invoke_fr, *invoke_box,
78 gchar string_buff[SUM_STR_MAX];
81 int tot_invokes, tot_rr;
82 double tot_invokes_size, tot_rr_size;
84 /* initialize the tally */
85 summary_fill_in(&cfile, &summary);
87 /* initial compututations */
88 seconds = summary.stop_time - summary.start_time;
90 sum_open_w = window_new(GTK_WINDOW_TOPLEVEL, "GSM MAP Statistics: Summary");
92 /* Container for each row of widgets */
93 main_vb = gtk_vbox_new(FALSE, 3);
94 gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
95 gtk_container_add(GTK_CONTAINER(sum_open_w), main_vb);
96 gtk_widget_show(main_vb);
99 file_fr = gtk_frame_new("File");
100 gtk_container_add(GTK_CONTAINER(main_vb), file_fr);
101 gtk_widget_show(file_fr);
103 file_box = gtk_vbox_new(FALSE, 3);
104 gtk_container_add(GTK_CONTAINER(file_fr), file_box);
105 gtk_widget_show(file_box);
108 g_snprintf(string_buff, SUM_STR_MAX, "Name: %s", ((summary.filename) ? summary.filename : "None"));
109 add_string_to_box(string_buff, file_box);
112 g_snprintf(string_buff, SUM_STR_MAX, "Length: %lu", summary.file_length);
113 add_string_to_box(string_buff, file_box);
116 g_snprintf(string_buff, SUM_STR_MAX, "Format: %s", wtap_file_type_string(summary.encap_type));
117 add_string_to_box(string_buff, file_box);
119 if (summary.has_snap) {
120 /* snapshot length */
121 g_snprintf(string_buff, SUM_STR_MAX, "Snapshot length: %u", summary.snap);
122 add_string_to_box(string_buff, file_box);
126 data_fr = gtk_frame_new("Data");
127 gtk_container_add(GTK_CONTAINER(main_vb), data_fr);
128 gtk_widget_show(data_fr);
130 data_box = gtk_vbox_new(FALSE, 3);
131 gtk_container_add(GTK_CONTAINER(data_fr), data_box);
132 gtk_widget_show(data_box);
135 g_snprintf(string_buff, SUM_STR_MAX, "Elapsed time: %.3f seconds", summary.elapsed_time);
136 add_string_to_box(string_buff, data_box);
138 g_snprintf(string_buff, SUM_STR_MAX, "Between first and last packet: %.3f seconds", seconds);
139 add_string_to_box(string_buff, data_box);
142 g_snprintf(string_buff, SUM_STR_MAX, "Packet count: %i", summary.packet_count);
143 add_string_to_box(string_buff, data_box);
146 tot_invokes_size = 0;
147 for (i=0; i < GSM_MAP_MAX_NUM_OPR_CODES; i++)
149 tot_invokes += gsm_map_stat.opr_code[i];
150 tot_invokes_size += gsm_map_stat.size[i];
155 for (i=0; i < GSM_MAP_MAX_NUM_OPR_CODES; i++)
157 tot_rr += gsm_map_stat.opr_code_rr[i];
158 tot_rr_size += gsm_map_stat.size_rr[i];
162 invoke_fr = gtk_frame_new("Invokes");
163 gtk_container_add(GTK_CONTAINER(main_vb), invoke_fr);
164 gtk_widget_show(invoke_fr);
166 invoke_box = gtk_vbox_new(FALSE, 3);
167 gtk_container_add(GTK_CONTAINER(invoke_fr), invoke_box);
168 gtk_widget_show(invoke_box);
170 /* Total number of invokes */
171 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes: %u", tot_invokes);
172 add_string_to_box(string_buff, invoke_box);
174 /* Total number of invokes per second */
176 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes per second: %.2f", tot_invokes/seconds);
178 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes per second: N/A");
179 add_string_to_box(string_buff, invoke_box);
181 /* Total size of invokes */
182 g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for Invokes: %.0f", tot_invokes_size);
183 add_string_to_box(string_buff, invoke_box);
185 /* Average size of invokes */
187 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Invoke: %.2f", tot_invokes_size/tot_invokes);
189 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Invoke: N/A");
190 add_string_to_box(string_buff, invoke_box);
192 /* Average size of invokes per second */
194 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: %.2f", tot_invokes_size/seconds);
196 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: N/A");
197 add_string_to_box(string_buff, invoke_box);
199 /* Return Results frame */
200 rr_fr = gtk_frame_new("Return Results");
201 gtk_container_add(GTK_CONTAINER(main_vb), rr_fr);
202 gtk_widget_show(rr_fr);
204 rr_box = gtk_vbox_new(FALSE, 3);
205 gtk_container_add(GTK_CONTAINER(rr_fr), rr_box);
206 gtk_widget_show(rr_box);
208 /* Total number of return results */
209 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results: %u", tot_rr);
210 add_string_to_box(string_buff, rr_box);
212 /* Total number of return results per second */
214 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results per second: %.2f", tot_rr/seconds);
216 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results per second: N/A");
217 add_string_to_box(string_buff, rr_box);
219 /* Total size of return results */
220 g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for Return Results: %.0f", tot_rr_size);
221 add_string_to_box(string_buff, rr_box);
223 /* Average size of return results */
225 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Return Result: %.2f", tot_rr_size/tot_rr);
227 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Return Result: N/A");
228 add_string_to_box(string_buff, rr_box);
230 /* Average size of return results per second */
232 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: %.2f", tot_rr_size/seconds);
234 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: N/A");
235 add_string_to_box(string_buff, rr_box);
238 tot_fr = gtk_frame_new("Totals");
239 gtk_container_add(GTK_CONTAINER(main_vb), tot_fr);
240 gtk_widget_show(tot_fr);
242 tot_box = gtk_vbox_new(FALSE, 3);
243 gtk_container_add(GTK_CONTAINER(tot_fr), tot_box);
244 gtk_widget_show(tot_box);
246 /* Total number of return results */
247 g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages: %u", tot_invokes + tot_rr);
248 add_string_to_box(string_buff, tot_box);
251 g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages per second: %.2f",
252 (tot_invokes + tot_rr)/seconds);
254 g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages per second: N/A");
255 add_string_to_box(string_buff, tot_box);
257 g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for GSM MAP messages: %.0f", tot_invokes_size + tot_rr_size);
258 add_string_to_box(string_buff, tot_box);
260 if (tot_invokes + tot_rr)
261 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per GSM MAP messages: %.2f",
262 (tot_invokes_size + tot_rr_size)/(tot_invokes + tot_rr));
264 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per GSM MAP messages: N/A");
265 add_string_to_box(string_buff, tot_box);
268 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes second: %.2f",
269 (tot_invokes_size + tot_rr_size)/seconds);
271 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes second: N/A");
272 add_string_to_box(string_buff, tot_box);
276 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
277 gtk_container_add(GTK_CONTAINER(main_vb), bbox);
278 gtk_widget_show(bbox);
280 close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
281 window_set_cancel_button(sum_open_w, close_bt, window_cancel_button_cb);
283 SIGNAL_CONNECT(sum_open_w, "delete_event", window_delete_event_cb, NULL);
285 gtk_widget_show(sum_open_w);
286 window_present(sum_open_w);
291 register_tap_listener_gtkgsm_map_summary(void)
293 register_stat_menu_item("GSM/MAP Summary", REGISTER_STAT_GROUP_TELEPHONY,
294 gsm_map_stat_gtk_sum_cb, NULL, NULL, NULL);