Ethereal-dev: Re: [Ethereal-dev] Re: [Ethereal-cvs] rev 13456: /trunk/gtk/: voip_calls.c

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: Sun, 20 Feb 2005 22:46:29 -0700


LEGO wrote:
I fixed few things that broke the compilation on unices (at least on
FreeBSD, Solaris and MacOSX the typedef boolean does not exist).

Other than that I removed few warnings about uninitialized variables,
I added g_assert(v != NULL) before dereferencing the now NULL
initialized values.

last tghe member hasDigitMap of struct _mgcp_info_t is a pointer to a
boolean and was used non dereferenced, I dereferenced it.
  
It shouldn't be pointer to a boolean, I changed  it.
Alejandro, you should have a look at those changes, and check if I did
broke something

  
I also fixed a change in H225calls_packet that broke it.
On Monday 21 February 2005 02:36:57 -0000 (GMT), lego@xxxxxxxxxxxx
<lego@xxxxxxxxxxxx> wrote:
  
User: lego
Date: 2005/02/20 08:36 PM

Log:
 fix few things:
 - boolean does not exists in *nix change them to g_boolean
 - removed some warnings about uninitialized variables
 - mgcp_info->hasDigitMap is a pointer to a boolean, dereference it

Directory: /trunk/gtk/
  Changes    Path            Action
  +23 -16    voip_calls.c    Modified

http://anonsvn.ethereal.com/viewcvs/viewcvs.py?rev=13456&view=rev

_______________________________________________
Ethereal-cvs mailing list
Ethereal-cvs@xxxxxxxxxxxx
http://www.ethereal.com/mailman/listinfo/ethereal-cvs

    
_______________________________________________
Ethereal-dev mailing list
Ethereal-dev@xxxxxxxxxxxx
http://www.ethereal.com/mailman/listinfo/ethereal-dev

  
Index: gtk/voip_calls.c
===================================================================
--- gtk/voip_calls.c	(revision 13457)
+++ gtk/voip_calls.c	(working copy)
@@ -1122,162 +1122,158 @@
 		strinfo->npackets = 0;
 
 		tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo);				
-	} else {
+	} 
+	/* let's analyze the call state */
+	g_memmove(&(tmp_src), pinfo->src.data, 4);
+	g_memmove(&(tmp_dst), pinfo->dst.data, 4);
 
-		/* let's analyze the call state */
+	strinfo->stop_sec=pinfo->fd->rel_secs;
+	strinfo->stop_usec=pinfo->fd->rel_usecs;
+	strinfo->last_frame_num=pinfo->fd->num;
+	++(strinfo->npackets);
+	/* increment the packets counter of all calls */
+	++(tapinfo->npackets);
 
-		g_memmove(&(tmp_src), pinfo->src.data, 4);
-		g_memmove(&(tmp_dst), pinfo->dst.data, 4);
-
-		strinfo->stop_sec=pinfo->fd->rel_secs;
-		strinfo->stop_usec=pinfo->fd->rel_usecs;
-		strinfo->last_frame_num=pinfo->fd->num;
-		++(strinfo->npackets);
-		/* increment the packets counter of all calls */
-		++(tapinfo->npackets);
-
-		/* XXX: it is supposed to be initialized isn't it? */
-		g_assert(tmp_h323info != NULL);
+	/* XXX: it is supposed to be initialized isn't it? */
+	g_assert(tmp_h323info != NULL);
 		
