[asterisk-commits] branch crichter/0.4.0 r36868 - in /team/crichter/0.4.0: ./ apps/ channels/ ch...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jul 3 09:51:21 MST 2006


Author: crichter
Date: Mon Jul  3 11:51:20 2006
New Revision: 36868

URL: http://svn.digium.com/view/asterisk?rev=36868&view=rev
Log:
Merged revisions 36086,36172,36174,36186,36189,36200,36259,36289,36292,36375,36378,36383,36703,36729,36799,36804,36842 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/team/crichter/0.3.0

................
r36086 | root | 2006-06-26 20:00:34 +0200 (Mo, 26 Jun 2006) | 1 line

automerge commit
................
r36172 | crichter | 2006-06-27 13:28:02 +0200 (Di, 27 Jun 2006) | 1 line

fixes segfault on incoming call which is disconnected in Alerting state
................
r36174 | crichter | 2006-06-27 13:31:53 +0200 (Di, 27 Jun 2006) | 1 line

that was a bit too much
................
r36186 | crichter | 2006-06-28 16:11:29 +0200 (Mi, 28 Jun 2006) | 1 line

fixed a few state problems when hanging up the call. also changed a few debug messages to higher log level
................
r36189 | crichter | 2006-06-28 16:24:01 +0200 (Mi, 28 Jun 2006) | 1 line

moved a notice into a log
................
r36200 | root | 2006-06-28 22:00:38 +0200 (Mi, 28 Jun 2006) | 1 line

automerge commit
................
r36259 | root | 2006-06-29 10:00:38 +0200 (Do, 29 Jun 2006) | 1 line

automerge commit
................
r36289 | crichter | 2006-06-29 13:44:52 +0200 (Do, 29 Jun 2006) | 1 line

added better L2 handling for ptp, if it's down we don't try to call on that port in groupdial anymore, also we try to get it up then. Additionally added the configoptions  ntdebugflags and ntdebugfile to debug the mISDNuser NT Stack (should have done that ages before..).
................
r36292 | root | 2006-06-29 22:00:26 +0200 (Do, 29 Jun 2006) | 1 line

automerge commit
................
r36375 | crichter | 2006-06-30 16:04:57 +0200 (Fr, 30 Jun 2006) | 1 line

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.
................
r36378 | crichter | 2006-06-30 16:09:34 +0200 (Fr, 30 Jun 2006) | 1 line

added a bit logging, when we split the bridge
................
r36383 | root | 2006-06-30 17:00:44 +0200 (Fr, 30 Jun 2006) | 1 line

automerge commit
................
r36703 | root | 2006-07-03 06:00:38 +0200 (Mo, 03 Jul 2006) | 1 line

automerge commit
................
r36729 | root | 2006-07-03 07:00:39 +0200 (Mo, 03 Jul 2006) | 1 line

automerge cancel
................
r36799 | crichter | 2006-07-03 09:55:01 +0200 (Mo, 03 Jul 2006) | 18 lines

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

........
r36725 | russell | 2006-07-03 06:19:09 +0200 (Mo, 03 Jul 2006) | 4 lines

