[asterisk-commits] branch group/asterisk-imap r37491 - in /team/group/asterisk-imap: ./ apps/ ch...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Jul 12 14:32:16 MST 2006


Author: mogorman
Date: Wed Jul 12 16:32:15 2006
New Revision: 37491

URL: http://svn.digium.com/view/asterisk?rev=37491&view=rev
Log:
Merged revisions 37380,37382,37396,37403,37418,37433,37440,37457,37459,37474-37477,37483-37485 via svnmerge from 
https://svn.digium.com/svn/asterisk/trunk

................
r37380 | file | 2006-07-11 14:03:56 -0500 (Tue, 11 Jul 2006) | 2 lines

And now the trunk version! Add an option for IAX2 users that allows you to set how many outstanding AUTHREQs chan_iax2 will wait for replies on.

................
r37382 | crichter | 2006-07-11 14:30:35 -0500 (Tue, 11 Jul 2006) | 6 lines

* Introducing a new way for the l1watcher thread using the ast_sched way. Now l1watcher timeouts can be configured separately for every portgroup.
* added a signal handler to allow waking up the misdn task thread (that may sleep in a poll call) via misdn_tasks_wakeup().
* overlap_dial functionality implemented.
* fixes a bug which leads to a segfault after reordering config elements in the enum or struct


................
r37396 | kpfleming | 2006-07-11 18:27:51 -0500 (Tue, 11 Jul 2006) | 2 lines

say times in spanish properly (using new sound files that are not yet released)

................
r37403 | mogorman | 2006-07-11 22:58:47 -0500 (Tue, 11 Jul 2006) | 10 lines

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

........
r37402 | mogorman | 2006-07-11 22:55:36 -0500 (Tue, 11 Jul 2006) | 2 lines

GRRR no fprintf!

........

................
r37418 | kpfleming | 2006-07-12 08:29:10 -0500 (Wed, 12 Jul 2006) | 10 lines

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

........
r37417 | kpfleming | 2006-07-12 08:18:21 -0500 (Wed, 12 Jul 2006) | 2 lines

get rid of some more printf's (although most of these were ifdef-ed out)

........

................
r37433 | kpfleming | 2006-07-12 09:04:16 -0500 (Wed, 12 Jul 2006) | 10 lines

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

........
r37419 | kpfleming | 2006-07-12 08:54:10 -0500 (Wed, 12 Jul 2006) | 2 lines

remove some more bad examples of using printf

........

................
r37440 | file | 2006-07-12 10:25:17 -0500 (Wed, 12 Jul 2006) | 10 lines

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

........
r37439 | file | 2006-07-12 11:23:59 -0400 (Wed, 12 Jul 2006) | 2 lines

Add support to have maxauthreq as a global option

........

................
r37457 | russell | 2006-07-12 13:28:31 -0500 (Wed, 12 Jul 2006) | 3 lines

make some counter variables unsigned, use ast_tvcmp instead of a custom
SOONER macro, and some other little cleanups for things like indentation

................
r37459 | tilghman | 2006-07-12 13:39:36 -0500 (Wed, 12 Jul 2006) | 10 lines

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

........
r37458 | tilghman | 2006-07-12 13:29:01 -0500 (Wed, 12 Jul 2006) | 2 lines

Merge fixup for asterisk startup script to zaptel startup script

........

................
r37474 | oej | 2006-07-12 14:09:55 -0500 (Wed, 12 Jul 2006) | 3 lines

Re-enable RTCP quality reports
(Bug found in SIP Master Class, Chicago)

................
r37475 | russell | 2006-07-12 14:25:50 -0500 (Wed, 12 Jul 2006) | 4 lines

repeat after me ...

I WILL TYPE "make" BEFORE COMMITTING ANY CODE

................
r37476 | russell | 2006-07-12 14:36:42 -0500 (Wed, 12 Jul 2006) | 3 lines

don't let make run configure or menuselect if the target is either
"clean" or "distclean"

................
r37477 | russell | 2006-07-12 14:48:22 -0500 (Wed, 12 Jul 2006) | 3 lines

add "update" to the list of targets to ignore various included files for and
check the targets in a little bit different way

................
r37483 | russell | 2006-07-12 15:27:46 -0500 (Wed, 12 Jul 2006) | 3 lines

revert this change for now since it isn't working correctly and there are more
important issues to work on at the moment ...

................
r37484 | russell | 2006-07-12 15:35:14 -0500 (Wed, 12 Jul 2006) | 2 lines

fix the build options for app_voicemail

................
r37485 | oej | 2006-07-12 15:56:49 -0500 (Wed, 12 Jul 2006) | 2 lines

- Change filename to current file name

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

Modified:
    team/group/asterisk-imap/   (props changed)
    team/group/asterisk-imap/apps/app_voicemail.c
    team/group/asterisk-imap/apps/app_zapras.c
    team/group/asterisk-imap/asterisk.c
    team/group/asterisk-imap/channels/chan_iax2.c
    team/group/asterisk-imap/channels/chan_misdn.c
    team/group/asterisk-imap/channels/chan_sip.c
    team/group/asterisk-imap/channels/chan_zap.c
    team/group/asterisk-imap/channels/misdn/chan_misdn_config.h
    team/group/asterisk-imap/channels/misdn/isdn_lib.c
    team/group/asterisk-imap/channels/misdn/isdn_lib.h
    team/group/asterisk-imap/channels/misdn_config.c
    team/group/asterisk-imap/configs/extconfig.conf.sample
    team/group/asterisk-imap/configs/iax.conf.sample
    team/group/asterisk-imap/contrib/init.d/rc.mandrake.zaptel
    team/group/asterisk-imap/enum.c
    team/group/asterisk-imap/pbx/pbx_config.c
    team/group/asterisk-imap/res/res_agi.c
    team/group/asterisk-imap/say.c
    team/group/asterisk-imap/sched.c
    team/group/asterisk-imap/utils.c

Propchange: team/group/asterisk-imap/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/group/asterisk-imap/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Jul 12 16:32:15 2006
@@ -1,1 +1,1 @@
-/trunk:1-37379
+/trunk:1-37490

