Witness: enum witness_notifyResponse_type
[wireshark-wip.git] / ui / gtk / compare_stat.c
blob4b2f15fe1b125f51e310b13a766cf7be03b20e94
1 /* compare_stat.c
2 * Compare two capture files
3 * Copyright 2008 Vincenzo Condoleo, Christophe Dirac, Reto Ruoss
4 * supported by HSR (Hochschule Rapperswil)
6 * $Id$
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 /* This module provides statistics about two merged capture files, to find packet loss,
28 * time delay, ip header checksum errors and order check.
29 * It's also detecting the matching regions of the different files.
30 * After the coloring is set Info column can be sorted to create zebra effect.
32 * The packets are compared by the ip id. MAC or TTL is used to distinct the different files.
35 #include "config.h"
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <string.h>
40 #include <math.h>
42 #include <glib.h>
43 #include <gtk/gtk.h>
45 #include <wsutil/report_err.h>
47 #include <epan/packet_info.h>
48 #include <epan/epan.h>
49 #include <epan/epan_dissect.h>
50 #include <epan/stat_cmd_args.h>
51 #include <epan/to_str.h>
52 #include <epan/tap.h>
53 #include <epan/emem.h>
54 #include <epan/packet.h>
55 #include <epan/dissectors/packet-ip.h>
56 #include <epan/in_cksum.h>
58 #include "../stat_menu.h"
59 #include "epan/timestats.h"
61 #include "ui/simple_dialog.h"
63 #include "ui/gtk/gui_stat_menu.h"
64 #include "ui/gtk/stock_icons.h"
65 #include "ui/gtk/help_dlg.h"
66 #include "ui/gtk/filter_autocomplete.h"
68 #include "gui_utils.h"
69 #include "dlg_utils.h"
70 #include "register.h"
71 #include "main.h"
72 #include "filter_dlg.h"
73 #include "service_response_time_table.h"
74 #include "gtkglobals.h"
75 #include "gui_utils.h"
76 #include "globals.h"
78 /* Color settings */
79 #include "color.h"
80 #include "color_filters.h"
81 #include "color_dlg.h"
82 #include "packet_list.h"
84 #include "ui/gtk/old-gtk-compat.h"
86 /* From colorize convertion */
87 #define COLOR_N 1
89 /* For checksum */
90 #define BYTES 8
91 #define WRONG_CHKSUM 0
93 #define MERGED_FILES 2
95 #define TTL_SEARCH 5
99 /* information which are needed for the display */
100 typedef struct _for_gui {
101 guint count;
102 guint16 cksum;
103 nstime_t predecessor_time;
104 struct _frame_info *partner;
105 } for_gui;
107 /* each tracked packet */
108 typedef struct _frame_info {
109 for_gui *fg;
110 column_info *cinfo;
111 guint32 num;
112 guint16 id;
113 guint8 ip_ttl;
114 address dl_dst;
115 nstime_t abs_ts, zebra_time, delta;
116 } frame_info;
118 /* used to keep track of the statistics for an entire program interface */
119 typedef struct _compstat_t {
120 GtkWidget *win, *treeview, *scrolled_win, *statis_label;
121 GtkTreeStore *simple_list;
122 GtkTreeIter iter, child;
123 emem_tree_t *packet_tree, *ip_id_tree, *nr_tree;
124 address eth_dst, eth_src;
125 nstime_t zebra_time, current_time;
126 timestat_t stats;
127 GArray *ip_ttl_list;
128 gboolean last_hit;
129 guint32 start_ongoing_hits, stop_ongoing_hits, start_packet_nr_first, start_packet_nr_second, stop_packet_nr_first, stop_packet_nr_second;
130 guint32 first_file_amount, second_file_amount;
131 } compstat_t;
133 /* column numbers */
134 enum
136 IP_ID=0,
137 PROBLEM,
138 COUNT,
139 DELTA,
140 COLUMNS
143 /* only one compare window should be open */
144 static gboolean first_window=TRUE;
146 /* allowed variace */
147 static GtkWidget *spin_var_int=NULL;
149 /* start/stop compare */
150 static GtkWidget *spin_start_int, *spin_stop_int;
152 /* to call directly _init */
153 static gdouble compare_variance=0.0;
154 static guint8 compare_start, compare_stop;
155 static gboolean TTL_method=TRUE, ON_method=TRUE;
156 static GtkWidget *radio_TTL, *radio_ON;
158 static void
159 comparestat_set_title(compstat_t *cs)
161 set_window_title(cs->win, "Compare two capture files");
164 /* called when new capture starts, when it rescans the packetlist after some prefs have
165 * changed
167 static void
168 comparestat_reset(void *arg)
170 compstat_t *cs=(compstat_t *)arg;
172 SET_ADDRESS(&cs->eth_src, AT_ETHER, 0, NULL);
173 SET_ADDRESS(&cs->eth_dst, AT_ETHER, 0, NULL);
175 gtk_tree_store_clear(cs->simple_list);
176 comparestat_set_title(cs);
179 /* This callback is invoked whenever the tap system has seen a packet
180 * we might be interested in.
181 * function returns :
182 * 0: no updates, no need to call (*draw) later
183 * !0: state has changed, call (*draw) sometime later
185 static int
186 comparestat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *arg2)
188 compstat_t *cs=(compstat_t *)arg;
189 const ws_ip *ci=(ws_ip *)arg2;
190 frame_info *fInfo, *fInfoTemp;
191 vec_t cksum_vec[3];
192 guint16 computed_cksum=0;
194 /* so this get filled, usually with the first frame */
195 if(cs->eth_dst.len==0) {
196 cs->eth_dst=pinfo->dl_dst;
197 cs->eth_src=pinfo->dl_src;
200 /* Set up the fields of the pseudo-header and create checksum */
201 cksum_vec[0].ptr=&ci->ip_v_hl;
202 cksum_vec[0].len=BYTES;
203 /* skip TTL */
204 cksum_vec[1].ptr=&ci->ip_p;
205 cksum_vec[1].len=1;
206 /* skip header checksum and ip's (because of NAT)*/
207 cksum_vec[2].ptr=(guint8 *)ci->ip_dst.data;
208 cksum_vec[2].ptr=cksum_vec[2].ptr+ci->ip_dst.len;
209 /* dynamic computation */
210 cksum_vec[2].len=ci->ip_len-20;
211 computed_cksum=in_cksum(&cksum_vec[0], 3);
213 /* Set up the new order to create the zebra effect */
214 fInfoTemp=(frame_info *)se_tree_lookup32(cs->packet_tree, pinfo->fd->num);
215 if((fInfoTemp!=NULL)){
216 col_set_time(pinfo->cinfo, COL_INFO, &fInfoTemp->zebra_time, "ZebraTime");
219 /* collect all packet infos */
220 fInfo=(frame_info*)se_alloc(sizeof(frame_info));
221 fInfo->fg=(for_gui*)se_alloc(sizeof(for_gui));
222 fInfo->fg->partner=NULL;
223 fInfo->fg->count=1;
224 fInfo->fg->cksum=computed_cksum;
225 fInfo->num=pinfo->fd->num;
226 fInfo->id=ci->ip_id;
227 fInfo->ip_ttl=ci->ip_ttl;
228 fInfo->dl_dst=pinfo->dl_dst;
229 fInfo->abs_ts=pinfo->fd->abs_ts;
230 /* clean memory */
231 nstime_set_zero(&fInfo->zebra_time);
232 nstime_set_zero(&fInfo->fg->predecessor_time);
233 se_tree_insert32(cs->packet_tree, pinfo->fd->num, fInfo);
235 if(cf_get_packet_count(&cfile)==abs(fInfo->num)){
236 nstime_set_unset(&cs->current_time);
237 return 1;
238 } else {
239 return 0;
243 /* Find equal packets, same IP-Id, count them and make time statistics */
244 static gboolean
245 call_foreach_count_ip_id(gpointer value, gpointer arg)
247 compstat_t *cs=(compstat_t*)arg;
248 frame_info *fInfo=(frame_info*)value, *fInfoTemp;
249 nstime_t delta;
250 guint i;
252 /* we only need one value out of pinfo we use a temp one */
253 packet_info *pinfo=(packet_info*)ep_alloc(sizeof(packet_info));
254 pinfo->fd=(frame_data*)ep_alloc(sizeof(frame_data));
255 pinfo->fd->num = fInfo->num;
257 fInfoTemp=(frame_info *)se_tree_lookup32(cs->ip_id_tree, fInfo->id);
258 if(fInfoTemp==NULL){
259 /* Detect ongoing package loss */
260 if((cs->last_hit==FALSE)&&(cs->start_ongoing_hits>compare_start)&&(cs->stop_ongoing_hits<compare_stop)){
261 cs->stop_ongoing_hits++;
262 cs->stop_packet_nr_first=fInfo->num;
263 } else if(cs->stop_ongoing_hits<compare_stop){
264 cs->stop_ongoing_hits=0;
265 cs->stop_packet_nr_first=G_MAXINT32;
267 cs->last_hit=FALSE;
269 fInfo->fg->count=1;
270 se_tree_insert32(cs->ip_id_tree, fInfo->id, fInfo);
271 } else {
272 /* Detect ongoing package hits, special behavior if start is set to 0 */
273 if((cs->last_hit||(compare_start==0))&&(cs->start_ongoing_hits<compare_start||(compare_start==0))){
274 if((compare_start==0)&&(cs->start_ongoing_hits!=0)){
275 /* start from the first packet so allready set */
276 } else {
277 cs->start_ongoing_hits++;
278 /* Take the lower number */
279 cs->start_packet_nr_first=fInfoTemp->num;
280 cs->start_packet_nr_second=fInfo->num;
282 } else if(cs->start_ongoing_hits<compare_start){
283 cs->start_ongoing_hits=0;
284 cs->start_packet_nr_first=G_MAXINT32;
286 cs->last_hit=TRUE;
288 fInfo->fg->count=fInfoTemp->fg->count + 1;
289 if(fInfoTemp->fg->cksum!=fInfo->fg->cksum){
290 fInfo->fg->cksum=WRONG_CHKSUM;
291 fInfoTemp->fg->cksum=WRONG_CHKSUM;
293 /* Add partner */
294 fInfo->fg->partner=fInfoTemp;
295 /* Create time statistic */
296 if(fInfo->fg->count==MERGED_FILES){
297 nstime_delta(&delta, &fInfo->abs_ts, &fInfoTemp->abs_ts);
298 /* Set delta in both packets */
299 nstime_set_zero(&fInfoTemp->delta);
300 nstime_add(&fInfoTemp->delta, &delta);
301 nstime_set_zero(&fInfo->delta);
302 nstime_add(&fInfo->delta, &delta);
303 time_stat_update(&cs->stats, &delta, pinfo);
305 se_tree_insert32(cs->ip_id_tree, fInfo->id, fInfo);
308 /* collect TTL's */
309 if(TTL_method && (fInfo->num<TTL_SEARCH)){
310 for(i=0; i < cs->ip_ttl_list->len; i++){
311 if(g_array_index(cs->ip_ttl_list, guint8, i) == fInfo->ip_ttl){
312 return FALSE;
315 g_array_append_val(cs->ip_ttl_list, fInfo->ip_ttl);
318 return FALSE;
321 /*Create new numbering in the Info column, to create a zebra effect */
322 static gboolean
323 call_foreach_new_order(gpointer value, gpointer arg)
325 compstat_t *cs=(compstat_t*)arg;
326 frame_info *fInfo=(frame_info*)value, *fInfoTemp;
328 /* overwrite Info column for new ordering */
329 fInfoTemp=(frame_info *)se_tree_lookup32(cs->nr_tree, fInfo->id);
330 if(fInfoTemp==NULL){
331 if(TTL_method==FALSE){
332 if((ADDRESSES_EQUAL(&cs->eth_dst, &fInfo->dl_dst)) || (ADDRESSES_EQUAL(&cs->eth_src, &fInfo->dl_dst))){
333 se_tree_insert32(cs->nr_tree, fInfo->id, fInfo);
334 fInfo->zebra_time=cs->zebra_time;
335 cs->zebra_time.nsecs=cs->zebra_time.nsecs + MERGED_FILES;
336 } else {
337 cs->zebra_time.nsecs++;
338 se_tree_insert32(cs->nr_tree, fInfo->id, fInfo);
339 fInfo->zebra_time=cs->zebra_time;
340 cs->zebra_time.nsecs++;
342 } else {
343 if((g_array_index(cs->ip_ttl_list, guint8, 0)==fInfo->ip_ttl) || (g_array_index(cs->ip_ttl_list, guint8, 1)==fInfo->ip_ttl)){
344 se_tree_insert32(cs->nr_tree, fInfo->id, fInfo);
345 fInfo->zebra_time=cs->zebra_time;
346 cs->zebra_time.nsecs=cs->zebra_time.nsecs + MERGED_FILES;
347 } else {
348 cs->zebra_time.nsecs++;
349 se_tree_insert32(cs->nr_tree, fInfo->id, fInfo);
350 fInfo->zebra_time=cs->zebra_time;
351 cs->zebra_time.nsecs++;
355 } else {
356 if(TTL_method==FALSE){
357 if(((ADDRESSES_EQUAL(&cs->eth_dst, &fInfo->dl_dst)) || (ADDRESSES_EQUAL(&cs->eth_src, &fInfo->dl_dst)))&&(!fmod(fInfoTemp->zebra_time.nsecs,MERGED_FILES))){
358 fInfo->zebra_time.nsecs=fInfoTemp->zebra_time.nsecs;
359 } else {
360 fInfo->zebra_time.nsecs=fInfoTemp->zebra_time.nsecs+1;
362 } else {
363 if(((g_array_index(cs->ip_ttl_list, guint8, 0)==fInfo->ip_ttl) || (g_array_index(cs->ip_ttl_list, guint8, 1)==fInfo->ip_ttl))&&(!fmod(fInfoTemp->zebra_time.nsecs,MERGED_FILES))){
364 fInfo->zebra_time.nsecs=fInfoTemp->zebra_time.nsecs;
365 } else {
366 fInfo->zebra_time.nsecs=fInfoTemp->zebra_time.nsecs+1;
371 /* count packets of file */
372 if(fmod(fInfo->zebra_time.nsecs, MERGED_FILES)){
373 cs->first_file_amount++;
374 } else {
375 cs->second_file_amount++;
378 /* ordering */
379 if(!nstime_is_unset(&cs->current_time)){
380 fInfo->fg->predecessor_time.nsecs=cs->current_time.nsecs;
383 cs->current_time.nsecs=fInfo->zebra_time.nsecs;
385 return FALSE;
388 /* calculate scopes if not set yet */
389 static gboolean
390 call_foreach_merge_settings(gpointer value, gpointer arg)
392 compstat_t *cs=(compstat_t*)arg;
393 frame_info *fInfo=(frame_info*)value, *fInfoTemp=NULL;
394 guint32 tot_packet_amount=cs->first_file_amount+cs->second_file_amount, swap;
396 if((fInfo->num==tot_packet_amount)&&(cs->stop_packet_nr_first!=G_MAXINT32)){
397 /* calculate missing stop number */
398 swap=cs->stop_packet_nr_first;
399 cs->stop_packet_nr_first=tot_packet_amount-cs->second_file_amount;
400 cs->stop_packet_nr_second=swap;
403 if((fInfo->num==tot_packet_amount)&&(cs->stop_packet_nr_first==G_MAXINT32)&&(cs->start_packet_nr_first!=G_MAXINT32)){
404 fInfoTemp=(frame_info *)se_tree_lookup32(cs->packet_tree, cs->start_packet_nr_first);
405 if(fInfoTemp==NULL){
406 fprintf(stderr,"ERROR: Incorrect start number\n");
408 if(fInfoTemp && fmod(fInfoTemp->zebra_time.nsecs, 2)){
409 /*first file*/
410 cs->stop_packet_nr_first=cs->start_packet_nr_first+abs(cs->second_file_amount-(cs->start_packet_nr_second-cs->first_file_amount));
411 if(cs->stop_packet_nr_first>(tot_packet_amount-cs->second_file_amount)){
412 cs->stop_packet_nr_first=tot_packet_amount-cs->second_file_amount;
414 /*this only happens if we have too many MAC's or TTL*/
415 if(cs->stop_packet_nr_first>cs->start_packet_nr_second){
416 cs->stop_packet_nr_first=cs->start_packet_nr_second-1;
418 fInfoTemp=(frame_info *)se_tree_lookup32(cs->packet_tree, cs->stop_packet_nr_first);
419 while((fInfoTemp!=NULL)?fmod(!fInfoTemp->zebra_time.nsecs, 2):TRUE){
420 cs->stop_packet_nr_first--;
421 fInfoTemp=(frame_info *)se_tree_lookup32(cs->packet_tree, cs->stop_packet_nr_first);
423 } else {
424 /*this only happens if we have too many MAC's or TTL*/
425 cs->stop_packet_nr_first=cs->first_file_amount+cs->start_packet_nr_first;
426 if(cs->stop_packet_nr_first>tot_packet_amount-cs->first_file_amount){
427 cs->stop_packet_nr_first=tot_packet_amount-cs->first_file_amount;
429 fInfoTemp=(frame_info *)se_tree_lookup32(cs->packet_tree, cs->stop_packet_nr_first);
430 while((fInfoTemp!=NULL)?fmod(fInfoTemp->zebra_time.nsecs, 2):TRUE){
431 cs->stop_packet_nr_first--;
432 fInfoTemp=(frame_info *)se_tree_lookup32(cs->packet_tree, cs->stop_packet_nr_first);
435 /* set second stop location */
436 cs->stop_packet_nr_second=cs->start_packet_nr_second+abs(cs->stop_packet_nr_first-cs->start_packet_nr_first);
437 if(cs->stop_packet_nr_second>tot_packet_amount){
438 cs->stop_packet_nr_second=tot_packet_amount;
442 /* no start found */
443 if(fInfo->num==tot_packet_amount&&compare_start!=0&&compare_stop!=0){
444 if(cs->start_packet_nr_first==G_MAXINT32){
445 report_failure("Start point couldn't be set. Please choose a lower start number.");
449 return FALSE;
453 /* build gtk-tree of lost, delayed, checksum error and wrong order Packets*/
454 static gboolean
455 call_foreach_print_ip_tree(gpointer value, gpointer user_data)
457 frame_info *fInfo=(frame_info*)value;
458 compstat_t *cs=(compstat_t*)user_data;
459 gdouble delta, average;
460 gboolean show_it=FALSE;
462 delta=fabs(get_average(&fInfo->delta,1));
463 average=fabs(get_average(&cs->stats.tot, cs->stats.num));
465 /* special case if both are set to zero ignore start and stop numbering */
466 if(compare_start!=0&&compare_stop!=0){
467 /* check out if packet is in searched scope */
468 if((cs->start_packet_nr_first<fInfo->num)&&(cs->stop_packet_nr_first>fInfo->num)){
469 show_it=TRUE;
470 } else {
471 /* so we won't miss the other file */
472 if((fInfo->num>cs->start_packet_nr_second)&&(fInfo->num<cs->stop_packet_nr_second)){
473 show_it=TRUE;
476 } else {
477 show_it=TRUE;
480 /* Create the gtk tree */
481 if(show_it){
482 if((fInfo->fg->count<MERGED_FILES)){
483 gtk_tree_store_append(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, NULL);
484 gtk_tree_store_set(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, IP_ID, fInfo->id, PROBLEM, "Lost packet", COUNT, fInfo->fg->count, DELTA, 0.0, -1);
487 if(fInfo->fg->count > MERGED_FILES){
488 gtk_tree_store_append(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, NULL);
489 gtk_tree_store_set(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, IP_ID, fInfo->id, PROBLEM, "More than two packets", COUNT, fInfo->fg->count, DELTA, 0.0, -1);
490 if(fInfo->fg->cksum == WRONG_CHKSUM) {
491 gtk_tree_store_append(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->child, &cs->iter);
492 gtk_tree_store_set(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->child, IP_ID, fInfo->id, PROBLEM, "IP header checksum incorrect", COUNT, fInfo->fg->count, DELTA, 0.0, -1);
495 if(fInfo->fg->count == MERGED_FILES){
496 if(fInfo->fg->cksum == WRONG_CHKSUM) {
497 gtk_tree_store_append(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, NULL);
498 gtk_tree_store_set(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, IP_ID, fInfo->id, PROBLEM, "IP header checksum incorrect", COUNT, fInfo->fg->count, DELTA, delta, -1);
499 if(((delta < (average-cs->stats.variance)) || (delta > (average+cs->stats.variance))) && (delta > 0.0) && (cs->stats.variance!=0)){
500 gtk_tree_store_append(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->child, &cs->iter);
501 gtk_tree_store_set(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->child, IP_ID, fInfo->id, PROBLEM, "Late arrival", COUNT, fInfo->fg->count, DELTA, delta, -1);
503 if((nstime_cmp(&fInfo->fg->predecessor_time, &fInfo->zebra_time)>0||nstime_cmp(&fInfo->fg->partner->fg->predecessor_time, &fInfo->fg->partner->zebra_time)>0) && (fInfo->zebra_time.nsecs!=MERGED_FILES) && ON_method){
504 gtk_tree_store_append(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->child, &cs->iter);
505 gtk_tree_store_set(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->child, IP_ID, fInfo->id, PROBLEM, "Out of order", COUNT, fInfo->fg->count, DELTA, delta, -1);
507 } else if(((delta < (average-cs->stats.variance)) || (delta > (average+cs->stats.variance))) && (delta > 0.0) && (cs->stats.variance!=0)) {
508 gtk_tree_store_append(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, NULL);
509 gtk_tree_store_set(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, IP_ID, fInfo->id, PROBLEM, "Late arrival", COUNT, fInfo->fg->count, DELTA, delta, -1);
510 if((nstime_cmp(&fInfo->fg->predecessor_time, &fInfo->zebra_time)>0||nstime_cmp(&fInfo->fg->partner->fg->predecessor_time, &fInfo->fg->partner->zebra_time)>0) && fInfo->zebra_time.nsecs != MERGED_FILES && ON_method){
511 gtk_tree_store_append(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->child, &cs->iter);
512 gtk_tree_store_set(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->child, IP_ID, fInfo->id, PROBLEM, "Out of order", COUNT, fInfo->fg->count, DELTA, delta, -1);
514 } else if((nstime_cmp(&fInfo->fg->predecessor_time, &fInfo->zebra_time)>0||nstime_cmp(&fInfo->fg->partner->fg->predecessor_time, &fInfo->fg->partner->zebra_time)>0) && fInfo->zebra_time.nsecs != MERGED_FILES && ON_method){
515 gtk_tree_store_append(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, NULL);
516 gtk_tree_store_set(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, IP_ID, fInfo->id, PROBLEM, "Out of order", COUNT, fInfo->fg->count, DELTA, delta, -1);
520 return FALSE;
523 static void
524 win_destroy_cb(GtkWindow *win _U_, gpointer data)
526 compstat_t *cs=(compstat_t *)data;
528 remove_tap_listener(cs);
530 first_window=TRUE;
531 gtk_tree_store_clear(cs->simple_list);
532 g_free(cs);
535 /* this may be called any time, perhaps once every 3 seconds or so.
537 static void
538 comparestat_draw(void *arg)
540 compstat_t *cs = (compstat_t *)arg;
541 GString *filter_str = g_string_new("");
542 const gchar *statis_string;
543 frame_info *fInfo;
544 guint32 first_file_amount, second_file_amount;
546 /* inital steps, clear all data before start*/
547 cs->zebra_time.secs=0;
548 cs->zebra_time.nsecs=1;
549 nstime_set_unset(&cs->current_time);
550 cs->ip_ttl_list=g_array_new(FALSE, FALSE, sizeof(guint8));
551 cs->last_hit=FALSE;
552 cs->start_ongoing_hits=0;
553 cs->stop_ongoing_hits=0;
554 cs->start_packet_nr_first=G_MAXINT32;
555 cs->start_packet_nr_second=G_MAXINT32;
556 cs->stop_packet_nr_first=G_MAXINT32;
557 cs->stop_packet_nr_second=G_MAXINT32;
558 cs->first_file_amount=0;
559 cs->second_file_amount=0;
561 time_stat_init(&cs->stats);
563 /* no need to do anything no file is open*/
564 if(cf_get_packet_count(&cfile)==0){
565 /* add statistic string */
566 statis_string=g_strdup_printf("No file open");
567 gtk_label_set_text((GtkLabel *) cs->statis_label, statis_string);
568 return;
571 /* not using g_free, because struct is managed by se binarytrees */
572 cs->ip_id_tree=se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "ip_id_tree");
573 emem_tree_foreach(cs->packet_tree, call_foreach_count_ip_id, cs);
575 /* set up TTL choice if only one number found */
576 if(TTL_method&&cs->ip_ttl_list->len==1){
577 g_array_append_val(cs->ip_ttl_list, g_array_index(cs->ip_ttl_list, guint8, 1));
580 emem_tree_foreach(cs->packet_tree, call_foreach_new_order,cs);
581 emem_tree_foreach(cs->packet_tree, call_foreach_merge_settings, cs);
583 /* remembering file amounts */
584 first_file_amount=cs->first_file_amount;
585 second_file_amount=cs->second_file_amount;
586 /* reset after numbering */
587 cs->nr_tree=se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "nr_tree");
588 /* microsecond precision for Info column*/
589 timestamp_set_precision(TS_PREC_AUTO_NSEC);
590 /* reset ordering */
591 nstime_set_unset(&cs->current_time);
593 /* set color filter, in Routing environment */
594 if(TTL_method&&cs->ip_ttl_list->len!=0){
595 g_string_printf(filter_str, "%s %i %s %i", "ip.ttl ==", g_array_index(cs->ip_ttl_list, guint8, 0), "|| ip.ttl ==", g_array_index(cs->ip_ttl_list, guint8, 1));
596 } else if(cs->eth_dst.len!=0&&cs->eth_src.len!=0){
597 g_string_printf(filter_str, "%s %s %s %s", "eth.dst==", ep_address_to_str(&cs->eth_dst), "|| eth.dst==", ep_address_to_str(&cs->eth_src));
599 color_filters_set_tmp(COLOR_N, filter_str->str, FALSE);
600 packet_list_colorize_packets();
601 /* Variance */
602 cs->stats.variance=compare_variance;
604 /* add statistic string */
605 statis_string=g_strdup_printf("Compare Statistics: \nNumber of packets total:%i 1st file:%i, 2nd file:%i\nScopes:\t start:%i stop:%i\nand:\t start:%i stop:%i\nEqual packets: %i \nAllowed variation: %f \nAverage time difference: %f", cf_get_packet_count(&cfile), first_file_amount, second_file_amount, cs->start_packet_nr_first, cs->stop_packet_nr_first, cs->start_packet_nr_second, cs->stop_packet_nr_second, cs->stats.num, cs->stats.variance, fabs(get_average(&cs->stats.tot, cs->stats.num)));
606 gtk_label_set_text((GtkLabel *) cs->statis_label, statis_string);
608 /* add start and stop of scanning */
609 if(cs->start_packet_nr_first!=G_MAXINT32&&compare_start!=0&&compare_stop!=0){
610 fInfo=(frame_info *)se_tree_lookup32(cs->packet_tree, cs->start_packet_nr_first);
611 if(fInfo){
612 gtk_tree_store_append(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, NULL);
613 gtk_tree_store_set(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, IP_ID, fInfo->id, PROBLEM, "Start scanning", COUNT, 0, DELTA, 0.0, -1);
616 if(cs->stop_packet_nr_first!=G_MAXINT32&&compare_start!=0&&compare_stop!=0){
617 fInfo=(frame_info *)se_tree_lookup32(cs->packet_tree, cs->stop_packet_nr_first);
618 if(fInfo){
619 gtk_tree_store_append(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, NULL);
620 gtk_tree_store_set(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cs->treeview))), &cs->iter, IP_ID, fInfo->id, PROBLEM, "Stop scanning", COUNT, 0, DELTA, 0.0, -1);
624 emem_tree_foreach(cs->ip_id_tree, call_foreach_print_ip_tree, cs);
625 g_string_free(filter_str, TRUE);
626 g_array_free(cs->ip_ttl_list, TRUE);
629 /* called when a tree row is (un)selected in the popup window */
630 static void
631 new_tree_view_selection_changed(GtkTreeSelection *sel, gpointer user_data)
633 gchar *problem;
634 GtkTreeModel *model;
635 GtkTreeIter iter;
636 frame_info *fInfo;
637 /* Because it could be zero */
638 gint id=-1;
640 compstat_t *cs=(compstat_t*)user_data;
642 /* if something is selected */
643 if(gtk_tree_selection_get_selected(sel, &model, &iter)){
644 gtk_tree_model_get(model, &iter, 0, &id, 1, &problem, -1);
645 if (id<0) return;
646 /* The id is not enough to find the start or the end packet */
647 if(strcmp("Start scanning",problem)==0){
648 cf_goto_frame(&cfile, cs->start_packet_nr_first);
649 return;
651 if(strcmp("Stop scanning",problem)==0){
652 cf_goto_frame(&cfile, cs->stop_packet_nr_first);
653 return;
655 fInfo=(frame_info *)se_tree_lookup32(cs->ip_id_tree, id);
656 if(fInfo != NULL){
657 cf_goto_frame(&cfile, fInfo->num);
663 /* add three columns to the GtkTreeView. All three of the columns will be
664 * displayed as text*/
665 static void
666 setup_tree_view(GtkWidget *treeview)
668 GtkCellRenderer *renderer;
669 GtkTreeViewColumn *column;
670 /* Create a new GtkCellRendererText, add it to the tree view column and
671 * append the column to the tree view. */
672 renderer=gtk_cell_renderer_text_new ();
673 column=gtk_tree_view_column_new_with_attributes("IP ID", renderer, "text", IP_ID, NULL);
674 gtk_tree_view_append_column(GTK_TREE_VIEW (treeview), column);
675 renderer=gtk_cell_renderer_text_new ();
676 column=gtk_tree_view_column_new_with_attributes("Problem", renderer, "text", PROBLEM, NULL);
677 gtk_tree_view_append_column(GTK_TREE_VIEW (treeview), column);
678 renderer=gtk_cell_renderer_text_new ();
679 column=gtk_tree_view_column_new_with_attributes("Count", renderer, "text", COUNT, NULL);
680 gtk_tree_view_append_column(GTK_TREE_VIEW (treeview), column);
681 renderer=gtk_cell_renderer_text_new ();
682 column=gtk_tree_view_column_new_with_attributes("Delta", renderer, "text", DELTA, NULL);
683 gtk_tree_view_append_column(GTK_TREE_VIEW (treeview), column);
686 /* when called, this function will create a new instance of gtk2-comparestat.
688 static void
689 gtk_comparestat_init(const char *opt_arg, void* userdata _U_)
691 compstat_t *cs;
692 char *display_name;
693 char *title_string;
694 char *filter_string;
695 GtkWidget *stat_label;
696 GtkWidget *filter_label;
697 GtkWidget *bbox;
698 GtkWidget *close_bt;
699 GtkWidget *help_bt;
700 GtkWidget *vbox;
701 gdouble variance;
702 gint start, stop,ttl, order, pos=0;
703 const char *filter=NULL;
704 GString *error_string;
706 if(sscanf(opt_arg,"compare,%d,%d,%d,%d,%lf%n",&start, &stop, &ttl, &order, &variance, &pos)==5){
707 if(pos){
708 if(*(opt_arg+pos)==',')
709 filter=opt_arg+pos+1;
710 else
711 filter=opt_arg+pos;
712 } else {
713 filter=NULL;
715 } else {
716 fprintf(stderr, "wireshark: invalid \"-z compare,<start>,<stop>,<ttl[0|1]>,<order[0|1]>,<variance>[,<filter>]\" argument\n");
717 exit(1);
720 compare_variance=variance;
721 compare_start=start;
722 compare_stop=stop;
723 TTL_method=ttl;
724 ON_method=order;
726 cs=(compstat_t *)g_malloc(sizeof(compstat_t));
727 nstime_set_unset(&cs->current_time);
728 cs->ip_ttl_list=g_array_new(FALSE, FALSE, sizeof(guint8));
729 cs->last_hit=FALSE;
730 cs->start_ongoing_hits=0;
731 cs->stop_ongoing_hits=0;
732 cs->start_packet_nr_first=G_MAXINT32;
733 cs->start_packet_nr_second=G_MAXINT32;
734 cs->stop_packet_nr_first=G_MAXINT32;
735 cs->stop_packet_nr_second=G_MAXINT32;
736 cs->first_file_amount=0;
737 cs->second_file_amount=0;
739 cs->zebra_time.secs=0;
740 cs->zebra_time.nsecs=1;
741 cs->nr_tree=se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "nr_tree");
742 /* microsecond precision */
743 timestamp_set_precision(TS_PREC_AUTO_NSEC);
745 /* transient_for top_level */
746 cs->win=dlg_window_new("compare-stat");
747 gtk_window_set_destroy_with_parent (GTK_WINDOW(cs->win), TRUE);
748 gtk_window_set_default_size(GTK_WINDOW(cs->win), 550, 400);
749 comparestat_set_title(cs);
751 vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
752 gtk_container_add(GTK_CONTAINER(cs->win), vbox);
753 gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
755 display_name = cf_get_display_name(&cfile);
756 title_string = g_strdup_printf("Compare two capture files: %s", display_name);
757 g_free(display_name);
758 stat_label=gtk_label_new(title_string);
759 g_free(title_string);
760 gtk_box_pack_start(GTK_BOX(vbox), stat_label, FALSE, FALSE, 0);
762 filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
763 filter_label=gtk_label_new(filter_string);
764 g_free(filter_string);
765 gtk_label_set_line_wrap(GTK_LABEL(filter_label), TRUE);
766 gtk_box_pack_start(GTK_BOX(vbox), filter_label, FALSE, FALSE, 0);
768 /* add statistik info to Window */
769 cs->statis_label=gtk_label_new("Statistics:");
770 gtk_label_set_line_wrap(GTK_LABEL(cs->statis_label), TRUE);
771 gtk_box_pack_start(GTK_BOX(vbox), cs->statis_label, FALSE, FALSE, 0);
773 /* we must display TOP LEVEL Widget before calling simple_list_new */
774 gtk_widget_show_all(cs->win);
776 cs->treeview=gtk_tree_view_new();
777 setup_tree_view(cs->treeview);
779 /* create a newtree model with four columns */
780 cs->simple_list=gtk_tree_store_new(COLUMNS, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT, G_TYPE_DOUBLE);
782 /* add the tree model to the tree view and unreference it so that the model will
783 * be destroyed along with the tree view. */
784 gtk_tree_view_set_model(GTK_TREE_VIEW (cs->treeview), GTK_TREE_MODEL (cs->simple_list));
785 g_object_unref(cs->simple_list);
787 /* call this method when row is chosen*/
788 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(cs->treeview)),GTK_SELECTION_SINGLE);
789 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(cs->treeview)), "changed", G_CALLBACK(new_tree_view_selection_changed), cs);
791 /* list with scrollbar's */
792 cs->scrolled_win=gtk_scrolled_window_new(NULL, NULL);
793 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(cs->scrolled_win), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
794 gtk_container_add(GTK_CONTAINER(cs->scrolled_win), cs->treeview);
795 gtk_box_pack_start(GTK_BOX(vbox), cs->scrolled_win, TRUE, TRUE, 0);
797 /* create a Hash to count the packets with the same ip.id */
798 cs->packet_tree=se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "Packet_info_tree");
800 error_string=register_tap_listener("ip", cs, filter, 0, comparestat_reset, comparestat_packet, comparestat_draw);
801 if(error_string){
802 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
803 g_string_free(error_string, TRUE);
804 gtk_tree_store_clear(cs->simple_list);
805 g_free(cs);
806 return;
809 /* button row. */
810 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
811 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
813 close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
814 window_set_cancel_button(cs->win, close_bt, window_cancel_button_cb);
816 help_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
817 g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_STATS_COMPARE_FILES_DIALOG);
819 g_signal_connect(cs->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
820 g_signal_connect(cs->win, "destroy", G_CALLBACK(win_destroy_cb), cs);
822 gtk_widget_show_all(cs->win);
823 window_present(cs->win);
825 cf_retap_packets(&cfile);
828 static GtkWidget *dlg=NULL;
829 static GtkWidget *filter_entry;
831 static void
832 comparestat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_)
834 GString *str;
835 const char *filter;
837 compare_start=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin_start_int));
838 compare_stop=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin_stop_int));
839 compare_variance=gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin_var_int));
840 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_TTL))){
841 TTL_method=TRUE;
842 } else {
843 TTL_method=FALSE;
845 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_ON))){
846 ON_method=TRUE;
847 } else {
848 ON_method=FALSE;
851 str = g_string_new("compare");
852 g_string_append_printf(str, ",%d,%d,%d,%d,%lf",compare_start, compare_stop, TTL_method, ON_method, compare_variance);
853 filter=gtk_entry_get_text(GTK_ENTRY(filter_entry));
854 if(filter[0]!=0){
855 g_string_append_printf(str, ",%s", filter);
858 if(first_window){
859 first_window = FALSE;
860 gtk_comparestat_init(str->str,NULL);
861 } else {
862 report_failure("cannot open more than one compare of the same type at once");
865 g_string_free(str, TRUE);
868 static void
869 dlg_destroy_cb(GtkWidget *w _U_, gpointer user_data _U_)
871 dlg=NULL;
874 /* create and show first view of this module
876 void
877 gtk_comparestat_cb(GtkAction *action _U_, gpointer user_data _U_)
879 GtkAdjustment *start_integer, *stop_integer, *var_integer;
880 GtkWidget *dlg_box;
881 GtkWidget *spin_start_label, *spin_stop_label, *spin_start_box, *spin_stop_box;
882 GtkWidget *spin_var_box, *spin_var_label;
883 GtkWidget *order_box, *radio_MAC, *order_label;
884 GtkWidget *differ_box, *radio_OFF, *differ_label;
885 GtkWidget *filter_box, *filter_bt;
886 GtkWidget *bbox, *start_button, *cancel_button;
887 const char *filter;
888 static construct_args_t args = {
889 "Compare statistics",
890 TRUE,
891 FALSE,
892 FALSE
895 /* if the window is already open, bring it to front */
896 if(dlg){
897 gdk_window_raise(gtk_widget_get_window(dlg));
898 return;
901 dlg=dlg_window_new("Wireshark: Compare two capture files");
902 gtk_window_set_default_size(GTK_WINDOW(dlg), 300, -1);
904 dlg_box=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 10, FALSE);
905 gtk_container_set_border_width(GTK_CONTAINER(dlg_box), 10);
906 gtk_container_add(GTK_CONTAINER(dlg), dlg_box);
907 gtk_widget_show(dlg_box);
909 /* spin Box */
910 spin_start_box=ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10, FALSE);
911 spin_stop_box=ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10, FALSE);
913 /* spin label */
914 gtk_container_set_border_width(GTK_CONTAINER(spin_start_box), 1);
915 spin_start_label=gtk_label_new("Start compare:");
916 gtk_box_pack_start(GTK_BOX(spin_start_box), spin_start_label, FALSE, FALSE, 0);
917 gtk_widget_show(spin_start_label);
918 gtk_container_set_border_width(GTK_CONTAINER(spin_stop_box), 1);
919 spin_stop_label=gtk_label_new("Stop compare: ");
920 gtk_box_pack_start(GTK_BOX(spin_stop_box), spin_stop_label, FALSE, FALSE, 0);
921 gtk_widget_show(spin_stop_label);
923 /* create adjustments. Spans between 0 and 100, starting at 0 and
924 * moves in increments of 1 */
925 start_integer=GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 5.0, 0.0));
926 stop_integer=GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 5.0, 0.0));
928 /* create spin button. Not displaying decimal */
929 spin_start_int=gtk_spin_button_new(start_integer, 1.0, 0);
930 spin_stop_int=gtk_spin_button_new(stop_integer, 1.0, 0);
932 /* pack it up */
933 gtk_box_pack_start(GTK_BOX(spin_start_box), spin_start_int, TRUE, TRUE, 0);
934 gtk_box_pack_start(GTK_BOX(spin_stop_box), spin_stop_int, TRUE, TRUE, 0);
936 gtk_box_pack_start(GTK_BOX(dlg_box), spin_start_box, FALSE, FALSE, 0);
937 gtk_widget_show(spin_start_box);
938 gtk_box_pack_start(GTK_BOX(dlg_box), spin_stop_box, FALSE, FALSE, 0);
939 gtk_widget_show(spin_stop_box);
941 /* differ Box */
942 differ_box=ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10, FALSE);
944 /* radio label */
945 gtk_container_set_border_width(GTK_CONTAINER(differ_box), 1);
946 differ_label=gtk_label_new("Endpoint distinction:");
947 gtk_box_pack_start(GTK_BOX(differ_box), differ_label, FALSE, FALSE, 0);
948 gtk_widget_show(differ_label);
950 /* create radio buttons */
951 radio_MAC=gtk_radio_button_new_with_label (NULL, "MAC");
952 radio_TTL=gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON(radio_MAC), "TTL");
953 gtk_box_pack_start(GTK_BOX(differ_box), radio_MAC, TRUE, TRUE, 0);
954 gtk_box_pack_start(GTK_BOX(differ_box), radio_TTL, TRUE, TRUE, 0);
955 gtk_widget_show(radio_MAC);
956 gtk_widget_show(radio_TTL);
958 gtk_box_pack_start(GTK_BOX(dlg_box), differ_box, FALSE, FALSE, 0);
959 gtk_widget_show(differ_box);
961 /* order Box */
962 order_box=ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10, FALSE);
964 /* order label */
965 gtk_container_set_border_width(GTK_CONTAINER(order_box), 1);
966 order_label=gtk_label_new("Check order: ");
967 gtk_box_pack_start(GTK_BOX(order_box), order_label, FALSE, FALSE, 0);
968 gtk_widget_show(order_label);
970 /* create radio buttons */
971 radio_ON=gtk_radio_button_new_with_label (NULL, "On");
972 radio_OFF=gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON(radio_ON), "Off");
973 gtk_box_pack_start(GTK_BOX(order_box), radio_ON, TRUE, TRUE, 0);
974 gtk_box_pack_start(GTK_BOX(order_box), radio_OFF, TRUE, TRUE, 0);
975 gtk_widget_show(radio_ON);
976 gtk_widget_show(radio_OFF);
978 gtk_box_pack_start(GTK_BOX(dlg_box), order_box, FALSE, FALSE, 0);
979 gtk_widget_show(order_box);
981 /* spin box */
982 spin_var_box=ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10, FALSE);
984 /* spin label */
985 gtk_container_set_border_width(GTK_CONTAINER(spin_var_box), 1);
986 spin_var_label=gtk_label_new("Time variance (sec +/-):");
987 gtk_box_pack_start(GTK_BOX(spin_var_box), spin_var_label, FALSE, FALSE, 0);
988 gtk_widget_show(spin_var_label);
990 /* create adjustments. Spans between 0 and 100, starting at 0 and
991 * moves in increments of 1 */
992 var_integer=GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 5.0, 0.0));
994 /* create spin button. Not displaying decimal */
995 spin_var_int=gtk_spin_button_new(var_integer, 0.0, 2);
997 /* pack it up */
998 gtk_box_pack_start(GTK_BOX(spin_var_box), spin_var_int, TRUE, TRUE, 0);
999 gtk_widget_show(spin_var_int);
1001 gtk_box_pack_start(GTK_BOX(dlg_box), spin_var_box, FALSE, FALSE, 0);
1002 gtk_widget_show(spin_var_box);
1004 /* filter box */
1005 filter_box=ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
1007 /* filter label */
1008 filter_bt=gtk_button_new_from_stock(WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY);
1009 g_signal_connect(filter_bt, "clicked", G_CALLBACK(display_filter_construct_cb), &args);
1010 gtk_box_pack_start(GTK_BOX(filter_box), filter_bt, FALSE, TRUE, 0);
1011 gtk_widget_show(filter_bt);
1013 /* filter entry */
1014 filter_entry=gtk_entry_new();
1015 g_signal_connect(filter_entry, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
1016 g_object_set_data(G_OBJECT(filter_box), E_FILT_AUTOCOMP_PTR_KEY, NULL);
1017 g_signal_connect(filter_entry, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
1018 g_signal_connect(dlg, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
1020 /* filter prefs dialog */
1021 g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_entry);
1022 /* filter prefs dialog */
1024 gtk_box_pack_start(GTK_BOX(filter_box), filter_entry, TRUE, TRUE, 0);
1025 filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
1026 if(filter){
1027 gtk_entry_set_text(GTK_ENTRY(filter_entry), filter);
1029 gtk_widget_show(filter_entry);
1031 gtk_box_pack_start(GTK_BOX(dlg_box), filter_box, TRUE, TRUE, 0);
1032 gtk_widget_show(filter_box);
1034 /* button box */
1035 bbox = dlg_button_row_new(WIRESHARK_STOCK_CREATE_STAT, GTK_STOCK_CANCEL, NULL);
1036 gtk_box_pack_start(GTK_BOX(dlg_box), bbox, FALSE, FALSE, 0);
1037 gtk_widget_show(bbox);
1039 start_button = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CREATE_STAT);
1040 g_signal_connect_swapped(start_button, "clicked", G_CALLBACK(comparestat_start_button_clicked), NULL);
1042 cancel_button = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
1043 window_set_cancel_button(dlg, cancel_button, window_cancel_button_cb);
1045 /* give the initial focus to the "filter" entry box. */
1046 gtk_widget_grab_focus(filter_entry);
1048 gtk_widget_grab_default(start_button );
1050 g_signal_connect(dlg, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
1051 g_signal_connect(dlg, "destroy", G_CALLBACK(dlg_destroy_cb), NULL);
1053 gtk_widget_show_all(dlg);
1054 window_present(dlg);
1058 void
1059 register_tap_listener_gtkcomparestat(void)
1061 register_stat_cmd_arg("compare", gtk_comparestat_init, NULL);