use ast_set_callerid to be more consistent and to make sure that the
"callerid" option in the conf files is always handled the same way and sets ANI
(issue #7285, gkloepfer)

........
r36751 | russell | 2006-07-03 07:12:03 +0200 (Mo, 03 Jul 2006) | 3 lines

fix a race condition that caused asterisk to log a *ton* of warnings on mac
osx about poll returning an error because the polled file descriptor was bad.

........

................
r36804 | crichter | 2006-07-03 10:00:56 +0200 (Mo, 03 Jul 2006) | 1 line

settet props for automerging
................
r36842 | root | 2006-07-03 18:00:37 +0200 (Mo, 03 Jul 2006) | 1 line

automerge commit
................

Modified:
    team/crichter/0.4.0/   (props changed)
    team/crichter/0.4.0/Makefile
    team/crichter/0.4.0/apps/app_directory.c
    team/crichter/0.4.0/asterisk.c
    team/crichter/0.4.0/channels/chan_agent.c
    team/crichter/0.4.0/channels/chan_features.c
    team/crichter/0.4.0/channels/chan_h323.c
    team/crichter/0.4.0/channels/chan_iax2.c
    team/crichter/0.4.0/channels/chan_local.c
    team/crichter/0.4.0/channels/chan_mgcp.c
    team/crichter/0.4.0/channels/chan_misdn.c
    team/crichter/0.4.0/channels/chan_modem.c
    team/crichter/0.4.0/channels/chan_phone.c
    team/crichter/0.4.0/channels/chan_sip.c
    team/crichter/0.4.0/channels/chan_skinny.c
    team/crichter/0.4.0/channels/misdn/chan_misdn_config.h
    team/crichter/0.4.0/channels/misdn/isdn_lib.c
    team/crichter/0.4.0/channels/misdn/isdn_lib.h
    team/crichter/0.4.0/channels/misdn/isdn_lib_intern.h
    team/crichter/0.4.0/channels/misdn_config.c
    team/crichter/0.4.0/configs/misdn.conf.sample
    team/crichter/0.4.0/configs/queues.conf.sample
    team/crichter/0.4.0/configs/sip.conf.sample
    team/crichter/0.4.0/dsp.c

Propchange: team/crichter/0.4.0/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/crichter/0.4.0/
------------------------------------------------------------------------------
--- automerge-email (original)
+++ automerge-email Mon Jul  3 11:51:20 2006
@@ -1,1 +1,1 @@
-cr at beronet.com
+christian.richter at beronet.com

Propchange: team/crichter/0.4.0/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jul  3 11:51:20 2006
@@ -1,1 +1,1 @@
-/team/crichter/0.3.0:1-36082
+/team/crichter/0.3.0:1-36865

Modified: team/crichter/0.4.0/Makefile
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/Makefile?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/Makefile (original)
+++ team/crichter/0.4.0/Makefile Mon Jul  3 11:51:20 2006
@@ -28,6 +28,7 @@
 ifeq ($(CROSS_COMPILE),)
   OSARCH=$(shell uname -s)
   OSREV=$(shell uname -r)
+  OSCPU=$(shell uname -m)
 else
   OSARCH=$(CROSS_ARCH)
   OSREV=$(CROSS_REV)
@@ -82,6 +83,8 @@
 #   *CLI> show memory summary [filename]
 #
 MALLOC_DEBUG = #-include $(PWD)/include/asterisk/astmm.h
+
+INSTALL=install
 
 # Where to install asterisk after compiling
 # Default -> leave empty
@@ -211,12 +214,15 @@
 endif
 
 GREP=grep
+LN=ln
 ID=id
 
 ifeq ($(OSARCH),SunOS)
   GREP=/usr/xpg4/bin/grep
   M4=/usr/local/bin/m4
   ID=/usr/xpg4/bin/id
+  LN=/usr/xpg4/bin/ln
+  INSTALL=ginstall
 endif
 
 INCLUDE+=-Iinclude -I../include
@@ -283,7 +289,10 @@
 
 ifeq ($(OSARCH),SunOS)
   ASTCFLAGS+=-Wcast-align -DSOLARIS
-  INCLUDE+=-Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
+  INCLUDE+=-Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/opt/ssl/include -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
+  ifeq ($(OSCPU),sun4u)
+    OPTIMIZE+=-mcpu=v9 -mcpu=ultrasparc
+  endif
 endif
 
 ifeq ($(findstring CYGWIN,$(OSARCH)),CYGWIN)
@@ -360,7 +369,11 @@
 ifeq ($(OSARCH),Linux)
   LIBS+=-ldl -lpthread -lncurses -lm -lresolv  #-lnjamd
 else
-  LIBS+=-lncurses -lm
+  ifeq ($(OSARCH),SunOS)
+    LIBS+=-lm -lcurses
+  else
+    LIBS+=-lncurses -lm
+  endif
 endif
 
 ifeq ($(OSARCH),Darwin)
@@ -390,10 +403,10 @@
 endif
 
 ifeq ($(OSARCH),SunOS)
-  LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
+  LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L$(CROSS_COMPILE_TARGET)/opt/ssl/lib -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
   OBJS+=strcompat.o
   ASTLINK=
-  SOLINK=-shared -fpic -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
+  SOLINK=-shared -fpic -L$(CROSS_COMPILE_TARGET)/opt/ssl/lib -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
 endif
 
 ifeq ($(MAKETOPLEVEL),$(MAKELEVEL))
@@ -408,8 +421,6 @@
 endif
 
 LIBS+=-lssl
-
-INSTALL=install
 
 _all: all
 	@echo " +--------- Asterisk Build Complete ---------+"  
@@ -634,7 +645,7 @@
 	if [ -f asterisk ]; then $(INSTALL) -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/; fi
 	if [ -f cygwin/asterisk.exe ]; then $(INSTALL) -m 755 cygwin/asterisk.exe $(DESTDIR)$(ASTSBINDIR)/; fi
 	if [ -f asterisk.dll ]; then $(INSTALL) -m 755 asterisk.dll $(DESTDIR)$(ASTSBINDIR)/; fi
-	ln -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
+	$(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
 	$(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
 	$(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/	
 	if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \

Modified: team/crichter/0.4.0/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_directory.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_directory.c (original)
+++ team/crichter/0.4.0/apps/app_directory.c Mon Jul  3 11:51:20 2006
@@ -41,6 +41,16 @@
 #include "asterisk/config.h"
 #include "asterisk/say.h"
 #include "asterisk/utils.h"
+
+#ifdef USE_ODBC_STORAGE
+#include <errno.h>
+#include <sys/mman.h>
+#include "asterisk/res_odbc.h"
+
+static char odbc_database[80] = "asterisk";
+static char odbc_table[80] = "voicemessages";
+static char vmfmts[80] = "wav";
+#endif
 
 static char *tdesc = "Extension Directory";
 static char *app = "Directory";
@@ -77,6 +87,101 @@
 
 LOCAL_USER_DECL;
 
+#ifdef USE_ODBC_STORAGE
+static void retrieve_file(char *dir)
+{
+	int x = 0;
+	int res;
+	int fd=-1;
+	size_t fdlen = 0;
+	void *fdm=NULL;
+	SQLHSTMT stmt;
+	char sql[256];
+	char fmt[80]="";
+	char *c;
+	SQLLEN colsize;
+	char full_fn[256];
+
+	odbc_obj *obj;
+	obj = fetch_odbc_obj(odbc_database, 0);
+	if (obj) {
+		do {
+			ast_copy_string(fmt, vmfmts, sizeof(fmt));
+			c = strchr(fmt, '|');
+			if (c)
+				*c = '\0';
+			if (!strcasecmp(fmt, "wav49"))
+				strcpy(fmt, "WAV");
+			snprintf(full_fn, sizeof(full_fn), "%s.%s", dir, fmt);
+			res = SQLAllocHandle(SQL_HANDLE_STMT, obj->con, &stmt);
+			if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+				ast_log(LOG_WARNING, "SQL Alloc Handle failed!\n");
+				break;
+			}
+			snprintf(sql, sizeof(sql), "SELECT recording FROM %s WHERE dir=? AND msgnum=-1", odbc_table);
+			res = SQLPrepare(stmt, (unsigned char *)sql, SQL_NTS);
+			if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+				ast_log(LOG_WARNING, "SQL Prepare failed![%s]\n", sql);
+				SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+				break;
+			}
+			SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(dir), 0, (void *)dir, 0, NULL);
+			res = odbc_smart_execute(obj, stmt);
+			if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+				ast_log(LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
+				SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+				break;
+			}
+			res = SQLFetch(stmt);
+			if (res == SQL_NO_DATA) {
+				SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+				break;
+			} else if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+				ast_log(LOG_WARNING, "SQL Fetch error!\n[%s]\n\n", sql);
+				SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+				break;
+			}
+			fd = open(full_fn, O_RDWR | O_CREAT | O_TRUNC, 0770);
+			if (fd < 0) {
+				ast_log(LOG_WARNING, "Failed to write '%s': %s\n", full_fn, strerror(errno));
+				SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+				break;
+			}
+
+			res = SQLGetData(stmt, 1, SQL_BINARY, NULL, 0, &colsize);
+			fdlen = colsize;
+			if (fd > -1) {
+				char tmp[1]="";
+				lseek(fd, fdlen - 1, SEEK_SET);
+				if (write(fd, tmp, 1) != 1) {
+					close(fd);
+					fd = -1;
+					break;
+				}
+				if (fd > -1)
+					fdm = mmap(NULL, fdlen, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+			}
+			if (fdm) {
+				memset(fdm, 0, fdlen);
+				res = SQLGetData(stmt, x + 1, SQL_BINARY, fdm, fdlen, &colsize);
+				if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+					ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
+					SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+					break;
+				}
+			}
+			SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+		} while (0);
+	} else
+		ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
+	if (fdm)
+		munmap(fdm, fdlen);
+	if (fd > -1)
+		close(fd);
+	return;
+}
+#endif
+
 static char *convert(char *lastname)
 {
 	char *tmp;
@@ -160,10 +265,16 @@
 	/* Check for the VoiceMail2 greeting first */
 	snprintf(fn, sizeof(fn), "%s/voicemail/%s/%s/greet",
 		(char *)ast_config_AST_SPOOL_DIR, context, ext);
+#ifdef USE_ODBC_STORAGE
+	retrieve_file(fn);
+#endif
 
 	/* Otherwise, check for an old-style Voicemail greeting */
 	snprintf(fn2, sizeof(fn2), "%s/vm/%s/greet",
 		(char *)ast_config_AST_SPOOL_DIR, ext);
+#ifdef USE_ODBC_STORAGE
+	retrieve_file(fn2);
+#endif
 
 	if (ast_fileexists(fn, NULL, chan->language) > 0) {
 		res = ast_streamfile(chan, fn, chan->language);
@@ -181,6 +292,10 @@
 		res = ast_say_character_str(chan, !ast_strlen_zero(name) ? name : ext,
 					AST_DIGIT_ANY, chan->language);
 	}
+#ifdef USE_ODBC_STORAGE
+	ast_filedelete(fn, NULL);	
+	ast_filedelete(fn2, NULL);	
+#endif
 
 	while (loop) {
 		if (!res) {
@@ -495,6 +610,25 @@
 
 int load_module(void)
 {
+#ifdef USE_ODBC_STORAGE
+	struct ast_config *cfg = ast_config_load(VOICEMAIL_CONFIG);
+	char *tmp;
+
+	if (cfg) {
+		if ((tmp = ast_variable_retrieve(cfg, "general", "odbcstorage"))) {
+			ast_copy_string(odbc_database, tmp, sizeof(odbc_database));
+		}
+		if ((tmp = ast_variable_retrieve(cfg, "general", "odbctable"))) {
+			ast_copy_string(odbc_table, tmp, sizeof(odbc_table));
+		}
+		if ((tmp = ast_variable_retrieve(cfg, "general", "format"))) {
+			ast_copy_string(vmfmts, tmp, sizeof(vmfmts));
+		}
+		ast_config_destroy(cfg);
+	} else
+		ast_log(LOG_WARNING, "Unable to load " VOICEMAIL_CONFIG " - ODBC defaults will be used\n");
+#endif
+
 	return ast_register_application(app, directory_exec, synopsis, descrip);
 }
 

Modified: team/crichter/0.4.0/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/asterisk.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/asterisk.c (original)
+++ team/crichter/0.4.0/asterisk.c Mon Jul  3 11:51:20 2006
@@ -592,6 +592,7 @@
 		fds[0].fd = ast_socket;
 		fds[0].events= POLLIN;
 		s = poll(fds, 1, -1);
+		pthread_testcancel();
 		if (s < 0) {
 			if (errno != EINTR)
 				ast_log(LOG_WARNING, "poll returned error: %s\n", strerror(errno));
@@ -905,13 +906,13 @@
 		ast_log(LOG_DEBUG, "Asterisk ending (%d).\n", num);
 	manager_event(EVENT_FLAG_SYSTEM, "Shutdown", "Shutdown: %s\r\nRestart: %s\r\n", ast_active_channels() ? "Uncleanly" : "Cleanly", restart ? "True" : "False");
 	if (ast_socket > -1) {
+		pthread_cancel(lthread);
 		close(ast_socket);
 		ast_socket = -1;
+		unlink(ast_config_AST_SOCKET);
 	}
 	if (ast_consock > -1)
 		close(ast_consock);
-	if (ast_socket > -1)
-		unlink((char *)ast_config_AST_SOCKET);
 	if (!option_remote) unlink((char *)ast_config_AST_PID);
 	printf(term_quit());
 	if (restart) {

Modified: team/crichter/0.4.0/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_agent.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_agent.c (original)
+++ team/crichter/0.4.0/channels/chan_agent.c Mon Jul  3 11:51:20 2006
@@ -661,18 +661,8 @@
 		/* Call on this agent */
 		if (option_verbose > 2)
 			ast_verbose(VERBOSE_PREFIX_3 "outgoing agentcall, to agent '%s', on '%s'\n", p->agent, p->chan->name);
-		if (p->chan->cid.cid_num)
-			free(p->chan->cid.cid_num);
-		if (ast->cid.cid_num)
-			p->chan->cid.cid_num = strdup(ast->cid.cid_num);
-		else
-			p->chan->cid.cid_num = NULL;
-		if (p->chan->cid.cid_name)
-			free(p->chan->cid.cid_name);
-		if (ast->cid.cid_name)
-			p->chan->cid.cid_name = strdup(ast->cid.cid_name);
-		else
-			p->chan->cid.cid_name = NULL;
+		ast_set_callerid(p->chan,
+			ast->cid.cid_num, ast->cid.cid_name, NULL);
 		ast_channel_inherit_variables(ast, p->chan);
 		res = ast_call(p->chan, p->loginchan, 0);
 		CLEANUP(ast,p);

Modified: team/crichter/0.4.0/channels/chan_features.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_features.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_features.c (original)
+++ team/crichter/0.4.0/channels/chan_features.c Mon Jul  3 11:51:20 2006
@@ -328,25 +328,14 @@
 		ast_mutex_lock(&p->lock);
 		x = indexof(p, ast, 0);
 		if (!x && p->subchan) {
-			if (p->owner->cid.cid_num)
-				p->subchan->cid.cid_num = strdup(p->owner->cid.cid_num);
-			else 
-				p->subchan->cid.cid_num = NULL;
-		
-			if (p->owner->cid.cid_name)
-				p->subchan->cid.cid_name = strdup(p->owner->cid.cid_name);
-			else 
-				p->subchan->cid.cid_name = NULL;
+			ast_set_callerid(p->subchan,
+				p->owner->cid.cid_num, p->owner->cid.cid_name,
+				p->owner->cid.cid_ani ? p->owner->cid.cid_ani : p->owner->cid.cid_num);
 		
 			if (p->owner->cid.cid_rdnis)
 				p->subchan->cid.cid_rdnis = strdup(p->owner->cid.cid_rdnis);
 			else
 				p->subchan->cid.cid_rdnis = NULL;
-		
-			if (p->owner->cid.cid_ani)
-				p->subchan->cid.cid_ani = strdup(p->owner->cid.cid_ani);
-			else
-				p->subchan->cid.cid_ani = NULL;
 		
 			p->subchan->cid.cid_pres = p->owner->cid.cid_pres;
 			strncpy(p->subchan->language, p->owner->language, sizeof(p->subchan->language) - 1);

Modified: team/crichter/0.4.0/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_h323.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_h323.c (original)
+++ team/crichter/0.4.0/channels/chan_h323.c Mon Jul  3 11:51:20 2006
@@ -769,16 +769,17 @@
 		if (pvt->amaflags) {
 			ch->amaflags = pvt->amaflags;
 		}
-		if (!ast_strlen_zero(pvt->cid_num)) {
-			ch->cid.cid_num = strdup(pvt->cid_num);
-		} else if (!ast_strlen_zero(pvt->cd.call_source_e164)) {
-			ch->cid.cid_num = strdup(pvt->cd.call_source_e164);
-		}
-		if (!ast_strlen_zero(pvt->cid_name)) {
-			ch->cid.cid_name = strdup(pvt->cid_name);
-		} else if (!ast_strlen_zero(pvt->cd.call_source_name)) {
-			ch->cid.cid_name = strdup(pvt->cd.call_source_name);
-		}
+
+		/*
+		 * If cid_num and cdi.call_source_e164 are both null, then
+		 * ast_set_callerid will do the right thing and leave the
+		 * cid_num and cid_ani for the channel alone.
+		 */
+		ast_set_callerid(ch,
+			!ast_strlen_zero(pvt->cid_num) ? pvt->cid_num : pvt->cd.call_source_e164,
+			pvt->cid_name,
+			!ast_strlen_zero(pvt->cid_num) ? pvt->cid_num : pvt->cd.call_source_e164);
+
 		if (!ast_strlen_zero(pvt->rdnis)) {
 			ch->cid.cid_rdnis = strdup(pvt->rdnis);
 		}

Modified: team/crichter/0.4.0/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_iax2.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_iax2.c (original)
+++ team/crichter/0.4.0/channels/chan_iax2.c Mon Jul  3 11:51:20 2006
@@ -3412,12 +3412,8 @@
 		tmp->writeformat = ast_best_codec(capability);
 		tmp->tech_pvt = CALLNO_TO_PTR(i->callno);
 
-		if (!ast_strlen_zero(i->cid_num))
-			tmp->cid.cid_num = strdup(i->cid_num);
-		if (!ast_strlen_zero(i->cid_name))
-			tmp->cid.cid_name = strdup(i->cid_name);
-		if (!ast_strlen_zero(i->ani))
-			tmp->cid.cid_ani = strdup(i->ani);
+		ast_set_callerid(tmp, i->cid_num, i->cid_name,
+			i->ani ? i->ani : i->cid_num);
 		if (!ast_strlen_zero(i->language))
 			ast_copy_string(tmp->language, i->language, sizeof(tmp->language));
 		if (!ast_strlen_zero(i->dnid))

Modified: team/crichter/0.4.0/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_local.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_local.c (original)
+++ team/crichter/0.4.0/channels/chan_local.c Mon Jul  3 11:51:20 2006
@@ -336,25 +336,15 @@
 	size_t len, namelen;
 	
 	ast_mutex_lock(&p->lock);
-	if (p->owner->cid.cid_num)
-		p->chan->cid.cid_num = strdup(p->owner->cid.cid_num);
-	else 
-		p->chan->cid.cid_num = NULL;
-
-	if (p->owner->cid.cid_name)
-		p->chan->cid.cid_name = strdup(p->owner->cid.cid_name);
-	else 
-		p->chan->cid.cid_name = NULL;
+
+	ast_set_callerid(p->chan,
+		p->owner->cid.cid_num, p->owner->cid.cid_name,
+		p->owner->cid.cid_ani ? p->chan->cid.cid_ani : p->owner->cid.cid_num);
 
 	if (p->owner->cid.cid_rdnis)
 		p->chan->cid.cid_rdnis = strdup(p->owner->cid.cid_rdnis);
 	else
 		p->chan->cid.cid_rdnis = NULL;
-
-	if (p->owner->cid.cid_ani)
-		p->chan->cid.cid_ani = strdup(p->owner->cid.cid_ani);
-	else
-		p->chan->cid.cid_ani = NULL;
 
 	p->chan->cid.cid_pres = p->owner->cid.cid_pres;
 

Modified: team/crichter/0.4.0/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_mgcp.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_mgcp.c (original)
+++ team/crichter/0.4.0/channels/chan_mgcp.c Mon Jul  3 11:51:20 2006
@@ -1428,10 +1428,7 @@
 		strncpy(tmp->call_forward, i->call_forward, sizeof(tmp->call_forward) - 1);
 		strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
 		strncpy(tmp->exten, i->exten, sizeof(tmp->exten)-1);
-		if (!ast_strlen_zero(i->cid_num))
-			tmp->cid.cid_num = strdup(i->cid_num);
-		if (!ast_strlen_zero(i->cid_name))
-			tmp->cid.cid_name = strdup(i->cid_name);
+		ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
 		if (!i->adsi)
 			tmp->adsicpe = AST_ADSI_UNAVAILABLE;
 		tmp->priority = 1;
@@ -2621,21 +2618,10 @@
 					/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
 					ast_indicate(chan, -1);
 					strncpy(chan->exten, exten, sizeof(chan->exten)-1);
-					if (!ast_strlen_zero(p->cid_num)) {
-						if (!p->hidecallerid) {
-							/* SC: free existing chan->callerid */
-							if (chan->cid.cid_num)
-								free(chan->cid.cid_num);
-							chan->cid.cid_num = strdup(p->cid_num);
-							/* SC: free existing chan->callerid */
-							if (chan->cid.cid_name)
-								free(chan->cid.cid_name);
-							chan->cid.cid_name = strdup(p->cid_name);
-						}
-						if (chan->cid.cid_ani)
-							free(chan->cid.cid_ani);
-						chan->cid.cid_ani = strdup(p->cid_num);
-					}
+					ast_set_callerid(chan,
+							p->hidecallerid ? "" : p->cid_num,
+							p->hidecallerid ? "" : p->cid_name,
+							chan->cid.cid_ani ? NULL : p->cid_num);
 					ast_setstate(chan, AST_STATE_RING);
 					/*zt_enable_ec(p);*/
 					if (p->dtmfmode & MGCP_DTMF_HYBRID) {
@@ -2692,12 +2678,7 @@
 			}
 			/* Disable Caller*ID if enabled */
 			p->hidecallerid = 1;
-			if (chan->cid.cid_num)
-				free(chan->cid.cid_num);
-			chan->cid.cid_num = NULL;
-			if (chan->cid.cid_name)
-				free(chan->cid.cid_name);
-			chan->cid.cid_name = NULL;
+			ast_set_callerid(chan, "", "", NULL);
 			/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
 			transmit_notify_request(sub, "L/sl");
 			len = 0;
@@ -2776,14 +2757,7 @@
 			}
 			/* Enable Caller*ID if enabled */
 			p->hidecallerid = 0;
-			if (chan->cid.cid_num)
-				free(chan->cid.cid_num);
-			if (!ast_strlen_zero(p->cid_num))
-				chan->cid.cid_num = strdup(p->cid_num);
-			if (chan->cid.cid_name)
-				free(chan->cid.cid_name);
-			if (!ast_strlen_zero(p->cid_name))
-				chan->cid.cid_name = strdup(p->cid_name);
+			ast_set_callerid(chan, p->cid_num, p->cid_name, NULL);
 			/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
 			transmit_notify_request(sub, "L/sl");
 			len = 0;

Modified: team/crichter/0.4.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_misdn.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_misdn.c (original)
+++ team/crichter/0.4.0/channels/chan_misdn.c Mon Jul  3 11:51:20 2006
@@ -739,6 +739,14 @@
 		misdn_debug[i] = cfg_debug;
 		misdn_debug_only[i] = 0;
 	}
+
+	int ntflags=0;
+	char ntfile[BUFFERSIZE+1];
+
+	misdn_cfg_get( 0, MISDN_GEN_NTDEBUGFLAGS, &ntflags, sizeof(int));
+	misdn_cfg_get( 0, MISDN_GEN_NTDEBUGFILE, &ntfile, BUFFERSIZE);
+
+	misdn_lib_nt_debug_init(ntflags,ntfile);
 }
 
 static int misdn_reload (int fd, int argc, char *argv[])
@@ -2184,6 +2192,8 @@
 				misdn_lib_send_event(bc, EVENT_DISCONNECT);
 			}
 		}
+
+		p->state=MISDN_CLEANING;
     
 	}
 	
