[asterisk-commits] branch oej/aum-trunk - r7781 in /team/oej/aum-trunk: ./ apps/ channels/ confi...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Jan 4 06:52:09 CST 2006


Author: oej
Date: Wed Jan  4 06:51:54 2006
New Revision: 7781

URL: http://svn.digium.com/view/asterisk?rev=7781&view=rev
Log:
Merged revisions 7720,7725,7728-7734,7737,7739,7741,7744-7745,7747-7748,7750-7751,7770,7774-7779 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r7720 | russell | 2006-01-02 19:54:34 +0100 (Mon, 02 Jan 2006) | 2 lines

doxygen updates

................
r7725 | russell | 2006-01-03 00:52:33 +0100 (Tue, 03 Jan 2006) | 2 lines

initialize sip_auth list

................
r7728 | oej | 2006-01-03 09:40:55 +0100 (Tue, 03 Jan 2006) | 2 lines

Bug #6118: Clean up list handling in image.c (drumkilla)

................
r7729 | oej | 2006-01-03 09:54:19 +0100 (Tue, 03 Jan 2006) | 2 lines

Bug #6116: Use list macros in autoservice.c (drumkilla)

................
r7730 | oej | 2006-01-03 10:30:19 +0100 (Tue, 03 Jan 2006) | 2 lines

Bug #6109: Fix unprotected list in RTP, implement AST_LIST macros, update doxygen docs

................
r7731 | oej | 2006-01-03 12:21:48 +0100 (Tue, 03 Jan 2006) | 2 lines

Bug 5345; Add configuration option for minimum registration time. (folsson)

................
r7732 | oej | 2006-01-03 12:31:56 +0100 (Tue, 03 Jan 2006) | 2 lines

Bug #5228: Add caller ID and CallerIDname to OriginateSuccess/Failure manager events (outtolunc)

................
r7733 | oej | 2006-01-03 12:58:10 +0100 (Tue, 03 Jan 2006) | 2 lines

Bug #6071: Broken rport match in check_via(). (rizzo)

................
r7734 | oej | 2006-01-03 13:25:32 +0100 (Tue, 03 Jan 2006) | 2 lines

Issue #5954: Implement printf-like append_history and implement AST_LIST for SIP history (rizzo)

................
r7737 | kpfleming | 2006-01-03 17:39:37 +0100 (Tue, 03 Jan 2006) | 10 lines

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

........
r7736 | kpfleming | 2006-01-03 10:34:12 -0600 (Tue, 03 Jan 2006) | 2 lines

don't leak memory for (most) expression evaluations

........

................
r7739 | kpfleming | 2006-01-03 18:08:35 +0100 (Tue, 03 Jan 2006) | 3 lines

fix breakage from rev 7730 (failure to unlock list in get_proto)
minor cleanups and simpler usage of list macros

................
r7741 | kpfleming | 2006-01-03 18:25:39 +0100 (Tue, 03 Jan 2006) | 12 lines

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

........
r7740 | kpfleming | 2006-01-03 11:24:56 -0600 (Tue, 03 Jan 2006) | 4 lines

revert incorrect fix for bug #6048 from revision 7709
put in correct (simpler) fix
add doxygen docs for channel spy 'state' values

........

................
r7744 | tilghman | 2006-01-03 19:17:42 +0100 (Tue, 03 Jan 2006) | 3 lines

Merged revisions 7743 via svnmerge from
/branches/1.2

................
r7745 | oej | 2006-01-03 20:12:50 +0100 (Tue, 03 Jan 2006) | 2 lines

Don't check user call limits for outbound calls.

................
r7747 | kpfleming | 2006-01-03 21:23:23 +0100 (Tue, 03 Jan 2006) | 10 lines

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

........
r7746 | kpfleming | 2006-01-03 14:22:18 -0600 (Tue, 03 Jan 2006) | 2 lines

remove unused 'old' expression parser

........

................
r7748 | kpfleming | 2006-01-03 21:33:28 +0100 (Tue, 03 Jan 2006) | 2 lines

