voip_calls: Regression fixes.
Fix struct initialization logic. Clear a GQueue instead of deleting it. Don't crash if we have no sequence diagram items. Make sure we show all flows and not just invites. Zero allocated memory in a couple of places. Change-Id: Ia5bb3ba57cf625de4b554b354e098aa0361dff28 Reviewed-on: https://code.wireshark.org/review/5390 Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
dc5b8f1093
commit
cfa0e5fd53
|
@ -242,7 +242,7 @@ gtk_save_graph_as_plain_text_file(graph_analysis_data_t *user_data)
|
|||
save_to_file_w = file_selection_new("Wireshark: Save graph to plain text file",
|
||||
GTK_WINDOW(user_data->dlg.window),
|
||||
FILE_SELECTION_SAVE);
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(save_to_file_w),
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(save_to_file_w),
|
||||
GTK_RESPONSE_ACCEPT);
|
||||
|
||||
pathname = file_selection_run(save_to_file_w);
|
||||
|
@ -365,12 +365,16 @@ static void dialog_graph_draw(graph_analysis_data_t *user_data)
|
|||
|
||||
GtkAllocation draw_area_time_alloc, draw_area_alloc, draw_area_comments_alloc;
|
||||
|
||||
if(!user_data->dlg.needs_redraw) {
|
||||
if (!user_data->dlg.needs_redraw) {
|
||||
return;
|
||||
}
|
||||
|
||||
user_data->dlg.needs_redraw = FALSE;
|
||||
|
||||
if (g_queue_get_length(user_data->graph_info->items) < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_widget_get_allocation(user_data->dlg.draw_area_time, &draw_area_time_alloc);
|
||||
gtk_widget_get_allocation(user_data->dlg.draw_area, &draw_area_alloc);
|
||||
gtk_widget_get_allocation(user_data->dlg.draw_area_comments, &draw_area_comments_alloc);
|
||||
|
@ -1742,7 +1746,7 @@ graph_analysis_data_t *graph_analysis_init(seq_analysis_info_t *sainfo)
|
|||
{
|
||||
graph_analysis_data_t *user_data;
|
||||
/* init */
|
||||
user_data = g_new(graph_analysis_data_t,1);
|
||||
user_data = g_new0(graph_analysis_data_t,1);
|
||||
user_data->graph_info = sainfo;
|
||||
|
||||
/* init user_data */
|
||||
|
@ -1816,3 +1820,17 @@ void graph_analysis_redraw(graph_analysis_data_t *user_data)
|
|||
window_present(user_data->dlg.window);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ typedef struct _graph_analysis_data_t {
|
|||
graph_analysis_dialog_data_t dlg;
|
||||
guint32 num_items;
|
||||
destroy_user_data_cb on_destroy_user_data; /**< callback info for destroy */
|
||||
void *data; /**< data to be passes when on destroy */
|
||||
void *data; /**< data to be passed when on destroy */
|
||||
} graph_analysis_data_t;
|
||||
|
||||
graph_analysis_data_t* graph_analysis_init(seq_analysis_info_t *sainfo);
|
||||
|
|
|
@ -356,11 +356,12 @@ on_graph_bt_clicked(GtkButton *button _U_, gpointer user_data _U_)
|
|||
GList* lista;
|
||||
GList* listb;
|
||||
voip_calls_info_t *listinfo;
|
||||
voip_calls_tapinfo_t *tapinfo = voip_calls_get_info();
|
||||
|
||||
g_queue_sort(voip_calls_get_info()->graph_analysis->items, graph_analysis_sort_compare, NULL);
|
||||
g_queue_sort(tapinfo->graph_analysis->items, graph_analysis_sort_compare, NULL);
|
||||
|
||||
/* reset the "display" parameter in graph analysis */
|
||||
listb = g_queue_peek_nth_link(voip_calls_get_info()->graph_analysis->items, 0);
|
||||
listb = g_queue_peek_nth_link(tapinfo->graph_analysis->items, 0);
|
||||
while (listb) {
|
||||
gai = (seq_analysis_item_t *)listb->data;
|
||||
gai->display = FALSE;
|
||||
|
@ -368,11 +369,11 @@ on_graph_bt_clicked(GtkButton *button _U_, gpointer user_data _U_)
|
|||
}
|
||||
|
||||
/* set the display for selected calls */
|
||||
lista = g_queue_peek_nth_link(voip_calls_get_info()->callsinfos, 0);
|
||||
lista = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
|
||||
while (lista) {
|
||||
listinfo = (voip_calls_info_t *)lista->data;
|
||||
if (listinfo->selected) {
|
||||
listb = g_queue_peek_nth_link(voip_calls_get_info()->graph_analysis->items, 0);
|
||||
listb = g_queue_peek_nth_link(tapinfo->graph_analysis->items, 0);
|
||||
while (listb) {
|
||||
gai = (seq_analysis_item_t *)listb->data;
|
||||
if (gai->conv_num == listinfo->call_num) {
|
||||
|
@ -393,7 +394,7 @@ on_graph_bt_clicked(GtkButton *button _U_, gpointer user_data _U_)
|
|||
|
||||
/****************************************************************************/
|
||||
static void
|
||||
on_flow_bt_clicked(GtkButton *button _U_, gpointer user_data _U_)
|
||||
on_flow_bt_clicked(GtkButton *button, gpointer user_data)
|
||||
{
|
||||
on_graph_bt_clicked(button,user_data);
|
||||
}
|
||||
|
@ -948,7 +949,7 @@ voip_calls_launch(GtkAction *action _U_, gpointer user_data _U_)
|
|||
void
|
||||
voip_flows_launch(GtkAction *action _U_, gpointer user_data _U_)
|
||||
{
|
||||
voip_calls_get_info()->fs_option = FLOW_ONLY_INVITES;
|
||||
voip_calls_get_info()->fs_option = FLOW_ALL;
|
||||
voip_calls_dlg_init_taps("", NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -362,7 +362,7 @@ static gint add_or_get_node(seq_analysis_info_t *sainfo, address *node) {
|
|||
if ( CMP_ADDRESS(&(sainfo->nodes[i]), node) == 0 ) return i; /* it is in the array */
|
||||
}
|
||||
|
||||
if (i == MAX_NUM_NODES) {
|
||||
if (i >= MAX_NUM_NODES) {
|
||||
return NODE_OVERFLOW;
|
||||
} else {
|
||||
sainfo->num_nodes++;
|
||||
|
@ -394,7 +394,7 @@ sequence_analysis_get_nodes(seq_analysis_info_t *sainfo)
|
|||
{
|
||||
struct sainfo_counter sc = {sainfo, 0};
|
||||
|
||||
/* fill the node array */
|
||||
/* Fill the node array */
|
||||
g_queue_foreach(sainfo->items, sequence_analysis_get_nodes_item_proc, &sc);
|
||||
|
||||
return sc.num_items;
|
||||
|
|
|
@ -71,7 +71,7 @@ typedef struct _seq_analysis_info {
|
|||
gboolean all_packets; /**< all packets vs only displayed */
|
||||
gboolean any_addr; /**< any addr (DL+net) vs net-only */
|
||||
int nconv; /**< number of conversations in the list */
|
||||
GQueue* items; /**< list with the graph analysis items */
|
||||
GQueue* items; /**< list with the graph analysis items */
|
||||
GHashTable *ht; /**< hash table for retrieving graph analysis items */
|
||||
address nodes[MAX_NUM_NODES]; /**< horizontal node list */
|
||||
guint32 num_nodes; /**< actual number of nodes */
|
||||
|
|
|
@ -303,25 +303,27 @@ voip_calls_reset(voip_calls_tapinfo_t *tapinfo)
|
|||
g_hash_table_remove_all (tapinfo->callsinfo_hashtable[SIP_HASH]);
|
||||
|
||||
/* free the graph data items first */
|
||||
if(NULL != tapinfo->graph_analysis) {
|
||||
if (NULL != tapinfo->graph_analysis->ht) {
|
||||
g_hash_table_remove_all(tapinfo->graph_analysis->ht);
|
||||
}
|
||||
list = g_queue_peek_nth_link(tapinfo->graph_analysis->items, 0);
|
||||
while (list)
|
||||
{
|
||||
graph_item = (seq_analysis_item_t *)list->data;
|
||||
g_free(graph_item->frame_label);
|
||||
g_free(graph_item->comment);
|
||||
g_free((void *)graph_item->src_addr.data);
|
||||
g_free((void *)graph_item->dst_addr.data);
|
||||
g_free(graph_item->time_str);
|
||||
g_free(list->data);
|
||||
list = g_list_next(list);
|
||||
}
|
||||
g_queue_free(tapinfo->graph_analysis->items);
|
||||
if(NULL == tapinfo->graph_analysis) {
|
||||
graph_analysis_data_init(tapinfo);
|
||||
}
|
||||
|
||||
if (NULL != tapinfo->graph_analysis->ht) {
|
||||
g_hash_table_remove_all(tapinfo->graph_analysis->ht);
|
||||
}
|
||||
list = g_queue_peek_nth_link(tapinfo->graph_analysis->items, 0);
|
||||
while (list)
|
||||
{
|
||||
graph_item = (seq_analysis_item_t *)list->data;
|
||||
g_free(graph_item->frame_label);
|
||||
g_free(graph_item->comment);
|
||||
g_free((void *)graph_item->src_addr.data);
|
||||
g_free((void *)graph_item->dst_addr.data);
|
||||
g_free(graph_item->time_str);
|
||||
g_free(list->data);
|
||||
list = g_list_next(list);
|
||||
}
|
||||
g_queue_clear(tapinfo->graph_analysis->items);
|
||||
|
||||
/* free the strinfo data items first */
|
||||
list = g_list_first(tapinfo->rtp_stream_list);
|
||||
while(list)
|
||||
|
@ -339,19 +341,14 @@ voip_calls_reset(voip_calls_tapinfo_t *tapinfo)
|
|||
memset(tapinfo->h245_labels, 0, sizeof(h245_labels_t));
|
||||
}
|
||||
|
||||
/* memset(tapinfo, 0, sizeof(voip_calls_tapinfo_t)); More trouble than it's worth. */
|
||||
|
||||
graph_analysis_data_init(tapinfo);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
void
|
||||
graph_analysis_data_init(voip_calls_tapinfo_t *tapinfo) {
|
||||
tapinfo->graph_analysis = (seq_analysis_info_t *)g_malloc(sizeof(seq_analysis_info_t));
|
||||
tapinfo->graph_analysis->nconv = 0;
|
||||
tapinfo->graph_analysis->items = g_queue_new();;
|
||||
tapinfo->graph_analysis = (seq_analysis_info_t *) g_new0(seq_analysis_info_t, 1);
|
||||
tapinfo->graph_analysis->items = g_queue_new();
|
||||
tapinfo->graph_analysis->ht= g_hash_table_new(g_int_hash, g_int_equal);
|
||||
}
|
||||
|
||||
|
@ -363,6 +360,10 @@ add_to_graph(voip_calls_tapinfo_t *tapinfo, packet_info *pinfo, epan_dissect_t *
|
|||
seq_analysis_item_t *gai;
|
||||
gchar time_str[COL_MAX_LEN];
|
||||
|
||||
if (!tapinfo->graph_analysis) {
|
||||
return;
|
||||
}
|
||||
|
||||
gai = (seq_analysis_item_t *)g_malloc(sizeof(seq_analysis_item_t));
|
||||
gai->fd = pinfo->fd;
|
||||
COPY_ADDRESS(&(gai->src_addr),src_addr);
|
||||
|
@ -370,6 +371,7 @@ add_to_graph(voip_calls_tapinfo_t *tapinfo, packet_info *pinfo, epan_dissect_t *
|
|||
|
||||
gai->port_src=pinfo->srcport;
|
||||
gai->port_dst=pinfo->destport;
|
||||
|
||||
if (frame_label != NULL)
|
||||
gai->frame_label = g_strdup(frame_label);
|
||||
else
|
||||
|
@ -379,17 +381,15 @@ add_to_graph(voip_calls_tapinfo_t *tapinfo, packet_info *pinfo, epan_dissect_t *
|
|||
gai->comment = g_strdup(comment);
|
||||
else
|
||||
gai->comment = g_strdup("");
|
||||
|
||||
gai->conv_num=call_num;
|
||||
gai->line_style=line_style;
|
||||
set_fd_time(edt->session, gai->fd, time_str);
|
||||
gai->time_str = g_strdup(time_str);
|
||||
gai->display=FALSE;
|
||||
|
||||
if(tapinfo->graph_analysis){
|
||||
g_queue_push_tail(tapinfo->graph_analysis->items, gai);
|
||||
g_hash_table_insert(tapinfo->graph_analysis->ht, &gai->fd->num, gai);
|
||||
}
|
||||
|
||||
g_queue_push_tail(tapinfo->graph_analysis->items, gai);
|
||||
g_hash_table_insert(tapinfo->graph_analysis->ht, &gai->fd->num, gai);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
@ -1147,7 +1147,7 @@ sip_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt ,
|
|||
}
|
||||
}
|
||||
|
||||
if (callsinfo!=NULL) {
|
||||
if (callsinfo != NULL) {
|
||||
tmp_sipinfo = (sip_calls_info_t *)callsinfo->prot_info;
|
||||
|
||||
/* let's analyze the call state */
|
||||
|
|
Loading…
Reference in New Issue