[svn-commits] branch crichter/0.3.0 r27344 - in /team/crichter/0.3.0/channels: ./ misdn/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue May 16 07:05:01 MST 2006


Author: crichter
Date: Tue May 16 09:05:00 2006
New Revision: 27344

URL: http://svn.digium.com/view/asterisk?rev=27344&view=rev
Log:
fixed very bad memory overwrite which leaded to segfaults on some systems. removed redundant buffer betweend mISDN reading thread and ast_read in favour of the already existing pipe, this clarifies the way a voice frame takes between mISDN and asterisk a lot. centralized debugging of NumberPlan. removed a compiler warning.

Modified:
    team/crichter/0.3.0/channels/chan_misdn.c
    team/crichter/0.3.0/channels/misdn/isdn_lib.c
    team/crichter/0.3.0/channels/misdn/isdn_lib.h
    team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c

Modified: team/crichter/0.3.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_misdn.c?rev=27344&r1=27343&r2=27344&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_misdn.c (original)
+++ team/crichter/0.3.0/channels/chan_misdn.c Tue May 16 09:05:00 2006
@@ -101,6 +101,7 @@
 available data is returned and the return value indicates the number
 of data. */
 int misdn_jb_empty(struct misdn_jb *jb, char *data, int len);
+
 
 
 
@@ -204,6 +205,12 @@
 	struct robin_list *prev;
 };
 static struct robin_list *robin = NULL;
+
+
+
+struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame *frame);
+
+
 
 static inline void free_robin_list_r (struct robin_list *r)
 {
@@ -1230,6 +1237,28 @@
 }
 
 