@@ -2395,6 +2405,12 @@
     
 		if (!f || f->frametype == AST_FRAME_CONTROL) {
 			/* got hangup .. */
+
+			if (!f) 
+				chan_misdn_log(1,ch1->bc->port,"Read Null Frame\n");
+			else
+				chan_misdn_log(1,ch1->bc->port,"Read Frame Controll class:%d\n",f->subclass);
+			
 			*fo=f;
 			*rc=who;
       
@@ -2997,13 +3013,6 @@
 		release_unlock;
 		
 		chan_misdn_log(1, bc->port, "release_chan: bc with l3id: %x\n",bc->l3_id);
-#if 0
-		if (ch->dummy) {
-			ast_hangup(ast);
-			ch->ast=NULL;
-			ast=NULL;
-		}
-#endif
 		
 		/*releaseing jitterbuffer*/
 		if (ch->jb ) {
@@ -3025,6 +3034,7 @@
 			
 			close(ch->pipe[0]);
 			close(ch->pipe[1]);
+
 			
 			if (ast && MISDN_ASTERISK_TECH_PVT(ast)) {
 				chan_misdn_log(1, bc->port, "* RELEASING CHANNEL pid:%d ctx:%s dad:%s oad:%s state: %s\n",bc?bc->pid:-1, ast->context, ast->exten,AST_CID_P(ast),misdn_get_ch_state(ch));
@@ -3055,8 +3065,6 @@
 				case MISDN_PROCEEDING:
 					chan_misdn_log(2,  bc->port, "* --> In State Dialin\n");
 					chan_misdn_log(2,  bc->port, "* --> Queue Hangup\n");
-					
-					ch->state=MISDN_CLEANING;
 					ast_queue_hangup(ast);
 					
 					break;
@@ -3090,6 +3098,7 @@
 					}
 				}
 			}
