[asterisk-commits] crichter: branch crichter/0.3.0 r38656 - in /team/crichter/0.3.0/channels: ./...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Aug 1 12:57:35 MST 2006


Author: crichter
Date: Tue Aug  1 14:57:35 2006
New Revision: 38656

URL: http://svn.digium.com/view/asterisk?rev=38656&view=rev
Log:
* removed pp_l2_check (fixed L2 bug in mISDNuser)
* added blocking flag to stack object. A port can be blocked/unblocked from the
  cli
* added EVENT_PORT_ALARM to send alarm infos to the chan_misdn.c layer (later	
  we can add a manager event for that)
* added block_on_alarm option, to block the port whenever a ALARM occurs
* added need_busy flag to indicate if we've sended a CONTROL_BUSY already
* changed a bunch of cb_log(-1,..) to cb_log(0,..) due to funny behaviour in 
  recent asterisk ast_log messages..
* fixed a few ETSI state violations, especially when finishing calls in 
  different seldom states
* changed debug levels a lot to make the log more readable in low debuglevels
* some first fixes for the HOLD/RETRIEVE stuff (doesn't work totally still)
* removed the PRECONNECTED state stuff
* added cause 27 when we get a CLEANUP directly after a outgoing SETUP, this
  creates a CHANISUNAVAIL instead of a NOANSWER
* removed the addr pointer from "misdn show stacks" that's not needed anymore 
  and makes the output more unreadable
* added cause saving on RELEASE/RELEASE_COMPLETE
* set cause to 16 on prepare_bc
* removed stack getting from ph_control functions, we don't really need it 
  there
* added beroec api


Modified:
    team/crichter/0.3.0/channels/Makefile
    team/crichter/0.3.0/channels/chan_misdn.c
    team/crichter/0.3.0/channels/misdn/Makefile
    team/crichter/0.3.0/channels/misdn/chan_misdn_config.h
    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_lib_intern.h
    team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c
    team/crichter/0.3.0/channels/misdn_config.c

Modified: team/crichter/0.3.0/channels/Makefile
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/Makefile?rev=38656&r1=38655&r2=38656&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/Makefile (original)
+++ team/crichter/0.3.0/channels/Makefile Tue Aug  1 14:57:35 2006
@@ -83,7 +83,12 @@
 
 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/mISDNuser/mISDNlib.h),)
   CHANNEL_LIBS+=chan_misdn.so
-  CFLAGS+=-Imisdn 
+  CFLAGS+=-Imisdn  
+endif
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libbnec.so),)
+  MISDNECLIB=-lbnec
+  CFLAGS+=-DWITH_BEROEC
 endif
 
 CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
@@ -237,8 +242,8 @@
 misdn/chan_misdn_lib.a:
 	make -C misdn
 
-chan_misdn.so: chan_misdn.o misdn_config.o misdn/chan_misdn_lib.a
-	$(CC) -shared -Xlinker -x -L/usr/lib -o $@ $^ -lisdnnet -lmISDN
+chan_misdn.so: chan_misdn.o misdn_config.o misdn/chan_misdn_lib.a 
+	$(CC) -shared -Xlinker -x -L/usr/lib -o $@ $^ -lisdnnet -lmISDN $(MISDNECLIB)
 
 chan_misdn.o: chan_misdn.c 
 	$(CC) $(CFLAGS) -DCHAN_MISDN_VERSION=\"0.3.0\" -c $< -o $@

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=38656&r1=38655&r2=38656&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_misdn.c (original)
+++ team/crichter/0.3.0/channels/chan_misdn.c Tue Aug  1 14:57:35 2006
@@ -138,6 +138,7 @@
 	enum misdn_chan_state state;
 	int need_queue_hangup;
 	int need_hangup;
+	int need_busy;
 	
 	int holded; 
 	int orginator;
@@ -521,6 +522,35 @@
 }
 
 
