voip_calls.c Use the hastable instead, we should do away with the list.

graph_analysis.h Doxygen changes.

svn path=/trunk/; revision=41545
This commit is contained in:
Anders Broman 2012-03-14 16:46:59 +00:00
parent 4c801c8604
commit 1d4f630589
2 changed files with 96 additions and 33 deletions

View File

@ -37,51 +37,51 @@
#define MAX_NUM_NODES 40
/* defines an entry in for the graph analysis */
/** defines an entry for the graph analysis */
typedef struct _graph_analysis_item {
frame_data *fd; /* Holds the frame number and time information */
frame_data *fd; /**< Holds the frame number and time information */
address src_addr;
guint16 port_src;
address dst_addr;
guint16 port_dst;
gchar *frame_label; /* the label on top of the arrow */
gchar *comment; /* a comment that appears at the left of the graph */
guint16 conv_num; /* the conversation number, each conversation will be colored */
gboolean display; /* indicate if the packet is displayed or not in the graph */
guint16 src_node; /* this is used by graph_analysis.c to identify the node */
guint16 dst_node; /* a node is an IP address that will be displayed in columns */
guint16 line_style; /* the arrow line width in pixels*/
gchar *frame_label; /**< the label on top of the arrow */
gchar *comment; /**< a comment that appears at the left of the graph */
guint16 conv_num; /**< the conversation number, each conversation will be colored */
gboolean display; /**< indicate if the packet is displayed or not in the graph */
guint16 src_node; /**< this is used by graph_analysis.c to identify the node */
guint16 dst_node; /**< a node is an IP address that will be displayed in columns */
guint16 line_style; /**< the arrow line width in pixels*/
} graph_analysis_item_t;
/* defines the graph analysis structure */
/** defines the graph analysis structure */
typedef struct _graph_analysis_info {
int nconv; /* number of conversations in the list */
GList* list; /* list with the graph analysis items */
GHashTable *ht; /* hash table for retrieving graph analysis items */
int nconv; /**< number of conversations in the list */
GList* list; /**< list with the graph analysis items */
GHashTable *ht; /**< hash table for retrieving graph analysis items */
} graph_analysis_info_t;
/* max number of nodes to display, each node will be an IP address */
/** max number of nodes to display, each node will be an IP address */
#define MAX_NUM_COL_CONV 10
#define NODE_OVERFLOW MAX_NUM_NODES+1
#define NUM_DISPLAY_ITEMS 1000
typedef struct _display_items {
frame_data *fd; /* Holds the frame number and time information */
frame_data *fd; /**< Holds the frame number and time information */
guint16 port_src;
guint16 port_dst;
gchar *frame_label; /* the label on top of the arrow */
gchar *comment; /* a comment that appears at the left of the graph */
guint16 conv_num; /* the conversation number, each conversation will be colored */
guint16 src_node; /* this is used by graph_analysis.c to identify the node */
guint16 dst_node; /* a node is an IP address that will be displayed in columns */
guint16 line_style; /* the arrow line width in pixels*/
gchar *frame_label; /**< the label on top of the arrow */
gchar *comment; /**< a comment that appears at the left of the graph */
guint16 conv_num; /**< the conversation number, each conversation will be colored */
guint16 src_node; /**< this is used by graph_analysis.c to identify the node */
guint16 dst_node; /**< a node is an IP address that will be displayed in columns */
guint16 line_style; /**< the arrow line width in pixels*/
} display_items_t;
typedef struct _graph_analysis_dialog_data_t {
GtkWidget *window;
GtkWidget *parent_w;
gboolean needs_redraw;
gboolean inverse; /* set the nodes in reverse mode as "dst <---- src" instead of "src ----> dst"*/
gboolean inverse; /**< set the nodes in reverse mode as "dst <---- src" instead of "src ----> dst"*/
gint selected_row;
GtkWidget *draw_area_time;
GtkWidget *draw_area;
@ -103,29 +103,29 @@ typedef struct _graph_analysis_dialog_data_t {
GtkWidget *hpane;
int surface_width;
int surface_height;
guint16 first_node; /* the first node on the left to show in the screen */
guint32 first_item; /* the first item (row) to show from the top */
guint32 selected_item; /* the selected item */
guint16 first_node; /**< the first node on the left to show in the screen */
guint32 first_item; /**< the first item (row) to show from the top */
guint32 selected_item; /**< the selected item */
display_items_t items[NUM_DISPLAY_ITEMS];
guint32 left_x_border;
char *save_file;
char *title; /* Graph analysis window's title */
char *title; /**< Graph analysis window's title */
} graph_analysis_dialog_data_t;
typedef void (*destroy_user_data_cb)(void *data);
/* structure that holds general information and the dialog */
/** structure that holds general information and the dialog */
typedef struct _graph_analysis_data_t {
/* graphic data */
/**> graphic data */
graph_analysis_info_t *graph_info;
/* dialog associated data */
/**> dialog associated data */
graph_analysis_dialog_data_t dlg;
address nodes[MAX_NUM_NODES];
guint32 num_nodes;
guint32 num_items;
destroy_user_data_cb on_destroy_user_data; /* callback info for destroy */
void *data; /* data to be passes when on destroy */
destroy_user_data_cb on_destroy_user_data; /**< callback info for destroy */
void *data; /**< data to be passes when on destroy */
} graph_analysis_data_t;
graph_analysis_data_t* graph_analysis_init(void);

View File

@ -385,6 +385,7 @@ static void insert_to_graph_t38(voip_calls_tapinfo_t *tapinfo _U_, packet_info *
gai = list->data;
if (gai->fd->num > frame_num){
the_tapinfo_struct.graph_analysis->list = g_list_insert(the_tapinfo_struct.graph_analysis->list, new_gai, item_num);
g_hash_table_insert(tapinfo->graph_analysis->ht, &new_gai->fd->num, new_gai);
inserted = TRUE;
break;
}
@ -392,7 +393,10 @@ static void insert_to_graph_t38(voip_calls_tapinfo_t *tapinfo _U_, packet_info *
item_num++;
}
if (!inserted) tapinfo->graph_analysis->list = g_list_prepend(tapinfo->graph_analysis->list, new_gai);
if (!inserted){
tapinfo->graph_analysis->list = g_list_prepend(tapinfo->graph_analysis->list, new_gai);
g_hash_table_insert(tapinfo->graph_analysis->ht, &new_gai->fd->num, new_gai);
}
}
/****************************************************************************/
@ -588,6 +592,65 @@ RTP_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, void cons
/****************************************************************************/
/* whenever a redraw in the RTP tap listener */
static void RTP_packet_draw(void *prs _U_)
{
voip_rtp_tapinfo_t *rtp_tapinfo = &the_tapinfo_rtp_struct;
GList *rtp_streams_list;
voip_rtp_stream_info_t *rtp_listinfo;
GList *voip_calls_graph_list;
graph_analysis_item_t *gai;
graph_analysis_item_t *new_gai;
guint16 conv_num;
guint32 duration;
/* add each rtp stream to the graph */
rtp_streams_list = g_list_first(rtp_tapinfo->list);
while (rtp_streams_list)
{
rtp_listinfo = rtp_streams_list->data;
/* using the setup frame number of the RTP stream, we get the call number that it belongs to*/
voip_calls_graph_list = g_list_first(the_tapinfo_struct.graph_analysis->list);
gai = g_hash_table_lookup(the_tapinfo_struct.graph_analysis->ht, &rtp_listinfo->setup_frame_number);
if(gai != NULL){
/* Found the setup frame*/
conv_num = gai->conv_num;
/* if RTP was already in the Graph, just update the comment information */
gai = g_hash_table_lookup(the_tapinfo_struct.graph_analysis->ht, &rtp_listinfo->start_fd->num);
if(gai != NULL){
duration = (guint32)(nstime_to_msec(&rtp_listinfo->stop_fd->rel_ts) - nstime_to_msec(&rtp_listinfo->start_fd->rel_ts));
g_free(gai->comment);
gai->comment = g_strdup_printf("%s Num packets:%u Duration:%u.%03us SSRC:0x%X",
(rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->npackets,
duration/1000,(duration%1000), rtp_listinfo->ssrc);
}else{
new_gai = g_malloc(sizeof(graph_analysis_item_t));
new_gai->fd = rtp_listinfo->start_fd;
COPY_ADDRESS(&(new_gai->src_addr),&(rtp_listinfo->src_addr));
COPY_ADDRESS(&(new_gai->dst_addr),&(rtp_listinfo->dest_addr));
new_gai->port_src = rtp_listinfo->src_port;
new_gai->port_dst = rtp_listinfo->dest_port;
duration = (guint32)(nstime_to_msec(&rtp_listinfo->stop_fd->rel_ts) - nstime_to_msec(&rtp_listinfo->start_fd->rel_ts));
new_gai->frame_label = g_strdup_printf("%s (%s) %s",
(rtp_listinfo->is_srtp)?"SRTP":"RTP",
rtp_listinfo->pt_str,
(rtp_listinfo->rtp_event == -1)?
"":val_to_str_const(rtp_listinfo->rtp_event, rtp_event_type_values, "Unknown RTP Event"));
new_gai->comment = g_strdup_printf("%s Num packets:%u Duration:%u.%03us SSRC:0x%X",
(rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->npackets,
duration/1000,(duration%1000), rtp_listinfo->ssrc);
new_gai->conv_num = conv_num;
new_gai->display=FALSE;
new_gai->line_style = 2; /* the arrow line will be 2 pixels width */
the_tapinfo_struct.graph_analysis->list = g_list_prepend(the_tapinfo_struct.graph_analysis->list, new_gai);
g_hash_table_insert(the_tapinfo_struct.graph_analysis->ht, &rtp_listinfo->start_fd, new_gai);
}
}
rtp_streams_list = g_list_next(rtp_streams_list);
}/* while (rtp_streams_list) */
}
#if 0
static void RTP_packet_draw(void *prs _U_)
{
voip_rtp_tapinfo_t *rtp_tapinfo = &the_tapinfo_rtp_struct;
GList *rtp_streams_list;
@ -664,7 +727,7 @@ static void RTP_packet_draw(void *prs _U_)
rtp_streams_list = g_list_next(rtp_streams_list);
}
}
#endif
static gboolean have_RTP_tap_listener=FALSE;
/****************************************************************************/
void