+			ch->state=MISDN_CLEANING;
 			cl_dequeue_chan(&cl_te, ch);
 			
 			free(ch);
@@ -3283,14 +3292,19 @@
 		ch=find_chan_by_l3id(cl_te, bc->l3_id);
 	
 	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\n", manager_isdn_get_info(event), bc->oad, bc->dad, bc->pid);
+		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));
 	}
 	
 	if (event != EVENT_SETUP) {
 		if (!ch) {
-			if (event != EVENT_CLEANUP )
+			if (event == EVENT_RELEASE_COMPLETE) {
+				chan_misdn_log(1, bc->port, " --> no Ch, so we've already released.\n");
+				return 0;
+			}
+		
+			if (event != EVENT_CLEANUP && event != EVENT_TONE_GENERATE && event != EVENT_BCHAN_DATA)
 				ast_log(LOG_NOTICE, "Chan not existing at the moment bc->l3id:%x bc:%p event:%s port:%d channel:%d\n",bc->l3_id, bc, manager_isdn_get_info( event), bc->port,bc->channel);
 			return -1;
 		}
@@ -3809,7 +3823,8 @@
 			   dialled number, or perhaps even giving an
 			   alternative number, then play it instead of
 			   immediately releasing the call */
-			chan_misdn_log(0,bc->port, " --> Inband Info Avail, not sending RELEASE\n");
+			chan_misdn_log(1,bc->port, " --> Inband Info Avail, not sending RELEASE\n");
+		
 			ch->state=MISDN_DISCONNECTED;
 			start_bc_tones(ch);
 			break;
@@ -3827,6 +3842,7 @@
 		stop_bc_tones(ch);
 		bc->out_cause=-1;
 		
+		release_chan(bc);
 		misdn_lib_send_event(bc,EVENT_RELEASE);
 	}
 	break;