Modified: team/group/asterisk-imap/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/apps/app_voicemail.c?rev=37491&r1=37490&r2=37491&view=diff
==============================================================================
--- team/group/asterisk-imap/apps/app_voicemail.c (original)
+++ team/group/asterisk-imap/apps/app_voicemail.c Wed Jul 12 16:32:15 2006
@@ -46,7 +46,7 @@
  */
 
 /*** MAKEOPTS
-<category name="MENUSELECT_app_voicemail" displayname="Voicemail Build Options" positive_output="yes" remove_on_change="apps/app_voicemail.o">
+<category name="MENUSELECT_OPTS_app_voicemail" displayname="Voicemail Build Options" positive_output="yes" remove_on_change="apps/app_voicemail.o">
 	<member name="ODBC_STORAGE" displayname="Storage of Voicemail using ODBC">
 		<depend>unixodbc</depend>
 		<defaultenabled>no</defaultenabled>

Modified: team/group/asterisk-imap/apps/app_zapras.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/apps/app_zapras.c?rev=37491&r1=37490&r2=37491&view=diff
==============================================================================
--- team/group/asterisk-imap/apps/app_zapras.c (original)
+++ team/group/asterisk-imap/apps/app_zapras.c Wed Jul 12 16:32:15 2006
@@ -125,12 +125,6 @@
 	argv[argc++] = "plugin";
 	argv[argc++] = "zaptel.so";
 	argv[argc++] = "stdin";
-
-#if 0
-	for (x=0;x<argc;x++) {
-		fprintf(stderr, "Arg %d: %s\n", x, argv[x]);
-	}
-#endif
 
 	/* Finally launch PPP */
 	execv(PPP_EXEC, argv);

Modified: team/group/asterisk-imap/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/asterisk.c?rev=37491&r1=37490&r2=37491&view=diff
==============================================================================
--- team/group/asterisk-imap/asterisk.c (original)
+++ team/group/asterisk-imap/asterisk.c Wed Jul 12 16:32:15 2006
@@ -983,15 +983,9 @@
  Called by soft_hangup to interrupt the poll, read, or other
  system call.  We don't actually need to do anything though.  
  Remember: Cannot EVER ast_log from within a signal handler 
- SLD: seems to be some pthread activity relating to the printf anyway:
- which is leading to a deadlock? 
  */
 static void urg_handler(int num)
 {
-#if 0
-	if (option_debug > 2) 
-		printf("-- Asterisk Urgent handler\n");
-#endif
 	signal(num, urg_handler);
 	return;
 }
@@ -1248,46 +1242,40 @@
 {
 	printf(term_end());
 	fflush(stdout);
+
 	/* Called when readline data is available */
-	if (s && !ast_all_zeros(s))
+	if (!ast_all_zeros(s))
 		ast_el_add_history(s);
-	/* Give the console access to the shell */
-	if (s) {
-		/* The real handler for bang */
-		if (s[0] == '!') {
-			if (s[1])
-				ast_safe_system(s+1);
-			else
-				ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
-		} else 
+	/* The real handler for bang */
+	if (s[0] == '!') {
+		if (s[1])
+			ast_safe_system(s+1);
+		else
+			ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
+	} else 
 		ast_cli_command(STDOUT_FILENO, s);
-	} else
-		fprintf(stdout, "\nUse \"quit\" to exit\n");
 }
 
 static int remoteconsolehandler(char *s)
 {
 	int ret = 0;
+
 	/* Called when readline data is available */
-	if (s && !ast_all_zeros(s))
+	if (!ast_all_zeros(s))
 		ast_el_add_history(s);
-	/* Give the console access to the shell */
-	if (s) {
-		/* The real handler for bang */
-		if (s[0] == '!') {
-			if (s[1])
-				ast_safe_system(s+1);
-			else
-				ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
-			ret = 1;
-		}
-		if ((strncasecmp(s, "quit", 4) == 0 || strncasecmp(s, "exit", 4) == 0) &&
-		    (s[4] == '\0' || isspace(s[4]))) {
-			quit_handler(0, 0, 0, 0);
-			ret = 1;
-		}
-	} else
-		fprintf(stdout, "\nUse \"quit\" to exit\n");
+	/* The real handler for bang */
+	if (s[0] == '!') {
+		if (s[1])
+			ast_safe_system(s+1);
+		else
+			ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
+		ret = 1;
+	}
+	if ((strncasecmp(s, "quit", 4) == 0 || strncasecmp(s, "exit", 4) == 0) &&
+	    (s[4] == '\0' || isspace(s[4]))) {
+		quit_handler(0, 0, 0, 0);
+		ret = 1;
+	}
 
 	return ret;
 }
@@ -2733,7 +2721,7 @@
 				consolehandler((char *)buf);
 			} else {
 				if (write(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n",
-						strlen("\nUse EXIT or QUIT to exit the asterisk console\n")) < 0) {
+					  strlen("\nUse EXIT or QUIT to exit the asterisk console\n")) < 0) {
 					/* Whoa, stdout disappeared from under us... Make /dev/null's */
 					int fd;
 					fd = open("/dev/null", O_RDWR);

Modified: team/group/asterisk-imap/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/channels/chan_iax2.c?rev=37491&r1=37490&r2=37491&view=diff
==============================================================================
--- team/group/asterisk-imap/channels/chan_iax2.c (original)
+++ team/group/asterisk-imap/channels/chan_iax2.c Wed Jul 12 16:32:15 2006
@@ -145,6 +145,7 @@
 static char language[MAX_LANGUAGE] = "";
 static char regcontext[AST_MAX_CONTEXT] = "";
 
+static int maxauthreq = 0;
 static int max_retries = 4;
 static int ping_time = 20;
 static int lagrq_time = 10;
@@ -248,7 +249,7 @@
 	IAX_USEJITTERBUF =	(1 << 5),	/*!< Use jitter buffer */
 	IAX_DYNAMIC =		(1 << 6),	/*!< dynamic peer */
 	IAX_SENDANI = 		(1 << 7),	/*!< Send ANI along with CallerID */
-	/* (1 << 8) is currently unused due to the deprecation of an old option. Go ahead, take it! */	
+        /* (1 << 8) is currently unused due to the deprecation of an old option. Go ahead, take it! */
 	IAX_ALREADYGONE =	(1 << 9),	/*!< Already disconnected */
 	IAX_PROVISION =		(1 << 10),	/*!< This is a provisioning request */
 	IAX_QUELCH = 		(1 << 11),	/*!< Whether or not we quelch audio */
@@ -263,7 +264,8 @@
 	IAX_FORCEJITTERBUF =	(1 << 20),	/*!< Force jitterbuffer, even when bridged to a channel that can take jitter */ 
 	IAX_RTIGNOREREGEXPIRE =	(1 << 21),	/*!< When using realtime, ignore registration expiration */
 	IAX_TRUNKTIMESTAMPS =	(1 << 22),	/*!< Send trunk timestamps */
-	IAX_TRANSFERMEDIA = 	(1 << 23)   /*!< When doing IAX2 transfers, transfer media only */
+	IAX_TRANSFERMEDIA = 	(1 << 23),      /*!< When doing IAX2 transfers, transfer media only */
+	IAX_MAXAUTHREQ =        (1 << 24),      /*!< Maximum outstanding AUTHREQ restriction is in place */
 } iax2_flags;
 
 static int global_rtautoclear = 120;
