[svn-commits] crichter: trunk r64952 - in /trunk: ./ channels/ channels/misdn/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri May 18 02:36:16 MST 2007


Author: crichter
Date: Fri May 18 04:36:16 2007
New Revision: 64952

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

................
r59064 | crichter | 2007-03-20 14:16:06 +0100 (Di, 20 Mär 2007) | 21 lines

Merged revisions 58849-58850,59062-59063 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r58849 | crichter | 2007-03-13 12:58:16 +0100 (Di, 13 Mär 2007) | 1 line

added method standard_dec for dialing out on groups, to avoid conflicts, which caused issues with some ISDN providers
........
r58850 | crichter | 2007-03-13 13:58:32 +0100 (Di, 13 Mär 2007) | 1 line

fixed the crypt_keys stuff
........
r59062 | crichter | 2007-03-20 10:18:06 +0100 (Di, 20 Mär 2007) | 1 line

avoid sending a disconnect when we already received one.
........
r59063 | crichter | 2007-03-20 10:23:22 +0100 (Di, 20 Mär 2007) | 1 line

modified a loglevel
........

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

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

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?view=diff&rev=64952&r1=64951&r2=64952
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Fri May 18 04:36:16 2007
@@ -2972,6 +2972,7 @@
 	char *tokb=NULL, *p=NULL;
 	int channel=0, port=0;
 	struct misdn_bchannel *newbc = NULL;
+	int dec=0;
 	
 	struct chan_list *cl=init_chan_list(ORG_AST);
 	
@@ -3000,23 +3001,27 @@
 		else {
 			port = atoi(port_str);
 		}
-		
-		
 	} else {
 		ast_log(LOG_WARNING, " --> ! IND : CALL dad:%s WITHOUT PORT/Group, check extension.conf\n",ext);
 		return NULL;
 	}
 