@@ -3845,6 +3861,8 @@
 				*/
 				
 				/*return RESPONSE_OK;*/
+				if (!bc->nt) release_chan(bc);
+
 				break;
 			}
 			
@@ -3862,6 +3880,7 @@
 		break;
 	case EVENT_RELEASE_COMPLETE:
 	{
+		ch->state=MISDN_CLEANING;
 		stop_bc_tones(ch);
 		release_chan(bc);
 	}
@@ -4230,8 +4249,7 @@
 
 	misdn_cfg_get( 0, MISDN_GEN_TRACEFILE, global_tracefile, BUFFERSIZE);
 
-
-
+	reload_config();
 	
 	chan_misdn_log(0, 0, "-- mISDN Channel Driver Registred -- (BE AWARE THIS DRIVER IS EXPERIMENTAL!)\n");
 

Modified: team/crichter/0.4.0/channels/chan_modem.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_modem.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_modem.c (original)
+++ team/crichter/0.4.0/channels/chan_modem.c Mon Jul  3 11:51:20 2006
@@ -576,10 +576,7 @@
 		tmp->tech_pvt = i;
 		strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
 
-		if (!ast_strlen_zero(i->cid_num))
-			tmp->cid.cid_num = strdup(i->cid_num);
-		if (!ast_strlen_zero(i->cid_name))
-			tmp->cid.cid_name = strdup(i->cid_name);
+		ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
 
 		if (!ast_strlen_zero(i->language))
 			strncpy(tmp->language,i->language, sizeof(tmp->language)-1);