@@ -284,6 +286,8 @@
 	int amaflags;
 	unsigned int flags;
 	int capability;
+	int maxauthreq; /*!< Maximum allowed outstanding AUTHREQs */
+	int curauthreq; /*!< Current number of outstanding AUTHREQs */
 	char cid_num[AST_MAX_EXTENSION];
 	char cid_name[AST_MAX_EXTENSION];
 	struct ast_codec_pref prefs;
@@ -1616,6 +1620,20 @@
 
 static void iax2_destroy_helper(struct chan_iax2_pvt *pvt)
 {
+	struct iax2_user *user = NULL;
+
+	/* Decrement AUTHREQ count if needed */
+	if (ast_test_flag(pvt, IAX_MAXAUTHREQ)) {
+		AST_LIST_LOCK(&users);
+		AST_LIST_TRAVERSE(&users, user, entry) {
+			if (!strcmp(user->name, pvt->username)) {
+				user->curauthreq--;
+				break;
+			}
+		}
+		AST_LIST_UNLOCK(&users);
+		ast_clear_flag(pvt, IAX_MAXAUTHREQ);
+	}
 	/* No more pings or lagrq's */
 	if (pvt->pingid > -1)
 		ast_sched_del(sched, pvt->pingid);
@@ -2147,10 +2165,7 @@
 	
 	when = ast_tvdiff_ms(ast_tvnow(), pvt->rxcore);
 	
-	/*    fprintf(stderr, "now = %d, next=%d\n", when, jb_next(pvt->jb)); */
-	
 	when = jb_next(pvt->jb) - when;
-	/*   fprintf(stderr, "when = %d\n", when); */
 	
 	if(pvt->jbid > -1) ast_sched_del(sched, pvt->jbid);
 	
@@ -2185,7 +2200,6 @@
 		return;
 	}
 
-	/*  fprintf(stderr, "get_from_jb called\n"); */
 	pvt->jbid = -1;
 	
 	gettimeofday(&tv,NULL);
@@ -2200,7 +2214,6 @@
 		ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat));
 		switch(ret) {
 		case JB_OK:
-			/*if(frame.type == JB_TYPE_VOICE && next + 20 != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(pvt->jb), next); */
 			fr = frame.data;
 			__do_deliver(fr);
 			break;
@@ -2208,10 +2221,7 @@
 		{
 			struct ast_frame af;
 			
-			/*if(next + 20 != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(pvt->jb), next); */
-			
 			/* create an interpolation frame */
-			/*fprintf(stderr, "Making Interpolation frame\n"); */
 			af.frametype = AST_FRAME_VOICE;
 			af.subclass = pvt->voiceformat;
 			af.datalen  = 0;
@@ -2229,7 +2239,6 @@
 		}
 		break;
 		case JB_DROP:
-			/*if(next != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not next %ld!\n", jb_next(pvt->jb), next); */
 			iax2_frame_free(frame.data);
 			break;
 		case JB_NOFRAME:
@@ -3418,9 +3427,6 @@
 	p->lastsent = ms;
 	if (voice)
 		p->nextpred = p->nextpred + f->samples / 8;
-#if 0
-	printf("TS: %s - %dms\n", voice ? "Audio" : "Control", ms);
-#endif	
 	return ms;
 }
 
@@ -4524,7 +4530,7 @@
 	int version = 2;
 	struct iax2_user *user = NULL, *best = NULL;
 	int bestscore = 0;
-	int gotcapability=0;
+	int gotcapability = 0;
 	char iabuf[INET_ADDRSTRLEN];
 	struct ast_variable *v = NULL, *tmpvar = NULL;
 
@@ -4643,6 +4649,9 @@
 				iaxs[callno]->vars = tmpvar;
 			}
 		}
+		/* If a max AUTHREQ restriction is in place, activate it */
+		if (user->maxauthreq > 0)
+			ast_set_flag(iaxs[callno], IAX_MAXAUTHREQ);
 		iaxs[callno]->prefs = user->prefs;
 		ast_copy_flags(iaxs[callno], user, IAX_CODEC_USER_FIRST);
 		ast_copy_flags(iaxs[callno], user, IAX_CODEC_NOPREFS);
@@ -4745,9 +4754,35 @@
 
 static int authenticate_request(struct chan_iax2_pvt *p)
 {
+	struct iax2_user *user = NULL;
 	struct iax_ie_data ied;
-	int res;
+	int res = -1, authreq_restrict = 0;
+
 	memset(&ied, 0, sizeof(ied));
+
+	/* If an AUTHREQ restriction is in place, make sure we can send an AUTHREQ back */
+	if (ast_test_flag(p, IAX_MAXAUTHREQ)) {
+		AST_LIST_LOCK(&users);
+		AST_LIST_TRAVERSE(&users, user, entry) {
+			if (!strcmp(user->name, p->username)) {
+				if (user->curauthreq == user->maxauthreq)
+					authreq_restrict = 1;
+				else
+					user->curauthreq++;
+				break;
+			}
+		}
+		AST_LIST_UNLOCK(&users);
+	}
+
+	/* If the AUTHREQ limit test failed, send back an error */
+	if (authreq_restrict) {
+		iax_ie_append_str(&ied, IAX_IE_CAUSE, "Unauthenticated call limit reached");
+		iax_ie_append_byte(&ied, IAX_IE_CAUSECODE, AST_CAUSE_CALL_REJECTED);
+		send_command_final(p, AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied.buf, ied.pos, -1);
+		return 0;
+	}
+
 	iax_ie_append_short(&ied, IAX_IE_AUTHMETHODS, p->authmethods);
 	if (p->authmethods & (IAX_AUTH_MD5 | IAX_AUTH_RSA)) {
 		snprintf(p->challenge, sizeof(p->challenge), "%d", (int)ast_random());
@@ -4755,10 +4790,14 @@
 	}
 	if (p->encmethods)
 		iax_ie_append_short(&ied, IAX_IE_ENCRYPTION, p->encmethods);
+
 	iax_ie_append_str(&ied,IAX_IE_USERNAME, p->username);
+
 	res = send_command(p, AST_FRAME_IAX, IAX_COMMAND_AUTHREQ, 0, ied.buf, ied.pos, -1);
+
 	if (p->encmethods)
 		ast_set_flag(p, IAX_ENCRYPTED);
+
 	return res;
 }
 
