aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/graph_analysis.c
diff options
context:
space:
mode:
authorLuis Ontanon <luis.ontanon@gmail.com>2007-03-19 00:36:42 +0000
committerLuis Ontanon <luis.ontanon@gmail.com>2007-03-19 00:36:42 +0000
commit529c65f713a781f5dd58a16d69503662e206850e (patch)
tree3c78a5ffa30a9c5c435c247a8274dc44a0a1fa89 /gtk/graph_analysis.c
parentd3120ba5075b04f1dcdcb98c758b4feef4833622 (diff)
downloadwireshark-529c65f713a781f5dd58a16d69503662e206850e.tar.gz
wireshark-529c65f713a781f5dd58a16d69503662e206850e.tar.bz2
wireshark-529c65f713a781f5dd58a16d69503662e206850e.zip
voip_calls.c:
- instead of wrongly using the h248 call counter use tapinfo's counter graph_analysis.c: - beautify the code (I was trying to the bug that got fixed by bzeroing m3ua tap data however this looks better!). svn path=/trunk/; revision=21063
Diffstat (limited to 'gtk/graph_analysis.c')
-rw-r--r--gtk/graph_analysis.c90
1 files changed, 20 insertions, 70 deletions
diff --git a/gtk/graph_analysis.c b/gtk/graph_analysis.c
index f5c9e1c421..3189b27adf 100644
--- a/gtk/graph_analysis.c
+++ b/gtk/graph_analysis.c
@@ -1654,96 +1654,46 @@ static void dialog_graph_create_window(graph_analysis_data_t* user_data)
* and Return -2 if the array is full
*/
/****************************************************************************/
-static gint is_node_array(graph_analysis_data_t* user_data, address* node)
-{
- int i;
- for (i=0; i<MAX_NUM_NODES; i++){
- if (user_data->nodes[i].type == AT_NONE) return -1; /* it is not in the array */
- if (ADDRESSES_EQUAL((&user_data->nodes[i]),node)) return i; /* it is in the array */
+static gint add_or_get_node(graph_analysis_data_t* user_data, address* node) {
+ guint i;
+
+ if (node->type == AT_NONE) return NODE_OVERFLOW;
+
+ for (i=0; i<MAX_NUM_NODES && i < user_data->num_nodes ; i++){
+ if ( CMP_ADDRESS(&(user_data->nodes[i]), node) == 0 ) return i; /* it is in the array */
+ }
+
+ if (i == MAX_NUM_NODES) {
+ return NODE_OVERFLOW;
+ } else {
+ user_data->num_nodes++;
+ COPY_ADDRESS(&(user_data->nodes[i]),node);
+ return i;
}
- return -2; /* array full */
}
-
/* Get the nodes from the list */
/****************************************************************************/
static void get_nodes(graph_analysis_data_t* user_data)
{
GList* list;
graph_analysis_item_t *gai;
- gint index;
/* fill the node array */
list = g_list_first(user_data->graph_info->list);
while (list)
{
gai = list->data;
- if (gai->display){
+ if (gai->display) {
user_data->num_items++;
if (!user_data->dlg.inverse) {
- /* check source node address */
- index = is_node_array(user_data, &(gai->src_addr));
- switch(index){
- case -2: /* array full */
- gai->src_node = NODE_OVERFLOW;
- break;
- case -1: /* not in array */
- COPY_ADDRESS(&(user_data->nodes[user_data->num_nodes]),&(gai->src_addr));
- gai->src_node = user_data->num_nodes;
- user_data->num_nodes++;
- break;
- default: /* it is in the array, just update the src_node */
- gai->src_node = (guint16)index;
- }
-
- /* check destination node address*/
- index = is_node_array(user_data, &(gai->dst_addr));
- switch(index){
- case -2: /* array full */
- gai->dst_node = NODE_OVERFLOW;
- break;
- case -1: /* not in array */
- COPY_ADDRESS(&(user_data->nodes[user_data->num_nodes]),&(gai->dst_addr));
- gai->dst_node = user_data->num_nodes;
- user_data->num_nodes++;
- break;
- default: /* it is in the array, just update the dst_node */
- gai->dst_node = (guint16)index;
- }
+ gai->src_node = (guint16)add_or_get_node(user_data, &(gai->src_addr));
+ gai->dst_node = (guint16)add_or_get_node(user_data, &(gai->dst_addr));
} else {
- /* check destination node address*/
- index = is_node_array(user_data, &(gai->dst_addr));
- switch(index){
- case -2: /* array full */
- gai->dst_node = NODE_OVERFLOW;
- break;
- case -1: /* not in array */
- COPY_ADDRESS(&(user_data->nodes[user_data->num_nodes]),&(gai->dst_addr));
- gai->dst_node = user_data->num_nodes;
- user_data->num_nodes++;
- break;
- default: /* it is in the array, just update the dst_node */
- gai->dst_node = (guint16)index;
- }
-
- /* check source node address */
- index = is_node_array(user_data, &(gai->src_addr));
- switch(index){
- case -2: /* array full */
- gai->src_node = NODE_OVERFLOW;
- break;
- case -1: /* not in array */
- COPY_ADDRESS(&(user_data->nodes[user_data->num_nodes]),&(gai->src_addr));
- gai->src_node = user_data->num_nodes;
- user_data->num_nodes++;
- break;
- default: /* it is in the array, just update the src_node */
- gai->src_node = (guint16)index;
- }
-
+ gai->dst_node = (guint16)add_or_get_node(user_data, &(gai->src_addr));
+ gai->src_node = (guint16)add_or_get_node(user_data, &(gai->dst_addr));
}
}
-
list = g_list_next(list);
}
}