-		/* change the status */
-		if (pi->msg_type == H225_CS){
-			if (tmp_h323info->q931_crv == -1) {
-				tmp_h323info->q931_crv = q931_crv;
-			} else if (tmp_h323info->q931_crv != q931_crv) {
-				tmp_h323info->q931_crv2 = q931_crv;
-			}
+	/* change the status */
+	if (pi->msg_type == H225_CS){
+		if (tmp_h323info->q931_crv == -1) {
+			tmp_h323info->q931_crv = q931_crv;
+		} else if (tmp_h323info->q931_crv != q931_crv) {
+			tmp_h323info->q931_crv2 = q931_crv;
+		}
 
-			if (pi->is_h245 == TRUE){
-				add_h245_Address(tmp_h323info, pi->h245_address, pi->h245_port);
-			}
+		if (pi->is_h245 == TRUE){
+			add_h245_Address(tmp_h323info, pi->h245_address, pi->h245_port);
+		}
 
-			if (pi->cs_type != H225_RELEASE_COMPLET) tmp_h323info->is_h245Tunneling = pi->is_h245Tunneling;
+		if (pi->cs_type != H225_RELEASE_COMPLET) tmp_h323info->is_h245Tunneling = pi->is_h245Tunneling;
 
-			frame_label = g_strdup(pi->frame_label);
+		frame_label = g_strdup(pi->frame_label);
 
-			switch(pi->cs_type){
-			case H225_SETUP:
-				tmp_h323info->is_faststart_Setup = pi->is_faststart;
-				/* set te calling and called number from the Q931 packet */
-				if (q931_frame_num == pinfo->fd->num){
-					if (q931_calling_number != NULL){
-						g_free(strinfo->from_identity);
-						strinfo->from_identity=g_strdup(q931_calling_number);
-					}
-					if (q931_called_number != NULL){
-						g_free(strinfo->to_identity);
-						strinfo->to_identity=g_strdup(q931_called_number);
-					}
+		switch(pi->cs_type){
+		case H225_SETUP:
+			tmp_h323info->is_faststart_Setup = pi->is_faststart;
+			/* set te calling and called number from the Q931 packet */
+			if (q931_frame_num == pinfo->fd->num){
+				if (q931_calling_number != NULL){
+					g_free(strinfo->from_identity);
+					strinfo->from_identity=g_strdup(q931_calling_number);
 				}
-				/* check if there is an LRQ/LCF that match this Setup */
-				/* TODO: we are just checking the DialedNumer in LRQ/LCF agains the Setup 
-				  we should also check if the h225 signaling IP and port match the destination 
-				  Setup ip and port */
-				list = g_list_first(tapinfo->strinfo_list);
-						foo=	g_list_length(list);
-				while (list)
-				{
-					tmp_listinfo=list->data;
-					if (tmp_listinfo->protocol == VOIP_H323){
-						tmp2_h323info = tmp_listinfo->prot_info;
+				if (q931_called_number != NULL){
+					g_free(strinfo->to_identity);
+					strinfo->to_identity=g_strdup(q931_called_number);
+				}
+			}
+			/* check if there is an LRQ/LCF that match this Setup */
+			/* TODO: we are just checking the DialedNumer in LRQ/LCF agains the Setup 
+			  we should also check if the h225 signaling IP and port match the destination 
+			  Setup ip and port */
+			list = g_list_first(tapinfo->strinfo_list);
+					foo=	g_list_length(list);
+			while (list)
+			{
+				tmp_listinfo=list->data;
+				if (tmp_listinfo->protocol == VOIP_H323){
+					tmp2_h323info = tmp_listinfo->prot_info;
 
-						/* check if there called number match a LRQ/LCF */
-						if ( (strcmp(strinfo->to_identity, tmp_listinfo->to_identity)==0)  
-								&& (memcmp(tmp2_h323info->guid, guid_allzero, GUID_LEN) == 0) ){ 
-							/* change the call graph to the LRQ/LCF to belong to this call */
-							strinfo->npackets += change_call_num_graph(tapinfo, tmp_listinfo->call_num, strinfo->call_num);
+					/* check if there called number match a LRQ/LCF */
+					if ( (strcmp(strinfo->to_identity, tmp_listinfo->to_identity)==0)  
+							&& (memcmp(tmp2_h323info->guid, guid_allzero, GUID_LEN) == 0) ){ 
+						/* change the call graph to the LRQ/LCF to belong to this call */
+						strinfo->npackets += change_call_num_graph(tapinfo, tmp_listinfo->call_num, strinfo->call_num);
 
-							/* remove this LRQ/LCF call entry because we have found the Setup that match them */
-							g_free(tmp_listinfo->from_identity);
-							g_free(tmp_listinfo->to_identity);
-							g_free(tmp2_h323info->guid);
-							g_list_free(tmp2_h323info->h245_list);
-							tmp2_h323info->h245_list = NULL;		
-							g_free(tmp_listinfo->prot_info);
-							tapinfo->strinfo_list = g_list_remove(tapinfo->strinfo_list, tmp_listinfo);
-							break;
-						}
+						/* remove this LRQ/LCF call entry because we have found the Setup that match them */
+						g_free(tmp_listinfo->from_identity);
+						g_free(tmp_listinfo->to_identity);
+						g_free(tmp2_h323info->guid);
+						g_list_free(tmp2_h323info->h245_list);
+						tmp2_h323info->h245_list = NULL;		
+						g_free(tmp_listinfo->prot_info);
+						tapinfo->strinfo_list = g_list_remove(tapinfo->strinfo_list, tmp_listinfo);
+						break;
 					}
-					list = g_list_next (list);
 				}
-						foo=	g_list_length(list);
-				/* Set the Setup address if it was not set */
-				if (tmp_h323info->h225SetupAddr == 0) g_memmove(&(tmp_h323info->h225SetupAddr), pinfo->src.data,4);
-				strinfo->call_state=VOIP_CALL_SETUP;
-				comment = g_strdup_printf("H225 From: %s To:%s  TunnH245:%s FS:%s", strinfo->from_identity, strinfo->to_identity, (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"), 
-											(pi->is_faststart==TRUE?"on":"off"));
-				break;
-			case H225_CONNECT:
-				strinfo->call_state=VOIP_IN_CALL;
-				if (pi->is_faststart == TRUE) tmp_h323info->is_faststart_Proc = TRUE;
-				comment = g_strdup_printf("H225 TunnH245:%s FS:%s", (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"), 
-											(pi->is_faststart==TRUE?"on":"off"));
-				break;
-			case H225_RELEASE_COMPLET:
-				g_memmove(&(tmp_src), pinfo->src.data, 4);
-				if (strinfo->call_state==VOIP_CALL_SETUP){
-					if (tmp_h323info->h225SetupAddr == tmp_src){  /* forward direction */
-						strinfo->call_state=VOIP_CANCELLED;
-					}
-					else{												/* reverse */
-						strinfo->call_state=VOIP_REJECTED;
-						tapinfo->rejected_calls++;
-					}
+				list = g_list_next (list);
+			}
+					foo=	g_list_length(list);
+			/* Set the Setup address if it was not set */
+			if (tmp_h323info->h225SetupAddr == 0) g_memmove(&(tmp_h323info->h225SetupAddr), pinfo->src.data,4);
+			strinfo->call_state=VOIP_CALL_SETUP;
+			comment = g_strdup_printf("H225 From: %s To:%s  TunnH245:%s FS:%s", strinfo->from_identity, strinfo->to_identity, (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"), 
+										(pi->is_faststart==TRUE?"on":"off"));
+			break;
+		case H225_CONNECT:
+			strinfo->call_state=VOIP_IN_CALL;
+			if (pi->is_faststart == TRUE) tmp_h323info->is_faststart_Proc = TRUE;
+			comment = g_strdup_printf("H225 TunnH245:%s FS:%s", (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"), 
+										(pi->is_faststart==TRUE?"on":"off"));
+			break;
+		case H225_RELEASE_COMPLET:
+			g_memmove(&(tmp_src), pinfo->src.data, 4);
+			if (strinfo->call_state==VOIP_CALL_SETUP){
+				if (tmp_h323info->h225SetupAddr == tmp_src){  /* forward direction */
+					strinfo->call_state=VOIP_CANCELLED;
 				}
-				else if (strinfo->call_state == VOIP_IN_CALL){
-					strinfo->call_state = VOIP_COMPLETED;
-					tapinfo->completed_calls++;
+				else{												/* reverse */
+					strinfo->call_state=VOIP_REJECTED;
+					tapinfo->rejected_calls++;
 				}
-				/* get the Q931 Release cause code */
-				if (q931_frame_num == pinfo->fd->num &&
-				    q931_cause_value != 0xFF){		
-					comment = g_strdup_printf("H225 Q931 Rel Cause (%i):%s", q931_cause_value, val_to_str(q931_cause_value, q931_cause_code_vals, "<unknown>"));
-				} else {			/* Cause not set */
-					comment = g_strdup("H225 No Q931 Rel Cause");
-				}
-				break;
-			case H225_PROGRESS:
-			case H225_ALERTING:
-			case H225_CALL_PROCEDING:
-				if (pi->is_faststart == TRUE) tmp_h323info->is_faststart_Proc = TRUE;
-				comment = g_strdup_printf("H225 TunnH245:%s FS:%s", (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"), 
-											(pi->is_faststart==TRUE?"on":"off"));
-				break;
-			default:
-				comment = g_strdup_printf("H225 TunnH245:%s FS:%s", (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"), 
-											(pi->is_faststart==TRUE?"on":"off"));
-
 			}
-		} else if (pi->msg_type == H225_RAS){
-			switch(pi->msg_tag){
-			case 18:  /* LRQ */
-				if (!pi->is_duplicate){
-					g_free(strinfo->to_identity);
-					strinfo->to_identity=g_strdup(pi->dialedDigits);
-					tmp_h323info->requestSeqNum = pi->requestSeqNum;
-				}
-			case 19: /* LCF */
-				if (strlen(pi->dialedDigits)) 
-					comment = g_strdup_printf("H225 RAS dialedDigits: %s", pi->dialedDigits);
-				else
-					comment = g_strdup("H225 RAS");
-				break;
-			default:
-				comment = g_strdup("H225 RAS");
+			else if (strinfo->call_state == VOIP_IN_CALL){
+				strinfo->call_state = VOIP_COMPLETED;
+				tapinfo->completed_calls++;
 			}
-			frame_label = g_strdup_printf("%s", val_to_str(pi->msg_tag, RasMessage_vals, "<unknown>"));
-		} else {
-			frame_label = g_strdup("H225: Unknown");
-			comment = g_strdup("");
+			/* get the Q931 Release cause code */
+			if (q931_frame_num == pinfo->fd->num &&
+			    q931_cause_value != 0xFF){		
+				comment = g_strdup_printf("H225 Q931 Rel Cause (%i):%s", q931_cause_value, val_to_str(q931_cause_value, q931_cause_code_vals, "<unknown>"));
+			} else {			/* Cause not set */
+				comment = g_strdup("H225 No Q931 Rel Cause");
+			}
+			break;
+		case H225_PROGRESS:
+		case H225_ALERTING:
+		case H225_CALL_PROCEDING:
+			if (pi->is_faststart == TRUE) tmp_h323info->is_faststart_Proc = TRUE;
+			comment = g_strdup_printf("H225 TunnH245:%s FS:%s", (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"), 
+										(pi->is_faststart==TRUE?"on":"off"));
+			break;
+		default:
+			comment = g_strdup_printf("H225 TunnH245:%s FS:%s", (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"), 
+										(pi->is_faststart==TRUE?"on":"off"));
 		}
+	} else if (pi->msg_type == H225_RAS){
+		switch(pi->msg_tag){
+		case 18:  /* LRQ */
+			if (!pi->is_duplicate){
+				g_free(strinfo->to_identity);
+				strinfo->to_identity=g_strdup(pi->dialedDigits);
+				tmp_h323info->requestSeqNum = pi->requestSeqNum;
+			}
+		case 19: /* LCF */
+			if (strlen(pi->dialedDigits)) 
+				comment = g_strdup_printf("H225 RAS dialedDigits: %s", pi->dialedDigits);
+			else
+				comment = g_strdup("H225 RAS");
+			break;
+		default:
+			comment = g_strdup("H225 RAS");
+		}
+		frame_label = g_strdup_printf("%s", val_to_str(pi->msg_tag, RasMessage_vals, "<unknown>"));
+	} else {
+		frame_label = g_strdup("H225: Unknown");
+		comment = g_strdup("");
+	}
 
-		/* add to graph analysis */
-		if (!append_to_frame_graph(tapinfo, pinfo->fd->num, pi->frame_label, comment))		/* if the frame number exists in graph, append to it*/
-			add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num);  /* if not exist, add to the graph */
+	/* add to graph analysis */
+	if (!append_to_frame_graph(tapinfo, pinfo->fd->num, pi->frame_label, comment))		/* if the frame number exists in graph, append to it*/
+		add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num);  /* if not exist, add to the graph */
 
-		g_free(frame_label);
-		g_free(comment);
-	}
+	g_free(frame_label);
+	g_free(comment);
 
 	return 1;  /* refresh output */
 }
@@ -1784,9 +1780,9 @@
 			}
 
 			if (pi->signalReq != NULL)
-				frame_label = g_strdup_printf("%s%sSigReq:%s",pi->code, (*(pi->hasDigitMap) == TRUE)?" DigitMap ":"", pi->signalReq);
+				frame_label = g_strdup_printf("%s%sSigReq:%s",pi->code, (pi->hasDigitMap == TRUE)?" DigitMap ":"", pi->signalReq);
 			else
-				frame_label = g_strdup_printf("%s%s",pi->code, (*(pi->hasDigitMap) == TRUE)?" DigitMap ":"");
+				frame_label = g_strdup_printf("%s%s",pi->code, (pi->hasDigitMap == TRUE)?" DigitMap ":"");
 			
 			/* use the CallerID info to fill the "From" for the call */
 			if (!tmp_mgcpinfo->fromEndpoint) mgcpCallerID(pi->signalReq, &(strinfo->from_identity));
Index: plugins/mgcp/packet-mgcp.h
===================================================================
--- plugins/mgcp/packet-mgcp.h	(revision 13457)
+++ plugins/mgcp/packet-mgcp.h	(working copy)
@@ -45,7 +45,7 @@
   gchar *observedEvents;
   guint32 rspcode;
   gchar *signalReq;
-  gboolean *hasDigitMap;
+  gboolean hasDigitMap;
 } mgcp_info_t;
 
 /* Item of request list */