@@ -4770,7 +4809,20 @@
 	char rsasecret[256] = "";
 	int res = -1; 
 	int x;
-	
+	struct iax2_user *user = NULL;
+
+	if (ast_test_flag(p, IAX_MAXAUTHREQ)) {
+		AST_LIST_LOCK(&users);
+		AST_LIST_TRAVERSE(&users, user, entry) {
+			if (!strcmp(user->name, p->username)) {
+				user->curauthreq--;
+				break;
+			}
+		}
+		AST_LIST_UNLOCK(&users);
+		ast_clear_flag(p, IAX_MAXAUTHREQ);
+	}
+
 	if (!ast_test_flag(&p->state, IAX_STATE_AUTHENTICATED))
 		return res;
 	if (ies->password)
@@ -6808,8 +6860,8 @@
 					merge_encryption(iaxs[fr->callno],ies.encmethods);
 				else
 					iaxs[fr->callno]->encmethods = 0;
-				authenticate_request(iaxs[fr->callno]);
-				ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_AUTHENTICATED);
+				if (!authenticate_request(iaxs[fr->callno]))
+					ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_AUTHENTICATED);
 				break;
 			case IAX_COMMAND_DPREQ:
 				/* Request status in the dialplan */
@@ -8320,6 +8372,7 @@
 	struct ast_ha *oldha = NULL;
 	struct iax2_context *oldcon = NULL;
 	int format;
+	int oldcurauthreq = 0;
 	char *varname = NULL, *varval = NULL;
 	struct ast_variable *tmpvar = NULL;
 	
@@ -8334,6 +8387,7 @@
 		user = NULL;
 	
 	if (user) {
+		oldcurauthreq = user->curauthreq;
 		oldha = user->ha;
 		oldcon = user->contexts;
 		user->ha = NULL;
@@ -8349,6 +8403,8 @@
 	
 	if (user) {
 		memset(user, 0, sizeof(struct iax2_user));
+		user->maxauthreq = maxauthreq;
+		user->curauthreq = oldcurauthreq;
 		user->prefs = prefs;
 		user->capability = iax2_capability;
 		user->encmethods = iax2_encryption;
@@ -8440,6 +8496,10 @@
 				}
 			} else if (!strcasecmp(v->name, "inkeys")) {
 				ast_copy_string(user->inkeys, v->value, sizeof(user->inkeys));
+			} else if (!strcasecmp(v->name, "maxauthreq")) {
+				user->maxauthreq = atoi(v->value);
+				if (user->maxauthreq < 0)
+					user->maxauthreq = 0;
 			}/* else if (strcasecmp(v->name,"type")) */
 			/*	ast_log(LOG_WARNING, "Ignoring %s\n", v->name); */
 			v = v->next;
@@ -8806,6 +8866,10 @@
 			}
 		} else if (!strcasecmp(v->name, "language")) {
 			ast_copy_string(language, v->value, sizeof(language));
+		} else if (!strcasecmp(v->name, "maxauthreq")) {
+			maxauthreq = atoi(v->value);
+			if (maxauthreq < 0)
+				maxauthreq = 0;
 		} /*else if (strcasecmp(v->name,"type")) */
 		/*	ast_log(LOG_WARNING, "Ignoring %s\n", v->name); */
 		v = v->next;

Modified: team/group/asterisk-imap/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/channels/chan_misdn.c?rev=37491&r1=37490&r2=37491&view=diff
==============================================================================
--- team/group/asterisk-imap/channels/chan_misdn.c (original)
+++ team/group/asterisk-imap/channels/chan_misdn.c Wed Jul 12 16:32:15 2006
@@ -41,7 +41,10 @@
 #include <arpa/inet.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
+#include <signal.h>
 #include <sys/file.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
 
 #include "asterisk/channel.h"
 #include "asterisk/config.h"
@@ -63,6 +66,7 @@
 #include "asterisk/app.h"
 #include "asterisk/features.h"
 #include "asterisk/term.h"
+#include "asterisk/sched.h"
 #include "asterisk/stringfields.h"
 
 #include "chan_misdn_config.h"
@@ -99,12 +103,6 @@
 available data is returned and the return value indicates the number
 of data. */
 int misdn_jb_empty(struct misdn_jb *jb, char *data, int len);
-
-
-
-
-/* BEGIN: chan_misdn.h */
-
 
 
 enum misdn_chan_state {
@@ -137,8 +135,6 @@
 
 struct chan_list {
   
-	ast_mutex_t lock;
-
 	char allowed_bearers[BUFFERSIZE+1];
 	
 	enum misdn_chan_state state;
@@ -192,6 +188,11 @@
 
 	const struct tone_zone_sound *ts;
 	
+	int overlap_dial;
+	int overlap_dial_task;
+	ast_mutex_t overlap_tv_lock;
+	struct timeval overlap_tv;
+  
 	struct chan_list *peer;
 	struct chan_list *next;
 	struct chan_list *prev;
@@ -251,6 +252,11 @@
 	return robin;
 }
 
+
+/* the main schedule context for stuff like l1 watcher, overlap dial, ... */
+static struct sched_context *misdn_tasks = NULL;
+static pthread_t misdn_tasks_thread;
+static int misdn_tasks_semid;
 
 static void chan_misdn_log(int level, int port, char *tmpl, ...);
 
@@ -435,6 +441,177 @@
 	}
 }
 /*************** Helpers END *************/
