[Asterisk-cvs] asterisk/channels chan_iax2.c,1.359,1.360

markster markster
Sun Oct 23 14:18:45 CDT 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv26611/channels

Modified Files:
	chan_iax2.c 
Log Message:
Fix segfault when building peer based on IP


Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.359
retrieving revision 1.360
diff -u -d -r1.359 -r1.360
--- chan_iax2.c	19 Oct 2005 18:19:22 -0000	1.359
+++ chan_iax2.c	23 Oct 2005 18:11:54 -0000	1.360
@@ -2129,7 +2129,8 @@
     pvt->jbid = ast_sched_add(sched, when, get_from_jb, (void *)pvt);
 }
 
-static int get_from_jb(void *p) {
+static int get_from_jb(void *p) 
+{
 	/* make sure pvt is valid! */	
     struct chan_iax2_pvt *pvt = p;
     struct iax_frame *fr;
@@ -2152,49 +2153,49 @@
     now = ast_tvdiff_ms(tv, pvt->rxcore);
 
     if(now >= (next = jb_next(pvt->jb))) {
-	ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat));
-	switch(ret) {
-	    case JB_OK:
-		/*if(frame.type == JB_TYPE_VOICE && next + 20 != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(pvt->jb), next); */
-		fr = frame.data;
-		__do_deliver(fr);
-	    break;
-	    case JB_INTERP:
-	    {
-		struct ast_frame af;
-
-		/*if(next + 20 != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(pvt->jb), next); */
-
-		/* create an interpolation frame */
-		/*fprintf(stderr, "Making Interpolation frame\n"); */
-		af.frametype = AST_FRAME_VOICE;
-		af.subclass = pvt->voiceformat;
-		af.datalen  = 0;
-		af.samples  = frame.ms * 8;
-		af.mallocd  = 0;
-		af.src  = "IAX2 JB interpolation";
-		af.data  = NULL;
-		af.delivery = ast_tvadd(pvt->rxcore, ast_samp2tv(next, 1000));
-		af.offset=AST_FRIENDLY_OFFSET;
-
-		/* queue the frame:  For consistency, we would call __do_deliver here, but __do_deliver wants an iax_frame,
-		 * which we'd need to malloc, and then it would free it.  That seems like a drag */
-		if (iaxs[pvt->callno] && !ast_test_flag(iaxs[pvt->callno], IAX_ALREADYGONE))
-			iax2_queue_frame(pvt->callno, &af);
-	    }
-	    break;
-	    case JB_DROP:
-		/*if(next != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not next %ld!\n", jb_next(pvt->jb), next); */
-		iax2_frame_free(frame.data);
-	    break;
-	    case JB_NOFRAME:
-	    case JB_EMPTY:
-		/* do nothing */
-	    break;
-	    default:
-		/* shouldn't happen */
-	    break;
-	}
+		ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat));
+		switch(ret) {
+		case JB_OK:
+			/*if(frame.type == JB_TYPE_VOICE && next + 20 != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(pvt->jb), next); */
+			fr = frame.data;
+			__do_deliver(fr);
+		    break;
+		case JB_INTERP:
+		    {
+			struct ast_frame af;
+	
+			/*if(next + 20 != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(pvt->jb), next); */
+	
+			/* create an interpolation frame */
+			/*fprintf(stderr, "Making Interpolation frame\n"); */
+			af.frametype = AST_FRAME_VOICE;
+			af.subclass = pvt->voiceformat;
+			af.datalen  = 0;
+			af.samples  = frame.ms * 8;
+			af.mallocd  = 0;
+			af.src  = "IAX2 JB interpolation";
+			af.data  = NULL;
+			af.delivery = ast_tvadd(pvt->rxcore, ast_samp2tv(next, 1000));
+			af.offset=AST_FRIENDLY_OFFSET;
+	
+			/* queue the frame:  For consistency, we would call __do_deliver here, but __do_deliver wants an iax_frame,
+			 * which we'd need to malloc, and then it would free it.  That seems like a drag */
+			if (iaxs[pvt->callno] && !ast_test_flag(iaxs[pvt->callno], IAX_ALREADYGONE))
+				iax2_queue_frame(pvt->callno, &af);
+		    }
+		    break;
+		case JB_DROP:
+			/*if(next != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not next %ld!\n", jb_next(pvt->jb), next); */
+			iax2_frame_free(frame.data);
+		    break;
+		case JB_NOFRAME:
+		case JB_EMPTY:
+			/* do nothing */
+		    break;
+		default:
+			/* shouldn't happen */
+		    break;
+		}
     }
     update_jbsched(pvt);
     ast_mutex_unlock(&iaxsl[pvt->callno]);
@@ -2533,6 +2534,15 @@
 		ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr);
 		sprintf(porta, "%d", ntohs(sin->sin_port));
 		var = ast_load_realtime("iaxpeers", "ipaddr", iabuf, "port", porta, NULL);
+		if (var) {
+			/* We'll need the peer name in order to build the structure! */
+			tmp = var;
+			while(tmp) {
+				if (!strcasecmp(tmp->name, "name"))
+					peername = tmp->value;
+				tmp = tmp->next;
+			}
+		}
 	}
 	if (!var)
 		return NULL;




More information about the svn-commits mailing list