+static int misdn_port_block(int fd, int argc, char *argv[])
+{
+	int port;
+  
+	if (argc != 4)
+		return RESULT_SHOWUSAGE;
+  
+	port = atoi(argv[3]);
+
+	misdn_lib_port_block(port);
+
+	return 0;
+}
+
+static int misdn_port_unblock(int fd, int argc, char *argv[])
+{
+	int port;
+  
+	if (argc != 4)
+		return RESULT_SHOWUSAGE;
+  
+	port = atoi(argv[3]);
+
+	misdn_lib_port_unblock(port);
+
+	return 0;
+}
+
+
 static int misdn_restart_port (int fd, int argc, char *argv[])
 {
 	int port;
@@ -632,6 +662,7 @@
 	{MISDN_ALERTING,"ALERTING"}, /*  when Alerting */
 	{MISDN_BUSY,"BUSY"}, /*  when BUSY */
 	{MISDN_CONNECTED,"CONNECTED"}, /*  when connected */
+	{MISDN_PRECONNECTED,"PRECONNECTED"}, /*  when connected */
 	{MISDN_DISCONNECTED,"DISCONNECTED"}, /*  when connected */
 	{MISDN_RELEASED,"RELEASED"}, /*  when connected */
 	{MISDN_BRIDGED,"BRIDGED"}, /*  when bridged */
@@ -664,7 +695,6 @@
 void reload_config(void)
 {
 	int i, cfg_debug;
-	chan_misdn_log(-1, 0, "Dynamic Crypting Activation is not support during reload at the moment\n");
 	
 	free_robin_list();
 	misdn_cfg_reload();
@@ -1074,6 +1104,19 @@
   complete_ch
 };
 
+static struct ast_cli_entry cli_port_block=
+{ {"misdn","port","block", NULL},
+  misdn_port_block,
+  "Blocks the given port", 
+  "Usage: misdn port block\n"
+};
+
+static struct ast_cli_entry cli_port_unblock=
+{ {"misdn","port","unblock", NULL},
+  misdn_port_unblock,
+  "Unblocks the given port", 
+  "Usage: misdn port unblock\n"
+};
 
 
 static struct ast_cli_entry cli_restart_port =
@@ -1244,12 +1287,12 @@
 	} else {
 		
 		if (len <=100 || len > 8000) {
-			chan_misdn_log(-1,bc->port,"config_jb: Jitterbuffer out of Bounds, setting to 1000\n");
+			chan_misdn_log(0,bc->port,"config_jb: Jitterbuffer out of Bounds, setting to 1000\n");
 			len=1000;
 		}
 		
 		if ( threshold > len ) {
-			chan_misdn_log(-1,bc->port,"config_jb: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1\n");
+			chan_misdn_log(0,bc->port,"config_jb: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1\n");
 		}
 		
 		if ( ch->jb) {
@@ -1359,21 +1402,38 @@
 	
 	ast_copy_string (ast->context,ch->context,sizeof(ast->context));	
 	{
-		int ec, ectr;
+		int ec;
 		
 		misdn_cfg_get( port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
 		
-		misdn_cfg_get( port, MISDN_CFG_ECHOTRAINING, &ectr, sizeof(int));
 		if (ec == 1 ) {
 			bc->ec_enable=1;
 		} else if ( ec > 1 ) {
 			bc->ec_enable=1;
 			bc->ec_deftaps=ec;
 		}
+#ifdef WITH_ECHOTRAINING 
+		int ectr;
+		misdn_cfg_get( port, MISDN_CFG_ECHOTRAINING, &ectr, sizeof(int));
 		
 		if ( ectr >= 0 ) {
 			bc->ec_training=ectr;
 		}
+#endif
+
+#ifdef WITH_BEROEC
+		misdn_cfg_get(port, MISDN_CFG_BNECHOCANCEL,&bc->bnec_tail, sizeof(int));
+		misdn_cfg_get(port, MISDN_CFG_BNEC_ANTIHOWL, &bc->bnec_ah, sizeof(int));
+		misdn_cfg_get(port, MISDN_CFG_BNEC_NLP, &bc->bnec_nlp, sizeof(int));
+		misdn_cfg_get(port, MISDN_CFG_BNEC_TD, &bc->bnec_td, sizeof(int));
+		misdn_cfg_get(port, MISDN_CFG_BNEC_ADAPT, &bc->bnec_adapt, sizeof(int));
+		misdn_cfg_get(port, MISDN_CFG_BNEC_ZEROCOEFF, &bc->bnec_zero, sizeof(int));
+
+		if (bc->bnec_tail && bc->ec_enable) {
+			ast_log(LOG_WARNING,"Are you sure you wan't to mix BNEC with Zapec ? This might cause bad audio quality!\n");
+			bc->ec_enable=0;
+		}
+#endif
 	}
 	
 	{
@@ -1518,7 +1578,7 @@
 			if (ext) {
 				opts=strtok_r(NULL,"/",&tokb);
 			} else {
-				chan_misdn_log(-1,0,"misdn_call: No Extension given!\n");
+				chan_misdn_log(0,0,"misdn_call: No Extension given!\n");
 				return -1;
 			}
 		}
@@ -1936,6 +1996,10 @@
 		return 0;
 	}
 
+	p->need_hangup=0;
+	p->need_queue_hangup=0;
+
+
 	if (!p->bc->nt) 
 		stop_bc_tones(p);
 
@@ -1966,13 +2030,8 @@
 			start_bc_tones(p);
 			hanguptone_indicate(p);
 		
-			if (bc->nt) {
-				if (bc->need_disconnect)
-					misdn_lib_send_event( bc, EVENT_DISCONNECT);
-			} else {
-				misdn_lib_send_event( bc, EVENT_RELEASE_COMPLETE);
-				p->state=MISDN_CLEANING;
-			}
+			if (bc->need_disconnect)
+				misdn_lib_send_event( bc, EVENT_DISCONNECT);
 			break;
 
 		case MISDN_CALLING_ACKNOWLEDGE:
@@ -1994,6 +2053,7 @@
 				misdn_lib_send_event( bc, EVENT_DISCONNECT);
 			break;
 		case MISDN_CONNECTED:
+		case MISDN_PRECONNECTED:
 			/*  Alerting or Disconect */
 			if (p->bc->nt) {
 				start_bc_tones(p);
@@ -2379,6 +2439,7 @@
 	cl->orginator=orig;
 	cl->need_queue_hangup=1;
 	cl->need_hangup=1;
+	cl->need_busy=1;
 	
 	return cl;
 	
@@ -2467,18 +2528,19 @@
 					
 					if (!strcasecmp(cfg_group, group)) {
 						int port_up;
-						int check,checkl2;
+						int check;
 						misdn_cfg_get(port, MISDN_CFG_PMP_L1_CHECK, &check, sizeof(int));
-						misdn_cfg_get(port, MISDN_CFG_PP_L2_CHECK, &checkl2, sizeof(int));
-						check=checkl2?2:check;
-
 						port_up = misdn_lib_port_up(port, check);
 
 						if (check && !port_up) 
 							chan_misdn_log(1,port,"L1 is not Up on this Port\n");
 						
+						if (check && port_up<0) {
+							ast_log(LOG_WARNING,"This port (%d) is blocked\n", port);
+						}
 						
-						if ( port_up )	{
+						
+						if ( port_up>0 )	{
 							newbc = misdn_lib_get_free_bc(port, robin_channel);
 							if (newbc) {
 								chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
@@ -2494,7 +2556,7 @@
 			} while (!newbc && robin_channel != rr->channel);
 			
 			if (!newbc)
-				chan_misdn_log(4, port, " Failed! No free channel in group %d!", group);
+				chan_misdn_log(-1, port, " Failed! No free channel in group %d!", group);
 		}
 		
 		else {		
@@ -2506,15 +2568,13 @@
 				chan_misdn_log(3,port, "Group [%s] Port [%d]\n", group, port);
 				if (!strcasecmp(cfg_group, group)) {
 					int port_up;
-					int check,checkl2;
+					int check;
 					misdn_cfg_get(port, MISDN_CFG_PMP_L1_CHECK, &check, sizeof(int));
-					misdn_cfg_get(port, MISDN_CFG_PP_L2_CHECK, &checkl2, sizeof(int));
-					check=checkl2?2:check;
 					port_up = misdn_lib_port_up(port, check);
 					
 					chan_misdn_log(4, port, "portup:%d\n", port_up);
 					
-					if ( port_up )	{
+					if ( port_up>0 ) {
 						newbc = misdn_lib_get_free_bc(port, 0);
 						if (newbc)
 							break;
@@ -2842,9 +2902,11 @@
 		return;
 	}
 
+	cb_log(1,ch->bc?ch->bc->port:0,"hangup_chan\n");
 
 	if (ch->need_hangup) 
 	{
+		cb_log(1,ch->bc->port,"-> hangup\n");
 		send_cause2ast(ch->ast,ch->bc,ch);
 		ch->need_hangup=0;
 		ch->need_queue_hangup=0;
@@ -2860,7 +2922,10 @@
 	ch->need_queue_hangup=0;
 	if (ch->ast) {
 		send_cause2ast(ch->ast,ch->bc,ch);
-		ast_queue_hangup(ch->ast);
+
+		if (ch->ast)
+			ast_queue_hangup(ch->ast);
+		cb_log(1,ch->bc->port,"-> queue_hangup\n");
 	} else {
 		cb_log(1,ch->bc->port,"Cannot hangup chan, no ast\n");
 	}
@@ -3035,10 +3100,19 @@
 		
 	case 21:
 	case 17: /* user busy */
+	
+		ch->state=MISDN_BUSY;
+			
+		if (!ch->need_busy) {
+			chan_misdn_log(1,bc?bc->port:0, "Queued busy already\n");
+			break;
+		}
+		
 		chan_misdn_log(1,  bc?bc->port:0, " --> * SEND: Queue Busy pid:%d\n", bc?bc->pid:-1);
-	
-		ch->state=MISDN_BUSY;
+		
 		ast_queue_control(ast, AST_CONTROL_BUSY);
+		
+		ch->need_busy=0;
 		
 		break;
 	}
@@ -3079,9 +3153,16 @@
 	struct chan_list *ch=find_chan_by_bc(cl_te, bc);
 	
 	if (event != EVENT_BCHAN_DATA && event != EVENT_TONE_GENERATE) { /*  Debug Only Non-Bchan */
-		chan_misdn_log(1, bc->port, "I IND :%s oad:%s dad:%s pid:%d state:%s\n", manager_isdn_get_info(event), bc->oad, bc->dad, bc->pid, ch?misdn_get_ch_state(ch):"none");
-		misdn_lib_log_ies(bc);
-		chan_misdn_log(2,bc->port," --> bc_state:%s\n",bc_state2str(bc->bc_state));
+		int debuglevel=1;
+	
+		if ( event==EVENT_CLEANUP && !user_data)
+			debuglevel=5;
+
+		chan_misdn_log(debuglevel, bc->port, "I IND :%s oad:%s dad:%s pid:%d state:%s\n", manager_isdn_get_info(event), bc->oad, bc->dad, bc->pid, ch?misdn_get_ch_state(ch):"none");
+		if (debuglevel==1) {
+			misdn_lib_log_ies(bc);
+			chan_misdn_log(4,bc->port," --> bc_state:%s\n",bc_state2str(bc->bc_state));
+		}
 	}
 	
 	if (!ch) {
@@ -3126,29 +3207,29 @@
 	
 	
 	switch (event) {
+	case EVENT_PORT_ALARM:
+		{
+			int boa=0;
+
+			misdn_cfg_get( bc->port, MISDN_CFG_ALARM_BLOCK, &boa, sizeof(int));
+			if (boa) {
+				cb_log(1,bc->port," --> blocking\n");
+				misdn_lib_port_block(bc->port);	
+			}
+		}
+		break;
 
 	case EVENT_BCHAN_ACTIVATED:
 		break;
-		
 		
 	case EVENT_NEW_L3ID:
 		ch->l3id=bc->l3_id;
 		ch->addr=bc->addr;
-
-		if (bc->nt && ch->state == MISDN_PRECONNECTED ) {
-			/* OK we've got the very new l3id so we can answer
-			   now */
-			start_bc_tones(ch);
-		
-			ch->state = MISDN_CONNECTED;
-			ast_queue_control(ch->ast, AST_CONTROL_ANSWER);
-
-		}
 		break;
 
 	case EVENT_NEW_BC:
 		if (bc)
-			ch->bc=bc;
+			ch->bc=(struct misdn_bchannel*)user_data;
 		break;
 		
 	case EVENT_DTMF_TONE:
@@ -3579,6 +3660,7 @@
 	break;
 	case EVENT_CONNECT:
 	{
+		/*we answer when we've got our very new L3 ID from the NT stack */
 		misdn_lib_send_event(bc,EVENT_CONNECT_ACKNOWLEDGE);
 	
 		struct ast_channel *bridged=AST_BRIDGED_P(ch->ast);
@@ -3597,11 +3679,6 @@
 		}
 	}
 	
-	/*we answer when we've got our very new L3 ID from the NT stack */
-	if (bc->nt) { 
-		ch->state=MISDN_PRECONNECTED;
-		break;
-	}
 	
 	/* notice that we don't break here!*/
 
@@ -3622,9 +3699,6 @@
 	if (ch) {
 		struct chan_list *holded_ch=find_holded(cl_te, bc);
 	
-		if (ch->ast)	
-			send_cause2ast(ch->ast,bc,ch);
-
 		chan_misdn_log(3,bc->port," --> org:%d nt:%d, inbandavail:%d state:%d\n", ch->orginator, bc->nt, misdn_inband_avail(bc), ch->state);
 		if ( ch->orginator==ORG_AST && !bc->nt && misdn_inband_avail(bc) && ch->state != MISDN_CONNECTED) {
 			/* If there's inband information available (e.g. a
@@ -3641,11 +3715,12 @@
 		
 		/*Check for holded channel, to implement transfer*/
 		if (holded_ch && ch->ast ) {
+			cb_log(1,bc->port," --> found holded ch\n");
 			if  (ch->state == MISDN_CONNECTED ) {
 				misdn_transfer_bc(ch, holded_ch) ;
-				misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
-				break;
 			}
+			misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
+			break;
 		}
 		
 		stop_bc_tones(ch);
@@ -3662,7 +3737,7 @@
 			hangup_chan(ch);
 			release_chan(bc);
 		
-			if (bc->cause >= 0 && bc->need_release_complete) 
+			if (bc->need_release_complete) 
 				misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
 		}
 		break;
@@ -3678,6 +3753,15 @@
 	case EVENT_CLEANUP:
 	{
 		stop_bc_tones(ch);
+		
+		switch(ch->state) {
+			case MISDN_CALLING:
+				bc->cause=27; /* Destination out of order */
+			break;
+			default:
+			break;
+		}
+		
 		hangup_chan(ch);
 		release_chan(bc);
 	}
@@ -4009,6 +4093,8 @@
 	ast_cli_register(&cli_show_port);
 	ast_cli_register(&cli_show_stacks);
 
+	ast_cli_register(&cli_port_block);
+	ast_cli_register(&cli_port_unblock);
 	ast_cli_register(&cli_restart_port);
 	ast_cli_register(&cli_port_up);
 	ast_cli_register(&cli_port_down);
@@ -4073,6 +4159,8 @@
 	ast_cli_unregister(&cli_show_config);
 	ast_cli_unregister(&cli_show_port);
 	ast_cli_unregister(&cli_show_stacks);
+	ast_cli_unregister(&cli_port_block);
+	ast_cli_unregister(&cli_port_unblock);
 	ast_cli_unregister(&cli_restart_port);
 	ast_cli_unregister(&cli_port_up);
 	ast_cli_unregister(&cli_port_down);
@@ -4283,6 +4371,10 @@
 			if (neglect) {
 				chan_misdn_log(1, ch->bc->port, " --> disabled\n");
 				ch->bc->ec_enable=0;
+
+#ifdef WITH_BEROEC
+				ch->bc->bnec_tail=0;
+#endif
 			} else {
 				ch->bc->ec_enable=1;
 				ch->bc->orig=ch->orginator;
@@ -4562,6 +4654,7 @@
 
 	if (level == -1)
 		ast_log(LOG_WARNING, buf);
+
 	else if (misdn_debug_only[port] ? 
 			(level==1 && misdn_debug[port]) || (level==misdn_debug[port]) 
 		 : level <= misdn_debug[port]) {

Modified: team/crichter/0.3.0/channels/misdn/Makefile
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/Makefile?rev=38656&r1=38655&r2=38656&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/Makefile (original)
+++ team/crichter/0.3.0/channels/misdn/Makefile Tue Aug  1 14:57:35 2006
@@ -12,6 +12,13 @@
 SOURCES		= isdn_lib.c isdn_msg_parser.c 
 OBJDIR		= .
 OBJS		= isdn_lib.o isdn_msg_parser.o fac.o
+
+
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libbnec.so),)
+CFLAGS+=-DBEROEC_VERSION=1
+CFLAGS+=-DWITH_BEROEC
+endif
+
 
 
 all: chan_misdn_lib.a 

Modified: team/crichter/0.3.0/channels/misdn/chan_misdn_config.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/chan_misdn_config.h?rev=38656&r1=38655&r2=38656&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/chan_misdn_config.h (original)
+++ team/crichter/0.3.0/channels/misdn/chan_misdn_config.h Tue Aug  1 14:57:35 2006
@@ -29,7 +29,7 @@
 	MISDN_CFG_TXGAIN,              /* int */
 	MISDN_CFG_TE_CHOOSE_CHANNEL,   /* int (bool) */
 	MISDN_CFG_PMP_L1_CHECK,        /* int (bool) */
-	MISDN_CFG_PP_L2_CHECK,        /* int (bool) */
+	MISDN_CFG_ALARM_BLOCK,        /* int (bool) */
 	MISDN_CFG_HDLC,                /* int (bool) */
 	MISDN_CFG_CONTEXT,             /* char[] */
 	MISDN_CFG_LANGUAGE,            /* char[] */
@@ -52,7 +52,18 @@
 	MISDN_CFG_INCOMING_EARLY_AUDIO,      /* int (bool) */
 	MISDN_CFG_ECHOCANCEL,          /* int */
 	MISDN_CFG_ECHOCANCELWHENBRIDGED,  /* int (bool) */
+#ifdef WITH_ECHOTRAINGING
 	MISDN_CFG_ECHOTRAINING,        /* int (bool) */
+#endif
+
+#ifdef WITH_BEROEC
+	MISDN_CFG_BNECHOCANCEL,
+	MISDN_CFG_BNEC_ANTIHOWL,
+	MISDN_CFG_BNEC_NLP,
+	MISDN_CFG_BNEC_ZEROCOEFF,
+	MISDN_CFG_BNEC_TD,
+	MISDN_CFG_BNEC_ADAPT,
+#endif
 	MISDN_CFG_NEED_MORE_INFOS,     /* bool */
 	MISDN_CFG_JITTERBUFFER,              /* int */
 	MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD,              /* int */

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=38656&r1=38655&r2=38656&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/isdn_lib.c (original)
+++ team/crichter/0.3.0/channels/misdn/isdn_lib.c Tue Aug  1 14:57:35 2006
@@ -14,7 +14,6 @@
 #include "isdn_lib_intern.h"
 #include <mISDNuser/isdn_debug.h>
 
-
 void misdn_join_conf(struct misdn_bchannel *bc, int conf_id);
 void misdn_split_conf(struct misdn_bchannel *bc, int conf_id);
 
@@ -24,6 +23,36 @@
 
 struct misdn_stack* get_misdn_stack( void );
 
+#ifdef WITH_BEROEC
+static int bec_initialized=0;
+#endif
+
+
+int misdn_lib_port_block(int port)
+{
+	struct misdn_stack *stack=get_misdn_stack();
+	for ( ; stack; stack=stack->next) {
+		if (stack->port == port) {
+			stack->blocked=1;
+			return 0;
+		}
+	}
+	return -1;
+
+}
+
+int misdn_lib_port_unblock(int port)
+{
+	struct misdn_stack *stack=get_misdn_stack();
+	for ( ; stack; stack=stack->next) {
+		if (stack->port == port) {
+			stack->blocked=0;
+			return 0;
+		}
+	}
+	return -1;
+
+}
 
 int misdn_lib_is_ptp(int port)
 {
@@ -75,7 +104,7 @@
 	}
 	
 	if (stack) {
-		sprintf(buf, "* Stack Addr:%x Port %d Type %s Prot. %s L2Link %s L1Link:%s", stack->upper_id, stack->port, stack->nt?"NT":"TE", stack->ptp?"PTP":"PMP", stack->l2link?"UP":"DOWN", stack->l1link?"UP":"DOWN");
+		sprintf(buf, "* Port %d Type %s Prot. %s L2Link %s L1Link:%s Blocked:%d", stack->port, stack->nt?"NT":"TE", stack->ptp?"PTP":"PMP", stack->l2link?"UP":"DOWN", stack->l1link?"UP":"DOWN",stack->blocked);
 
 	} else {
 		buf[0]=0;
@@ -413,11 +442,11 @@
 int empty_chan_in_stack(struct misdn_stack *stack, int channel)
 {
 	if (channel<=0) {
-		cb_log(-1,stack?stack->port:0, "empty_chan_inst_stack: cannot empty channel %d\n",channel);
+		cb_log(0,stack?stack->port:0, "empty_chan_inst_stack: cannot empty channel %d\n",channel);
 		return -1;
 	}
 	
-	cb_log (1, stack?stack->port:0, "empty_chan_in_stack: %d\n",channel); 
+	cb_log (4, stack?stack->port:0, "empty_chan_in_stack: %d\n",channel); 
 	stack->channels[channel-1] = 0;
 	dump_chan_list(stack);
 	return 0;
@@ -454,7 +483,7 @@
 
 void bc_state_change(struct misdn_bchannel *bc, enum bchannel_state state)
 {
-	cb_log(3,bc->port,"BC_STATE_CHANGE: from:%s to:%s\n",
+	cb_log(5,bc->port,"BC_STATE_CHANGE: from:%s to:%s\n",
 	       bc_state2str(bc->bc_state),
 	       bc_state2str(state) );
 	
@@ -473,7 +502,7 @@
 
 void bc_next_state_change(struct misdn_bchannel *bc, enum bchannel_state state)
 {
-	cb_log(3,bc->port,"BC_NEXT_STATE_CHANGE: from:%s to:%s\n",
+	cb_log(5,bc->port,"BC_NEXT_STATE_CHANGE: from:%s to:%s\n",
 	       bc_state2str(bc->next_bc_state),
 	       bc_state2str(state) );
 
@@ -595,6 +624,12 @@
 	
 	manager_bchannel_deactivate(bc);
 
+#ifdef WITH_BEROEC
+	if (bc->ec)
+		beroec_destroy(bc->ec);
+	bc->ec=NULL;
+#endif
+
 	if ( misdn_cap_is_speech(bc->capability) && bc->ec_enable) {
 		manager_ec_disable(bc);
 	}
@@ -616,9 +651,10 @@
 void clear_l3(struct misdn_stack *stack)
 {
 	int 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);
+			cb_event(EVENT_CLEANUP, &stack->bc[i], NULL); 
 			empty_chan_in_stack(stack,i+1);
 			empty_bc(&stack->bc[i]);
 			clean_up_bc(&stack->bc[i]);
@@ -630,11 +666,11 @@
 int set_chan_in_stack(struct misdn_stack *stack, int channel)
 {
 
-	cb_log(1,stack->port,"set_chan_in_stack: %d\n",channel);
+	cb_log(4,stack->port,"set_chan_in_stack: %d\n",channel);
 	if (channel >=1 ) {
 		stack->channels[channel-1] = 1;
 	} else {
-		cb_log(-1,stack->port,"couldn't set channel %d in\n", channel );
+		cb_log(0,stack->port,"couldn't set channel %d in\n", channel );
 	}
   
 	return 0;
@@ -798,7 +834,7 @@
 			if (stack->procids[i]==0) break;
     
 		if (i== MAXPROCS) {
-			cb_log(-1, stack->port, "Couldnt Create New ProcId.\n");
+			cb_log(0, stack->port, "Couldnt Create New ProcId.\n");
 			return -1;
 		}
 		stack->procids[i]=1;
@@ -869,7 +905,7 @@
 	struct misdn_stack *stack=get_stack_by_bc(bc);
 
 	if (!stack) {
-		cb_log(-1, bc->port, "setup_bc: NO STACK FOUND!!\n");
+		cb_log(0, bc->port, "setup_bc: NO STACK FOUND!!\n");
 		return -1;
 	}
 	
@@ -889,7 +925,7 @@
 	cb_log(5, stack->port, "$$$ Setting up bc with stid :%x\n", b_stid);
 	
 	if (b_stid <= 0) {
-		cb_log(-1, stack->port," -- Stid <=0 at the moment in channel:%d\n",channel);
+		cb_log(0, stack->port," -- Stid <=0 at the moment in channel:%d\n",channel);
 		
 		bc_state_change(bc,BCHAN_ERROR);
 		return 1;
@@ -939,7 +975,7 @@
 		
 		ret = mISDN_new_layer(midev, &li);
 		if (ret ) {
-			cb_log(-1, stack->port,"New Layer Err: %d %s\n",ret,strerror(errno));
+			cb_log(0, stack->port,"New Layer Err: %d %s\n",ret,strerror(errno));
 
 			bc_state_change(bc,BCHAN_ERROR);
 			return(-EINVAL);
@@ -986,7 +1022,7 @@
 	ret = mISDN_set_stack(midev, bc->b_stid, &pid);
 
 	if (ret){
-		cb_log(-1, stack->port,"$$$ Set Stack Err: %d %s\n",ret,strerror(errno));
+		cb_log(0, stack->port,"$$$ Set Stack Err: %d %s\n",ret,strerror(errno));
 		
 		mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
 		
@@ -998,7 +1034,7 @@
 	ret = mISDN_get_setstack_ind(midev, bc->layer_id);
 
 	if (ret) {
-		cb_log(-1, stack->port,"$$$ Set StackIND Err: %d %s\n",ret,strerror(errno));
+		cb_log(0, stack->port,"$$$ Set StackIND Err: %d %s\n",ret,strerror(errno));
 		mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
 		
 		bc_state_change(bc,BCHAN_ERROR);
@@ -1010,7 +1046,7 @@
 	bc->addr = ret>0? ret : 0;
 
 	if (!bc->addr) {
-		cb_log(-1, stack->port,"$$$ Get Layerid Err: %d %s\n",ret,strerror(errno));
+		cb_log(0, stack->port,"$$$ Get Layerid Err: %d %s\n",ret,strerror(errno));
 		mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
 		
 		bc_state_change(bc,BCHAN_ERROR);
@@ -1034,7 +1070,7 @@
   
 	if (!bc) return -1;
   
-	cb_log(4, port, "Init.BC %d.\n",bidx);
+	cb_log(8, port, "Init.BC %d.\n",bidx);
 	
 	memset(bc, 0,sizeof(struct misdn_bchannel));
 	
@@ -1074,13 +1110,13 @@
 		stack_info_t *stinf;
 		ret = mISDN_get_stack_info(midev, stack->port, buff, sizeof(buff));
 		if (ret < 0) {
-			cb_log(-1, port, "%s: Cannot get stack info for this port. (ret=%d)\n", __FUNCTION__, ret);
+			cb_log(0, port, "%s: Cannot get stack info for this port. (ret=%d)\n", __FUNCTION__, ret);
 			return -1;
 		}
     
 		stinf = (stack_info_t *)&frm->data.p;
     
-		cb_log(4, port, " --> Child %x\n",stinf->child[bidx]);
+		cb_log(8, port, " --> Child %x\n",stinf->child[bidx]);
 	}
   
 	return 0;
@@ -1100,7 +1136,7 @@
 	struct misdn_stack *stack = malloc(sizeof(struct misdn_stack));
 	if (!stack ) return NULL;
 
-	cb_log(4, port, "Init. Stack.\n");
+	cb_log(8, port, "Init. Stack.\n");
   
 	memset(stack,0,sizeof(struct misdn_stack));
   
@@ -1119,7 +1155,7 @@
 	/* query port's requirements */
 	ret = mISDN_get_stack_info(midev, port, buff, sizeof(buff));
 	if (ret < 0) {
-		cb_log(-1, port, "%s: Cannot get stack info for this port. (ret=%d)\n", __FUNCTION__, ret);
+		cb_log(0, port, "%s: Cannot get stack info for this port. (ret=%d)\n", __FUNCTION__, ret);
 		return(NULL);
 	}
   
@@ -1136,7 +1172,7 @@
 		stack->nt=0;
 		break;
 	case ISDN_PID_L0_NT_S0:
-		cb_log(4, port, "NT Stack\n");
+		cb_log(8, port, "NT Stack\n");
 
 		stack->nt=1;
 		break;
@@ -1150,18 +1186,18 @@
 	case ISDN_PID_L0_NT_UP2:
 		break;
 	case ISDN_PID_L0_TE_E1:
-		cb_log(4, port, "TE S2M Stack\n");
+		cb_log(8, port, "TE S2M Stack\n");
 		stack->nt=0;
 		stack->pri=1;
 		break;
 	case ISDN_PID_L0_NT_E1:
-		cb_log(4, port, "TE S2M Stack\n");
+		cb_log(8, port, "TE S2M Stack\n");
 		stack->nt=1;
 		stack->pri=1;
 		
 		break;
 	default:
-		cb_log(-1, port, "this is a unknown port type 0x%08x\n", stinf->pid.protocol[0]);
+		cb_log(0, port, "this is a unknown port type 0x%08x\n", stinf->pid.protocol[0]);
 
 	}
 
@@ -1177,7 +1213,7 @@
 		int ret;
 		int nt=stack->nt;
 
-		cb_log(4, port, "Init. Stack.\n");
+		cb_log(8, port, "Init. Stack.\n");
 		
 		memset(&li, 0, sizeof(li));
 		{
@@ -1194,7 +1230,7 @@
 		
 		ret = mISDN_new_layer(midev, &li);
 		if (ret) {
-			cb_log(-1, port, "%s: Cannot add layer %d to this port.\n", __FUNCTION__, nt?2:4);
+			cb_log(0, port, "%s: Cannot add layer %d to this port.\n", __FUNCTION__, nt?2:4);
 			return(NULL);
 		}
 		
@@ -1203,23 +1239,23 @@
 		ret = mISDN_register_layer(midev, stack->d_stid, stack->upper_id);
 		if (ret)
 		{
-			cb_log(-1,port,"Cannot register layer %d of this port.\n", nt?2:4);
+			cb_log(0,port,"Cannot register layer %d of this port.\n", nt?2:4);
 			return(NULL);
 		}
 		
 		stack->lower_id = mISDN_get_layerid(midev, stack->d_stid, nt?1:3); 
 		if (stack->lower_id < 0) {
-			cb_log(-1, port, "%s: Cannot get layer(%d) id of this port.\n", __FUNCTION__, nt?1:3);
+			cb_log(0, port, "%s: Cannot get layer(%d) id of this port.\n", __FUNCTION__, nt?1:3);
 			return(NULL);
 		}
 		
 		stack->upper_id = mISDN_get_layerid(midev, stack->d_stid, nt?2:4);
 		if (stack->upper_id < 0) {
-			cb_log(-1, port, "%s: Cannot get layer(%d) id of this port.\n", __FUNCTION__, 2);
+			cb_log(0, port, "%s: Cannot get layer(%d) id of this port.\n", __FUNCTION__, 2);
 			return(NULL);
 		}
 		
-		cb_log(4, port, "NT Stacks upper_id %x\n",stack->upper_id);
+		cb_log(8, port, "NT Stacks upper_id %x\n",stack->upper_id);
 		
 		
 		/* create nst (nt-mode only) */
@@ -1267,7 +1303,7 @@
 		misdn_lib_get_l2_up(stack);
 	}
 
-	cb_log(1,0,"stack_init: port:%d lowerId:%x  upperId:%x\n",stack->port,stack->lower_id, stack->upper_id);
+	cb_log(8,0,"stack_init: port:%d lowerId:%x  upperId:%x\n",stack->port,stack->lower_id, stack->upper_id);
 	
 	return stack;
 }
@@ -1416,7 +1452,7 @@
 			if ( !misdn_cap_is_speech(bc->capability)) {
 				int ret=setup_bc(bc);
 				if (ret == -EINVAL){
-					cb_log(-1,bc->port,"send_event: setup_bc failed\n");
+					cb_log(0,bc->port,"send_event: setup_bc failed\n");
 				}
 			}
 #endif	
@@ -1440,7 +1476,7 @@
 			if (bc->channel == 0xff) {
 				bc->channel=find_free_chan_in_stack(stack, 0);
 				if (!bc->channel) {
-					cb_log(-1, stack->port, "Any Channel Requested, but we have no more!!\n");
+					cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n");
 					break;
 				}
 			}  
@@ -1452,7 +1488,7 @@
 #if 0
 			int ret=setup_bc(bc);
 			if (ret == -EINVAL){
-				cb_log(-1,bc->port,"handle_event: setup_bc failed\n");
+				cb_log(0,bc->port,"handle_event: setup_bc failed\n");
 				misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
 			}
 #endif
@@ -1463,7 +1499,9 @@
 		case EVENT_RELEASE:
 			if (bc->channel>0)
 				empty_chan_in_stack(stack,bc->channel);
+			int tmpcause=bc->cause;	
 			empty_bc(bc);
+			bc->cause=tmpcause;
 			clean_up_bc(bc);
 			break;
 		default:
@@ -1482,7 +1520,7 @@
 	
 	
 	if (!bc) {
-		cb_log(-1, stack->port, " --> !! lib: No free channel!\n");
+		cb_log(0, stack->port, " --> !! lib: No free channel!\n");
 		return -1;
 	}
   
@@ -1533,6 +1571,10 @@
 				
 				dump_chan_list(stack);
 				/*bc->pid = 0;*/
+				bc->need_disconnect=0;
+				bc->need_release=0;
+				bc->need_release_complete=0;
+				
 				cb_event(EVENT_CLEANUP, bc, glob_mgr->user_data);
 				if (bc->stack_holder) {
 					cb_log(4,stack->port, "REMOVEING Holder\n");
@@ -1642,15 +1684,18 @@
 		if ( !stack->ptp && !check) return 1;
 		
 		if (stack->port == port) {
+
+			if (stack->blocked) {
+				cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link);
+				return -1;
+			}
+
 			if (stack->ptp ) {
-				if (stack->l1link) {
-					if (check==2 && !stack->l2link) {
-						cb_log(-1,port, "Port Down L2 (checked):%d L1:%d\n", stack->l2link, stack->l1link);
-						return 0;
-					}
+
+				if (stack->l1link && stack->l2link) {
 					return 1;
 				} else {
-					cb_log(-1,port, "Port Down L2:%d L1:%d\n",
+					cb_log(0,port, "Port Down L2:%d L1:%d\n",
 						stack->l2link, stack->l1link);
 					return 0;
 				}
@@ -1658,7 +1703,7 @@
 				if ( stack->l1link)
 					return 1;
 				else {
-					cb_log(-1,port, "Port down PMP\n");
+					cb_log(0,port, "Port down PMP\n");
 					return 0;
 				}
 			}
@@ -1686,7 +1731,7 @@
 	hh=(mISDNuser_head_t*)msg->data;
 	port=stack->port;
 	
-	cb_log(4, stack->port, " --> lib: prim %x dinfo %x\n",hh->prim, hh->dinfo);
+	cb_log(5, stack->port, " --> lib: prim %x dinfo %x\n",hh->prim, hh->dinfo);
 	{
 		switch(hh->prim){
 		case CC_RETRIEVE|INDICATION:
@@ -1708,9 +1753,10 @@
 			}
 			
 			struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo);
-			cb_event(EVENT_NEW_BC, bc, glob_mgr->user_data);
 			struct misdn_bchannel *hold_bc=stack_holder_find(stack,bc->l3_id);
+
 			if (hold_bc) {
+				cb_event(EVENT_NEW_BC, hold_bc, bc);
 				cb_log(4, stack->port, "REMOVEING Holder\n");
 				stack_holder_remove(stack, hold_bc);
 				free(hold_bc);
@@ -1760,7 +1806,7 @@
 				if ( !misdn_cap_is_speech(bc->capability)) {
 					int ret=setup_bc(bc);
 					if (ret == -EINVAL){
-						cb_log(-1,bc->port,"send_event: setup_bc failed\n");
+						cb_log(0,bc->port,"send_event: setup_bc failed\n");
 						
 					}
 				}
@@ -1780,9 +1826,9 @@
 			
 			if (!bc) {
 				msg_t *dmsg;
-				cb_log(-1, stack->port,"!!!! We didn't found our bc, dinfo:%x on this port.\n",hh->dinfo);
+				cb_log(0, stack->port,"!!!! We didn't found our bc, dinfo:%x on this port.\n",hh->dinfo);
 				
-				cb_log(-1, stack->port, "Releaseing call %x (No free Chan for you..)\n", hh->dinfo);
+				cb_log(0, stack->port, "Releaseing call %x (No free Chan for you..)\n", hh->dinfo);
 				dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST,MT_RELEASE_COMPLETE, hh->dinfo,sizeof(RELEASE_COMPLETE_t), 1);
 				stack->nst.manager_l3(&stack->nst, dmsg);
 				free_msg(msg);
@@ -1791,7 +1837,7 @@
 			}
 			int ret=setup_bc(bc);
 			if (ret == -EINVAL){
-				cb_log(-1,bc->port,"handle_event_nt: setup_bc failed\n");
+				cb_log(0,bc->port,"handle_event_nt: setup_bc failed\n");
 				misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
 			}
 #endif
@@ -1874,7 +1920,7 @@
 					stack->procids[bc->l3_id&0xff] = 0 ;
 				}
 			}
-			else cb_log(-1, stack->port, "Couldnt find BC so I couldnt remove the Process!!!! this is a bad port.\n");
+			else cb_log(0, stack->port, "Couldnt find BC so I couldnt remove the Process!!!! this is a bad port.\n");
 	
 			if (handle_cr(stack, &frm)<0) {
 			}
@@ -1890,7 +1936,7 @@
 		{
 			struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo);
 			int l3id = *((int *)(((u_char *)msg->data)+ mISDNUSER_HEAD_SIZE));
-			if (!bc) { cb_log(-1, stack->port, " --> In NEW_CR: didn't found bc ??\n"); return -1;};
+			if (!bc) { cb_log(0, stack->port, " --> In NEW_CR: didn't found bc ??\n"); return -1;};
 			if (((l3id&0xff00)!=0xff00) && ((bc->l3_id&0xff00)==0xff00)) {
 				cb_log(4, stack->port, " --> Removing Process Id:%x on this port.\n", 0xff&bc->l3_id);
 				stack->procids[bc->l3_id&0xff] = 0 ;
@@ -1907,7 +1953,13 @@
 		case DL_ESTABLISH | INDICATION:
 		case DL_ESTABLISH | CONFIRM:
 		{
-			cb_log(4, stack->port, "%% GOT L2 Activate Info.\n");
+			cb_log(3, stack->port, "%% GOT L2 Activate Info.\n");
+			
+			if (stack->ptp && stack->l2link) {
+				cb_log(0, stack->port, "%% GOT L2 Activate Info. but we're activated already.. this l2 is faulty, blocking port\n");
+				cb_event(EVENT_PORT_ALARM, &stack->bc[0], glob_mgr->user_data);
+			}
+			
 			stack->l2link = 1;
 			stack->l2upcnt=0;
 			
@@ -1921,20 +1973,22 @@
 		case DL_RELEASE | CONFIRM:
 		{
 			if (stack->ptp) {
-				cb_log(-1 , stack->port, "%% GOT L2 DeActivate Info.\n");
+				cb_log(3 , 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");
+					cb_log(0 , stack->port, "!!! Could not Get the L2 up after 3 Attemps!!!\n");
 				}  else {
 #if 0
 					if (stack->nt) misdn_lib_reinit_nt_stack(stack->port);
 #endif
-					misdn_lib_get_l2_up(stack);
-					stack->l2upcnt++;
+					if (stack->l1link) {
+						misdn_lib_get_l2_up(stack);
+						stack->l2upcnt++;
+					}
 				}
 				
 			} else 
-				cb_log(4, stack->port, "%% GOT L2 DeActivate Info.\n");
+				cb_log(3, stack->port, "%% GOT L2 DeActivate Info.\n");
 			
 			stack->l2link = 0;
 			free_msg(msg);
@@ -1971,17 +2025,17 @@
 						if (stack->ptp) 
 							set_chan_in_stack(stack, bc->channel);
 						else 
-							cb_log(-1,stack->port," --> PTMP but channel requested\n");
+							cb_log(0,stack->port," --> PTMP but channel requested\n");
 
 					} else {
 
 						bc->channel = find_free_chan_in_stack(stack, 0);
 						if (!bc->channel) {
-							cb_log(-1, stack->port, " No free channel at the moment\n");
+							cb_log(0, stack->port, " No free channel at the moment\n");
 					
 							msg_t *dmsg;
 				
-							cb_log(-1, stack->port, "Releaseing call %x (No free Chan for you..)\n", hh->dinfo);
+							cb_log(0, stack->port, "Releaseing call %x (No free Chan for you..)\n", hh->dinfo);
 								dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST,MT_RELEASE_COMPLETE, hh->dinfo,sizeof(RELEASE_COMPLETE_t), 1);
 							stack->nst.manager_l3(&stack->nst, dmsg);
 							free_msg(msg);
@@ -1998,7 +2052,9 @@
 				case EVENT_RELEASE_COMPLETE:
 					if (bc->channel>0)
                         			empty_chan_in_stack(stack, bc->channel);
+					int tmpcause=bc->cause;	
 			                empty_bc(bc);
+					bc->cause=tmpcause;
 					clean_up_bc(bc);
 					break;
 
@@ -2016,7 +2072,7 @@
 
 							break;
 						default:
-							return 0;
+							break;
 					}
 				}
 				cb_event(event, bc, glob_mgr->user_data);
@@ -2078,7 +2134,7 @@
 			}
 		}
     
-		cb_log(-1, 0, "Timer Msg without Timer ??\n");
+		cb_log(0, 0, "Timer Msg without Timer ??\n");
 		free_msg(msg);
 		return 1;
 	}
@@ -2132,6 +2188,14 @@
 		
 		if (jlen < len) {
 			cb_log(7,bc->port,"Jitterbuffer Underrun.\n");
+		} else {
+#ifdef WITH_BEROEC
+			if (bc->ec) {
+				flip_buf_bits(data,len);
+				beroec_cancel_alaw_chunk(bc->ec, data, bc->bframe, len);
+				flip_buf_bits(data,len);
+			}
+#endif
 		}
 		
 		txfrm->prim = DL_DATA|REQUEST;
@@ -2196,11 +2260,11 @@
 	switch (frm->prim) {
 
 	case MGR_SETSTACK| CONFIRM:
-		cb_log(2, stack->port, "BCHAN: MGR_SETSTACK|CONFIRM pid:%d\n",bc->pid);
+		cb_log(3, stack->port, "BCHAN: MGR_SETSTACK|CONFIRM pid:%d\n",bc->pid);
 		break;
 		
 	case MGR_SETSTACK| INDICATION:
-		cb_log(2, stack->port, "BCHAN: MGR_SETSTACK|IND pid:%d\n",bc->pid);
+		cb_log(3, stack->port, "BCHAN: MGR_SETSTACK|IND pid:%d\n",bc->pid);
 	break;
 #if 0
 	AGAIN:
@@ -2218,7 +2282,7 @@
 			   data. */
 			bc->addr= frm->addr;
 		} else if ( bc->addr < 0) {
-			cb_log(-1, stack->port,"$$$ bc->addr <0 Error:%s\n",strerror(errno));
+			cb_log(0, stack->port,"$$$ bc->addr <0 Error:%s\n",strerror(errno));
 			bc->addr=0;
 		}
 		
@@ -2234,18 +2298,18 @@
 
 		case BCHAN_CLEAN_REQUEST:
 		default:
-			cb_log(-1, stack->port," --> STATE WASN'T SETUP (but %s) in SETSTACK|IND pid:%d\n",bc_state2str(bc->bc_state), bc->pid);
+			cb_log(0, stack->port," --> STATE WASN'T SETUP (but %s) in SETSTACK|IND pid:%d\n",bc_state2str(bc->bc_state), bc->pid);
 			clean_up_bc(bc);
 		}
 		return 1;
 #endif
 
 	case MGR_DELLAYER| INDICATION:
-		cb_log(2, stack->port, "BCHAN: MGR_DELLAYER|IND pid:%d\n",bc->pid);
+		cb_log(3, stack->port, "BCHAN: MGR_DELLAYER|IND pid:%d\n",bc->pid);
 		break;
 		
 	case MGR_DELLAYER| CONFIRM:
-		cb_log(2, stack->port, "BCHAN: MGR_DELLAYER|CNF pid:%d\n",bc->pid);
+		cb_log(3, stack->port, "BCHAN: MGR_DELLAYER|CNF pid:%d\n",bc->pid);
 		
 		bc->pid=0;
 		bc->addr=0;
@@ -2255,7 +2319,7 @@
 		
 	case PH_ACTIVATE | INDICATION:
 	case DL_ESTABLISH | INDICATION:
-		cb_log(2, stack->port, "BCHAN: ACT Ind pid:%d\n", bc->pid);
+		cb_log(3, stack->port, "BCHAN: ACT Ind pid:%d\n", bc->pid);
 
 		free_msg(msg);
 		return 1;    
@@ -2263,7 +2327,7 @@
 	case PH_ACTIVATE | CONFIRM:
 	case DL_ESTABLISH | CONFIRM:
 		
-		cb_log(2, stack->port, "BCHAN: bchan ACT Confirm pid:%d\n",bc->pid);
+		cb_log(3, stack->port, "BCHAN: bchan ACT Confirm pid:%d\n",bc->pid);
 		free_msg(msg);
 		
 		return 1;    
@@ -2286,14 +2350,14 @@
 		
 	case PH_DEACTIVATE | INDICATION:
 	case DL_RELEASE | INDICATION:
-		cb_log (2, stack->port, "BCHAN: DeACT Ind pid:%d\n",bc->pid);
+		cb_log (3, stack->port, "BCHAN: DeACT Ind pid:%d\n",bc->pid);
 		
 		free_msg(msg);
 		return 1;
     
 	case PH_DEACTIVATE | CONFIRM:
 	case DL_RELEASE | CONFIRM:
-		cb_log(4, stack->port, "BCHAN: DeACT Conf pid:%d\n",bc->pid);
+		cb_log(3, stack->port, "BCHAN: DeACT Conf pid:%d\n",bc->pid);
 		
 		free_msg(msg);
 		return 1;
@@ -2359,7 +2423,7 @@
 		}
 		
 #if MISDN_DEBUG
-		cb_log(-1, stack->port, "DL_DATA INDICATION Len %d\n", frm->len);
+		cb_log(0, stack->port, "DL_DATA INDICATION Len %d\n", frm->len);
 
 #endif
 		
@@ -2409,7 +2473,7 @@
 
 
 	case PH_CONTROL | CONFIRM:
-		cb_log(2, stack->port, "PH_CONTROL|CNF bc->addr:%x\n", frm->addr);
+		cb_log(4, stack->port, "PH_CONTROL|CNF bc->addr:%x\n", frm->addr);
 		free_msg(msg);
 		return 1;
 
@@ -2417,7 +2481,7 @@
 	case DL_DATA|CONFIRM:
 #if MISDN_DEBUG
 
-		cb_log(-1, stack->port, "Data confirmed\n");
+		cb_log(0, stack->port, "Data confirmed\n");
 
 #endif
 		free_msg(msg);
@@ -2425,7 +2489,7 @@
 		return 1;
 	case DL_DATA|RESPONSE:
 #if MISDN_DEBUG
-		cb_log(-1, stack->port, "Data response\n");
+		cb_log(0, stack->port, "Data response\n");
 
 #endif
 		break;
@@ -2456,9 +2520,9 @@
 		if (nt_err_cnt > 0 ) {
 			if (nt_err_cnt < 100) {
 				nt_err_cnt++; 
-				cb_log(-1, stack->port, "NT Stack sends us error: %d \n", err);
+				cb_log(0, stack->port, "NT Stack sends us error: %d \n", err);
 			} else if (nt_err_cnt < 105){
-				cb_log(-1, stack->port, "NT Stack sends us error: %d over 100 times, so I'll stop this message\n", err);
+				cb_log(0, stack->port, "NT Stack sends us error: %d over 100 times, so I'll stop this message\n", err);
 				nt_err_cnt = - 1; 
 			}
 		}
@@ -2512,7 +2576,7 @@
 			cb_log(5, stack->port, "lib Got Prim: Addr %x prim %x dinfo %x\n",frm->addr, frm->prim, frm->dinfo);
       
 			if(!isdn_get_info(msgs_g,event,0)) 
-				cb_log(-1, stack->port, "Unknown Event Ind: Addr:%x prim %x dinfo %x\n",frm->addr, frm->prim, frm->dinfo);
+				cb_log(0, stack->port, "Unknown Event Ind: Addr:%x prim %x dinfo %x\n",frm->addr, frm->prim, frm->dinfo);
 			else 
 				response=cb_event(event, bc, glob_mgr->user_data);
 #if 1
@@ -2520,7 +2584,7 @@
 				switch (response) {
 				case RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE:
 

[... 771 lines stripped ...]


More information about the asterisk-commits mailing list