Modified: team/crichter/0.4.0/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_phone.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_phone.c (original)
+++ team/crichter/0.4.0/channels/chan_phone.c Mon Jul  3 11:51:20 2006
@@ -825,10 +825,7 @@
 			strncpy(tmp->exten, "s",  sizeof(tmp->exten) - 1);
 		if (!ast_strlen_zero(i->language))
 			strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
-		if (!ast_strlen_zero(i->cid_num))
-			tmp->cid.cid_num = strdup(i->cid_num);
-		if (!ast_strlen_zero(i->cid_name))
-			tmp->cid.cid_name = strdup(i->cid_name);
+		ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
 		i->owner = tmp;
 		ast_mutex_lock(&usecnt_lock);
 		usecnt++;

Modified: team/crichter/0.4.0/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_sip.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_sip.c (original)
+++ team/crichter/0.4.0/channels/chan_sip.c Mon Jul  3 11:51:20 2006
@@ -2176,9 +2176,6 @@
 		ast_log(LOG_WARNING, "Trying to destroy \"%s\", not found in dialog list?!?! \n", p->callid);
 		return;
 	} 
-	if (p->initid > -1)
-		ast_sched_del(sched, p->initid);
-
 	while((cp = p->packets)) {
 		p->packets = p->packets->next;
 		if (cp->retransid > -1) {
@@ -2773,11 +2770,11 @@
 	fmt = ast_best_codec(tmp->nativeformats);
 
 	if (title)
-		snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%04x", title, thread_safe_rand() & 0xffff);
+		snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%08x", title, (int)(long) i);
 	else if (strchr(i->fromdomain,':'))
-		snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%08x", strchr(i->fromdomain,':')+1, (int)(long)(i));
+		snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%08x", strchr(i->fromdomain,':') + 1, (int)(long) i);
 	else
-		snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%08x", i->fromdomain, (int)(long)(i));
+		snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%08x", i->fromdomain, (int)(long) i);
 
 	tmp->type = channeltype;
 	if (ast_test_flag(i, SIP_DTMF) ==  SIP_DTMF_INBAND) {
@@ -2820,10 +2817,7 @@
 	ast_mutex_unlock(&usecnt_lock);
 	ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
 	ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
-	if (!ast_strlen_zero(i->cid_num)) 
-		tmp->cid.cid_num = strdup(i->cid_num);
-	if (!ast_strlen_zero(i->cid_name))
-		tmp->cid.cid_name = strdup(i->cid_name);
+	ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
 	if (!ast_strlen_zero(i->rdnis))
 		tmp->cid.cid_rdnis = strdup(i->rdnis);
 	if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s"))
@@ -3942,7 +3936,7 @@
 /*! \brief  add_route: Add route header into request per learned route ---*/
 static void add_route(struct sip_request *req, struct sip_route *route)
 {
-	char r[256], *p;
+	char r[BUFSIZ*2], *p;
 	int n, rem = sizeof(r);
 
 	if (!route) return;

Modified: team/crichter/0.4.0/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_skinny.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_skinny.c (original)
+++ team/crichter/0.4.0/channels/chan_skinny.c Mon Jul  3 11:51:20 2006
@@ -1741,11 +1741,12 @@
                     			getforward = 0;
                 		} else  {
                     			strncpy(chan->exten, exten, sizeof(chan->exten)-1);
+
                     			if (!ast_strlen_zero(l->cid_num)) {
-                        			if (!l->hidecallerid) {
-                            				chan->cid.cid_num = strdup(l->cid_num);
-                        				chan->cid.cid_ani = strdup(l->cid_num);
-                    				}
+						ast_set_callerid(chan,
+							l->hidecallerid ? "" : l->cid_num,
+							l->hidecallerid ? "" : l->cid_name,
+							chan->cid.cid_ani ? NULL : l->cid_num);
                     				ast_setstate(chan, AST_STATE_RING);
                     				res = ast_pbx_run(chan);
                     				if (res) {
@@ -1792,14 +1793,7 @@
             		}
 		       	/* Disable Caller*ID if enabled */
 		        l->hidecallerid = 1;
-       			if (chan->cid.cid_num) {
-	               		free(chan->cid.cid_num);
-	    		}
-	            	chan->cid.cid_num = NULL;
-	   		if (chan->cid.cid_name) {
-               			free(chan->cid.cid_name);
-	    		}
-	      		chan->cid.cid_name = NULL;
+			ast_set_callerid(chan, "", "", NULL);
             		transmit_tone(s, SKINNY_DIALTONE);
        			len = 0;
            		memset(exten, 0, sizeof(exten));
@@ -1873,18 +1867,7 @@
        			}
        			/* Enable Caller*ID if enabled */
        			l->hidecallerid = 0;
-       			if (chan->cid.cid_num) {
-              			free(chan->cid.cid_num);	
-    			}
-            		if (!ast_strlen_zero(l->cid_num)) {
-                		chan->cid.cid_num = strdup(l->cid_num);
-	    		}
-      			if (chan->cid.cid_name) {
-               			free(chan->cid.cid_name);
-    			}
-            		if (!ast_strlen_zero(l->cid_name)) {
-               			chan->cid.cid_name = strdup(l->cid_name);	
-			}
+			ast_set_callerid(chan, l->cid_num, l->cid_name, NULL);
             		transmit_tone(s, SKINNY_DIALTONE);
             		len = 0;
             		memset(exten, 0, sizeof(exten));
@@ -2296,12 +2279,7 @@
 		strncpy(tmp->call_forward, l->call_forward, sizeof(tmp->call_forward) - 1);
 		strncpy(tmp->context, l->context, sizeof(tmp->context)-1);
 		strncpy(tmp->exten,l->exten, sizeof(tmp->exten)-1);
-		if (!ast_strlen_zero(l->cid_num)) {
-			tmp->cid.cid_num = strdup(l->cid_num);
-		}
-		if (!ast_strlen_zero(l->cid_name)) {
-			tmp->cid.cid_name = strdup(l->cid_name);
-		}
+		ast_set_callerid(tmp, l->cid_num, l->cid_name, l->cid_num);
 		tmp->priority = 1;
 		tmp->adsicpe = AST_ADSI_UNAVAILABLE;
 

Modified: team/crichter/0.4.0/channels/misdn/chan_misdn_config.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/chan_misdn_config.h?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/chan_misdn_config.h (original)
+++ team/crichter/0.4.0/channels/misdn/chan_misdn_config.h Mon Jul  3 11:51:20 2006
@@ -75,6 +75,8 @@
 	MISDN_GEN_CRYPT_PREFIX,        /* char[] */
 	MISDN_GEN_CRYPT_KEYS,          /* char[] */
 	MISDN_GEN_L1_TIMEOUT,          /* int */
+	MISDN_GEN_NTDEBUGFLAGS,          /* int */
+	MISDN_GEN_NTDEBUGFILE,          /* char[] */
 	MISDN_GEN_LAST
 };
 

Modified: team/crichter/0.4.0/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_lib.c?rev=36868&r1=36867&r2=36868&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_lib.c (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_lib.c Mon Jul  3 11:51:20 2006
@@ -20,6 +20,7 @@
 
 int queue_cleanup_bc(struct misdn_bchannel *bc) ;
 
+int misdn_lib_get_l2_up(struct misdn_stack *stack);
 
 struct misdn_stack* get_misdn_stack( void );
 
@@ -174,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) ;
@@ -1279,10 +1280,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);
@@ -1644,12 +1650,21 @@
 		if ( !stack->ptp && !check) return 1;
 		
 		if (stack->port == port) {
-			if (stack->l1link)
-				return 1;
-			else {
-				cb_log(-1,port, "Port down [%s]\n",
-				       stack->ptp?"PP":"PMP");
-				return 0;
+			if (stack->ptp ) {
+				if (stack->l1link && stack->l2link) {
+					return 1;
+				} else {
+					cb_log(-1,port, "Port Down L2:%d L1:%d\n",
+						stack->l2link, stack->l1link);
+					return 0;
+				}
+			} else {
+				if ( stack->l1link)
+					return 1;
+				else {
+					cb_log(-1,port, "Port down PMP\n");
+					return 0;
+				}
 			}
 		}
 	}
@@ -1896,6 +1911,7 @@
 		{
 			cb_log(4, stack->port, "%% GOT L2 Activate Info.\n");
 			stack->l2link = 1;
+			stack->l2upcnt=0;
 			
 			free_msg(msg);
 			return 0;
@@ -1906,9 +1922,21 @@
 		case DL_RELEASE | INDICATION:
 		case DL_RELEASE | CONFIRM:
 		{
-			cb_log(4, stack->port, "%% GOT L2 DeActivate Info.\n");
+			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++;
+				}
+				
+			} else 
+				cb_log(4, stack->port, "%% GOT L2 DeActivate Info.\n");
+			
 			stack->l2link = 0;
-			
 			free_msg(msg);
 			return 0;
 		}
@@ -2100,7 +2128,7 @@
 		flip_buf_bits( data, jlen);
 		
 		if (jlen < len) {
-			cb_log(5,bc->port,"Jitterbuffer Underrun.\n");
+			cb_log(7,bc->port,"Jitterbuffer Underrun.\n");
 		}
 		
 		txfrm->prim = DL_DATA|REQUEST;
@@ -3432,7 +3460,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);
@@ -3454,48 +3482,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;
@@ -3605,6 +3595,27 @@
 	return max;
 }
 
+
+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 , f, f, f);
+		init=1;
+	} else {
+		debug_close();

[... 271 lines stripped ...]


More information about the asterisk-commits mailing list