+void debug_numplan(int port, int numplan, char *type)
+{
+	switch (numplan) {
+	case NUMPLAN_INTERNATIONAL:
+		chan_misdn_log(2, port, " --> %s: International\n",type);
+		break;
+	case NUMPLAN_NATIONAL:
+		chan_misdn_log(2, port, " --> %s: National\n",type);
+		break;
+	case NUMPLAN_SUBSCRIBER:
+		chan_misdn_log(2, port, " --> %s: Subscriber\n",type);
+		break;
+	case NUMPLAN_UNKNOWN:
+		chan_misdn_log(2, port, " --> %s: Unknown\n",type);
+		break;
+		/* Maybe we should cut off the prefix if present ? */
+	default:
+		chan_misdn_log(0, port, " --> !!!! Wrong dialplan setting, please see the misdn.conf sample file\n ");
+		break;
+	}
+}
+
 static int read_config(struct chan_list *ch, int orig) {
 
 	if (!ch) {
@@ -1292,8 +1321,7 @@
 	
 	misdn_cfg_get( bc->port, MISDN_CFG_CONTEXT, ch->context, sizeof(ch->context));
 	
-	ast_copy_string (ast->context,ch->context,sizeof(ast->context));
-	
+	ast_copy_string (ast->context,ch->context,sizeof(ast->context));	
 	{
 		int ec, ectr;
 		
@@ -1312,7 +1340,6 @@
 		}
 	}
 	
-	
 	{
 		int eb3;
 		
@@ -1322,7 +1349,6 @@
 	
 	port=bc->port;
 	
-
 	{
 		char buf[256];
 		ast_group_t pg,cg;
@@ -1335,10 +1361,8 @@
 		ast->callgroup=cg;
 	}
 	
-	
 	if ( orig  == ORG_AST) {
 		misdn_cfg_get( port, MISDN_CFG_TE_CHOOSE_CHANNEL, &(bc->te_choose_channel), sizeof(int));
-		
 		
 		{
 			char callerid[BUFFERSIZE+1];
@@ -1355,67 +1379,11 @@
 
 			
 			misdn_cfg_get( port, MISDN_CFG_DIALPLAN, &bc->dnumplan, sizeof(int));
-			switch (bc->dnumplan) {
-			case NUMPLAN_INTERNATIONAL:
-				chan_misdn_log(2, port, " --> TON: International\n");
-				break;
-			case NUMPLAN_NATIONAL:
-				chan_misdn_log(2, port, " --> TON: National\n");
-				break;
-			case NUMPLAN_SUBSCRIBER:
-				chan_misdn_log(2, port, " --> TON: Subscriber\n");
-				break;
-			case NUMPLAN_UNKNOWN:
-				chan_misdn_log(2, port, " --> TON: Unknown\n");
-				break;
-				/* Maybe we should cut off the prefix if present ? */
-			default:
-				chan_misdn_log(0, port, " --> !!!! Wrong dialplan setting, please see the misdn.conf sample file\n ");
-				break;
-			}
-
-
 			misdn_cfg_get( port, MISDN_CFG_LOCALDIALPLAN, &bc->onumplan, sizeof(int));
-			switch (bc->onumplan) {
-			case NUMPLAN_INTERNATIONAL:
-				chan_misdn_log(2, port, " --> LTON: International\n");
-				break;
-			case NUMPLAN_NATIONAL:
-				chan_misdn_log(2, port, " --> LTON: National\n");
-				break;
-			case NUMPLAN_SUBSCRIBER:
-				chan_misdn_log(2, port, " --> LTON: Subscriber\n");
-				break;
-			case NUMPLAN_UNKNOWN:
-				chan_misdn_log(2, port, " --> LTON: Unknown\n");
-				break;
-				/* Maybe we should cut off the prefix if present ? */
-			default:
-					chan_misdn_log(0, port, " --> !!!! Wrong dialplan setting, please see the misdn.conf sample file\n ");
-					break;
-			}
-
 			misdn_cfg_get( port, MISDN_CFG_CPNDIALPLAN, &bc->cpnnumplan, sizeof(int));
-
-			switch (bc->cpnnumplan) {
-			case NUMPLAN_INTERNATIONAL:
-				chan_misdn_log(2, port, " --> CTON: International\n");
-				break;
-			case NUMPLAN_NATIONAL:
-				chan_misdn_log(2, port, " --> CTON: National\n");
-				break;
-			case NUMPLAN_SUBSCRIBER:
-				chan_misdn_log(2, port, " --> CTON: Subscriber\n");
-				break;
-			case NUMPLAN_UNKNOWN:
-				chan_misdn_log(2, port, " --> CTON: Unknown\n");
-				break;
-				/* Maybe we should cut off the prefix if present ? */
-			default:
-					chan_misdn_log(0, port, " --> !!!! Wrong dialplan setting, please see the misdn.conf sample file\n ");
-					break;
-			}
-
+			debug_numplan(port, bc->dnumplan,"TON");
+			debug_numplan(port, bc->onumplan,"LTON");
+			debug_numplan(port, bc->cpnnumplan,"CTON");
 		}
 
 		
@@ -1423,25 +1391,7 @@
 	} else { /** ORIGINATOR MISDN **/
 	
 		misdn_cfg_get( port, MISDN_CFG_CPNDIALPLAN, &bc->cpnnumplan, sizeof(int));
-
-		switch (bc->cpnnumplan) {
-			case NUMPLAN_INTERNATIONAL:
-				chan_misdn_log(2, port, " --> CTON: International\n");
-				break;
-			case NUMPLAN_NATIONAL:
-				chan_misdn_log(2, port, " --> CTON: National\n");
-				break;
-			case NUMPLAN_SUBSCRIBER:
-				chan_misdn_log(2, port, " --> CTON: Subscriber\n");
-				break;
-			case NUMPLAN_UNKNOWN:
-				chan_misdn_log(2, port, " --> CTON: Unknown\n");
-				break;
-				/* Maybe we should cut off the prefix if present ? */
-			default:
-				chan_misdn_log(0, port, " --> !!!! Wrong dialplan setting, please see the misdn.conf sample file\n ");
-				break;
-		}
+		debug_numplan(port, bc->cpnnumplan,"CTON");
 		
 		char prefix[BUFFERSIZE+1]="";
 		switch( bc->onumplan ) {
@@ -1452,14 +1402,6 @@
 		case NUMPLAN_NATIONAL:
 			misdn_cfg_get( bc->port, MISDN_CFG_NATPREFIX, prefix, BUFFERSIZE);
 			break;
-			
-			
-		case NUMPLAN_SUBSCRIBER:
-			/* dunno what to do here ? */
-			break;
-			
-		case NUMPLAN_UNKNOWN:
-				break;
 		default:
 			break;
 		}
@@ -1472,7 +1414,6 @@
 			strcpy(bc->oad,tmp);
 		}
 		
-		
 		if (!ast_strlen_zero(bc->dad)) {
 			ast_copy_string(bc->orig_dad,bc->dad, sizeof(bc->orig_dad));
 		}
@@ -1480,23 +1421,15 @@
 		if ( ast_strlen_zero(bc->dad) && !ast_strlen_zero(bc->keypad)) {
 			ast_copy_string(bc->dad,bc->keypad, sizeof(bc->dad));
 		}
+
 		prefix[0] = 0;
 		
 		switch( bc->dnumplan ) {
 		case NUMPLAN_INTERNATIONAL:
 			misdn_cfg_get( bc->port, MISDN_CFG_INTERNATPREFIX, prefix, BUFFERSIZE);
 			break;
-			
-			case NUMPLAN_NATIONAL:
-				misdn_cfg_get( bc->port, MISDN_CFG_NATPREFIX, prefix, BUFFERSIZE);
-				break;
-				
-				
-		case NUMPLAN_SUBSCRIBER:
-				/* dunno what to do here ? */
-			break;
-			
-		case NUMPLAN_UNKNOWN:
+		case NUMPLAN_NATIONAL:
+			misdn_cfg_get( bc->port, MISDN_CFG_NATPREFIX, prefix, BUFFERSIZE);
 			break;
 		default:
 			break;
@@ -1518,7 +1451,9 @@
 		
 		if ( !ast_strlen_zero(bc->rad) ) 
 			ast->cid.cid_rdnis=strdup(bc->rad);
-	}
+		
+	} /* ORIG MISDN END */
+	
 	return 0;
 }
 
