[asterisk-commits] trunk r36376 - in /trunk/channels/misdn: isdn_lib.c isdn_lib.h

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Jun 30 07:05:42 MST 2006


Author: crichter
Date: Fri Jun 30 09:05:42 2006
New Revision: 36376

URL: http://svn.digium.com/view/asterisk?rev=36376&view=rev
Log:
added fix, that if the L2 goes down on ptp-NT that we reinitialize the NT Library. Also if we have no ntflags, we don't pass the filename to the debug routines of mISDNuser.

Modified:
    trunk/channels/misdn/isdn_lib.c
    trunk/channels/misdn/isdn_lib.h

Modified: trunk/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.c?rev=36376&r1=36375&r2=36376&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_lib.c (original)
+++ trunk/channels/misdn/isdn_lib.c Fri Jun 30 09:05:42 2006
@@ -175,7 +175,7 @@
 /* from isdn_lib.h */
 int init_bc(struct misdn_stack * stack,  struct misdn_bchannel *bc, int midev, int port, int bidx, char *msn, int firsttime);
 struct misdn_stack* stack_init(int midev,  int port, int ptp);
-void stack_te_destroy(struct misdn_stack* stack);
+void stack_destroy(struct misdn_stack* stack);
 	/* user iface */
 int te_lib_init( void ) ; /* returns midev */
 void te_lib_destroy(int midev) ;
@@ -1278,10 +1278,15 @@
 }
 
 
-void stack_te_destroy(struct misdn_stack* stack)
+void stack_destroy(struct misdn_stack* stack)
 {
 	char buf[1024];
 	if (!stack) return;
+
+	if (stack->nt) {
+		cleanup_Isdnl2(&stack->nst);
+		cleanup_Isdnl3(&stack->nst);
+	}
   
 	if (stack->lower_id) 
 		mISDN_write_frame(stack->midev, buf, stack->lower_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
@@ -1917,9 +1922,11 @@
 		{
 			if (stack->ptp) {
 				cb_log(-1 , stack->port, "%% GOT L2 DeActivate Info.\n");
+
 				if (stack->l2upcnt>3) {
 					cb_log(-1 , stack->port, "!!! Could not Get the L2 up after 3 Attemps!!!\n");
 				}  else {
+					if (stack->nt) misdn_lib_reinit_nt_stack(stack->port);
 					misdn_lib_get_l2_up(stack);
 					stack->l2upcnt++;
 				}
@@ -3452,7 +3459,7 @@
 	cb_log(0, port, "Restarting this port.\n");
 	if (stack) {
 		cb_log(0, port, "Stack:%p\n",stack);
-		
+			
 		clear_l3(stack);
 		{
 			msg_t *msg=alloc_msg(MAX_MSG_SIZE);
@@ -3474,48 +3481,10 @@
 			msg_queue_tail(&glob_mgr->activatequeue, msg);
 			sem_post(&glob_mgr->new_msg);
 		}
-		return 0;
+
+		if (stack->nt)
+			misdn_lib_reinit_nt_stack(stack->port);
     
-		stack_te_destroy(stack);
-      
-		{
-			struct misdn_stack *tmpstack;
-			struct misdn_stack *newstack=stack_init(stack->midev ,port, stack->ptp);
-      
-      
-			if (stack == glob_mgr->stack_list) {
-				struct misdn_stack *n=glob_mgr->stack_list->next;
-				glob_mgr->stack_list = newstack ;
-				glob_mgr->stack_list->next = n;
-			} else {
-				for (tmpstack=glob_mgr->stack_list;
-				     tmpstack->next;
-				     tmpstack=tmpstack->next) 
-					if (tmpstack->next == stack) break;
-
-				if (!tmpstack->next) {
-					cb_log(-1, port, "Stack to restart not found\n");
-					return 0;
-				}  else {
-					struct misdn_stack *n=tmpstack->next->next;
-					tmpstack->next=newstack;
-					newstack->next=n;
-				}
-			}
-      
-			{
-				int i;
-				for(i=0;i<newstack->b_num; i++) {
-					int r;
-					if ((r=init_bc(newstack, &newstack->bc[i], newstack->midev,port,i, "", 1))<0) {
-						cb_log(-1, port, "Got Err @ init_bc :%d\n",r);
-						return 0;
-					}
-				}
-			}
-      
-			free(stack);
-		}
 	}
 
 	return 0;
@@ -3629,13 +3598,19 @@
 void misdn_lib_nt_debug_init( int flags, char *file ) 
 {
 	int static init=0;
+	char *f;
+	
+	if (!flags) 
+		f=NULL;
+	else
+		f=file;
 
 	if (!init) {
-		debug_init( flags , file, file, file);
+		debug_init( flags , f, f, f);
 		init=1;
 	} else {
 		debug_close();
-		debug_init( flags , file, file, file);
+		debug_init( flags , f, f, f);
 	}
 }
 
@@ -3779,7 +3754,7 @@
 			help->bc[i].addr = 0;
 		}
 		cb_log (1, help->port, "Destroying this port.\n");
-		stack_te_destroy(help);
+		stack_destroy(help);
 	}
 	
 	if (global_state == MISDN_INITIALIZED) {
@@ -4213,3 +4188,41 @@
 }
 
 
+
+void misdn_lib_reinit_nt_stack(int port)
+{
+	struct misdn_stack *stack=find_stack_by_port(port);
+	
+	if (stack) {
+		cleanup_Isdnl3(&stack->nst);
+		cleanup_Isdnl2(&stack->nst);
+
+
+		memset(&stack->nst, 0, sizeof(net_stack_t));
+		memset(&stack->mgr, 0, sizeof(manager_t));
+   
+		stack->mgr.nst = &stack->nst;
+		stack->nst.manager = &stack->mgr;
+    
+		stack->nst.l3_manager = handle_event_nt;
+		stack->nst.device = glob_mgr->midev;
+		stack->nst.cardnr = port;
+		stack->nst.d_stid = stack->d_stid;
+   
+		stack->nst.feature = FEATURE_NET_HOLD;
+		if (stack->ptp)
+			stack->nst.feature |= FEATURE_NET_PTP;
+		if (stack->pri)
+			stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID;
+		
+		stack->nst.l1_id = stack->lower_id;
+		stack->nst.l2_id = stack->upper_id;
+		
+		msg_queue_init(&stack->nst.down_queue);
+	
+		Isdnl2Init(&stack->nst);
+		Isdnl3Init(&stack->nst);
+	}
+}
+
+

Modified: trunk/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.h?rev=36376&r1=36375&r2=36376&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_lib.h (original)
+++ trunk/channels/misdn/isdn_lib.h Fri Jun 30 09:05:42 2006
@@ -410,6 +410,8 @@
 int misdn_lib_is_ptp(int port);
 int misdn_lib_get_maxchans(int port);
 
+void misdn_lib_reinit_nt_stack(int port);
+
 #define PRI_TRANS_CAP_SPEECH                                    0x0
 #define PRI_TRANS_CAP_DIGITAL                                   0x08
 #define PRI_TRANS_CAP_RESTRICTED_DIGITAL                        0x09



More information about the asterisk-commits mailing list