[asterisk-commits] crichter: trunk r44841 - in /trunk: ./ channels/ channels/misdn/ configs/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Oct 11 01:34:04 MST 2006


Author: crichter
Date: Wed Oct 11 03:34:03 2006
New Revision: 44841

URL: http://svn.digium.com/view/asterisk?rev=44841&view=rev
Log:
Merged revisions 44561 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r44561 | crichter | 2006-10-06 14:50:25 +0200 (Fr, 06 Okt 2006) | 9 lines

Merged revisions 44334 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r44334 | crichter | 2006-10-04 17:13:58 +0200 (Mi, 04 Okt 2006) | 1 line

added the option 'reject_cause' to make it possible to set the RELEASE_COMPLETE - cause on the 3. incoming PMP channel, which is automatically rejected because chan_misdn does not support that kind of callwaiting. Therefore chan_misdn supports now 3 incoming channels on a PMP BRI Port. misdn_lib_get_free_bc now gets the info if the requested channel is incoming or outgoing to make the 3. channel possible
........

................

Modified:
    trunk/   (props changed)
    trunk/channels/chan_misdn.c
    trunk/channels/misdn/chan_misdn_config.h
    trunk/channels/misdn/isdn_lib.c
    trunk/channels/misdn/isdn_lib.h
    trunk/channels/misdn_config.c
    trunk/configs/misdn.conf.sample

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?rev=44841&r1=44840&r2=44841&view=diff
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Wed Oct 11 03:34:03 2006
@@ -2941,7 +2941,7 @@
 						
 						
 						if ( port_up>0 )	{
-							newbc = misdn_lib_get_free_bc(port, robin_channel);
+							newbc = misdn_lib_get_free_bc(port, robin_channel,0);
 							if (newbc) {
 								chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
 								if (port_up)
@@ -2975,7 +2975,7 @@
 					chan_misdn_log(4, port, "portup:%d\n", port_up);
 					
 					if ( port_up>0 ) {
-						newbc = misdn_lib_get_free_bc(port, 0);
+						newbc = misdn_lib_get_free_bc(port, 0, 0);
 						if (newbc)
 							break;
 					}
@@ -2986,7 +2986,7 @@
 	} else {
 		if (channel)
 			chan_misdn_log(1, port," --> preselected_channel: %d\n",channel);
-		newbc = misdn_lib_get_free_bc(port, channel);
+		newbc = misdn_lib_get_free_bc(port, channel, 0);
 	}
 	
 	if (!newbc) {
@@ -3836,6 +3836,14 @@
 	}
 
 	
+	if (bc->cw) {
+		chan_misdn_log(0, bc->port, " --> Call Waiting on PMP sending RELEASE_COMPLETE\n");
+		int cause;
+		misdn_cfg_get( bc->port, MISDN_CFG_REJECT_CAUSE, &cause, sizeof(cause));
+		bc->out_cause=cause?cause:16;
+		return RESPONSE_RELEASE_SETUP;
+	}
+
 	print_bearer(bc);
     
 	{

Modified: trunk/channels/misdn/chan_misdn_config.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/chan_misdn_config.h?rev=44841&r1=44840&r2=44841&view=diff
==============================================================================
--- trunk/channels/misdn/chan_misdn_config.h (original)
+++ trunk/channels/misdn/chan_misdn_config.h Wed Oct 11 03:34:03 2006
@@ -29,6 +29,7 @@
 	MISDN_CFG_TXGAIN,              /* int */
 	MISDN_CFG_TE_CHOOSE_CHANNEL,   /* int (bool) */
 	MISDN_CFG_PMP_L1_CHECK,        /* int (bool) */
+	MISDN_CFG_REJECT_CAUSE,		/* int */
 	MISDN_CFG_ALARM_BLOCK,        /* int (bool) */
 	MISDN_CFG_HDLC,                /* int (bool) */
 	MISDN_CFG_CONTEXT,             /* char[] */

Modified: trunk/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.c?rev=44841&r1=44840&r2=44841&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_lib.c (original)
+++ trunk/channels/misdn/isdn_lib.c Wed Oct 11 03:34:03 2006
@@ -109,7 +109,7 @@
 	
 	for ( ; stack; stack=stack->next) {
 		int i;
-		for (i=0; i <stack->b_num; i++) {
+		for (i=0; i <=stack->b_num; i++) {
 			if ( bc->port == stack->port) return stack;
 		}
 	}
@@ -183,6 +183,10 @@
 void misdn_tx_jitter(struct misdn_bchannel *bc, int len);
 
 struct misdn_bchannel *find_bc_by_l3id(struct misdn_stack *stack, unsigned long l3id);
+
+struct misdn_bchannel *find_bc_by_confid(unsigned long confid);
+
+struct misdn_bchannel *stack_holder_find_bychan(struct misdn_stack *stack, int chan);
 
 int setup_bc(struct misdn_bchannel *bc);
 
@@ -418,7 +422,7 @@
 {
 	int i;
 
-	for (i=0; i <stack->b_num; i++) {
+	for (i=0; i <= stack->b_num; i++) {
 		cb_log(6, stack->port, "Idx:%d stack->cchan:%d Chan:%d\n",i,stack->channels[i], i+1);
 	}
 }
@@ -535,6 +539,7 @@
 	
 
 	bc->in_use= 0;
+	bc->cw= 0;
 
 	bc->channel = 0;
 
@@ -667,7 +672,7 @@
 {
 	int i;
 
-	for (i=0; i<stack->b_num; i++) {
+	for (i=0; i<=stack->b_num; i++) {
 		if (global_state == MISDN_INITIALIZED)  {
 			cb_event(EVENT_CLEANUP, &stack->bc[i], NULL); 
 			empty_chan_in_stack(stack,i+1);
@@ -1164,7 +1169,7 @@
 	stack->d_stid = stinf->id;
 	stack->b_num = stinf->childcnt;
 
-	for (i=0; i<stinf->childcnt; i++)
+	for (i=0; i<=stinf->childcnt; i++)
 		stack->b_stids[i] = stinf->child[i];
   
 	switch(stinf->pid.protocol[0] & ~ISDN_PID_FEATURE_MASK) {
@@ -1377,7 +1382,7 @@
 static struct misdn_bchannel *find_bc_by_masked_l3id(struct misdn_stack *stack, unsigned long l3id, unsigned long mask)
 {
 	int i;
-	for (i=0; i<stack->b_num; i++) {
+	for (i=0; i<=stack->b_num; i++) {
 		if ( (stack->bc[i].l3_id & mask)  ==  (l3id & mask)) return &stack->bc[i] ;
 	}
 	return stack_holder_find(stack,l3id);
@@ -1387,7 +1392,7 @@
 struct misdn_bchannel *find_bc_by_l3id(struct misdn_stack *stack, unsigned long l3id)
 {
 	int i;
-	for (i=0; i<stack->b_num; i++) {
+	for (i=0; i<=stack->b_num; i++) {
 		if (stack->bc[i].l3_id == l3id) return &stack->bc[i] ;
 	}
 	return stack_holder_find(stack,l3id);
@@ -1396,7 +1401,7 @@
 static struct misdn_bchannel *find_bc_holded(struct misdn_stack *stack)
 {
 	int i;
-	for (i=0; i<stack->b_num; i++) {
+	for (i=0; i<=stack->b_num; i++) {
 		if (stack->bc[i].holded ) return &stack->bc[i] ;
 	}
 	return NULL;
@@ -1411,7 +1416,7 @@
 	for (stack=glob_mgr->stack_list;
 	     stack;
 	     stack=stack->next) {
-		for (i=0; i< stack->b_num; i++) {
+		for (i=0; i<=stack->b_num; i++) {
 			if ( (stack->bc[i].addr&STACK_ID_MASK)==(addr&STACK_ID_MASK) ||  stack->bc[i].layer_id== addr ) {
 				return &stack->bc[i];
 			}
@@ -1429,7 +1434,7 @@
 	for (stack=glob_mgr->stack_list;
 	     stack;
 	     stack=stack->next) {
-		for (i=0; i< stack->b_num; i++) {
+		for (i=0; i<=stack->b_num; i++) {
 			if ( stack->bc[i].conf_id==confid ) {
 				return &stack->bc[i];
 			}
@@ -1446,7 +1451,7 @@
 
 	if (!stack) return NULL;	
 	
-	for (i=0; i< stack->b_num; i++) {
+	for (i=0; i<=stack->b_num; i++) {
 		if ( stack->bc[i].channel== channel ) {
 			return &stack->bc[i];
 		}
@@ -1536,7 +1541,7 @@
 static int handle_new_process(struct misdn_stack *stack, iframe_t *frm)
 {
   
-	struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0);
+	struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1);
 	
 	
 	if (!bc) {
@@ -1556,8 +1561,9 @@
 	switch (frm->prim) {
 	case CC_NEW_CR|INDICATION:
 		cb_log(7, stack->port, " --> lib: NEW_CR Ind with l3id:%x on this port.\n",frm->dinfo);
-		if (handle_new_process(stack, frm) <0) 
+		if (handle_new_process(stack, frm) <0) {
 			return -1;
+		}
 		return 1;
 	case CC_NEW_CR|CONFIRM:
 		return 1;
@@ -2183,6 +2189,30 @@
 }
 
 
+#ifdef MISDN_SAVE_DATA
+static void misdn_save_data(int id, char *p1, int l1, char *p2, int l2) 
+{
+	char n1[32],n2[32];
+
+	sprintf(n1,"/tmp/misdn-rx-%d.raw",id);
+	sprintf(n2,"/tmp/misdn-tx-%d.raw",id);
+
+	FILE *rx=fopen(n1,"a+"); 
+	FILE *tx=fopen(n2,"a+");
+
+	if (!rx || !tx) {
+		cb_log(0,0,"Couldn't open files: %s\n",strerror(errno));
+		return ;
+	}
+	
+	fwrite(p1,1,l1,rx);
+	fwrite(p2,1,l2,tx);
+	
+	fclose(rx);
+	fclose(tx);
+
+}
+#endif
 
 void misdn_tx_jitter(struct misdn_bchannel *bc, int len)
 {
@@ -2194,6 +2224,9 @@
 	jlen=cb_jb_empty(bc,data,len);
 	
 	if (jlen) {
+#ifdef MISDN_SAVE_DATA
+		misdn_save_data((bc->port*100+bc->channel), data, jlen, bc->bframe, bc->bframe_len);
+#endif
 		flip_buf_bits( data, jlen);
 		
 		if (jlen < len) {
@@ -2208,7 +2241,7 @@
 		
 		txfrm->len =jlen;
 		cb_log(9, bc->port, "Transmitting %d samples 2 misdn\n", txfrm->len);
-		
+
 		r=mISDN_write( glob_mgr->midev, buf, txfrm->len + mISDN_HEADER_LEN, 8000 );
 	} else {
 #define MISDN_GEN_SILENCE
@@ -2555,6 +2588,8 @@
 
 		if (ret<0) {
 			cb_log(3,stack?stack->port:0,"handle_frm: handle_cr <0 prim:%x addr:%x\n", frm->prim, frm->addr);
+
+
 		}
 
 		if(ret) {
@@ -2590,8 +2625,9 @@
 					break;
 				case RESPONSE_IGNORE_SETUP:
 					/* I think we should send CC_RELEASE_CR, but am not sure*/
-
 					bc->out_cause=16;
+				
+				case RESPONSE_RELEASE_SETUP:
 					misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
 					if (bc->channel>0)
 						empty_chan_in_stack(stack, bc->channel);
@@ -2660,7 +2696,7 @@
 			free_msg(msg);
 		}
 		
-		for (i=0;i<stack->b_num; i++) {
+		for (i=0;i<=stack->b_num; i++) {
 			if (stack->bc[i].evq != EVENT_NOTHING) {
 				cb_log(4, stack->port, "Fireing Queued Event %s because L1 got up\n", isdn_get_info(msgs_g, stack->bc[i].evq, 0));
 				misdn_lib_send_event(&stack->bc[i],stack->bc[i].evq);
@@ -2684,7 +2720,7 @@
 	case PH_DEACTIVATE | INDICATION:
 		cb_log (3, stack->port, "L1: PH L1Link Down! \n");
 		
-		for (i=0; i<stack->b_num; i++) {
+		for (i=0; i<=stack->b_num; i++) {
 			if (global_state == MISDN_INITIALIZED)  {
 				cb_event(EVENT_CLEANUP, &stack->bc[i], glob_mgr->user_data);
 			}
@@ -3002,7 +3038,7 @@
 	for (stack=glob_mgr->stack_list;
 	     stack;
 	     stack=stack->next) {
-		for (i=0; i<stack->b_num; i++)
+		for (i=0; i<=stack->b_num; i++)
 			if (stack->bc[i].pid == pid) return &stack->bc[i];
 	}
   
@@ -3037,7 +3073,7 @@
 #endif
 }
 
-struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel)
+struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout)
 {
 	struct misdn_stack *stack;
 	int i;
@@ -3068,8 +3104,14 @@
 					return NULL;
 				}
 			}
-			for (i = 0; i < stack->b_num; i++) {
+
+			int maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num;
+			for (i = 0; i <maxnum; i++) {
 				if (!stack->bc[i].in_use) {
+					/* 3. channel on bri means CW*/
+					if (!stack->pri && i==stack->b_num)
+						stack->bc[i].cw=1;
+
 					prepare_bc(&stack->bc[i], channel);
 					return &stack->bc[i];
 				}
@@ -3775,7 +3817,7 @@
     
 		{
 			int i;
-			for(i=0;i<stack->b_num; i++) {
+			for(i=0;i<=stack->b_num; i++) {
 				int r;
 				if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "", 1))<0) {
 					cb_log(0, port, "Got Err @ init_bc :%d\n",r);
@@ -3822,7 +3864,7 @@
 	int i;
   
 	for ( help=glob_mgr->stack_list; help; help=help->next ) {
-		for(i=0;i<help->b_num; i++) {
+		for(i=0;i<=help->b_num; i++) {
 			char buf[1024];
 			mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
 			help->bc[i].addr = 0;

Modified: trunk/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.h?rev=44841&r1=44840&r2=44841&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_lib.h (original)
+++ trunk/channels/misdn/isdn_lib.h Wed Oct 11 03:34:03 2006
@@ -19,6 +19,14 @@
 /** For initialization usage **/
 /* typedef int ie_nothing_t ;*/
 /** end of init usage **/
+
+
+/* 
+ * uncomment the following to make chan_misdn create
+ * record files in /tmp/misdn-{rx|tx}-PortChannel format 
+ * */
+
+/*#define MISDN_SAVE_DATA*/
 
 #ifdef WITH_BEROEC
 typedef int beroec_t;
@@ -95,6 +103,7 @@
 enum event_response_e {
 	RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE,
 	RESPONSE_IGNORE_SETUP,
+	RESPONSE_RELEASE_SETUP,
 	RESPONSE_ERR,
 	RESPONSE_OK
 };
@@ -214,6 +223,7 @@
 	int channel_preselected;
 	
 	int in_use;
+	int cw;
 	int addr;
 
 	char * bframe;
@@ -382,7 +392,7 @@
 
 void misdn_lib_transfer(struct misdn_bchannel* holded_bc);
 
-struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel);
+struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout);
 
 void manager_bchannel_activate(struct misdn_bchannel *bc);
 void manager_bchannel_deactivate(struct misdn_bchannel * bc);

Modified: trunk/channels/misdn_config.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn_config.c?rev=44841&r1=44840&r2=44841&view=diff
==============================================================================
--- trunk/channels/misdn_config.c (original)
+++ trunk/channels/misdn_config.c Wed Oct 11 03:34:03 2006
@@ -271,6 +271,9 @@
 	{ "max_outgoing", MISDN_CFG_MAX_OUT, MISDN_CTYPE_INT, "-1", NONE,
 		"Defines the maximum amount of outgoing calls per port for this group\n"
 		"\texceeding calls will be rejected" },
+
+	{ "reject_cause", MISDN_CFG_REJECT_CAUSE, MISDN_CTYPE_INT, "21", NONE,
+		"Defines the cause with which a 3. call is rejected on PTMP BRI."},
 	{ "faxdetect", MISDN_CFG_FAXDETECT, MISDN_CTYPE_STR, "no", NONE,
 		"Setup fax detection:\n"
 		"\t    no        - no fax detection\n"
@@ -302,6 +305,7 @@
 		"MSN's for TE ports, listen on those numbers on the above ports, and\n"
 		"\tindicate the incoming calls to Asterisk.\n"
 		"\tHere you can give a comma seperated list, or simply an '*' for any msn." },
+
 };
 
 static const struct misdn_cfg_spec gen_spec[] = {

Modified: trunk/configs/misdn.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/misdn.conf.sample?rev=44841&r1=44840&r2=44841&view=diff
==============================================================================
--- trunk/configs/misdn.conf.sample (original)
+++ trunk/configs/misdn.conf.sample Wed Oct 11 03:34:03 2006
@@ -203,6 +203,17 @@
 pmp_l1_check=yes
 pp_l2_check=no
 
+
+
+;
+; in PMP this option defines which cause should be sent out to 
+; the 3. caller. chan_misdn does not support callwaiting on TE
+; PMP side. This allows to modify the RELEASE_COMPLETE cause 
+; at least.
+;
+reject_cause=16
+
+
 ;
 ; Send Setup_Acknowledge on incoming calls anyway (instead of PROCEEDING), 
 ; this requests additional Infos, so we can waitfordigits 



More information about the asterisk-commits mailing list