Ethereal-dev: [Ethereal-dev] Voip graph patch
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Alejandro Vaquero <alejandrovaquero@xxxxxxxxx>
Date: Tue, 05 Jul 2005 13:36:03 -0600
Hi All,Find attached a patch for multiple small fixes for the Voip Analysis tool: - avoid the clist of the calls dlg to be refreshed multiple times when first appear.
- destroy the Graph window when the data is not valid anymore. - fixes an H245 packet count error - resizing the Graph windows when is displayed (up to 5 columns). Regards Alejandro
Index: gtk/voip_calls_dlg.c =================================================================== --- gtk/voip_calls_dlg.c (revision 14849) +++ gtk/voip_calls_dlg.c (working copy) @@ -89,9 +89,11 @@ static guint32 calls_nb = 0; /* number of displayed calls */ static guint32 calls_ns = 0; /* number of selected calls */ -static graph_analysis_data_t *graph_analysis_data; +static graph_analysis_data_t *graph_analysis_data = NULL; #define NUM_COLS 9 +static const GdkColor COLOR_SELECT = {0, 0x00ff, 0x80ff, 0x80ff}; +static const GdkColor COLOR_DEFAULT = {0, 0xffff, 0xffff, 0xffff}; /****************************************************************************/ /* append a line to clist */ @@ -105,10 +107,12 @@ isup_calls_info_t *tmp_isupinfo; h323_calls_info_t *tmp_h323info; gboolean tmp_bool = FALSE; + GdkColor color = COLOR_SELECT; for (c=0;c<NUM_COLS;c++){ data[c]=&field[c][0]; } +/* strinfo->selected = FALSE;*/ g_snprintf(field[0], 15, "%i.%2i", strinfo->start_sec, strinfo->start_usec/10000); g_snprintf(field[1], 15, "%i.%2i", strinfo->stop_sec, strinfo->stop_usec/10000); @@ -144,6 +148,12 @@ added_row = gtk_clist_append(GTK_CLIST(clist), data); + /* set the background color if selected */ + if (strinfo->selected) { + calls_ns++; + gtk_clist_set_background(GTK_CLIST(clist), added_row, &color); + } + /* set data pointer of last row to point to user data for that row */ gtk_clist_set_row_data(GTK_CLIST(clist), added_row, strinfo); @@ -197,10 +207,12 @@ voip_calls_remove_tap_listener(); /* Clean up memory used by calls tap */ - voip_calls_reset((voip_calls_tapinfo_t*) voip_calls_get_info()); + voip_calls_dlg_reset(NULL); /* Note that we no longer have a "VoIP Calls" dialog box. */ voip_calls_dlg = NULL; + + graph_analysis_data = NULL; } @@ -379,9 +391,6 @@ graph_analysis_update(graph_analysis_data); /* refresh it */ } -static const GdkColor COLOR_SELECT = {0, 0x00ff, 0x80ff, 0x80ff}; -static const GdkColor COLOR_DEFAULT = {0, 0xffff, 0xffff, 0xffff}; - /****************************************************************************/ /* when the user selects a row in the calls list */ static void @@ -396,6 +405,9 @@ selected_call_fwd = gtk_clist_get_row_data(GTK_CLIST(clist), row); + if (selected_call_fwd==NULL) + return; + if (!selected_call_fwd->selected) calls_ns++; else @@ -424,11 +436,15 @@ color = COLOR_DEFAULT; gtk_clist_set_background(GTK_CLIST(clist), row, &color); - - /*gtk_widget_set_sensitive(bt_unselect, TRUE);*/ - gtk_widget_set_sensitive(bt_filter, TRUE); - gtk_widget_set_sensitive(bt_graph, TRUE); + if (calls_ns > 0) { + gtk_widget_set_sensitive(bt_filter, TRUE); + gtk_widget_set_sensitive(bt_graph, TRUE); + } else { + gtk_widget_set_sensitive(bt_filter, FALSE); + gtk_widget_set_sensitive(bt_graph, FALSE); + } + /* TODO: activate other buttons when implemented */ } @@ -665,26 +681,27 @@ void voip_calls_dlg_update(GList *list) { gchar label_text[256]; -guint foo; if (voip_calls_dlg != NULL) { - gtk_clist_clear(GTK_CLIST(clist)); calls_nb = 0; calls_ns = 0; - g_snprintf(label_text, 256, - "Total: Calls: %d Start packets: %d Completed calls: %d Rejected calls: %d", - g_list_length(voip_calls_get_info()->strinfo_list), - voip_calls_get_info()->start_packets, - voip_calls_get_info()->completed_calls, - voip_calls_get_info()->rejected_calls); - gtk_label_set(GTK_LABEL(status_label), label_text); - foo= g_list_length(list); + g_snprintf(label_text, 256, + "Total: Calls: %d Start packets: %d Completed calls: %d Rejected calls: %d", + g_list_length(voip_calls_get_info()->strinfo_list), + voip_calls_get_info()->start_packets, + voip_calls_get_info()->completed_calls, + voip_calls_get_info()->rejected_calls); + gtk_label_set(GTK_LABEL(status_label), label_text); + + gtk_clist_freeze(GTK_CLIST(clist)); + gtk_clist_clear(GTK_CLIST(clist)); list = g_list_first(list); while (list) { add_to_clist((voip_calls_info_t*)(list->data)); list = g_list_next(list); } + gtk_clist_thaw(GTK_CLIST(clist)); g_snprintf(label_text, 256, "Detected %d VoIP %s. Selected %d %s.", @@ -693,8 +710,6 @@ calls_ns, plurality(calls_ns, "Call", "Calls")); gtk_label_set(GTK_LABEL(top_label), label_text); - - voip_calls_on_unselect(NULL, NULL); } last_list = list; @@ -705,7 +720,10 @@ /* draw function for tap listeners to keep the window up to date */ void voip_calls_dlg_draw(void *ptr _U_) { - voip_calls_dlg_update(voip_calls_get_info()->strinfo_list); + if (voip_calls_get_info()->redraw) { + voip_calls_dlg_update(voip_calls_get_info()->strinfo_list); + voip_calls_get_info()->redraw = FALSE; + } } /* reset function for tap listeners to clear window, if necessary */ @@ -713,14 +731,29 @@ { /* Clean up memory used by calls tap */ voip_calls_reset((voip_calls_tapinfo_t*) voip_calls_get_info()); + + /* close the graph window if open */ + if (graph_analysis_data->dlg.window != NULL) { + window_cancel_button_cb(NULL, graph_analysis_data->dlg.window); + graph_analysis_data->dlg.window = NULL; + } } /* init function for tap */ static void voip_calls_init_tap(char *dummy _U_) { - graph_analysis_data_init(); + gint c; + gchar *data[NUM_COLS]; + gchar field[NUM_COLS][50]; + if (graph_analysis_data == NULL) { + graph_analysis_data_init(); + /* init the Graph Analysys */ + graph_analysis_data = graph_analysis_init(); + graph_analysis_data->graph_info = voip_calls_get_info()->graph_analysis; + } + /* Clean up memory used by calls tap */ voip_calls_reset((voip_calls_tapinfo_t*) voip_calls_get_info()); @@ -739,10 +772,6 @@ mgcp_calls_init_tap(); } actrace_calls_init_tap(); - - /* init the Graph Analysys */ - graph_analysis_data = graph_analysis_init(); - graph_analysis_data->graph_info = voip_calls_get_info()->graph_analysis; /* create dialog box if necessary */ if (voip_calls_dlg == NULL) { @@ -751,10 +780,20 @@ /* There's already a dialog box; reactivate it. */ reactivate_window(voip_calls_dlg); } + + voip_calls_get_info()->redraw = TRUE; + voip_calls_dlg_draw(NULL); + voip_calls_get_info()->redraw = TRUE; + for (c=0;c<NUM_COLS;c++){ + data[c]=&field[c][0]; + field[c][0] = NULL; + } + g_snprintf(field[3], 50, "Please wait..."); + gtk_clist_append(GTK_CLIST(clist), data); /* Scan for VoIP calls calls (redissect all packets) */ cf_retap_packets(&cfile); - + /* Tap listener will be removed and cleaned up in voip_calls_on_destroy */ } Index: gtk/graph_analysis.c =================================================================== --- gtk/graph_analysis.c (revision 14849) +++ gtk/graph_analysis.c (working copy) @@ -1421,7 +1421,6 @@ { GtkWidget *vbox; GtkWidget *hbox; - GtkWidget *scroll_window; GtkWidget *viewport; GtkWidget *scroll_window_comments; GtkWidget *viewport_comments; @@ -1457,12 +1456,15 @@ user_data->dlg.draw_area=gtk_drawing_area_new(); user_data->dlg.pixmap_width = user_data->num_nodes * NODE_WIDTH; WIDGET_SET_SIZE(user_data->dlg.draw_area, user_data->dlg.pixmap_width, user_data->dlg.pixmap_height); - scroll_window=gtk_scrolled_window_new(NULL, NULL); - WIDGET_SET_SIZE(scroll_window, NODE_WIDTH*2, user_data->dlg.pixmap_height); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scroll_window), GTK_POLICY_ALWAYS, GTK_POLICY_NEVER); - viewport = gtk_viewport_new(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scroll_window)), gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scroll_window))); + user_data->dlg.scroll_window=gtk_scrolled_window_new(NULL, NULL); + if ( user_data->num_nodes < 6) + WIDGET_SET_SIZE(user_data->dlg.scroll_window, NODE_WIDTH*user_data->num_nodes, user_data->dlg.pixmap_height); + else + WIDGET_SET_SIZE(user_data->dlg.scroll_window, NODE_WIDTH*5, user_data->dlg.pixmap_height); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(user_data->dlg.scroll_window), GTK_POLICY_ALWAYS, GTK_POLICY_NEVER); + viewport = gtk_viewport_new(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(user_data->dlg.scroll_window)), gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(user_data->dlg.scroll_window))); gtk_container_add(GTK_CONTAINER(viewport), user_data->dlg.draw_area); - gtk_container_add(GTK_CONTAINER(scroll_window), viewport); + gtk_container_add(GTK_CONTAINER(user_data->dlg.scroll_window), viewport); gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE); OBJECT_SET_DATA(user_data->dlg.draw_area, "graph_analysis_data_t", user_data); GTK_WIDGET_SET_FLAGS(user_data->dlg.draw_area, GTK_CAN_FOCUS); @@ -1493,13 +1495,13 @@ gtk_widget_show(user_data->dlg.draw_area_comments); gtk_widget_show(viewport_comments); - gtk_widget_show(scroll_window); + gtk_widget_show(user_data->dlg.scroll_window); gtk_widget_show(scroll_window_comments); gtk_box_pack_start(GTK_BOX(hbox), user_data->dlg.draw_area_time, FALSE, FALSE, 0); user_data->dlg.hpane = gtk_hpaned_new(); - gtk_paned_pack1(GTK_PANED (user_data->dlg.hpane), scroll_window, TRUE, TRUE); + gtk_paned_pack1(GTK_PANED (user_data->dlg.hpane), user_data->dlg.scroll_window, TRUE, TRUE); gtk_paned_pack2(GTK_PANED (user_data->dlg.hpane), scroll_window_comments, FALSE, TRUE); #if GTK_MAJOR_VERSION >= 2 SIGNAL_CONNECT(user_data->dlg.hpane, "notify::position", pane_callback, user_data); @@ -1671,6 +1673,13 @@ /* get nodes (each node is an address) */ get_nodes(user_data); + user_data->dlg.pixmap_width = user_data->num_nodes * NODE_WIDTH; + WIDGET_SET_SIZE(user_data->dlg.draw_area, user_data->dlg.pixmap_width, user_data->dlg.pixmap_height); + if ( user_data->num_nodes < 6) + WIDGET_SET_SIZE(user_data->dlg.scroll_window, NODE_WIDTH*user_data->num_nodes, user_data->dlg.pixmap_height); + else + WIDGET_SET_SIZE(user_data->dlg.scroll_window, NODE_WIDTH*5, user_data->dlg.pixmap_height); + /* redraw the graph */ dialog_graph_redraw(user_data); Index: gtk/graph_analysis.h =================================================================== --- gtk/graph_analysis.h (revision 14849) +++ gtk/graph_analysis.h (working copy) @@ -89,6 +89,7 @@ GdkPixmap *pixmap_time; GdkPixmap *pixmap; GdkPixmap *pixmap_comments; + GtkWidget *scroll_window; GtkWidget *v_scrollbar; GtkAdjustment *v_scrollbar_adjustment; GtkWidget *hpane; Index: gtk/voip_calls.c =================================================================== --- gtk/voip_calls.c (revision 14849) +++ gtk/voip_calls.c (working copy) @@ -101,7 +101,7 @@ /****************************************************************************/ /* the one and only global voip_calls_tapinfo_t structure */ static voip_calls_tapinfo_t the_tapinfo_struct = - {0, NULL, 0, NULL, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + {0, NULL, 0, NULL, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; /* the one and only global voip_rtp_tapinfo_t structure */ static voip_rtp_tapinfo_t the_tapinfo_rtp_struct = @@ -197,8 +197,6 @@ gai = g_malloc(sizeof(graph_analysis_item_t)); gai->frame_num = pinfo->fd->num; gai->time= (double)pinfo->fd->rel_secs + (double) pinfo->fd->rel_usecs/1000000; -/* COPY_ADDRESS(&(gai->src_addr),&(pinfo->src)); - COPY_ADDRESS(&(gai->dst_addr),&(pinfo->dst));*/ COPY_ADDRESS(&(gai->src_addr),src_addr); COPY_ADDRESS(&(gai->dst_addr),dst_addr); @@ -494,6 +492,9 @@ strinfo->stop_rel_sec = pinfo->fd->rel_secs; strinfo->stop_rel_usec = pinfo->fd->rel_usecs; } + + the_tapinfo_struct.redraw = TRUE; + return 1; } @@ -750,12 +751,15 @@ sdp_summary = NULL; } } + + tapinfo->redraw = TRUE; + return 1; /* refresh output */ } /****************************************************************************/ -const voip_calls_tapinfo_t* voip_calls_get_info(void) +voip_calls_tapinfo_t* voip_calls_get_info(void) { return &the_tapinfo_struct; } @@ -991,10 +995,9 @@ g_free(frame_label); } + tapinfo->redraw = TRUE; - - - return 1; + return 1; /* refresh output */ } /****************************************************************************/ @@ -1273,6 +1276,9 @@ if (!append_to_frame_graph(tapinfo, q931_frame_num, "", comment)) { /* if not exist, add to the graph */ add_to_graph(tapinfo, pinfo, "", comment, tmp_listinfo->call_num, &(pinfo->src), &(pinfo->dst)); + ++(tmp_listinfo->npackets); + /* increment the packets counter of all calls */ + ++(tapinfo->npackets); } /* Add the H245 info if exists to the Graph */ @@ -1380,7 +1386,9 @@ g_free((char *)pstn_add.data); } - return 0; + tapinfo->redraw = TRUE; + + return 1; /* refresh output */ } /****************************************************************************/ @@ -1652,6 +1660,8 @@ } + tapinfo->redraw = TRUE; + return 1; /* refresh output */ } @@ -1804,6 +1814,9 @@ /* Tunnel is OFF, and we matched the h245 add so we add it to graph */ if (strinfo!=NULL){ + ++(strinfo->npackets); + /* increment the packets counter of all calls */ + ++(tapinfo->npackets); frame_label = g_strdup(pi->frame_label); comment = g_strdup(pi->comment); /* if the frame number exists in graph, append to it*/ @@ -1821,6 +1834,8 @@ h245_add_label(pinfo->fd->num, (gchar *) pi->frame_label, (gchar *) pi->comment); } + tapinfo->redraw = TRUE; + return 1; /* refresh output */ } @@ -1890,6 +1905,8 @@ sdp_summary = g_strdup_printf("SDP (%s)", pi->summary_str); append_to_frame_graph(tapinfo, pinfo->fd->num, sdp_summary, NULL); + tapinfo->redraw = TRUE; + return 1; /* refresh output */ } @@ -2257,6 +2274,8 @@ sdp_summary = NULL; } + tapinfo->redraw = TRUE; + return 1; /* refresh output */ } @@ -2391,6 +2410,9 @@ g_free(comment); g_free((char *)pstn_add.data); } + + tapinfo->redraw = TRUE; + return 1; /* refresh output */ } @@ -2459,6 +2481,8 @@ ++(tapinfo->npackets); } + tapinfo->redraw = TRUE; + return 1; } */ Index: gtk/voip_calls.h =================================================================== --- gtk/voip_calls.h (revision 14849) +++ gtk/voip_calls.h (working copy) @@ -160,6 +160,7 @@ int completed_calls; int rejected_calls; graph_analysis_info_t* graph_analysis; + gboolean redraw; /* * Now add dummy variables, one for each tap listener. * Their address will be used to distinguish between them. @@ -249,7 +250,7 @@ * Retrieves a constant reference to the unique info structure of the voip_calls tap listener. * The user should not modify the data pointed to. */ -const voip_calls_tapinfo_t* voip_calls_get_info(void); +voip_calls_tapinfo_t* voip_calls_get_info(void); /* * Cleans up memory of voip calls tap.
- Follow-Ups:
- SV: [Ethereal-dev] Voip graph patch
- From: Anders Broman
- SV: [Ethereal-dev] Voip graph patch
- Prev by Date: SV: [Ethereal-dev] Bug in RTP stream analysis
- Next by Date: SV: [Ethereal-dev] A few little LWAPP fixes
- Previous by thread: SV: [Ethereal-dev] Bug in RTP stream analysis
- Next by thread: SV: [Ethereal-dev] Voip graph patch
- Index(es):