+
+static void sighandler(int sig)
+{}
+
+static void* misdn_tasks_thread_func (void *data)
+{
+	int wait;
+	struct sigaction sa;
+	struct sembuf semb = {
+		.sem_num = 0,
+		.sem_op = 1,
+		.sem_flg = 0
+	};
+
+	sa.sa_handler = sighandler;
+	sa.sa_flags = SA_NODEFER;
+	sigemptyset(&sa.sa_mask);
+	sigaddset(&sa.sa_mask, SIGUSR1);
+	sigaction(SIGUSR1, &sa, NULL);
+	
+	semop(misdn_tasks_semid, &semb, 1);
+
+	while (1) {
+		wait = ast_sched_wait(misdn_tasks);
+		if (wait < 0)
+			wait = 8000;
+		if (poll(NULL, 0, wait) < 0)
+			chan_misdn_log(4, 0, "Waking up misdn_tasks thread\n");
+		ast_sched_runq(misdn_tasks);
+	}
+	return NULL;
+}
+
+static void misdn_tasks_init (void)
+{
+	key_t key;
+	union {
+		int val;
+		struct semid_ds *buf;
+		unsigned short *array;
+		struct seminfo *__buf;
+	} semu;
+	struct sembuf semb = {
+		.sem_num = 0,
+		.sem_op = -1,
+		.sem_flg = 0
+	};
+	
+	chan_misdn_log(4, 0, "Starting misdn_tasks thread\n");
+	
+	key = ftok("/etc/asterisk/misdn.conf", 'E');
+	if (key == -1) {
+		perror("chan_misdn: Failed to create a semaphore key!");
+		exit(1);
+	}
+
+	misdn_tasks_semid = semget(key, 10, 0666 | IPC_CREAT);
+	if (misdn_tasks_semid == -1) {
+		perror("chan_misdn: Failed to get a semaphore!");
+		exit(1);
+	}
+
+	semu.val = 0;
+	if (semctl(misdn_tasks_semid, 0, SETVAL, semu) == -1) {
+		perror("chan_misdn: Failed to initialize semaphore!");
+		exit(1);
+	}
+
+	misdn_tasks = sched_context_create();
+	pthread_create(&misdn_tasks_thread, NULL, misdn_tasks_thread_func, NULL);
+
+	semop(misdn_tasks_semid, &semb, 1);
+	semctl(misdn_tasks_semid, 0, IPC_RMID, semu);
+}
+
+static void misdn_tasks_destroy (void)
+{
+	if (misdn_tasks) {
+		chan_misdn_log(4, 0, "Killing misdn_tasks thread\n");
+		if ( pthread_cancel(misdn_tasks_thread) == 0 ) {
+			cb_log(4, 0, "Joining misdn_tasks thread\n");
+			pthread_join(misdn_tasks_thread, NULL);
+		}
+		sched_context_destroy(misdn_tasks);
+	}
+}
+
+static inline void misdn_tasks_wakeup (void)
+{
+	pthread_kill(misdn_tasks_thread, SIGUSR1);
+}
+
+static inline int _misdn_tasks_add_variable (int timeout, ast_sched_cb callback, void *data, int variable)
+{
+	int task_id;
+
+	if (!misdn_tasks) {
+		misdn_tasks_init();
+	}
+	task_id = ast_sched_add_variable(misdn_tasks, timeout, callback, data, variable);
+	misdn_tasks_wakeup();
+
+	return task_id;
+}
+
+static int misdn_tasks_add (int timeout, ast_sched_cb callback, void *data)
+{
+	return _misdn_tasks_add_variable(timeout, callback, data, 0);
+}
+
+static int misdn_tasks_add_variable (int timeout, ast_sched_cb callback, void *data)
+{
+	return _misdn_tasks_add_variable(timeout, callback, data, 1);
+}
+
+static void misdn_tasks_remove (int task_id)
+{
+	ast_sched_del(misdn_tasks, task_id);
+}
+
+static int misdn_l1_task (void *data)
+{
+	misdn_lib_isdn_l1watcher((int)data);
+	chan_misdn_log(5, (int)data, "L1watcher timeout\n");
+	return 1;
+}
+
+static int misdn_overlap_dial_task (void *data)
+{
+	struct timeval tv_end, tv_now;
+	int diff;
+	struct chan_list *ch = (struct chan_list *)data;
+
+	chan_misdn_log(4, ch->bc->port, "overlap dial task, chan_state: %d\n", ch->state);
+
+	if (ch->state != MISDN_WAITING4DIGS) {
+		ch->overlap_dial_task = -1;
+		return 0;
+	}
+	
+	ast_mutex_lock(&ch->overlap_tv_lock);
+	tv_end = ch->overlap_tv;
+	ast_mutex_unlock(&ch->overlap_tv_lock);
+	
+	tv_end.tv_sec += ch->overlap_dial;
+	tv_now = ast_tvnow();
+
+	diff = ast_tvdiff_ms(tv_end, tv_now);
+
+	if (diff <= 100) {
+		/* if we are 100ms near the timeout, we are satisfied.. */
+		stop_indicate(ch);
+		if (ast_exists_extension(ch->ast, ch->context, ch->bc->dad, 1, ch->bc->oad)) {
+			ch->state=MISDN_DIALING;
+			if (pbx_start_chan(ch) < 0) {
+				chan_misdn_log(-1, ch->bc->port, "ast_pbx_start returned < 0 in misdn_overlap_dial_task\n");
+				goto misdn_overlap_dial_task_disconnect;
+			}
+		} else {
+misdn_overlap_dial_task_disconnect:
+			hanguptone_indicate(ch);
+			if (ch->bc->nt)
+				misdn_lib_send_event(ch->bc, EVENT_RELEASE_COMPLETE );
+			else
+				misdn_lib_send_event(ch->bc, EVENT_RELEASE);
+		}
+		ch->overlap_dial_task = -1;
+		return 0;
+	} else
+		return diff;
+}
 
 static void send_digit_to_chan(struct chan_list *cl, char digit )
 {
@@ -632,7 +809,7 @@
 				ok = 1;
 			}
 			if ((argc == 4) || ((argc == 5) && !strcmp(argv[4], "ports"))) {
-				for (elem = MISDN_CFG_FIRST + 1; elem < MISDN_CFG_LAST; ++elem) {
+				for (elem = MISDN_CFG_FIRST + 1; elem < MISDN_CFG_LAST - 1 /* the ptp hack, remove the -1 when ptp is gone */; ++elem) {
 					show_config_description(fd, elem);
 					ast_cli(fd, "\n");
 				}
@@ -872,9 +1049,7 @@
 		ast_cli(fd,"  %s  Debug:%d%s\n", buf, misdn_debug[port], misdn_debug_only[port]?"(only)":"");
 	}
 		
-
 	return 0;
-
 }
 
 