+	if (misdn_cfg_is_group_method(group, METHOD_STANDARD_DEC)) {
+		chan_misdn_log(4, port, " --> STARTING STANDARDDEC...\n");
+		dec=1;
+	}
+
 	if (!ast_strlen_zero(group)) {
 	
 		char cfg_group[BUFFERSIZE+1];
 		struct robin_list *rr = NULL;
 
 		if (misdn_cfg_is_group_method(group, METHOD_ROUND_ROBIN)) {
-			chan_misdn_log(4, port, " --> STARTING ROUND ROBIN...");
+			chan_misdn_log(4, port, " --> STARTING ROUND ROBIN...\n");
 			rr = get_robin_position(group);
 		}
 		
+			
 		if (rr) {
 			int robin_channel = rr->channel;
 			int port_start;
@@ -3058,7 +3063,7 @@
 						
 						
 						if ( port_up>0 )	{
-							newbc = misdn_lib_get_free_bc(port, robin_channel,0);
+							newbc = misdn_lib_get_free_bc(port, robin_channel,0, 0);
 							if (newbc) {
 								chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
 								if (port_up)
@@ -3074,9 +3079,7 @@
 			
 			if (!newbc)
 				chan_misdn_log(-1, port, " Failed! No free channel in group %d!", group);
-		}
-		
-		else {		
+		} else {		
 			for (port=misdn_cfg_get_next_port(0); port > 0;
 				 port=misdn_cfg_get_next_port(port)) {
 				
@@ -3092,18 +3095,17 @@
 					chan_misdn_log(4, port, "portup:%d\n", port_up);
 					
 					if ( port_up>0 ) {
-						newbc = misdn_lib_get_free_bc(port, 0, 0);
+						newbc = misdn_lib_get_free_bc(port, 0, 0, dec);
 						if (newbc)
 							break;
 					}
 				}
 			}
 		}
-		
 	} else {
 		if (channel)
 			chan_misdn_log(1, port," --> preselected_channel: %d\n",channel);
-		newbc = misdn_lib_get_free_bc(port, channel, 0);
+		newbc = misdn_lib_get_free_bc(port, channel, 0, dec);
 	}
 	
 	if (!newbc) {
@@ -4397,6 +4399,8 @@
 			cb_log(1,bc->port," --> found holded ch\n");
 			misdn_transfer_bc(ch, holded_ch) ;
 		}
+
+		bc->need_disconnect=0;
 		
 		stop_bc_tones(ch);
 		hangup_chan(ch);
@@ -4413,6 +4417,9 @@
 	
 	case EVENT_RELEASE:
 		{
+			bc->need_disconnect=0;
+			bc->need_release=0;
+
 			hangup_chan(ch);
 			release_chan(bc);
 		
@@ -4422,6 +4429,10 @@
 		break;
 	case EVENT_RELEASE_COMPLETE:
 	{
+		bc->need_disconnect=0;
+		bc->need_release=0;
+		bc->need_release_complete=0;
+
 		stop_bc_tones(ch);
 		hangup_chan(ch);
 		release_chan(bc);

Modified: trunk/channels/misdn/chan_misdn_config.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/chan_misdn_config.h?view=diff&rev=64952&r1=64951&r2=64952
==============================================================================
--- trunk/channels/misdn/chan_misdn_config.h (original)
+++ trunk/channels/misdn/chan_misdn_config.h Fri May 18 04:36:16 2007
@@ -101,7 +101,8 @@
 
 enum misdn_cfg_method {
 	METHOD_STANDARD = 0,
-	METHOD_ROUND_ROBIN
+	METHOD_ROUND_ROBIN,
+	METHOD_STANDARD_DEC
 };
 
 /* you must call misdn_cfg_init before any other function of this header file */

Modified: trunk/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.c?view=diff&rev=64952&r1=64951&r2=64952
==============================================================================
--- trunk/channels/misdn/isdn_lib.c (original)
+++ trunk/channels/misdn/isdn_lib.c Fri May 18 04:36:16 2007
@@ -431,7 +431,7 @@
 
 
 
-static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchannel *bc, int channel)
+static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchannel *bc, int channel, int dec)
 {
 	int i;
 
@@ -443,14 +443,25 @@
 	}
 	
 	channel--;
-  
-	for (i = 0; i < stack->b_num; i++) {
-		if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 Dchannel ;) and work with chan preselection */
-			if (!stack->channels[i]) {
-				cb_log (3, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
-				bc->channel=i+1;
-				cb_event(EVENT_NEW_CHANNEL, bc, NULL);
-				return i+1;
+ 
+ 	if (dec) {
+		for (i = stack->b_num-1; i >=0; i--) {
+			if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 Dchannel ;) and work with chan preselection */
+				if (!stack->channels[i]) {
+					cb_log (3, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
+					bc->channel=i+1;
+					return i+1;
+				}
+			}
+		}
+	} else {
+		for (i = 0; i < stack->b_num; i++) {
+			if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 Dchannel ;) and work with chan preselection */
+				if (!stack->channels[i]) {
+					cb_log (3, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
+					bc->channel=i+1;
+					return i+1;
+				}
 			}
 		}
 	}
@@ -541,6 +552,7 @@
 	bc->in_use= 0;
 	bc->cw= 0;
 
+	bc->dec=0;
 	bc->channel = 0;
 
 	bc->sending_complete = 0;
@@ -690,7 +702,7 @@
 		if (!stack->channels[channel-1])
 			stack->channels[channel-1] = 1;
 		else {
-			cb_log(0,stack->port,"channel already in use:%d\n", channel );
+			cb_log(4,stack->port,"channel already in use:%d\n", channel );
 			return -1;
 		}
 	} else {
@@ -838,7 +850,7 @@
 	struct misdn_stack *stack=get_stack_by_bc(bc);
   
 	if (stack->nt) {
-		if (!find_free_chan_in_stack(stack, bc, bc->channel_preselected ? bc->channel : 0))
+		if (!find_free_chan_in_stack(stack, bc, bc->channel_preselected ? bc->channel : 0, 0))
 			return -1;
 		/*bc->channel=free_chan;*/
 
@@ -870,10 +882,11 @@
 	} else { 
 		if (stack->ptp || bc->te_choose_channel) {
 			/* we know exactly which channels are in use */
-			if (!find_free_chan_in_stack(stack, bc, bc->channel_preselected ? bc->channel : 0))
+			if (!find_free_chan_in_stack(stack, bc, bc->channel_preselected ? bc->channel : 0, 0))
 				return -1;
 			/*bc->channel=free_chan;*/
 			cb_log(2,stack->port, " -->  found channel: %d\n", bc->channel);
+
 			if (set_chan_in_stack(stack ,bc->channel)<0) return -1;
 		} else {
 			/* other phones could have made a call also on this port (ptmp) */
@@ -1509,7 +1522,7 @@
 		case EVENT_SETUP:
 		{
 			if (bc->channel == 0xff) {
-				if (!find_free_chan_in_stack(stack, bc, 0)) {
+				if (!find_free_chan_in_stack(stack, bc, 0, 0)) {
 					cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n");
 					bc->out_cause=34;
 					misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
@@ -1558,7 +1571,7 @@
 	case CC_NEW_CR|INDICATION:
 		cb_log(7, stack->port, " --> lib: NEW_CR Ind with l3id:%x on this port.\n",frm->dinfo);
 
-		struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1);
+		struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1, 0);
 		if (!bc) {
 			cb_log(0, stack->port, " --> !! lib: No free channel!\n");
 			return -1;
@@ -1796,7 +1809,7 @@
       
 		case CC_SETUP|INDICATION:
 		{
-			struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1);
+			struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1, 0);
 			if (!bc) 
 			ERR_NO_CHANNEL:
 			{
@@ -2038,8 +2051,7 @@
 			switch (event) {
 				case EVENT_SETUP:
 					if (bc->channel<=0 || bc->channel==0xff) {
-						bc->channel=find_free_chan_in_stack(stack,bc, 0);
-		
+						bc->channel=find_free_chan_in_stack(stack,bc, 0,0);
 						if (bc->channel<=0)
 							goto ERR_NO_CHANNEL;
 					} else if (!stack->ptp) 
@@ -3053,7 +3065,7 @@
 #endif
 }
 
-struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout)
+struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, int dec)
 {
 	struct misdn_stack *stack;
 	int i;
@@ -3086,17 +3098,29 @@
 			}
 
 			int maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num;
-			//int maxnum=stack->b_num+1;
-
-			cb_log(0,0,"maxnum:%d",maxnum);
-			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];
+
+			if (dec) {
+				for (i = maxnum-1; i>=0; 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);
+						stack->bc[i].dec=1;
+						return &stack->bc[i];
+					}
+				}
+			} else {
+				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];
+					}
 				}
 			}
 