@@ -1550,10 +1485,7 @@
 				chan_misdn_log(-1,0,"misdn_call: No Extension given!\n");
 				return -1;
 			}
-			
-		}
-		
-		
+		}
 	}
 
 	if (!ast) {
@@ -1568,7 +1500,6 @@
 		return -1;
 	}
 
-
 	if (!ch) {
 		ast_log(LOG_WARNING, " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL)\n", ast->name);
 		ast->hangupcause=41;
@@ -1589,12 +1520,9 @@
 	strncpy(newbc->dad,ext,sizeof( newbc->dad));
 	strncpy(ast->exten,ext,sizeof(ast->exten));
 	
-	
 	chan_misdn_log(1, port, "* CALL: %s\n",dest);
 	
 	chan_misdn_log(1, port, " --> * dad:%s tech:%s ctx:%s\n",ast->exten,ast->name, ast->context);
-	
-	
 	
 	chan_misdn_log(3, port, " --> * adding2newbc ext %s\n",ast->exten);
 	if (ast->exten) {
@@ -1635,7 +1563,6 @@
 			misdn_set_opt_exec(ast,opts);
 		else
 			chan_misdn_log(2,port,"NO OPTS GIVEN\n");
-		
 		
 		ch->state=MISDN_CALLING;
 		
@@ -2052,49 +1979,19 @@
 static struct ast_frame  *misdn_read(struct ast_channel *ast)
 {
 	struct chan_list *tmp;
-	
-	char blah[255];
-	int len =0 ;
+	int len;
 	
 	if (!ast) return NULL;
 	if (! (tmp=MISDN_ASTERISK_TECH_PVT(ast)) ) return NULL;
 	if (!tmp->bc) return NULL;
 	
-	
-	read(tmp->pipe[0],blah,sizeof(blah));
-	
-	len = misdn_ibuf_usedcount(tmp->bc->astbuf);
-
-	if (!len) {
-		struct ast_frame *frame;
-		if(!tmp->zero_read_cnt)
-			chan_misdn_log(4,tmp->bc->port,"misdn_read: ZERO READ\n");
-		tmp->zero_read_cnt++;
-
-		if (tmp->zero_read_cnt > 5000) {
-			chan_misdn_log(4,tmp->bc->port,"misdn_read: ZERO READ counted > 5000 times\n");
-			tmp->zero_read_cnt=0;
-
-		}
-
-		/*faking Voice Frame*/
-		tmp->frame.frametype = AST_FRAME_VOICE;
-		tmp->frame.subclass = AST_FORMAT_ALAW;
-		
-		memset(tmp->ast_rd_buf,0,128);
-		tmp->frame.data = tmp->ast_rd_buf ;
-		tmp->frame.mallocd =0 ;
-		tmp->frame.datalen = 128;
-		tmp->frame.samples = 128;
-		
-		frame=ast_frisolate(&tmp->frame);
-		return frame;
-	}
-
-	/*shrinken len if necessary, we transmit at maximum 4k*/
-	len = len<=sizeof(tmp->ast_rd_buf)?len:sizeof(tmp->ast_rd_buf);
-	
-	misdn_ibuf_memcpy_r(tmp->ast_rd_buf, tmp->bc->astbuf,len);
+	len=read(tmp->pipe[0],tmp->ast_rd_buf,sizeof(tmp->ast_rd_buf));
+	
+	if (len<=0) {
+		/* we hangup here, since our pipe is closed */
+		chan_misdn_log(2,tmp->bc->port,"misdn_read: Pipe closed, hanging up\n");
+		return NULL;
+	}
 	
 	tmp->frame.frametype  = AST_FRAME_VOICE;
 	tmp->frame.subclass = AST_FORMAT_ALAW;
@@ -2104,11 +2001,13 @@
 	tmp->frame.offset= 0 ;
 	tmp->frame.src = NULL;
 	tmp->frame.data = tmp->ast_rd_buf ;
-
+	
+	if (tmp->faxdetect || tmp->ast_dsp ) {
+		return process_ast_dsp(tmp, &tmp->frame);
+	}
+	
 	return &tmp->frame;
 }
-
-
 
 
 static int misdn_write(struct ast_channel *ast, struct ast_frame *frame)
@@ -2122,10 +2021,6 @@
 		ast_log(LOG_WARNING, "private but no bc\n");
 		return -1;
 	}
-	
-	/*if (ch->bc->tone != TONE_NONE)
-	  tone_indicate(ch,TONE_NONE); */
-	
 	
 	if (ch->holded ) {
 		chan_misdn_log(5, ch->bc->port, "misdn_write: Returning because holded\n");
@@ -2191,10 +2086,6 @@
 	}
 
 	chan_misdn_log(9, ch->bc->port, "Sending :%d bytes 2 MISDN\n",frame->samples);
-	/*if speech flip bits*/
-	if ( misdn_cap_is_speech(ch->bc->capability) )
-		flip_buf_bits(frame->data,frame->samples);
-	
 	
 	if ( !ch->bc->nojitter && misdn_cap_is_speech(ch->bc->capability) ) {
 		/* Buffered Transmit (triggert by read from isdn side)*/
@@ -2676,114 +2567,50 @@
 }
 
 
-
-static int misdn_tx2ast_frm(struct chan_list * tmp, char * buf,  int len )
-{
-	struct ast_frame frame;
-
-	/* If in hold state we drop frame .. */
-	if (tmp->holded ) return 0;
-	
-	switch(tmp->state) {
-	case MISDN_CLEANING:
-	case MISDN_EXTCANTMATCH:
-		return 0;
-		
-	case MISDN_WAITING4DIGS:
-	default:
-		break;
-	}
-	
-	if (tmp->norxtone) {
-		chan_misdn_log(3, tmp->bc->port, "misdn_tx2ast_frm: Returning because norxtone\n");
-		return 0;
-	}
-	
-	frame.frametype  = AST_FRAME_VOICE;
-	frame.subclass = AST_FORMAT_ALAW;
-	frame.datalen = len;
-	frame.samples = len ;
-	frame.mallocd =0 ;
-	frame.offset= 0 ;
-	frame.src = NULL;
-	frame.data = buf ;
-	
-	if (tmp->faxdetect || tmp->ast_dsp ) {
-		struct ast_frame *f,*f2;
-		if (tmp->trans)
-			f2=ast_translate(tmp->trans, &frame,0);
-		else {
-			chan_misdn_log(0, tmp->bc->port, "No T-Path found\n");
-			return 0;
-		}
-		
-		f = ast_dsp_process(tmp->ast, tmp->dsp, f2);
-		if (f && (f->frametype == AST_FRAME_DTMF)) {
-			ast_log(LOG_DEBUG, "Detected inband DTMF digit: %c", f->subclass);
-			if (f->subclass == 'f' && tmp->faxdetect) {
-				/* Fax tone -- Handle and return NULL */
-				struct ast_channel *ast = tmp->ast;
-				if (!tmp->faxhandled) {
-					tmp->faxhandled++;
-					if (strcmp(ast->exten, "fax")) {
-						if (ast_exists_extension(ast, ast_strlen_zero(ast->macrocontext)? ast->context : ast->macrocontext, "fax", 1, AST_CID_P(ast))) {
-							if (option_verbose > 2)
-								ast_verbose(VERBOSE_PREFIX_3 "Redirecting %s to fax extension\n", ast->name);
-							/* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
-							pbx_builtin_setvar_helper(ast,"FAXEXTEN",ast->exten);
-							if (ast_async_goto(ast, ast->context, "fax", 1))
-								ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, ast->context);
-						} else
-							ast_log(LOG_NOTICE, "Fax detected, but no fax extension ctx:%s exten:%s\n",ast->context, ast->exten);
+struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame *frame)
+{
+	struct ast_frame *f,*f2;
+	if (tmp->trans)
+		f2=ast_translate(tmp->trans, frame,0);
+	else {
+		chan_misdn_log(0, tmp->bc->port, "No T-Path found\n");
+		return NULL;
+	}
+	
+	f = ast_dsp_process(tmp->ast, tmp->dsp, f2);
+	if (f && (f->frametype == AST_FRAME_DTMF)) {
+		ast_log(LOG_DEBUG, "Detected inband DTMF digit: %c", f->subclass);
+		if (f->subclass == 'f' && tmp->faxdetect) {
+			/* Fax tone -- Handle and return NULL */
+			struct ast_channel *ast = tmp->ast;
+			if (!tmp->faxhandled) {
+				tmp->faxhandled++;
+				if (strcmp(ast->exten, "fax")) {
+					if (ast_exists_extension(ast, ast_strlen_zero(ast->macrocontext)? ast->context : ast->macrocontext, "fax", 1, AST_CID_P(ast))) {
+						if (option_verbose > 2)
+							ast_verbose(VERBOSE_PREFIX_3 "Redirecting %s to fax extension\n", ast->name);
+						/* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
+						pbx_builtin_setvar_helper(ast,"FAXEXTEN",ast->exten);
+						if (ast_async_goto(ast, ast->context, "fax", 1))
+							ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, ast->context);
 					} else
-						ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+						ast_log(LOG_NOTICE, "Fax detected, but no fax extension ctx:%s exten:%s\n",ast->context, ast->exten);
 				} else
-					ast_log(LOG_DEBUG, "Fax already handled\n");
-				frame.frametype = AST_FRAME_NULL;
-				frame.subclass = 0;
-				f = &frame;
-			}  else if ( tmp->ast_dsp) {
-				struct ast_frame fr;
-				memset(&fr, 0 , sizeof(fr));
-				fr.frametype = AST_FRAME_DTMF;
-				fr.subclass = f->subclass ;
-				fr.src=NULL;
-				fr.data = NULL ;
-				fr.datalen = 0;
-				fr.samples = 0 ;
-				fr.mallocd =0 ;
-				fr.offset= 0 ;
-				
-				chan_misdn_log(2, tmp->bc->port, " --> * SEND: DTMF (AST_DSP) :%c\n",f->subclass);
-				ast_queue_frame(tmp->ast, &fr);
-				
-				frame.frametype = AST_FRAME_NULL;
-				frame.subclass = 0;
-				f = &frame;
-			}
-		}
-	}
-	
-	if (tmp && tmp->ast && MISDN_ASTERISK_PVT (tmp->ast) && MISDN_ASTERISK_TECH_PVT(tmp->ast) ) {
-#if MISDN_DEBUG
-		int i, max=5>len?len:5;
-    
-		printf("write2* %p %d bytes: ",tmp, len);
-    
-		for (i=0; i<  max ; i++) printf("%2.2x ",((char*) frame.data)[i]);
-		printf ("\n");
-#endif
-		chan_misdn_log(9, tmp->bc->port, "Queueing %d bytes 2 Asterisk\n",len);
-		ast_queue_frame(tmp->ast,&frame);
-
-	}  else {
-		ast_log (LOG_WARNING, "No ast || ast->pvt || ch\n");
-	}
-	
-	return 0;
-}
-
-/** Channel Queue ***/
+					ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+			} else
+				ast_log(LOG_DEBUG, "Fax already handled\n");
+			
+		}  else if ( tmp->ast_dsp) {
+			chan_misdn_log(2, tmp->bc->port, " --> * SEND: DTMF (AST_DSP) :%c\n",f->subclass);
+			return f;
+		}
+	}
+
+	frame->frametype = AST_FRAME_NULL;
+	frame->subclass = 0;
+	return frame;
+}
+
 
 static struct chan_list *find_chan_by_l3id(struct chan_list *list, unsigned long l3id)
 {
@@ -3695,40 +3522,24 @@
 		
 	case EVENT_BCHAN_DATA:
 	{
-		if ( !misdn_cap_is_speech(ch->bc->capability) || bc->nojitter) {
-			misdn_tx2ast_frm(ch, bc->bframe, bc->bframe_len );
+		if ( !misdn_cap_is_speech(ch->bc->capability) ) {
+			struct ast_frame frame;
+			/*In Data Modes we queue frames*/
+			frame.frametype  = AST_FRAME_VOICE; /*we have no data frames yet*/
+			frame.subclass = AST_FORMAT_ALAW;
+			frame.datalen = bc->bframe_len;
+			frame.samples = bc->bframe_len ;
+			frame.mallocd =0 ;
+			frame.offset= 0 ;
+			frame.src = NULL;
+			frame.data = bc->bframe ;
+			
+			ast_queue_frame(ch->ast,&frame);
 		} else {
-			int len=bc->bframe_len;
-			int free=misdn_ibuf_freecount(bc->astbuf);
-		
-			if (bc->bframe_len > free) {
-				ast_log(LOG_DEBUG, "sbuf overflow!\n");
-				len=misdn_ibuf_freecount(bc->astbuf);
-
-				if (len == 0) {
-					ast_log(LOG_WARNING, "BCHAN_DATA: write buffer overflow port:%d channel:%d!\n",bc->port,bc->channel);
-				}
-			}
-			
-			misdn_ibuf_memcpy_w(bc->astbuf, bc->bframe, len);
-			
-			{
-				char blah[1]="\0";
-#ifdef FLATTEN_JITTER
-				{
-					struct timeval tv;
-					gettimeofday(&tv,NULL);
-					
-					if (tv.tv_usec % 10000 > 0 ) {
-						write(ch->pipe[1], blah,sizeof(blah));
-						bc->time_usec=tv.tv_usec;
-					}
-				}
-#else
-				write(ch->pipe[1], blah,sizeof(blah));
-#endif
-				
-				
+			int ret=write(ch->pipe[1], bc->bframe, bc->bframe_len);
+
+			if (ret<=0) {
+				chan_misdn_log(1, bc->port, "Write returned <=0 (err=%s)\n",strerror(errno));
 			}
 		}
 	}

Modified: team/crichter/0.3.0/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/isdn_lib.c?rev=27344&r1=27343&r2=27344&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/isdn_lib.c (original)
+++ team/crichter/0.3.0/channels/misdn/isdn_lib.c Tue May 16 09:05:00 2006
@@ -19,42 +19,6 @@
 void misdn_split_conf(struct misdn_bchannel *bc, int conf_id);
 
 
-void misdn_free_ibuffer(void *ibuf)
-{
-	free_ibuffer((ibuffer_t*)ibuf);
-}
-
-
-void misdn_clear_ibuffer(void *ibuf)
-{
-	clear_ibuffer( (ibuffer_t*)ibuf);
-}
-
-void *misdn_init_ibuffer(int len)
-{
-	return init_ibuffer(len);
-}
-
-int misdn_ibuf_freecount(void *buf)
-{
-	return ibuf_freecount( (ibuffer_t*)buf);
-}
-
-int misdn_ibuf_usedcount(void *buf)
-{
-	return ibuf_usedcount( (ibuffer_t*)buf);
-}
-
-void misdn_ibuf_memcpy_r(char *to, void *buf, int len)
-{
-	ibuf_memcpy_r( to, (ibuffer_t*)buf, len);
-}
-
-void misdn_ibuf_memcpy_w(void *buf, char *from,  int len)
-{
-	ibuf_memcpy_w((ibuffer_t*)buf, from, len);
-}
-
 struct misdn_stack* get_misdn_stack( void );
 
 
@@ -196,7 +160,6 @@
 void te_lib_destroy(int midev) ;
 struct misdn_bchannel *manager_find_bc_by_pid(int pid);
 struct misdn_bchannel *manager_find_bc_holded(struct misdn_bchannel* bc);
-unsigned char * manager_flip_buf_bits ( unsigned char * buf , int len);
 void manager_ph_control_block(struct misdn_bchannel *bc, long c1, void *c2, int c2_len);
 void manager_clean_bc(struct misdn_bchannel *bc );
 void manager_bchannel_setup (struct misdn_bchannel *bc);
@@ -2033,6 +1996,7 @@
 	jlen=cb_jb_empty(bc,&buf[mISDN_HEADER_LEN],len);
 	
 	if (jlen) {
+		flip_buf_bits( &buf[mISDN_HEADER_LEN], jlen);
 		
 		if (jlen < len) {
 			cb_log(5,bc->port,"Jitterbuffer Underrun.\n");
@@ -3587,8 +3551,10 @@
 	
 	frm->len = len;
 	memcpy(&buf[mISDN_HEADER_LEN], data,len);
-	
-	if ( ! misdn_cap_is_speech(bc->capability))
+		
+	if ( misdn_cap_is_speech(bc->capability) ) 
+		flip_buf_bits( &buf[mISDN_HEADER_LEN], len);
+	else
 		cb_log(6, stack->port, "Writing %d data bytes\n",len);
 	
 	cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len);

Modified: team/crichter/0.3.0/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/isdn_lib.h?rev=27344&r1=27343&r2=27344&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/isdn_lib.h (original)
+++ team/crichter/0.3.0/channels/misdn/isdn_lib.h Tue May 16 09:05:00 2006
@@ -371,18 +371,6 @@
 void get_show_stack_details(int port, char *buf);
 
 
-/** Ibuf interface **/
-int misdn_ibuf_usedcount(void *buf);
-int misdn_ibuf_freecount(void *buf);
-void misdn_ibuf_memcpy_r(char *to, void *from, int len);
-void misdn_ibuf_memcpy_w(void *buf, char *from, int len);
-
-void misdn_free_ibuffer(void *ibuf);
-void misdn_clear_ibuffer(void *ibuf);
-void *misdn_init_ibuffer(int len);
-
-/** Ibuf interface End **/
-
 void misdn_lib_tone_generator_start(struct misdn_bchannel *bc);
 void misdn_lib_tone_generator_stop(struct misdn_bchannel *bc);
 
@@ -393,8 +381,6 @@
 void misdn_lib_split_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
 
 void misdn_lib_echo(struct misdn_bchannel *bc, int onoff);
-
-unsigned char * flip_buf_bits ( unsigned char * buf , int len);
 
 int misdn_lib_is_ptp(int port);
 

Modified: team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c?rev=27344&r1=27343&r2=27344&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c (original)
+++ team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c Tue May 16 09:05:00 2006
@@ -874,6 +874,8 @@
 
 void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) 
 {
+
+#ifdef FACILITY_DECODE
 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
 	FACILITY_t *facility=(FACILITY_t*)((unsigned long)(msg->data+HEADER_LEN)); 
 	Q931_info_t *qi=(Q931_info_t*)(msg->data+HEADER_LEN);  
@@ -882,7 +884,6 @@
 	printf("Parsing FACILITY Msg\n"); 
 #endif
 
-#ifdef FACILITY_DECODE
 	{
 		fac_dec(facility->FACILITY, qi, &bc->fac_type, &bc->fac, bc);
 	}



More information about the svn-commits mailing list