@@ -1564,8 +1739,7 @@
 			debug_numplan(port, bc->cpnnumplan,"CTON");
 		}
 
-		
-		
+		ch->overlap_dial = 0;
 	} else { /** ORIGINATOR MISDN **/
 	
 		misdn_cfg_get( port, MISDN_CFG_CPNDIALPLAN, &bc->cpnnumplan, sizeof(int));
@@ -1632,6 +1806,9 @@
 				free(ast->cid.cid_rdnis);
 			ast->cid.cid_rdnis = strdup(bc->rad);
 		}
+	
+		misdn_cfg_get(bc->port, MISDN_CFG_OVERLAP_DIAL, &ch->overlap_dial, sizeof(ch->overlap_dial));
+		ast_mutex_init(&ch->overlap_tv_lock);
 	} /* ORIG MISDN END */
 
 	return 0;
@@ -2297,12 +2474,12 @@
 	}
 	
 	if (ch->holded ) {
-		chan_misdn_log(5, ch->bc->port, "misdn_write: Returning because holded\n");
+		chan_misdn_log(7, ch->bc->port, "misdn_write: Returning because holded\n");
 		return 0;
 	}
 	
 	if (ch->notxtone) {
-		chan_misdn_log(5, ch->bc->port, "misdn_write: Returning because notxone\n");
+		chan_misdn_log(7, ch->bc->port, "misdn_write: Returning because notxone\n");
 		return 0;
 	}
 
@@ -2564,6 +2741,7 @@
 	cl->orginator=orig;
 	cl->need_queue_hangup=1;
 	cl->need_hangup=1;
+	cl->overlap_dial_task=-1;
 	
 	return cl;
 	
@@ -3035,6 +3213,13 @@
 				chan_misdn_log(5,bc->port,"Jitterbuffer already destroyed.\n");
 		}
 
+		if (ch->overlap_dial) {
+			if (ch->overlap_dial_task != -1) {
+				misdn_tasks_remove(ch->overlap_dial_task);
+				ch->overlap_dial_task = -1;
+			}
+			ast_mutex_destroy(&ch->overlap_tv_lock);
+		}
 
 		if (ch->orginator == ORG_AST) {
 			misdn_out_calls[bc->port]--;
@@ -3416,6 +3601,18 @@
 
 				break;
 			}
+
+			if (ch->overlap_dial) {
+				ast_mutex_lock(&ch->overlap_tv_lock);
+				ch->overlap_tv = ast_tvnow();
+				ast_mutex_unlock(&ch->overlap_tv_lock);
+				if (ch->overlap_dial_task == -1) {
+					ch->overlap_dial_task = 
+						misdn_tasks_add_variable(ch->overlap_dial, misdn_overlap_dial_task, ch);
+				}
+				break;
+			}
+
 			if (ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
 				ch->state=MISDN_DIALING;
 	  
@@ -3468,7 +3665,7 @@
 		struct chan_list *ch=find_chan_by_bc(cl_te, bc);
 		if (ch && ch->state != MISDN_NOTHING ) {
 			chan_misdn_log(1, bc->port, " --> Ignoring Call we have already one\n");
-			return RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE; /*  Ignore MSNs which are not in our List */
+			return RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE;
 		}
 	}
 	
@@ -3608,7 +3805,7 @@
 			break;
 		}
 		
-		if (ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
+		if (!ch->overlap_dial && ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
 			ch->state=MISDN_DIALING;
 			
 			if (bc->nt || (bc->need_more_infos && misdn_lib_is_ptp(bc->port)) ) {
@@ -3646,7 +3843,7 @@
 				}
 
 			} else {
-				
+
 				int ret= misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
 				if (ret == -ENOCHAN) {
 					ast_log(LOG_WARNING,"Channel was catched, before we could Acknowledge\n");
@@ -3656,18 +3853,30 @@
 				
 				/** ADD IGNOREPAT **/
 				
-				int stop_tone;
+				int stop_tone, dad_len;
 				misdn_cfg_get( 0, MISDN_GEN_STOP_TONE, &stop_tone, sizeof(int));
-				if ( (!ast_strlen_zero(bc->dad)) && stop_tone ) 
+
+				dad_len = ast_strlen_zero(bc->dad);
+				
+				if ( !dad_len && stop_tone )
 					stop_indicate(ch);
-				else {
+				else
 					dialtone_indicate(ch);
-				}
 				
 				ch->state=MISDN_WAITING4DIGS;
-			}
-		}
-      
+				
+				if (ch->overlap_dial && !dad_len) {
+					ast_mutex_lock(&ch->overlap_tv_lock);
+					ch->overlap_tv = ast_tvnow();
+					ast_mutex_unlock(&ch->overlap_tv_lock);
+					if (ch->overlap_dial_task == -1) {
+						ch->overlap_dial_task = 
+							misdn_tasks_add_variable(ch->overlap_dial, misdn_overlap_dial_task, ch);
+					}
+				}
+			}
+		}
+		
 	}
 	break;
 	case EVENT_SETUP_ACKNOWLEDGE:
@@ -4108,6 +4317,8 @@
 {
 	/* First, take us out of the channel loop */
 	ast_log(LOG_VERBOSE, "-- Unregistering mISDN Channel Driver --\n");
+
+	misdn_tasks_destroy();
 	
 	if (!g_config_initialized) return 0;
 	
@@ -4152,10 +4363,10 @@
 
 static int load_module(void *mod)
 {
-	int i;
+	int i, port;
 	
 	char ports[256]="";
-	
+
 	max_ports=misdn_lib_maxports_get();
 	
 	if (max_ports<=0) {
@@ -4194,10 +4405,6 @@
 	misdn_cfg_update_ptp();
 	misdn_cfg_get_ports_string(ports);
 
-
-	int l1watcher_timeout=0;
-	misdn_cfg_get( 0, MISDN_GEN_L1_TIMEOUT, &l1watcher_timeout, sizeof(int));
-	
 	if (strlen(ports))
 		chan_misdn_log(0, 0, "Got: %s from get_ports\n",ports);
 	
@@ -4206,7 +4413,6 @@
 			.cb_event = cb_events,
 			.cb_log = chan_misdn_log,
 			.cb_jb_empty = chan_misdn_jb_empty,
-			.l1watcher_timeout=l1watcher_timeout,
 		};
 		
 		if (misdn_lib_init(ports, &iface, NULL))
@@ -4280,8 +4486,16 @@
 
 	misdn_cfg_get( 0, MISDN_GEN_TRACEFILE, global_tracefile, BUFFERSIZE);
 
-
-
+	/* start the l1 watchers */
+	
+	for (port = misdn_cfg_get_next_port(0); port >= 0; port = misdn_cfg_get_next_port(port)) {
+		int l1timeout;
+		misdn_cfg_get(port, MISDN_CFG_L1_TIMEOUT, &l1timeout, sizeof(l1timeout));
+		if (l1timeout) {
+			chan_misdn_log(4, 0, "Adding L1watcher task: port:%d timeout:%ds\n", port, l1timeout);
+			misdn_tasks_add(l1timeout * 1000, misdn_l1_task, (void*)port);  
+		}
+	}
 	
 	chan_misdn_log(0, 0, "-- mISDN Channel Driver Registred -- (BE AWARE THIS DRIVER IS EXPERIMENTAL!)\n");
 

Modified: team/group/asterisk-imap/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/channels/chan_sip.c?rev=37491&r1=37490&r2=37491&view=diff
==============================================================================
--- team/group/asterisk-imap/channels/chan_sip.c (original)
+++ team/group/asterisk-imap/channels/chan_sip.c Wed Jul 12 16:32:15 2006
@@ -3150,6 +3150,7 @@
 	struct sip_pvt *p = ast->tech_pvt;
 	int needcancel = FALSE;
 	struct ast_flags locflags = {0};
+	struct ast_channel *oldowner = ast;
 
 	if (!p) {
 		ast_log(LOG_DEBUG, "Asked to hangup channel that was not connected\n");
@@ -3260,10 +3261,10 @@
 					if (p->vrtp)
 						append_history(p, "RTCPvideo", "Quality:%s", videoqos);
 				}
-				if (p->rtp && p->owner)
-					pbx_builtin_setvar_helper(p->owner, "RTPAUDIOQOS", audioqos);
-				if (p->vrtp && p->owner)
-					pbx_builtin_setvar_helper(p->owner, "RTPVIDEOQOS", videoqos);
+				if (p->rtp && oldowner)
+					pbx_builtin_setvar_helper(oldowner, "RTPAUDIOQOS", audioqos);
+				if (p->vrtp && oldowner)
+					pbx_builtin_setvar_helper(oldowner, "RTPVIDEOQOS", videoqos);
 			} else {
 				/* Note we will need a BYE when this all settles out
 				   but we can't send one while we have "INVITE" outstanding. */

Modified: team/group/asterisk-imap/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/channels/chan_zap.c?rev=37491&r1=37490&r2=37491&view=diff
==============================================================================
--- team/group/asterisk-imap/channels/chan_zap.c (original)
+++ team/group/asterisk-imap/channels/chan_zap.c Wed Jul 12 16:32:15 2006
@@ -3372,9 +3372,6 @@
 	do {
 		x = ZT_RING;
 		res = ioctl(p->subs[SUB_REAL].zfd, ZT_HOOK, &x);
-#if 0
-		printf("Res: %d, error: %s\n", res, strerror(errno));
-#endif						
 		if (res) {
 			switch (errno) {
 			case EBUSY:
@@ -5503,28 +5500,22 @@
 			return NULL;
 		}
 
-		if (p->sig == SIG_FGC_CAMA)
-		{
+		if (p->sig == SIG_FGC_CAMA) {
 			char anibuf[100];
 
-			if (ast_safe_sleep(chan,1000) == -1)
-			{
+			if (ast_safe_sleep(chan,1000) == -1) {
 	                        ast_hangup(chan);
 	                        return NULL;
 			}
                         zt_set_hook(p->subs[SUB_REAL].zfd, ZT_OFFHOOK);
-                        ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MF | p->dtmfrela\
-x);
+                        ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MF | p->dtmfrelax);
                         res = my_getsigstr(chan, anibuf, "#", 10000);
-                        if ((res > 0) && (strlen(anibuf) > 2))
-                          {
-                            if (anibuf[strlen(anibuf) - 1] == '#')
-                              anibuf[strlen(anibuf) - 1] = 0;
-                          ast_set_callerid(chan, anibuf + 2, NULL, anibuf + 2);
-                          printf("@@@@@ set ani to %s\n",anibuf + 2);
-                          }
-                        ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfre\
-lax);
+                        if ((res > 0) && (strlen(anibuf) > 2)) {
+				if (anibuf[strlen(anibuf) - 1] == '#')
+					anibuf[strlen(anibuf) - 1] = 0;
+				ast_set_callerid(chan, anibuf + 2, NULL, anibuf + 2);
+			}
+                        ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax);
 		}
 
 		ast_copy_string(exten, dtmfbuf, sizeof(exten));
@@ -5584,7 +5575,6 @@
 				}
 				if (s1)	ast_copy_string(exten, s1, sizeof(exten));
 				else ast_copy_string(exten, "911", sizeof(exten));
-				printf("E911/FGC CAMA: exten: %s, ANI: %s\n",exten, chan->cid.cid_ani);
 			} else
 				ast_log(LOG_WARNING, "Got a non-E911/FGC CAMA input on channel %d.  Assuming E&M Wink instead\n", p->channel);
 		}
@@ -6478,9 +6468,6 @@
 					}
 				} else
 					ast_log(LOG_WARNING, "Unable to create channel\n");
-#if 0
-				printf("Created thread %ld detached in switch\n", threadid);
-#endif
 			}
 			break;
 		case SIG_FXSLS:
@@ -6514,9 +6501,6 @@
 				} else if (!chan) {
 					ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
 				}
-#if 0
-				printf("Created thread %ld detached in switch(2)\n", threadid);
-#endif
 				break;
 		default:
 			ast_log(LOG_WARNING, "Don't know how to handle ring/answer with signalling %s on channel %d\n", sig2str(i->sig), i->channel);
@@ -6696,14 +6680,8 @@
 				if (!found && ((i == last) || ((i == iflist) && !last))) {
 					last = i;
 					if (last) {
-#if 0
-						printf("Checking channel %d\n", last->channel);
-#endif						
 						if (!last->cidspill && !last->owner && !ast_strlen_zero(last->mailbox) && (thispass - last->onhooktime > 3) &&
 							(last->sig & __ZT_SIG_FXO)) {
-#if 0
-							printf("Channel %d has mailbox %s\n", last->channel, last->mailbox);
-#endif							
 							res = ast_app_has_voicemail(last->mailbox, NULL);
 							if (last->msgstate != res) {
 								int x;
@@ -6718,9 +6696,6 @@
 									ioctl(last->subs[SUB_REAL].zfd, ZT_ONHOOKTRANSFER, &x);
 									last->cidlen = vmwi_generate(last->cidspill, res, 1, AST_LAW(last));
 									last->cidpos = 0;
-#if 0
-									printf("Made %d bytes of message waiting for %d\n", last->cidlen, res);
-#endif									
 									last->msgstate = res;
 									last->onhooktime = thispass;
 								}
@@ -6848,9 +6823,6 @@
 			return -1;
 		}
 	}
-#if 0
-	printf("Created thread %ld detached in restart monitor\n", monitor_thread);
-#endif
 	ast_mutex_unlock(&monlock);
 	return 0;
 }
@@ -7976,9 +7948,6 @@
 		ast_frfree(f);
 		ms = newms;
 	}
-#if 0
-	printf("Hanging up '%s'\n", chan->name);
-#endif
 	/* Hangup the channel since nothing happend */
 	ast_hangup(chan);
 	return NULL;
@@ -8250,12 +8219,6 @@
 				} else if (pri->pvts[x] && pri->pvts[x]->owner && pri->pvts[x]->isidlecall)
 					activeidles++;
 			}
-#if 0
-			printf("nextidle: %d, haveidles: %d, minunsed: %d\n",
-				nextidle, haveidles, minunused);
-			printf("nextidle: %d, haveidles: %d, ms: %ld, minunsed: %d\n",
-				nextidle, haveidles, ast_tvdiff_ms(ast_tvnow(), lastidle), minunused);
-#endif
 			if (nextidle > -1) {
 				if (ast_tvdiff_ms(ast_tvnow(), lastidle) > 1000) {
 					/* Don't create a new idle call more than once per second */
@@ -9893,7 +9856,7 @@
 
 	ctl = open("/dev/zap/ctl", O_RDWR);
 	if (ctl < 0) {
-		fprintf(stderr, "Unable to open /dev/zap/ctl: %s\n", strerror(errno));
+		ast_log(LOG_WARNING, "Unable to open /dev/zap/ctl: %s\n", strerror(errno));
 		ast_cli(fd, "No Zaptel interface found.\n");
 		return RESULT_FAILURE;
 	}

Modified: team/group/asterisk-imap/channels/misdn/chan_misdn_config.h
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/channels/misdn/chan_misdn_config.h?rev=37491&r1=37490&r2=37491&view=diff
==============================================================================
--- team/group/asterisk-imap/channels/misdn/chan_misdn_config.h (original)
+++ team/group/asterisk-imap/channels/misdn/chan_misdn_config.h Wed Jul 12 16:32:15 2006
@@ -59,9 +59,11 @@
 	MISDN_CFG_PICKUPGROUP,         /* ast_group_t */
 	MISDN_CFG_MAX_IN,              /* int */
 	MISDN_CFG_MAX_OUT,              /* int */
+	MISDN_CFG_L1_TIMEOUT,          /* int */
+	MISDN_CFG_OVERLAP_DIAL, 	/* int (bool)*/
 	MISDN_CFG_MSNS,                /* char[] */
+	MISDN_CFG_FAXDETECT,           /* char[] */
 	MISDN_CFG_PTP,                 /* int (bool) */
-	MISDN_CFG_FAXDETECT,           /* char[] */
 	MISDN_CFG_LAST,
 	
 	/* general config items */
@@ -75,7 +77,6 @@
 	MISDN_GEN_DYNAMIC_CRYPT,       /* int (bool) */
 	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/group/asterisk-imap/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/channels/misdn/isdn_lib.c?rev=37491&r1=37490&r2=37491&view=diff
==============================================================================
--- team/group/asterisk-imap/channels/misdn/isdn_lib.c (original)
+++ team/group/asterisk-imap/channels/misdn/isdn_lib.c Wed Jul 12 16:32:15 2006
@@ -108,12 +108,9 @@
 	int midev;
 	int midev_nt;
 
-	pthread_t l1watcher_thread;
 	pthread_t event_thread;
 	pthread_t event_handler_thread;
 
-	int l1watcher_timeout;
-	
 	void *user_data;
 
 	msg_queue_t upqueue;
@@ -163,7 +160,6 @@
 unsigned char tone_425_flip[TONE_425_SIZE];
 unsigned char tone_silence_flip[TONE_SILENCE_SIZE];
 
-static void misdn_lib_isdn_l1watcher(void *arg);
 static void misdn_lib_isdn_event_catcher(void *arg);
 static int handle_event_nt(void *dat, void *arg);
 
@@ -2810,30 +2806,20 @@
 	return NULL;
 }
 
-static void misdn_lib_isdn_l1watcher(void *arg)
-{
-	struct misdn_lib *mgr = arg;
+void misdn_lib_isdn_l1watcher(int port)
+{
 	struct misdn_stack *stack;
 
-	while (1) {
-		sleep(mgr->l1watcher_timeout);
-		
-		/* look out for l1 which are down
-		   and try to pull the up.
-
-		   We might even try to pull the l2 up in the
-		   ptp case.
-		*/
-		for (stack = mgr->stack_list;
-		     stack;
-		     stack = stack->next) {

[... 518 lines stripped ...]


More information about the asterisk-commits mailing list