@@ -3218,7 +3242,7 @@
 
 		if (stack->nt) {
 			if (bc->channel <=0 ) { /*  else we have the channel already */
-				if (!find_free_chan_in_stack(stack, bc, 0)) {
+				if (!find_free_chan_in_stack(stack, bc, 0,0)) {
 					cb_log(0, stack->port, " No free channel at the moment\n");
 					/*FIXME: add disconnect*/
 					err=-ENOCHAN;

Modified: trunk/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.h?view=diff&rev=64952&r1=64951&r2=64952
==============================================================================
--- trunk/channels/misdn/isdn_lib.h (original)
+++ trunk/channels/misdn/isdn_lib.h Fri May 18 04:36:16 2007
@@ -214,6 +214,7 @@
 	int need_release;
 	int need_release_complete;
 
+	int dec;
 	/** var stuff**/
 	int l3_id;
 	int pid;
@@ -398,7 +399,7 @@
 
 void misdn_lib_transfer(struct misdn_bchannel* holded_bc);
 
-struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout);
+struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, int dec);
 
 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?view=diff&rev=64952&r1=64951&r2=64952
==============================================================================
--- trunk/channels/misdn_config.c (original)
+++ trunk/channels/misdn_config.c Fri May 18 04:36:16 2007
@@ -658,9 +658,12 @@
 int misdn_cfg_is_group_method (char *group, enum misdn_cfg_method meth)
 {
 	int i, re = 0;
-	char *method = NULL;
+	char *method ;
 
 	misdn_cfg_lock();
+
+	method = port_cfg[0][map[MISDN_CFG_METHOD]].str;
+
 	for (i = 1; i <= max_ports; i++) {
 		if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) {
 			if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group))
@@ -668,11 +671,14 @@
 						  port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str);
 		}
 	}
+
 	if (method) {
 		switch (meth) {
 		case METHOD_STANDARD:		re = !strcasecmp(method, "standard");
 									break;
 		case METHOD_ROUND_ROBIN:	re = !strcasecmp(method, "round_robin");
+									break;
+		case METHOD_STANDARD_DEC:	re = !strcasecmp(method, "standard_dec");
 									break;
 		}
 	}



More information about the svn-commits mailing list