add script for simple 'no-brainer' restarts of safe_asterisk (issue #5139)

................
r7750 | kpfleming | 2006-01-03 23:07:12 +0100 (Tue, 03 Jan 2006) | 2 lines

add optional timestamps to manager events (issue #5535, simplified)

................
r7751 | kpfleming | 2006-01-03 23:16:23 +0100 (Tue, 03 Jan 2006) | 2 lines

update copyright headers for files changed this year

................
r7770 | bweschke | 2006-01-04 06:26:03 +0100 (Wed, 04 Jan 2006) | 3 lines

 Fix the 'if' clause to be true under the right conditions. Bug #6126


................
r7774 | russell | 2006-01-04 08:08:08 +0100 (Wed, 04 Jan 2006) | 10 lines

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

........
r7773 | russell | 2006-01-04 02:06:50 -0500 (Wed, 04 Jan 2006) | 2 lines

use a more correct way of determining the size of the destination buffer

........

................
r7775 | oej | 2006-01-04 10:10:56 +0100 (Wed, 04 Jan 2006) | 6 lines

- Remove "incominglimit" as a configuration option in sip.conf
- Add documentation on call-limit, explaining that there's two counters
  for a type="friend". 
- Document the removval of "incominglimit" in UPGRADE.txt


................
r7776 | oej | 2006-01-04 10:22:45 +0100 (Wed, 04 Jan 2006) | 2 lines

Issue #6127: Count in show channeltypes (junky)

................
r7777 | oej | 2006-01-04 11:16:53 +0100 (Wed, 04 Jan 2006) | 2 lines

Missing ">" in XML. Thanks, fenlander, for reporting this on IRC.

................
r7778 | russell | 2006-01-04 13:11:11 +0100 (Wed, 04 Jan 2006) | 2 lines

doxygen tweak

................
r7779 | oej | 2006-01-04 13:16:30 +0100 (Wed, 04 Jan 2006) | 2 lines

Issue #5952: Add destination protocol information to res_osp (homesick)

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

Added:
    team/oej/aum-trunk/contrib/scripts/safe_asterisk_restart
      - copied unchanged from r7779, trunk/contrib/scripts/safe_asterisk_restart
Removed:
    team/oej/aum-trunk/ast_expr.y
Modified:
    team/oej/aum-trunk/   (props changed)
    team/oej/aum-trunk/UPGRADE.txt
    team/oej/aum-trunk/apps/app_chanspy.c
    team/oej/aum-trunk/apps/app_mixmonitor.c
    team/oej/aum-trunk/apps/app_privacy.c
    team/oej/aum-trunk/apps/app_stack.c
    team/oej/aum-trunk/ast_expr2.fl
    team/oej/aum-trunk/ast_expr2f.c
    team/oej/aum-trunk/autoservice.c
    team/oej/aum-trunk/cdr.c
    team/oej/aum-trunk/channel.c
    team/oej/aum-trunk/channels/chan_iax2.c
    team/oej/aum-trunk/channels/chan_sip.c
    team/oej/aum-trunk/configs/manager.conf.sample
    team/oej/aum-trunk/configs/sip.conf.sample
    team/oej/aum-trunk/file.c
    team/oej/aum-trunk/funcs/func_moh.c
    team/oej/aum-trunk/image.c
    team/oej/aum-trunk/include/asterisk/chanspy.h
    team/oej/aum-trunk/include/asterisk/image.h
    team/oej/aum-trunk/include/asterisk/rtp.h
    team/oej/aum-trunk/manager.c
    team/oej/aum-trunk/pbx.c
    team/oej/aum-trunk/res/Makefile
    team/oej/aum-trunk/res/res_osp.c
    team/oej/aum-trunk/rtp.c

Propchange: team/oej/aum-trunk/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Jan  4 06:51:54 2006
@@ -1,1 +1,1 @@
-/trunk:1-7710
+/trunk:1-7780

Modified: team/oej/aum-trunk/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/oej/aum-trunk/UPGRADE.txt?rev=7781&r1=7780&r2=7781&view=diff
==============================================================================
--- team/oej/aum-trunk/UPGRADE.txt (original)
+++ team/oej/aum-trunk/UPGRADE.txt Wed Jan  4 06:51:54 2006
@@ -26,3 +26,6 @@
   functions.  You are encouraged to move towards the associated dialplan
   function, as these variables will be removed in a future release.
 
+The SIP channel:
+
+* The "incominglimit" setting is replaced by the "call-limit" setting in sip.conf.

Modified: team/oej/aum-trunk/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum-trunk/apps/app_chanspy.c?rev=7781&r1=7780&r2=7781&view=diff
==============================================================================
--- team/oej/aum-trunk/apps/app_chanspy.c (original)
+++ team/oej/aum-trunk/apps/app_chanspy.c Wed Jan  4 06:51:54 2006
@@ -2,6 +2,7 @@
  * Asterisk -- An open source telephony toolkit.
  *
  * Copyright (C) 2005 Anthony Minessale II (anthmct at yahoo.com)
+ * Copyright (C) 2005 - 2006, Digium, Inc.
  *
  * Disclaimed to Digium
  *
@@ -211,9 +212,9 @@
 
 static void stop_spying(struct ast_channel *chan, struct ast_channel_spy *spy) 
 {
-	/* If our status has changed, then the channel we're spying on is gone....
+	/* If our status has changed to DONE, then the channel we're spying on is gone....
 	   DON'T TOUCH IT!!!  RUN AWAY!!! */
-	if (spy->status != CHANSPY_RUNNING)
+	if (spy->status == CHANSPY_DONE)
 		return;
 
 	if (!chan)

Modified: team/oej/aum-trunk/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum-trunk/apps/app_mixmonitor.c?rev=7781&r1=7780&r2=7781&view=diff
==============================================================================
--- team/oej/aum-trunk/apps/app_mixmonitor.c (original)
+++ team/oej/aum-trunk/apps/app_mixmonitor.c Wed Jan  4 06:51:54 2006
@@ -2,7 +2,7 @@
  * Asterisk -- An open source telephony toolkit.
  *
  * Copyright (C) 2005, Anthony Minessale II
- * Copyright (C) 2005, Digium, Inc.
+ * Copyright (C) 2005 - 2006, Digium, Inc.
  *
  * Mark Spencer <markster at digium.com>
  * Kevin P. Fleming <kpfleming at digium.com>
@@ -86,7 +86,6 @@
 static const char *mixmonitor_spy_type = "MixMonitor";
 
 struct mixmonitor {
-	AST_LIST_ENTRY(mixmonitor) list;
 	struct ast_channel *chan;
 	char *filename;
 	char *post_process;
@@ -95,15 +94,12 @@
 	int writevol;
 };
 
-AST_LIST_HEAD_STATIC(monitors, mixmonitor);
-
 enum {
 	MUXFLAG_APPEND = (1 << 1),
 	MUXFLAG_BRIDGED = (1 << 2),
 	MUXFLAG_VOLUME = (1 << 3),
 	MUXFLAG_READVOLUME = (1 << 4),
 	MUXFLAG_WRITEVOLUME = (1 << 5),
-	FLAG_STOP = (1 << 6),
 } mixmonitor_flags;
 
 enum {
@@ -123,9 +119,9 @@
 
 static void stopmon(struct ast_channel *chan, struct ast_channel_spy *spy) 
 {
-	/* If our status has changed, then the channel we're spying on is gone....
+	/* If our status has changed to DONE, then the channel we're spying on is gone....
 	   DON'T TOUCH IT!!!  RUN AWAY!!! */
-	if (spy->status != CHANSPY_RUNNING)
+	if (spy->status == CHANSPY_DONE)
 		return;
 
 	if (!chan)
@@ -167,10 +163,6 @@
 	char post_process[1024] = "";
 	
 	STANDARD_INCREMENT_USECOUNT;
-
-	AST_LIST_LOCK(&monitors);
-	AST_LIST_INSERT_HEAD(&monitors, mixmonitor, list);
-	AST_LIST_UNLOCK(&monitors);
 
 	name = ast_strdupa(mixmonitor->chan->name);
 
@@ -226,7 +218,7 @@
 
 		ast_channel_spy_trigger_wait(&spy);
 		
-		if (ast_check_hangup(mixmonitor->chan) || spy.status != CHANSPY_RUNNING || ast_test_flag(mixmonitor, FLAG_STOP)) {
+		if (ast_check_hangup(mixmonitor->chan) || spy.status != CHANSPY_RUNNING) {
 			ast_mutex_unlock(&spy.lock);
 			break;
 		}
@@ -252,8 +244,6 @@
 		ast_mutex_unlock(&spy.lock);
 	}
 	
-	stopmon(mixmonitor->chan, &spy);
-
 	if (mixmonitor->post_process) {
 		char *p;
 
@@ -265,6 +255,8 @@
 		pbx_substitute_variables_helper(mixmonitor->chan, mixmonitor->post_process, post_process, sizeof(post_process) - 1);
 	}
 
+	stopmon(mixmonitor->chan, &spy);
+
 	if (option_verbose > 1)
 		ast_verbose(VERBOSE_PREFIX_2 "End MixMonitor Recording %s\n", name);
 
@@ -281,10 +273,6 @@
 		ast_closestream(fs);
 
 out:
-	AST_LIST_LOCK(&monitors);
-	AST_LIST_REMOVE(&monitors, mixmonitor, list);
-	AST_LIST_UNLOCK(&monitors);
-
 	free(mixmonitor);
 
 	STANDARD_DECREMENT_USECOUNT;
@@ -415,7 +403,6 @@
 static int mixmonitor_cli(int fd, int argc, char **argv) 
 {
 	struct ast_channel *chan;
-	struct mixmonitor *mon;
 
 	if (argc < 3)
 		return RESULT_SHOWUSAGE;
@@ -427,13 +414,8 @@
 
 	if (!strcasecmp(argv[1], "start"))
 		mixmonitor_exec(chan, argv[3]);
-	else if (!strcasecmp(argv[1], "stop")) {
-		AST_LIST_TRAVERSE_SAFE_BEGIN(&monitors, mon, list) {
-			if (chan == mon->chan)
-				ast_set_flag(mon, FLAG_STOP);
-		}
-		AST_LIST_TRAVERSE_SAFE_END;
-	}
+	else if (!strcasecmp(argv[1], "stop"))
+		ast_channel_spy_stop_by_type(chan, mixmonitor_spy_type);
 
 	ast_mutex_unlock(&chan->lock);
 

Modified: team/oej/aum-trunk/apps/app_privacy.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum-trunk/apps/app_privacy.c?rev=7781&r1=7780&r2=7781&view=diff
==============================================================================
--- team/oej/aum-trunk/apps/app_privacy.c (original)
+++ team/oej/aum-trunk/apps/app_privacy.c Wed Jan  4 06:51:54 2006
@@ -195,7 +195,7 @@
 		}
 		
 		/*Got a number, play sounds and send them on their way*/
-		if ((retries < maxretries) && res == 1 ) {
+		if ((retries < maxretries) && !res ) {
 			res = ast_streamfile(chan, "privacy-thankyou", chan->language);
 			if (!res)
 				res = ast_waitstream(chan, "");

Modified: team/oej/aum-trunk/apps/app_stack.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum-trunk/apps/app_stack.c?rev=7781&r1=7780&r2=7781&view=diff
==============================================================================
--- team/oej/aum-trunk/apps/app_stack.c (original)
+++ team/oej/aum-trunk/apps/app_stack.c Wed Jan  4 06:51:54 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (c) 2004-2005 Tilghman Lesher <app_stack_v002 at the-tilghman.com>.
+ * Copyright (c) 2004-2006 Tilghman Lesher <app_stack_v002 at the-tilghman.com>.
  *
  * This code is released by the author with no restrictions on usage.
  *
@@ -54,22 +54,18 @@
 
 static const char *gosub_descrip =
 "Gosub([[context|]exten|]priority)\n"
-"  Jumps to the label specified, saving the return address.\n"
-"  Returns 0 if the label exists or -1 otherwise.\n";
+"  Jumps to the label specified, saving the return address.\n";
 static const char *gosubif_descrip =
-"Gosub(condition?labeliftrue[:labeliffalse])\n"
+"GosubIf(condition?labeliftrue[:labeliffalse])\n"
 "  If the condition is true, then jump to labeliftrue.  If false, jumps to\n"
 "labeliffalse, if specified.  In either case, a jump saves the return point\n"
-"in the dialplan, to be returned to with a Return.\n"
-"  Returns 0 if the label exists or -1 otherwise.\n";
+"in the dialplan, to be returned to with a Return.\n";
 static const char *return_descrip =
 "Return()\n"
-"  Jumps to the last label in the stack, removing it.\n"
-"  Returns 0 if there's a label in the stack or -1 otherwise.\n";
+"  Jumps to the last label on the stack, removing it.\n";
 static const char *pop_descrip =
 "StackPop()\n"
-"  Removes last label in the stack, discarding it.\n"
-"  Always returns 0, even if the stack is empty.\n";
+"  Removes last label on the stack, discarding it.\n";
 
 STANDARD_LOCAL_USER;
 

Modified: team/oej/aum-trunk/ast_expr2.fl
URL: http://svn.digium.com/view/asterisk/team/oej/aum-trunk/ast_expr2.fl?rev=7781&r1=7780&r2=7781&view=diff
==============================================================================
--- team/oej/aum-trunk/ast_expr2.fl (original)
+++ team/oej/aum-trunk/ast_expr2.fl Wed Jan  4 06:51:54 2006
@@ -1,4 +1,27 @@
 %{
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2006, Digium, Inc.
+ *
+ * Mark Spencer <markster at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Dialplan Expression Parser
+ */
+
 #include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -98,42 +121,42 @@
 
 int ast_expr(char *expr, char *buf, int length)
 {
-	struct parse_io *io;
-	
-	io = calloc(sizeof(struct parse_io),1);
-	io->string = expr;  /* to pass to the error routine */
-	
-	ast_yylex_init(&io->scanner);
-	
-	ast_yy_scan_string(expr, io->scanner);
-	
-	ast_yyparse ((void *) io);
-
-	ast_yylex_destroy(io->scanner);
-
-	if (io->val == NULL) {
+	struct parse_io io;
+	int return_value = 0;
+	
+	memset(&io, 0, sizeof(io));
+	io.string = expr;  /* to pass to the error routine */
+	
+	ast_yylex_init(&io.scanner);
+	
+	ast_yy_scan_string(expr, io.scanner);
+	
+	ast_yyparse ((void *) &io);
+
+	ast_yylex_destroy(io.scanner);
+
+	if (!io.val) {
 		if (length > 1) {
 			strcpy(buf, "0");
-			return 1;
+			return_value = 1;
 		}
 	} else {
-		if (io->val->type == AST_EXPR_integer) {
+		if (io.val->type == AST_EXPR_integer) {
 			int res_length;
 
-			res_length = snprintf(buf, length, "%ld", (long int) io->val->u.i);
-			return res_length <= length ? res_length : length;
+			res_length = snprintf(buf, length, "%ld", (long int) io.val->u.i);
+			return_value = (res_length <= length) ? res_length : length;
 		} else {
 #ifdef STANDALONE
-			strncpy(buf, io->val->u.s, length - 1);
+			strncpy(buf, io.val->u.s, length - 1);
 #else /* !STANDALONE */
-			ast_copy_string(buf, io->val->u.s, length);
+			ast_copy_string(buf, io.val->u.s, length);
 #endif /* STANDALONE */
-			return strlen(buf);
+			return_value = strlen(buf);
 		}
-		free(io->val);
+		free(io.val);
 	}
-	free(io);
-	return 0;
+	return return_value;
 }
 
 int ast_yyerror (const char *s,  yyltype *loc, struct parse_io *parseio )

Modified: team/oej/aum-trunk/ast_expr2f.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum-trunk/ast_expr2f.c?rev=7781&r1=7780&r2=7781&view=diff
==============================================================================
--- team/oej/aum-trunk/ast_expr2f.c (original)
+++ team/oej/aum-trunk/ast_expr2f.c Wed Jan  4 06:51:54 2006
@@ -2562,42 +2562,42 @@
 
 int ast_expr(char *expr, char *buf, int length)
 {
-	struct parse_io *io;
+	struct parse_io io;
+	int return_value = 0;
 	
-	io = calloc(sizeof(struct parse_io),1);
-	io->string = expr;  /* to pass to the error routine */
+	memset(&io, 0, sizeof(io));
+	io.string = expr;  /* to pass to the error routine */
 	
-	ast_yylex_init(&io->scanner);
+	ast_yylex_init(&io.scanner);
 	
-	ast_yy_scan_string(expr, io->scanner);
+	ast_yy_scan_string(expr, io.scanner);
 	
-	ast_yyparse ((void *) io);
-
-	ast_yylex_destroy(io->scanner);
-
-	if (io->val == NULL) {
+	ast_yyparse ((void *) &io);
+
+	ast_yylex_destroy(io.scanner);
+
+	if (!io.val) {
 		if (length > 1) {
 			strcpy(buf, "0");
-			return 1;
+			return_value = 1;
 		}
 	} else {
-		if (io->val->type == AST_EXPR_integer) {
+		if (io.val->type == AST_EXPR_integer) {
 			int res_length;
 
-			res_length = snprintf(buf, length, "%ld", (long int) io->val->u.i);
-			return res_length <= length ? res_length : length;
+			res_length = snprintf(buf, length, "%ld", (long int) io.val->u.i);
+			return_value = (res_length <= length) ? res_length : length;
 		} else {
 #ifdef STANDALONE
-			strncpy(buf, io->val->u.s, length - 1);
+			strncpy(buf, io.val->u.s, length - 1);
 #else /* !STANDALONE */
-			ast_copy_string(buf, io->val->u.s, length);
+			ast_copy_string(buf, io.val->u.s, length);
 #endif /* STANDALONE */
-			return strlen(buf);
+			return_value = strlen(buf);
 		}
-		free(io->val);
+		free(io.val);
 	}
-	free(io);
-	return 0;
+	return return_value;
 }
 
 int ast_yyerror (const char *s,  yyltype *loc, struct parse_io *parseio )

Modified: team/oej/aum-trunk/autoservice.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum-trunk/autoservice.c?rev=7781&r1=7780&r2=7781&view=diff
==============================================================================
--- team/oej/aum-trunk/autoservice.c (original)
+++ team/oej/aum-trunk/autoservice.c Wed Jan  4 06:51:54 2006
@@ -53,14 +53,13 @@
 
 #define MAX_AUTOMONS 256
 
-AST_MUTEX_DEFINE_STATIC(autolock);
-
 struct asent {
 	struct ast_channel *chan;
-	struct asent *next;
+	AST_LIST_ENTRY(asent) list;
 };
 
-static struct asent *aslist = NULL;
+static AST_LIST_HEAD_STATIC(aslist, asent);
+
 static pthread_t asthread = AST_PTHREADT_NULL;
 
 static void *autoservice_run(void *ign)
@@ -71,23 +70,20 @@
 	struct ast_channel *chan;
 	struct asent *as;
 	struct ast_frame *f;
+
 	for(;;) {
 		x = 0;
-		ast_mutex_lock(&autolock);
-		as = aslist;
-		while(as) {
+		AST_LIST_LOCK(&aslist);
+		AST_LIST_TRAVERSE(&aslist, as, list) {
 			if (!as->chan->_softhangup) {
 				if (x < MAX_AUTOMONS)
 					mons[x++] = as->chan;
 				else
 					ast_log(LOG_WARNING, "Exceeded maximum number of automatic monitoring events.  Fix autoservice.c\n");
 			}
-			as = as->next;
 		}
-		ast_mutex_unlock(&autolock);
+		AST_LIST_UNLOCK(&aslist);
 
-/* 		if (!aslist)
-			break; */
 		ms = 500;
 		chan = ast_waitfor_n(mons, x, &ms);
 		if (chan) {
@@ -106,62 +102,62 @@
 	int res = -1;
 	struct asent *as;
 	int needstart;
-	ast_mutex_lock(&autolock);
-	needstart = (asthread == AST_PTHREADT_NULL) ? 1 : 0 /* aslist ? 0 : 1 */;
-	as = aslist;
-	while(as) {
+	AST_LIST_LOCK(&aslist);
+
+	/* Check if autoservice thread is executing */
+	needstart = (asthread == AST_PTHREADT_NULL) ? 1 : 0 ;
+
+	/* Check if the channel already has autoservice */
+	AST_LIST_TRAVERSE(&aslist, as, list) {
 		if (as->chan == chan)
 			break;
-		as = as->next;
 	}
+
+	/* If not, start autoservice on channel */
 	if (!as) {
-		as = malloc(sizeof(struct asent));
+		as = calloc(1, sizeof(struct asent));
 		if (as) {
-			memset(as, 0, sizeof(struct asent));
 			as->chan = chan;
-			as->next = aslist;
-			aslist = as;
+			AST_LIST_INSERT_HEAD(&aslist, as, list);
 			res = 0;
 			if (needstart) {
 				if (ast_pthread_create(&asthread, NULL, autoservice_run, NULL)) {
 					ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n");
-					free(aslist);
-					aslist = NULL;
+					/* There will only be a single member in the list at this point,
+					   the one we just added. */
+					AST_LIST_REMOVE(&aslist, as, list);
+					free(as);
 					res = -1;
 				} else
 					pthread_kill(asthread, SIGURG);
 			}
 		}
 	}
-	ast_mutex_unlock(&autolock);
+	AST_LIST_UNLOCK(&aslist);
 	return res;
 }
 
 int ast_autoservice_stop(struct ast_channel *chan)
 {
 	int res = -1;
-	struct asent *as, *prev;
-	ast_mutex_lock(&autolock);
-	as = aslist;
-	prev = NULL;
-	while(as) {
-		if (as->chan == chan)
+	struct asent *as;
+
+	AST_LIST_LOCK(&aslist);
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&aslist, as, list) {	
+		if (as->chan == chan) {
+			AST_LIST_REMOVE_CURRENT(&aslist, list);
+			free(as);
+			if (!chan->_softhangup)
+				res = 0;
 			break;
-		prev = as;
-		as = as->next;
+		}
 	}
-	if (as) {
-		if (prev)
-			prev->next = as->next;
-		else
-			aslist = as->next;
-		free(as);
-		if (!chan->_softhangup)
-			res = 0;
-	}
+	AST_LIST_TRAVERSE_SAFE_END
+
 	if (asthread != AST_PTHREADT_NULL) 
 		pthread_kill(asthread, SIGURG);
-	ast_mutex_unlock(&autolock);
+	AST_LIST_UNLOCK(&aslist);
+
 	/* Wait for it to un-block */
 	while(ast_test_flag(chan, AST_FLAG_BLOCKING))
 		usleep(1000);

Modified: team/oej/aum-trunk/cdr.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum-trunk/cdr.c?rev=7781&r1=7780&r2=7781&view=diff
==============================================================================
--- team/oej/aum-trunk/cdr.c (original)
+++ team/oej/aum-trunk/cdr.c Wed Jan  4 06:51:54 2006
@@ -22,7 +22,7 @@
  *
  * \author Mark Spencer <markster at digium.com>
  * 
- * Includes code and algorithms from the Zapata library.
+ * \note Includes code and algorithms from the Zapata library.
  *
  * \note We do a lot of checking here in the CDR code to try to be sure we don't ever let a CDR slip
  * through our fingers somehow.  If someone allocates a CDR, it must be completely handled normally

Modified: team/oej/aum-trunk/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum-trunk/channel.c?rev=7781&r1=7780&r2=7781&view=diff
==============================================================================
--- team/oej/aum-trunk/channel.c (original)
+++ team/oej/aum-trunk/channel.c Wed Jan  4 06:51:54 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
  *
  * Mark Spencer <markster at digium.com>
  *
@@ -168,8 +168,10 @@
 
 static int show_channeltypes(int fd, int argc, char *argv[])
 {
-#define FORMAT  "%-10.10s  %-30.30s %-12.12s %-12.12s %-12.12s\n"
+#define FORMAT  "%-10.10s  %-40.40s %-12.12s %-12.12s %-12.12s\n"
 	struct chanlist *cl;
+	int count_chan = 0;
+
 	ast_cli(fd, FORMAT, "Type", "Description",       "Devicestate", "Indications", "Transfer");
 	ast_cli(fd, FORMAT, "----------", "-----------", "-----------", "-----------", "--------");
 	if (ast_mutex_lock(&chlock)) {
@@ -181,8 +183,10 @@
 			(cl->tech->devicestate) ? "yes" : "no", 
 			(cl->tech->indicate) ? "yes" : "no",
 			(cl->tech->transfer) ? "yes" : "no");
+		count_chan++;
 	}
 	ast_mutex_unlock(&chlock);
+	ast_cli(fd, "----------\n%d channel drivers registered.\n", count_chan);
 	return RESULT_SUCCESS;
 
 #undef FORMAT
@@ -996,7 +1000,7 @@
 	AST_LIST_TRAVERSE(&chan->spies->list, spy, list) {
 		ast_mutex_lock(&spy->lock);
 		if ((spy->type == type) && (spy->status == CHANSPY_RUNNING)) {
-			spy->status = CHANSPY_DONE;
+			spy->status = CHANSPY_STOP;
 			if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE)
 				ast_cond_signal(&spy->trigger);
 		}

Modified: team/oej/aum-trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum-trunk/channels/chan_iax2.c?rev=7781&r1=7780&r2=7781&view=diff
==============================================================================
--- team/oej/aum-trunk/channels/chan_iax2.c (original)
+++ team/oej/aum-trunk/channels/chan_iax2.c Wed Jan  4 06:51:54 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
  *
  * Mark Spencer <markster at digium.com>
  *

Modified: team/oej/aum-trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum-trunk/channels/chan_sip.c?rev=7781&r1=7780&r2=7781&view=diff
==============================================================================
--- team/oej/aum-trunk/channels/chan_sip.c (original)
+++ team/oej/aum-trunk/channels/chan_sip.c Wed Jan  4 06:51:54 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
  *
  * Mark Spencer <markster at digium.com>
  *
@@ -104,6 +104,7 @@
 
 #define SIPDUMPER
 #define DEFAULT_DEFAULT_EXPIRY  120
+#define DEFAULT_MIN_EXPIRY	60
 #define DEFAULT_MAX_EXPIRY	3600
 #define DEFAULT_REGISTRATION_TIMEOUT	20
 #define DEFAULT_MAX_FORWARDS	"70"
@@ -120,6 +121,7 @@
 #define EXPIRY_GUARD_PCT	0.20	/* Percentage of expires timeout to use when 
 					   below EXPIRY_GUARD_LIMIT */
 
+static int min_expiry = DEFAULT_MIN_EXPIRY;
 static int max_expiry = DEFAULT_MAX_EXPIRY;
 static int default_expiry = DEFAULT_DEFAULT_EXPIRY;
 
@@ -498,9 +500,11 @@
 
 /*! \brief sip_history: Structure for saving transactions within a SIP dialog */
 struct sip_history {
-	char event[80];
-	struct sip_history *next;
+	AST_LIST_ENTRY(sip_history) list;
+	char event[0];	/* actually more, depending on needs */
 };
+
+AST_LIST_HEAD_NOLOCK(sip_history_head, sip_history); /*!< history list, entry in sip_pvt */
 
 /*! \brief sip_auth: Creadentials for authentication to other SIP services */
 struct sip_auth {
@@ -693,7 +697,7 @@
 	struct ast_rtp *rtp;			/*!< RTP Session */
 	struct ast_rtp *vrtp;			/*!< Video RTP session */
 	struct sip_pkt *packets;		/*!< Packets scheduled for re-transmission */
-	struct sip_history *history;		/*!< History of this SIP dialog */
+	struct sip_history_head *history;	/*!< History of this SIP dialog */
 	struct ast_variable *chanvars;		/*!< Channel variables to set for call */
 	struct sip_pvt *next;			/*!< Next call in chain */
 	struct sip_invite_param *options;	/*!< Options for INVITE */
@@ -881,7 +885,7 @@
 /* The list of manual NOTIFY types we know how to send */
 struct ast_config *notify_types;
 
-static struct sip_auth *authl;          /*!< Authentication list */
+static struct sip_auth *authl = NULL;          /*!< Authentication list */
 
 
 static int transmit_response(struct sip_pvt *p, char *msg, struct sip_request *req);
@@ -1126,40 +1130,51 @@
 	return 0;
 }
 
-/*! \brief  append_history: Append to SIP dialog history */
-/*	Always returns 0 */
-static int append_history(struct sip_pvt *p, const char *event, const char *data)
-{
-	struct sip_history *hist, *prev;
-	char *c;
+/*! \brief  append_history: Append to SIP dialog history 
+	\return Always returns 0 */
+#define append_history(p, event, fmt , args... )	append_history_full(p, "%-15s " fmt, event, ## args)
+
+static int append_history_full(struct sip_pvt *p, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
+
+/*! \brief  Append to SIP dialog history with arg list  */
+static void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap)
+{
+	char buf[80], *c = buf; /* max history length */
+	struct sip_history *hist;
+	int l;
+
+	vsnprintf(buf, sizeof(buf), fmt, ap);
+	strsep(&c, "\r\n"); /* Trim up everything after \r or \n */
+	l = strlen(buf) + 1;
+	hist = calloc(1, sizeof(*hist) + l);
+	if (!hist) {
+		ast_log(LOG_WARNING, "Can't allocate memory for history");
+		return;
+	}
+	if (p->history == NULL)
+		p->history = calloc(1, sizeof(struct sip_history_head));
+	if (p->history == NULL) {
+		ast_log(LOG_WARNING, "Can't allocate memory for history head");
+		free(hist);
+		return;
+	}
+	memcpy(hist->event, buf, l);
+	AST_LIST_INSERT_TAIL(p->history, hist, list);
+}
+
+/*! \brief  Append to SIP dialog history with arg list  */
+static int append_history_full(struct sip_pvt *p, const char *fmt, ...)
+{
+        va_list ap;
 
 	if (!recordhistory || !p)
 		return 0;
-	if(!(hist = malloc(sizeof(struct sip_history)))) {
-		ast_log(LOG_WARNING, "Can't allocate memory for history");
-		return 0;
-	}
-	memset(hist, 0, sizeof(struct sip_history));
-	snprintf(hist->event, sizeof(hist->event), "%-15s %s", event, data);
-	/* Trim up nicely */
-	c = hist->event;
-	while(*c) {
-		if ((*c == '\r') || (*c == '\n')) {
-			*c = '\0';
-			break;
-		}
-		c++;
-	}
-	/* Enqueue into history */
-	prev = p->history;
-	if (prev) {
-		while(prev->next)
-			prev = prev->next;
-		prev->next = hist;
-	} else {
-		p->history = hist;
-	}
-	return 0;
+        va_start(ap, fmt);
+        append_history_va(p, fmt, ap);
+        va_end(ap);
+
+        return 0;
 }
 
 /*! \brief  retrans_pkt: Retransmit SIP message if no answer ---*/
@@ -1173,8 +1188,6 @@
 	ast_mutex_lock(&pkt->owner->lock);
 
 	if (pkt->retrans < MAX_RETRANS) {
-		char buf[80];
-
 		pkt->retrans++;
  		if (!pkt->timer_t1) {	/* Re-schedule using timer_a and timer_t1 */
 			if (sipdebug && option_debug > 3)
@@ -1206,9 +1219,8 @@
 			else
 				ast_verbose("Retransmitting #%d (no NAT) to %s:%d:\n%s\n---\n", pkt->retrans, ast_inet_ntoa(iabuf, sizeof(iabuf), pkt->owner->sa.sin_addr), ntohs(pkt->owner->sa.sin_port), pkt->data);
 		}
-		snprintf(buf, sizeof(buf), "ReTx %d", reschedule);
-
-		append_history(pkt->owner, buf, pkt->data);
+
+		append_history(pkt->owner, "ReTx", "%d %s", reschedule, pkt->data);
 		__sip_xmit(pkt->owner, pkt->data, pkt->packetlen);
 		ast_mutex_unlock(&pkt->owner->lock);
 		return  reschedule;
@@ -1219,7 +1231,7 @@
 		if ((pkt->method == SIP_OPTIONS) && sipdebug)
 			ast_log(LOG_WARNING, "Cancelling retransmit of OPTIONs (call id %s) \n", pkt->owner->callid);
 	}
-	append_history(pkt->owner, "MaxRetries", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
+	append_history(pkt->owner, "MaxRetries", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
  		
 	pkt->retransid = -1;
 
@@ -1331,13 +1343,10 @@
 /*! \brief  sip_scheddestroy: Schedule destruction of SIP call ---*/
 static int sip_scheddestroy(struct sip_pvt *p, int ms)
 {
-	char tmp[80];
 	if (sip_debug_test_pvt(p))
 		ast_verbose("Scheduling destruction of call '%s' in %d ms\n", p->callid, ms);
-	if (recordhistory) {
-		snprintf(tmp, sizeof(tmp), "%d ms", ms);
-		append_history(p, "SchedDestroy", tmp);
-	}
+	if (recordhistory)
+		append_history(p, "SchedDestroy", "%d ms", ms);
 
 	if (p->autokillid > -1)
 		ast_sched_del(sched, p->autokillid);
@@ -1469,31 +1478,22 @@
 static int send_response(struct sip_pvt *p, struct sip_request *req, int reliable, int seqno)
 {
 	int res;
-	char iabuf[INET_ADDRSTRLEN];
-	struct sip_request tmp;
-	char tmpmsg[80];
 
 	if (sip_debug_test_pvt(p)) {
+		char iabuf[INET_ADDRSTRLEN];
 		if (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE)
 			ast_verbose("%sTransmitting (NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port), req->data);
 		else
 			ast_verbose("%sTransmitting (no NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), ntohs(p->sa.sin_port), req->data);
 	}
-	if (reliable) {
-		if (recordhistory) {
-			parse_copy(&tmp, req);
-			snprintf(tmpmsg, sizeof(tmpmsg), "%s / %s", tmp.data, get_header(&tmp, "CSeq"));
-			append_history(p, "TxRespRel", tmpmsg);
-		}
-		res = __sip_reliable_xmit(p, seqno, 1, req->data, req->len, (reliable > 1), req->method);
-	} else {
-		if (recordhistory) {
-			parse_copy(&tmp, req);
-			snprintf(tmpmsg, sizeof(tmpmsg), "%s / %s", tmp.data, get_header(&tmp, "CSeq"));
-			append_history(p, "TxResp", tmpmsg);
-		}
-		res = __sip_xmit(p, req->data, req->len);
-	}
+	if (recordhistory) {
+		struct sip_request tmp;
+		parse_copy(&tmp, req);
+		append_history(p, reliable ? "TxRespRel" : "TxResp", "%s / %s", tmp.data, get_header(&tmp, "CSeq"));
+	}
+	res = (reliable) ?
+		__sip_reliable_xmit(p, seqno, 1, req->data, req->len, (reliable > 1), req->method) :
+		__sip_xmit(p, req->data, req->len);
 	if (res > 0)
 		return 0;
 	return res;
@@ -1503,31 +1503,22 @@
 static int send_request(struct sip_pvt *p, struct sip_request *req, int reliable, int seqno)
 {
 	int res;
-	char iabuf[INET_ADDRSTRLEN];
-	struct sip_request tmp;
-	char tmpmsg[80];
 
 	if (sip_debug_test_pvt(p)) {
+		char iabuf[INET_ADDRSTRLEN];
 		if (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE)
 			ast_verbose("%sTransmitting (NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port), req->data);
 		else
 			ast_verbose("%sTransmitting (no NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), ntohs(p->sa.sin_port), req->data);
 	}
-	if (reliable) {
-		if (recordhistory) {
-			parse_copy(&tmp, req);
-			snprintf(tmpmsg, sizeof(tmpmsg), "%s / %s", tmp.data, get_header(&tmp, "CSeq"));
-			append_history(p, "TxReqRel", tmpmsg);
-		}
-		res = __sip_reliable_xmit(p, seqno, 0, req->data, req->len, (reliable > 1), req->method);
-	} else {
-		if (recordhistory) {
-			parse_copy(&tmp, req);
-			snprintf(tmpmsg, sizeof(tmpmsg), "%s / %s", tmp.data, get_header(&tmp, "CSeq"));
-			append_history(p, "TxReq", tmpmsg);
-		}
-		res = __sip_xmit(p, req->data, req->len);
-	}
+	if (recordhistory) {
+		struct sip_request tmp;
+		parse_copy(&tmp, req);
+		append_history(p, reliable ? "TxReqRel" : "TxReq", "%s / %s", tmp.data, get_header(&tmp, "CSeq"));
+	}
+	res = (reliable) ?
+		__sip_reliable_xmit(p, seqno, 0, req->data, req->len, (reliable > 1), req->method) :
+		__sip_xmit(p, req->data, req->len);
 	return res;
 }
 
@@ -2092,7 +2083,6 @@
 {
 	struct sip_pvt *cur, *prev = NULL;
 	struct sip_pkt *cp;
-	struct sip_history *hist;
 
 	if (sip_debug_test_pvt(p))
 		ast_verbose("Destroying call '%s'\n", p->callid);
@@ -2142,10 +2132,14 @@
 			ast_mutex_unlock(&p->owner->lock);
 	}
 	/* Clear history */
-	while(p->history) {
-		hist = p->history;
-		p->history = p->history->next;
-		free(hist);
+	if (p->history) {
+		while(!AST_LIST_EMPTY(p->history)) {
+			struct sip_history *hist = AST_LIST_FIRST(p->history);
+			AST_LIST_REMOVE_HEAD(p->history, list);
+			free(hist);
+		}
+		free(p->history);
+		p->history = NULL;
 	}
 
 	cur = iflist;
@@ -2183,8 +2177,15 @@
 }
 
 /*! \brief  update_call_counter: Handle call_limit for SIP users 
- * Note: This is going to be replaced by app_groupcount 
- * Thought: For realtime, we should propably update storage with inuse counter... */
+ * Setting a call-limit will cause calls above the limit not to be accepted.
+ *
+ * Remember that for a type=friend, there's one limit for the user and
+ * another for the peer, not a combined call limit.
+ * This will cause unexpected behaviour in subscriptions, since a "friend"
+ * is *two* devices in Asterisk, not one.
+ *
+ * Thought: For realtime, we should propably update storage with inuse counter... 
+ */
 static int update_call_counter(struct sip_pvt *fup, int event)
 {
 	char name[256];
@@ -2203,7 +2204,9 @@
 	ast_copy_string(name, fup->username, sizeof(name));
 
 	/* Check the list of users */
-	u = find_user(name, 1);
+	if (!outgoing)	/* Only check users for incoming calls */
+		u = find_user(name, 1);
+
 	if (u) {
 		inuse = &u->inUse;
 		call_limit = &u->call_limit;
@@ -3627,7 +3630,7 @@
 
 	/* Manager Hold and Unhold events must be generated, if necessary */
 	if (sin.sin_addr.s_addr && !sendonly) {	        
-	        append_history(p, "Unhold", req->data);
+	        append_history(p, "Unhold", "%s", req->data);
 
 		if (callevents && ast_test_flag(p, SIP_CALL_ONHOLD)) {
 			manager_event(EVENT_FLAG_CALL, "Unhold",
@@ -3640,7 +3643,7 @@
 		ast_clear_flag(p, SIP_CALL_ONHOLD);
 	} else {	        
 		/* No address for RTP, we're on hold */
-	        append_history(p, "Hold", req->data);
+	        append_history(p, "Hold", "%s", req->data);
 
 	        if (callevents && !ast_test_flag(p, SIP_CALL_ONHOLD)) {
 			manager_event(EVENT_FLAG_CALL, "Hold",
@@ -4241,7 +4244,7 @@
 		" <media_control>\r\n"
 		"  <vc_primitive>\r\n"
 		"   <to_encoder>\r\n"
-		"    <picture_fast_update\r\n"
+		"    <picture_fast_update>\r\n"
 		"    </picture_fast_update>\r\n"
 		"   </to_encoder>\r\n"
 		"  </vc_primitive>\r\n"
@@ -5221,11 +5224,8 @@
 	if (!r)
 		return 0;
 
-	if (r->call && recordhistory) {
-		char tmp[80];
-		snprintf(tmp, sizeof(tmp), "Account: %s@%s", r->username, r->hostname);
-		append_history(r->call, "RegistryRenew", tmp);
-	}
+	if (r->call && recordhistory)
+		append_history(r->call, "RegistryRenew", "Account: %s@%s", r->username, r->hostname);
 	/* Since registry's are only added/removed by the the monitor thread, this
 	   may be overkill to reference/dereference at all here */
 	if (sipdebug)
@@ -5326,11 +5326,8 @@
 			ast_log(LOG_WARNING, "Unable to allocate registration call\n");
 			return 0;
 		}
-		if (recordhistory) {
-			char tmp[80];
-			snprintf(tmp, sizeof(tmp), "Account: %s@%s", r->username, r->hostname);
-			append_history(p, "RegistryInit", tmp);
-		}
+		if (recordhistory)
+			append_history(p, "RegistryInit", "Account: %s@%s", r->username, r->hostname);
 		/* Find address to hostname */
 		if (create_addr(p, r->hostname)) {
 			/* we have what we hope is a temporary network error,
@@ -5894,8 +5891,10 @@
 
 	if (p->expire > -1)
 		ast_sched_del(sched, p->expire);
-	if ((expiry < 1) || (expiry > max_expiry))
+	if (expiry > max_expiry)
 		expiry = max_expiry;
+	if (expiry < min_expiry)
+		expiry = min_expiry;
 	if (!ast_test_flag(p, SIP_REALTIME))
 		p->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, p);
 	else
@@ -6307,7 +6306,7 @@
 		ast_verbose(VERBOSE_PREFIX_2 "Extension state: Watcher for hint %s %s. Notify User %s\n", exten, state == AST_EXTENSION_DEACTIVATED ? "deactivated" : "removed", p->username);
 		p->stateid = -1;
 		p->subscribed = NONE;
-		append_history(p, "Subscribestatus", state == AST_EXTENSION_REMOVED ? "HintRemoved" : "Deactivated");
+		append_history(p, "Subscribestatus", "%s", state == AST_EXTENSION_REMOVED ? "HintRemoved" : "Deactivated");
 		break;
 	default:	/* Tell user */
 		p->laststate = state;
@@ -6796,7 +6795,7 @@
 	return -1;
 }
 
-/*! \brief  check_via: check Via: headers ---*/
+/*! \brief check Via: header for hostname, port and rport request/answer */
 static int check_via(struct sip_pvt *p, struct sip_request *req)
 {
 	char via[256];
@@ -6806,9 +6805,16 @@
 	struct ast_hostent ahp;
 
 	ast_copy_string(via, get_header(req, "Via"), sizeof(via));
+
+	/* Check for rport */
+	c = strstr(via, ";rport");
+	if (c && (c[6] != '='))	/* rport query, not answer */
+		ast_set_flag(p, SIP_NAT_ROUTE);
+
 	c = strchr(via, ';');
 	if (c) 
 		*c = '\0';
+
 	c = strchr(via, ' ');

[... 1352 lines stripped ...]


More information about the asterisk-commits mailing list