[asterisk-commits] murf: branch murf/utf8-whatif r91150 - in /team/murf/utf8-whatif: ./ apps/ ch...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 5 00:28:47 CST 2007


Author: murf
Date: Wed Dec  5 00:28:47 2007
New Revision: 91150

URL: http://svn.digium.com/view/asterisk?view=rev&rev=91150
Log:
Merged revisions 90873,90877-90880,90899,90927-90930,90949,90991,90993,91010-91012,91029,91033,91069,91077,91114,91131,91133 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r90873 | mmichelson | 2007-12-04 10:08:36 -0700 (Tue, 04 Dec 2007) | 30 lines

Merged revisions 90735 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r90735 | mmichelson | 2007-12-03 17:12:17 -0600 (Mon, 03 Dec 2007) | 22 lines

A big one...

This is the merge of the forward-loop branch. The main change here is that call-forwards can no longer loop.
This is accomplished by creating a datastore on the calling channel which has a linked list of all devices
dialed. If a forward happens, then the local channel which is created inherits the datastore. If, through this
progression of forwards and datastore inheritance, a device is attempted to be dialed a second time, it will simply
be skipped and a warning message will be printed to the CLI. After the dialing has been completed, the datastore
is detached from the channel and destroyed.

This change also introduces some side effects to the code which I shall enumerate here:

1. Datastore inheritance has been backported from trunk into 1.4
2. A large chunk of code has been removed from app_dial. This chunk is the section of code
   which handles the call forward case after the channel has been requested but before it has
   been called. This was removed because call-forwarding still works fine without it, it makes the
   code less error-prone should it need changing, and it made this set of changes much less painful
   to just have the forwarding handled in one place in each module.
3. Two new files, global_datastores.h and .c have been added. These are necessary since the datastore
   which is attached to the channel may be created and attached in either app_dial or app_queue, so they
   need a common place to find the datastore info. This approach was taken in case similar datastores are
   needed in the future, there will be a common place to add them.

........

................
r90877 | qwell | 2007-12-04 10:35:40 -0700 (Tue, 04 Dec 2007) | 1 line

Fix build in trunk.  This was fixed in 1.4, but blocked in trunk since this hadn't been merged yet.
................
r90878 | russell | 2007-12-04 10:36:59 -0700 (Tue, 04 Dec 2007) | 2 lines

Fix a silly little typo :)

................
r90879 | qwell | 2007-12-04 10:38:51 -0700 (Tue, 04 Dec 2007) | 13 lines

Merged revisions 90876 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

(closes issue #11454)
........
r90876 | qwell | 2007-12-04 11:28:08 -0600 (Tue, 04 Dec 2007) | 4 lines

If we fail to create a channel after allocating a timing fd, we need to make sure to close it.

Issue 11454, patch by eliel.

........

................
r90880 | kpfleming | 2007-12-04 10:40:29 -0700 (Tue, 04 Dec 2007) | 2 lines

fix build of this module when libpri and/or libss7 are or are not present

................
r90899 | mmichelson | 2007-12-04 10:51:59 -0700 (Tue, 04 Dec 2007) | 3 lines

Wrong locking style got merged from 1.4 to trunk. My mistake.


................
r90927 | qwell | 2007-12-04 11:09:28 -0700 (Tue, 04 Dec 2007) | 1 line

Fix build, that some people aren't seeing for some reason.
................
r90928 | mmichelson | 2007-12-04 11:14:08 -0700 (Tue, 04 Dec 2007) | 3 lines

Suppress a compiler warning due to discarding a "const" qualifier


................
r90929 | qwell | 2007-12-04 11:15:17 -0700 (Tue, 04 Dec 2007) | 4 lines

Add Makefile alias target 'pdf' which does the same thing as asterisk.pdf.

Issue 11452, reported by blitzrage.

................
r90930 | mmichelson | 2007-12-04 11:29:35 -0700 (Tue, 04 Dec 2007) | 6 lines

Kevin suggested doing the reverse of my last commit, since imap_retrieve_file
does not modify the contents of the "mailbox" string. In other words, I'm changing
the imap_retrieve_file function to take a const char* as the third argument so that I
don't need to cast const char*'s as char*'s to suppress compiler warnings.


................
r90949 | russell | 2007-12-04 12:08:30 -0700 (Tue, 04 Dec 2007) | 15 lines

Add support for monitoring MWI on FXO lines.

This introduces two new options for zapata.conf: mwimonitor and mwimonitornotify.
The mwimonitor option enables MWI monitoring.  When the MWI state on a line changes,
then the script specified by mwimonitornotify will be executed for custom handling
of the state change, similar to the externnotify option of voicemail.conf.

Also, when the MWI state on an FXO line changes, an internal Asterisk event is
generated to indicate the new state of the associated mailbox.  That may, any
module that cares about MWI information will get notified and can handle it
just as if app_voicemail had sent this notification.

(BE-253, original patch from markster, with some minor modifications by me to
 add comments, documentation, and internal event support)

................
r90991 | qwell | 2007-12-04 14:23:30 -0700 (Tue, 04 Dec 2007) | 4 lines

Add manager action 'sipshowregistry'.

Closes issue #11464, patch by eliel.

................
r90993 | tilghman | 2007-12-04 14:46:27 -0700 (Tue, 04 Dec 2007) | 3 lines

Coding guidelines fixups
(Closes issue #11412)

................
r91010 | russell | 2007-12-04 15:02:48 -0700 (Tue, 04 Dec 2007) | 3 lines

Fix resetting mwimonitornotify on reload.  I guess I only added this line in my head.
(thanks to tzafrir for pointing it out)

................
r91011 | russell | 2007-12-04 15:07:35 -0700 (Tue, 04 Dec 2007) | 15 lines

Merged revisions 90967 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r90967 | russell | 2007-12-04 13:57:39 -0600 (Tue, 04 Dec 2007) | 7 lines

Make some changes to some additions I made recently for doing channel autoservice
when looking up extensions.  This code was added to handle the case where a
dialplan switch was in use that could block for a long time.  However, the way
that I added it, it did this for all extension lookups.  However, lookups in the
in-memory tree of extensions should _not_ take long enough to matter.  So, move
the autoservice stuff to be only around executing a switch.

........

................
r91012 | mattf | 2007-12-04 15:44:01 -0700 (Tue, 04 Dec 2007) | 1 line

Don't error when we don't have libpri installed with libss7 support.  Also, print the debug message anyway if we can't find the right PRI
................
r91029 | russell | 2007-12-04 16:01:15 -0700 (Tue, 04 Dec 2007) | 4 lines

Fix the build of astman.  Any file that includes any asterisk sub-headers
needs to first include asterisk.h.
(closes issue #11394)

................
r91033 | russell | 2007-12-04 16:47:28 -0700 (Tue, 04 Dec 2007) | 12 lines

Blocked revisions 91032 via svnmerge

........
r91032 | russell | 2007-12-04 17:46:40 -0600 (Tue, 04 Dec 2007) | 5 lines

Modify file.h to maintain API compatibility with earlier versions.  If a recent
compiler is being used, then a warning will show up for any modules still using
the old name "private" instead of "_private".
(patch suggested by paravoid)

........

................
r91069 | russell | 2007-12-04 16:57:31 -0700 (Tue, 04 Dec 2007) | 3 lines

Fix mwimonitornotify on reload ... again.  This option was only read at startup
so a reload would erase it and not reset it.  (pointed out by tzafrir)

................
r91077 | russell | 2007-12-04 17:49:19 -0700 (Tue, 04 Dec 2007) | 12 lines

Merged revisions 91074 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r91074 | russell | 2007-12-04 18:48:47 -0600 (Tue, 04 Dec 2007) | 4 lines

When DEBUG_THREADS is enabled, we only have the details about who is holding
a lock that we are waiting on for a mutex, not rwlocks.  This should fix the
problem where people have reported "core show locks" crashing sometimes.

........

................
r91114 | russell | 2007-12-04 18:59:32 -0700 (Tue, 04 Dec 2007) | 19 lines

Merged revisions 91070 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r91070 | russell | 2007-12-04 18:35:31 -0600 (Tue, 04 Dec 2007) | 11 lines

Fix some crashes in chan_iax2 that were reported as happening on Mac systems.
It turns out that the problem was the Mac version of the ast_atomic_fetchadd_int()
function.  The Mac atomic add function returns the _new_ value, while this function
is supposed to return the old value.  So, the crashes happened on unreferencing
objects.  If the reference count was decreased to 1, ao2_ref() thought that it
had been decreased to zero, and called the destructor.  However, there was still
an outstanding reference around.

(closes issue #11176)
(closes issue #11289)

........

................
r91131 | russell | 2007-12-04 20:34:51 -0700 (Tue, 04 Dec 2007) | 7 lines

Use ast_free() instead of free().

(closes issue #11309)
Reported by: Laureano
Patches: 
      res_odbc.c.patch uploaded by Laureano (license 265)

................
r91133 | kpfleming | 2007-12-04 20:48:53 -0700 (Tue, 04 Dec 2007) | 2 lines

revert part of my changes from earlier today since this code is no longer dependent on libpri.h

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

Added:
    team/murf/utf8-whatif/include/asterisk/global_datastores.h
      - copied unchanged from r91133, trunk/include/asterisk/global_datastores.h
    team/murf/utf8-whatif/main/global_datastores.c
      - copied unchanged from r91133, trunk/main/global_datastores.c
Modified:
    team/murf/utf8-whatif/   (props changed)
    team/murf/utf8-whatif/CHANGES
    team/murf/utf8-whatif/Makefile
    team/murf/utf8-whatif/apps/app_dial.c
    team/murf/utf8-whatif/apps/app_queue.c
    team/murf/utf8-whatif/apps/app_voicemail.c
    team/murf/utf8-whatif/channels/chan_local.c
    team/murf/utf8-whatif/channels/chan_sip.c
    team/murf/utf8-whatif/channels/chan_usbradio.c
    team/murf/utf8-whatif/channels/chan_zap.c
    team/murf/utf8-whatif/configs/zapata.conf.sample
    team/murf/utf8-whatif/include/asterisk/callerid.h
    team/murf/utf8-whatif/include/asterisk/channel.h
    team/murf/utf8-whatif/include/asterisk/lock.h
    team/murf/utf8-whatif/main/Makefile
    team/murf/utf8-whatif/main/callerid.c
    team/murf/utf8-whatif/main/channel.c
    team/murf/utf8-whatif/main/pbx.c
    team/murf/utf8-whatif/main/utils.c
    team/murf/utf8-whatif/res/res_odbc.c
    team/murf/utf8-whatif/utils/astman.c

Propchange: team/murf/utf8-whatif/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/murf/utf8-whatif/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/murf/utf8-whatif/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Dec  5 00:28:47 2007
@@ -1,1 +1,1 @@
-/trunk:1-90866
+/trunk:1-91149

Modified: team/murf/utf8-whatif/CHANGES
URL: http://svn.digium.com/view/asterisk/team/murf/utf8-whatif/CHANGES?view=diff&rev=91150&r1=91149&r2=91150
==============================================================================
--- team/murf/utf8-whatif/CHANGES (original)
+++ team/murf/utf8-whatif/CHANGES Wed Dec  5 00:28:47 2007
@@ -4,6 +4,7 @@
 
 AMI - The manager (TCP/TLS/HTTP)
 --------------------------------
+  * Added a new action 'SIPshowregistry' to list SIP registrations.
   * Added TLS support for the manager interface and HTTP server
   * Added the URI redirect option for the built-in HTTP server
   * The output of CallerID in Manager events is now more consistent.
@@ -277,7 +278,12 @@
   * CID matching information is now shown when doing 'dialplan show'.
   * Added zap show version CLI command to chan_zap.
   * Added setvar support to zapata.conf channel entries.
-
+  * Added two new options: mwimonitor and mwimonitornotify.  These options allow
+     you to enable MWI monitoring on FXO lines.  When the MWI state changes,
+     the script specified in the mwimonitornotify option is executed.  An internal
+	 event indicating the new state of the mailbox is also generated, so that
+	 the normal MWI facilities in Asterisk work as usual.
+ 
 H.323 Changes
 -------------
   * H323 remote hold notification support added (by NOTIFY message

Modified: team/murf/utf8-whatif/Makefile
URL: http://svn.digium.com/view/asterisk/team/murf/utf8-whatif/Makefile?view=diff&rev=91150&r1=91149&r2=91150
==============================================================================
--- team/murf/utf8-whatif/Makefile (original)
+++ team/murf/utf8-whatif/Makefile Wed Dec  5 00:28:47 2007
@@ -774,7 +774,8 @@
 	@echo "Generating input for menuselect ..."
 	@build_tools/prep_moduledeps > $@
 
+pdf: asterisk.pdf
 asterisk.pdf:
 	$(MAKE) -C doc/tex asterisk.pdf
 
-.PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) menuselect.makeopts
+.PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all pdf dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) menuselect.makeopts

Modified: team/murf/utf8-whatif/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/murf/utf8-whatif/apps/app_dial.c?view=diff&rev=91150&r1=91149&r2=91150
==============================================================================
--- team/murf/utf8-whatif/apps/app_dial.c (original)
+++ team/murf/utf8-whatif/apps/app_dial.c Wed Dec  5 00:28:47 2007
@@ -54,6 +54,7 @@
 #include "asterisk/manager.h"
 #include "asterisk/privacy.h"
 #include "asterisk/stringfields.h"
+#include "asterisk/global_datastores.h"
 
 static char *app = "Dial";
 
@@ -326,7 +327,6 @@
 	struct chanlist *next;
 	struct ast_channel *chan;
 	uint64_t flags;
-	int forwards;
 };
 
 
@@ -346,8 +346,6 @@
 		ast_free(oo);
 	}
 }
-
-#define AST_MAX_FORWARDS   8
 
 #define AST_MAX_WATCHERS 256
 
@@ -480,28 +478,22 @@
 		tech = "Local";
 	}
 	/* Before processing channel, go ahead and check for forwarding */
-	o->forwards++;
-	if (o->forwards < AST_MAX_FORWARDS) {
-		ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, c->name);
-		/* If we have been told to ignore forwards, just set this channel to null and continue processing extensions normally */
-		if (ast_test_flag64(peerflags, OPT_IGNORE_FORWARDING)) {
-			ast_verb(3, "Forwarding %s to '%s/%s' prevented.\n", in->name, tech, stuff);
-			c = o->chan = NULL;
-			cause = AST_CAUSE_BUSY;
-		} else {
-			/* Setup parameters */
-			c = o->chan = ast_request(tech, in->nativeformats, stuff, &cause);
-			if (c) {
-				if (single)
-					ast_channel_make_compatible(o->chan, in);
-				ast_channel_inherit_variables(in, o->chan);
-			} else
-				ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
-		}
+	ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, c->name);
+	/* If we have been told to ignore forwards, just set this channel to null and continue processing extensions normally */
+	if (ast_test_flag64(peerflags, OPT_IGNORE_FORWARDING)) {
+		ast_verb(3, "Forwarding %s to '%s/%s' prevented.\n", in->name, tech, stuff);
+		c = o->chan = NULL;
+		cause = AST_CAUSE_BUSY;
 	} else {
-		ast_verb(3, "Too many forwards from %s\n", c->name);
-		cause = AST_CAUSE_CONGESTION;
-		c = o->chan = NULL;
+		/* Setup parameters */
+		c = o->chan = ast_request(tech, in->nativeformats, stuff, &cause);
+		if (c) {
+			if (single)
+				ast_channel_make_compatible(o->chan, in);
+			ast_channel_inherit_variables(in, o->chan);
+			ast_channel_datastore_inherit(in, o->chan);
+		} else
+			ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
 	}
 	if (!c) {
 		ast_clear_flag64(o, DIAL_STILLGOING);	
@@ -1252,6 +1244,8 @@
 	);
 	struct ast_flags64 opts = { 0, };
 	char *opt_args[OPT_ARG_ARRAY_SIZE];
+	struct ast_datastore *datastore = NULL;
+	int fulldial = 0, num_dialed = 0;
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "Dial requires an argument (technology/number)\n");
@@ -1333,7 +1327,13 @@
 		struct ast_channel *tc;	/* channel for this destination */
 		/* Get a technology/[device:]number pair */
 		char *number = cur;
+		char *interface = ast_strdupa(number);
 		char *tech = strsep(&number, "/");
+		/* find if we already dialed this interface */
+		int dialed = 0;
+		struct ast_dialed_interface *di;
+		AST_LIST_HEAD(, ast_dialed_interface) *dialed_interfaces;
+		num_dialed++;
 		if (!number) {
 			ast_log(LOG_WARNING, "Dial argument takes format (technology/[device:]number1)\n");
 			goto out;
@@ -1353,6 +1353,50 @@
 		}
 		ast_copy_string(numsubst, number, sizeof(numsubst));
 		/* Request the peer */
+		if (!(datastore = ast_channel_datastore_find(chan, &dialed_interface_info, NULL))) {
+			if(!(datastore = ast_channel_datastore_alloc(&dialed_interface_info, NULL))) {
+				ast_log(LOG_WARNING, "Unable to create channel datastore for dialed interfaces. Aborting!\n"); 
+				free(tmp);
+				goto out;
+			}
+			else {
+				datastore->inheritance = DATASTORE_INHERIT_FOREVER;
+				if((dialed_interfaces = ast_calloc(1, sizeof(*dialed_interfaces)))) {
+					datastore->data = dialed_interfaces;
+					AST_LIST_HEAD_INIT(dialed_interfaces);
+					ast_channel_datastore_add(chan, datastore);
+				} else {
+					free(tmp);
+					goto out;
+				}
+			}
+		} else 
+			dialed_interfaces = datastore->data;
+		AST_LIST_LOCK(dialed_interfaces);
+		AST_LIST_TRAVERSE(dialed_interfaces, di, list) {
+			/* XXX case sensitive??? */
+			if(!strcasecmp(di->interface, interface)) {
+				dialed = 1;
+				break;
+			}
+		}
+		if(!dialed && strcasecmp(tech, "Local")) {
+			if(!(di = ast_calloc(1, sizeof(*di) + strlen(interface)))) {
+				AST_LIST_UNLOCK(dialed_interfaces);
+				free(tmp);
+				goto out;
+			}
+			strcpy(di->interface, interface);
+			AST_LIST_INSERT_TAIL(dialed_interfaces, di, list);
+		} else {
+			AST_LIST_UNLOCK(dialed_interfaces);
+			ast_log(LOG_WARNING, "Skipping dialing interface '%s' again since it has already been dialed\n", di->interface);
+			fulldial++;
+			free(tmp);
+			continue;
+		}
+		AST_LIST_UNLOCK(dialed_interfaces);
+
 		tc = ast_request(tech, chan->nativeformats, numsubst, &cause);
 		if (!tc) {
 			/* If we can't, just go on to the next call */
@@ -1365,50 +1409,6 @@
 			continue;
 		}
 		pbx_builtin_setvar_helper(tc, "DIALEDPEERNUMBER", numsubst);
-		if (!ast_strlen_zero(tc->call_forward)) {
-			char tmpchan[256];
-			char *stuff;
-			char *tech;
-			ast_copy_string(tmpchan, tc->call_forward, sizeof(tmpchan));
-			if ((stuff = strchr(tmpchan, '/'))) {
-				*stuff++ = '\0';
-				tech = tmpchan;
-			} else {
-				snprintf(tmpchan, sizeof(tmpchan), "%s@%s", tc->call_forward, tc->context);
-				stuff = tmpchan;
-				tech = "Local";
-			}
-			tmp->forwards++;
-			if (tmp->forwards < AST_MAX_FORWARDS) {
-				ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n",
-					chan->name, tech, stuff, tc->name);
-				ast_hangup(tc);
-				/* If we have been told to ignore forwards, just set this channel to null
-				 * and continue processing extensions normally */
-				if (ast_test_flag64(&opts, OPT_IGNORE_FORWARDING)) {
-					tc = NULL;
-					cause = AST_CAUSE_BUSY;
-					ast_verb(3, "Forwarding %s to '%s/%s' prevented.\n",
-							chan->name, tech, stuff);
-				} else {
-					tc = ast_request(tech, chan->nativeformats, stuff, &cause);
-				}
-				if (!tc)
-					ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
-				else
-					ast_channel_inherit_variables(chan, tc);
-			} else {
-				ast_verb(3, "Too many forwards from %s\n", tc->name);
-				ast_hangup(tc);
-				tc = NULL;
-				cause = AST_CAUSE_CONGESTION;
-			}
-			if (!tc) {
-				handle_cause(cause, &num);
-				ast_free(tmp);
-				continue;
-			}
-		}
 
 		/* Setup outgoing SDP to match incoming one */
 		ast_rtp_make_compatible(tc, chan, !outgoing && !rest);
@@ -1498,6 +1498,10 @@
 
 	if (!outgoing) {
 		strcpy(pa.status, "CHANUNAVAIL");
+		if(fulldial == num_dialed) {
+			res = -1;
+			goto out;
+		}
 	} else {
 		/* Our status will at least be NOANSWER */
 		strcpy(pa.status, "NOANSWER");
@@ -1520,7 +1524,9 @@
 
 	time(&start_time);
 	peer = wait_for_answer(chan, outgoing, &to, peerflags, &pa, &num, &result);
-	
+
+	ast_channel_datastore_remove(chan, datastore);
+	ast_channel_datastore_free(datastore);
 	if (!peer) {
 		if (result) {
 			res = result;

Modified: team/murf/utf8-whatif/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/murf/utf8-whatif/apps/app_queue.c?view=diff&rev=91150&r1=91149&r2=91150
==============================================================================
--- team/murf/utf8-whatif/apps/app_queue.c (original)
+++ team/murf/utf8-whatif/apps/app_queue.c Wed Dec  5 00:28:47 2007
@@ -87,6 +87,7 @@
 #include "asterisk/event.h"
 #include "asterisk/astobj2.h"
 #include "asterisk/strings.h"
+#include "asterisk/global_datastores.h"
 
 enum {
 	QUEUE_STRATEGY_RINGALL = 0,
@@ -2295,6 +2296,7 @@
 						numnochan++;
 					} else {
 						ast_channel_inherit_variables(in, o->chan);
+						ast_channel_datastore_inherit(in, o->chan);
 						if (o->chan->cid.cid_num)
 							ast_free(o->chan->cid.cid_num);
 						o->chan->cid.cid_num = ast_strdup(in->cid.cid_num);
@@ -2733,6 +2735,7 @@
 	int forwardsallowed = 1;
 	int callcompletedinsl;
 	struct ao2_iterator memi;
+	struct ast_datastore *datastore = ast_channel_datastore_find(qe->chan, &dialed_interface_info, NULL);
 
 	memset(&bridge_config, 0, sizeof(bridge_config));
 	tmpid[0] = 0;
@@ -2802,7 +2805,9 @@
 	memi = ao2_iterator_init(qe->parent->members, 0);
 	while ((cur = ao2_iterator_next(&memi))) {
 		struct callattempt *tmp = ast_calloc(1, sizeof(*tmp));
-
+		struct ast_dialed_interface *di;
+		int dialed = 0;
+		AST_LIST_HEAD(, ast_dialed_interface) *dialed_interfaces;
 		if (!tmp) {
 			ao2_ref(cur, -1);
 			ao2_unlock(qe->parent);
@@ -2810,6 +2815,49 @@
 				ao2_unlock(queues);
 			goto out;
 		}
+		if (!datastore) {
+			if(!(datastore = ast_channel_datastore_alloc(&dialed_interface_info, NULL))) {
+				ao2_ref(cur, -1);
+				ao2_unlock(qe->parent);
+				if(use_weight)
+					ao2_unlock(queues);
+				free(tmp);
+				goto out;
+			}
+			datastore->inheritance = DATASTORE_INHERIT_FOREVER;
+			dialed_interfaces = ast_calloc(1, sizeof(*dialed_interfaces));
+			datastore->data = dialed_interfaces;
+			AST_LIST_HEAD_INIT(dialed_interfaces);
+			ast_channel_datastore_add(qe->chan, datastore);
+		} else
+			dialed_interfaces = datastore->data;
+		AST_LIST_LOCK(dialed_interfaces);
+		AST_LIST_TRAVERSE(dialed_interfaces, di, list) {
+			/* XXX case sensitive ?? */
+			if(!strcasecmp(cur->interface, di->interface)) {
+				dialed = 1;
+				break;
+			}
+		}
+		if (!dialed && strncasecmp(cur->interface, "Local/", 6)) {
+			if(!(di = ast_calloc(1, sizeof(*di) + strlen(cur->interface)))) {
+				ao2_ref(cur, -1);
+				AST_LIST_UNLOCK(dialed_interfaces);
+				ao2_unlock(qe->parent);
+				if(use_weight)
+					ao2_unlock(queues);
+				free(tmp);
+				goto out;
+			}
+			strcpy(di->interface, cur->interface);
+			AST_LIST_INSERT_TAIL(dialed_interfaces, di, list);
+		} else {
+			AST_LIST_UNLOCK(dialed_interfaces);
+			ast_log(LOG_DEBUG, "Skipping dialing interface '%s' since it has already been dialed\n", di->interface);
+			free(tmp);
+			continue;
+		}
+		AST_LIST_UNLOCK(dialed_interfaces);
 		tmp->stillgoing = -1;
 		tmp->member = cur;
 		tmp->oldstatus = cur->status;
@@ -2842,6 +2890,8 @@
 	if (use_weight)
 		ao2_unlock(queues);
 	lpeer = wait_for_answer(qe, outgoing, &to, &digit, numbusies, ast_test_flag(&(bridge_config.features_caller), AST_FEATURE_DISCONNECT), forwardsallowed);
+	ast_channel_datastore_remove(qe->chan, datastore);
+	ast_channel_datastore_free(datastore);
 	ao2_lock(qe->parent);
 	if (qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY) {
 		store_next_rr(qe, outgoing);

Modified: team/murf/utf8-whatif/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/murf/utf8-whatif/apps/app_voicemail.c?view=diff&rev=91150&r1=91149&r2=91150
==============================================================================
--- team/murf/utf8-whatif/apps/app_voicemail.c (original)
+++ team/murf/utf8-whatif/apps/app_voicemail.c Wed Dec  5 00:28:47 2007
@@ -148,7 +148,7 @@
 static void update_messages_by_imapuser(const char *user, unsigned long number);
 
 static int imap_remove_file (char *dir, int msgnum);
-static int imap_retrieve_file (char *dir, int msgnum, char *mailbox, char *context);
+static int imap_retrieve_file (char *dir, int msgnum, const char *mailbox, char *context);
 static int imap_delete_old_greeting (char *dir, struct vm_state *vms);
 struct vmstate {
 	struct vm_state *vms;

Modified: team/murf/utf8-whatif/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/murf/utf8-whatif/channels/chan_local.c?view=diff&rev=91150&r1=91149&r2=91150
==============================================================================
--- team/murf/utf8-whatif/channels/chan_local.c (original)
+++ team/murf/utf8-whatif/channels/chan_local.c Wed Dec  5 00:28:47 2007
@@ -473,6 +473,7 @@
 			AST_LIST_INSERT_TAIL(&p->chan->varshead, new, entries);
 		}
 	}
+	ast_channel_datastore_inherit(p->owner, p->chan);
 
 	/* Start switch on sub channel */
 	if (!(res = ast_pbx_start(p->chan)))

Modified: team/murf/utf8-whatif/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/utf8-whatif/channels/chan_sip.c?view=diff&rev=91150&r1=91149&r2=91150
==============================================================================
--- team/murf/utf8-whatif/channels/chan_sip.c (original)
+++ team/murf/utf8-whatif/channels/chan_sip.c Wed Dec  5 00:28:47 2007
@@ -10811,6 +10811,59 @@
 
 	return CLI_SUCCESS;
 #undef FORMAT
+}
+
+/*! \brief Manager Action SIPShowRegistry description */
+static char mandescr_show_registry[] =
+"Description: Lists all registration requests and status\n"
+"Registrations will follow as separate events. followed by a final event called\n"
+"RegistrationsComplete.\n"
+"Variables: \n"
+"  ActionID: <id>       Action ID for this transaction. Will be returned.\n";
+
+/*! \brief Show SIP registrations in the manager API */
+static int manager_show_registry(struct mansession *s, const struct message *m)
+{
+	const char *id = astman_get_header(m, "ActionID");
+	char idtext[256] = "";
+	char tmpdat[256] = "";
+	int total = 0;
+	struct ast_tm tm;
+
+	if (!ast_strlen_zero(id))
+		snprintf(idtext, sizeof(idtext), "ActionID: %s\r\n", id);
+
+	astman_send_listack(s, m, "Registrations will follow", "start");
+
+	ASTOBJ_CONTAINER_TRAVERSE(&regl, 1, do {
+		ASTOBJ_RDLOCK(iterator);
+		if (iterator->regtime.tv_sec) {
+			ast_localtime(&iterator->regtime, &tm, NULL);
+			ast_strftime(tmpdat, sizeof(tmpdat), "%a, %d %b %Y %T", &tm);
+		} else
+			tmpdat[0] = '\0';
+		astman_append(s,
+			"Event: RegistryEntry\r\n"
+			"Host: %s\r\n"
+			"Port: %d\r\n"
+			"Username: %s\r\n"
+			"Refresh: %d\r\n"
+			"State: %s\r\n"
+			"Reg.Time: %s\r\n"
+			"\r\n", iterator->hostname, iterator->portno ? iterator->portno : STANDARD_SIP_PORT,
+			iterator->username, iterator->refresh, regstate2str(iterator->regstate), tmpdat);
+		ASTOBJ_UNLOCK(iterator);
+		total++;
+	} while(0));
+
+	astman_append(s,
+		"Event: RegistrationsComplete\r\n"
+		"EventList: Complete\r\n"
+		"ListItems: %d\r\n"
+		"%s"
+		"\r\n", total, idtext);
+	
+	return 0;
 }
 
 static char mandescr_show_peers[] = 
@@ -19307,7 +19360,8 @@
 			"List SIP peers (text format)", mandescr_show_peers);
 	ast_manager_register2("SIPshowpeer", EVENT_FLAG_SYSTEM, manager_sip_show_peer,
 			"Show SIP peer (text format)", mandescr_show_peer);
-
+	ast_manager_register2("SIPshowregistry", EVENT_FLAG_SYSTEM, manager_show_registry,
+			"Show SIP registrations (text format)", mandescr_show_registry);
 	sip_poke_all_peers();	
 	sip_send_all_registers();
 	
@@ -19348,6 +19402,7 @@
 	/* Unregister AMI actions */
 	ast_manager_unregister("SIPpeers");
 	ast_manager_unregister("SIPshowpeer");
+	ast_manager_unregister("SIPshowregistry");
 
 	dialoglist_lock();
 	/* Hangup all dialogs if they have an owner */

Modified: team/murf/utf8-whatif/channels/chan_usbradio.c
URL: http://svn.digium.com/view/asterisk/team/murf/utf8-whatif/channels/chan_usbradio.c?view=diff&rev=91150&r1=91149&r2=91150
==============================================================================
--- team/murf/utf8-whatif/channels/chan_usbradio.c (original)
+++ team/murf/utf8-whatif/channels/chan_usbradio.c Wed Dec  5 00:28:47 2007
@@ -79,15 +79,15 @@
 #include "./xpmr/xpmr.h"
 
 #if 0
-#define traceusb1(a) {printf a;}
+#define traceusb1(a, ...) ast_debug(4, a __VA_ARGS__)
 #else
-#define traceusb1(a)
+#define traceusb1(a, ...)
 #endif
 
 #if 0
-#define traceusb2(a) {printf a;}
+#define traceusb2(a, ...) ast_debug(4, a __VA_ARGS__)
 #else
-#define traceusb2(a)
+#define traceusb2(a, ...)
 #endif
 
 #ifdef __linux
@@ -300,7 +300,7 @@
 static FILE *ftxcapraw = NULL, *ftxcaptrace = NULL, *ftxoutraw = NULL;
 
 static int usbradio_debug;
-#if 0 //maw asdf sph
+#if 0 /* maw asdf sph */
 static int usbradio_debug_level = 0;
 #endif
 
@@ -356,12 +356,12 @@
 	 * nosound is set to disable the audio data from the channel
 	 * (so we can play the tones etc.).
 	 */
-	int sndcmd[2];				/* Sound command pipe */
-	int cursound;				/* index of sound to send */
-	int sampsent;				/* # of sound samples sent  */
-	int nosound;				/* set to block audio from the PBX */
-
-	int total_blocks;			/* total blocks in the output device */
+	int sndcmd[2];              /* Sound command pipe */
+	int cursound;               /* index of sound to send */
+	int sampsent;               /* # of sound samples sent  */
+	int nosound;                /* set to block audio from the PBX */
+
+	int total_blocks;           /* total blocks in the output device */
 	int sounddev;
 	enum { M_UNSET, M_FULL, M_READ, M_WRITE } duplex;
 	i16 cdMethod;
@@ -371,11 +371,11 @@
 	unsigned int queuesize;		/* max fragments in queue */
 	unsigned int frags;			/* parameter for SETFRAGMENT */
 
-	int warned;					/* various flags used for warnings */
+	int warned;                 /* various flags used for warnings */
 #define WARN_used_blocks	1
 #define WARN_speed		2
 #define WARN_frag		4
-	int w_errors;				/* overfull in the write path */
+	int w_errors;               /* overfull in the write path */
 	struct timeval lastopen;
 
 	int overridecontext;
@@ -385,8 +385,8 @@
 	 * be representable in 16 bits to avoid overflows.
 	 */
 #define	BOOST_SCALE	(1<<9)
-#define	BOOST_MAX	40			/* slightly less than 7 bits */
-	int boost;					/* input boost, scaled by BOOST_SCALE */
+#define	BOOST_MAX	40          /* slightly less than 7 bits */
+	int boost;                  /* input boost, scaled by BOOST_SCALE */
 	char devicenum;
 	int spkrmax;
 	int micmax;
@@ -394,96 +394,96 @@
 	pthread_t sthread;
 	pthread_t hidthread;
 
-	int stophid;
+	int     stophid;
 	struct ast_channel *owner;
-	char ext[AST_MAX_EXTENSION];
-	char ctx[AST_MAX_CONTEXT];
-	char language[MAX_LANGUAGE];
-	char cid_name[256];			/*XXX */
-	char cid_num[256];			/*XXX */
-	char mohinterpret[MAX_MUSICCLASS];
+	char    ext[AST_MAX_EXTENSION];
+	char    ctx[AST_MAX_CONTEXT];
+	char    language[MAX_LANGUAGE];
+	char    cid_name[256];          /* XXX */
+	char    cid_num[256];           /* XXX */
+	char    mohinterpret[MAX_MUSICCLASS];
 
 	/* buffers used in usbradio_write, 2 per int by 2 channels by 6 times oversampling (48KS/s) */
-	char usbradio_write_buf[FRAME_SIZE * 2 * 2 * 6];    
-	char usbradio_write_buf_1[FRAME_SIZE * 2 * 2* 6];
-
-	int usbradio_write_dst;
+	char    usbradio_write_buf[FRAME_SIZE * 2 * 2 * 6];
+	char    usbradio_write_buf_1[FRAME_SIZE * 2 * 2 * 6];
+
+	int     usbradio_write_dst;
 	/* buffers used in usbradio_read - AST_FRIENDLY_OFFSET space for headers
 	 * plus enough room for a full frame
 	 */
-	char usbradio_read_buf[FRAME_SIZE * (2 * 12) + AST_FRIENDLY_OFFSET];
-	char usbradio_read_buf_8k[FRAME_SIZE * 2 + AST_FRIENDLY_OFFSET];
-	int readpos;				/* read position above */
-	struct ast_frame read_f;	/* returned by usbradio_read */
+	char    usbradio_read_buf[FRAME_SIZE * (2 * 12) + AST_FRIENDLY_OFFSET];
+	char    usbradio_read_buf_8k[FRAME_SIZE * 2 + AST_FRIENDLY_OFFSET];
+	int     readpos;         /* read position above */
+	struct ast_frame read_f; /* returned by usbradio_read */
 	
 
-	char debuglevel;
-	char radioduplex;			
-
-	char lastrx;
-	char rxhidsq;
-	char rxcarrierdetect;		/*!< status from pmr channel */
-	char rxctcssdecode;			/*!< status from pmr channel */
-
-	char rxkeytype;
-	char rxkeyed;	  			/*!< indicates rx signal present */
-
-	char lasttx;
-	char txkeyed;				/*! tx key request from upper layers  */
-	char txchankey;
-	char txtestkey;
-
-	time_t lasthidtime;
+	char    debuglevel;
+	char    radioduplex;
+
+	char    lastrx;
+	char    rxhidsq;
+	char    rxcarrierdetect; /*!< status from pmr channel */
+	char    rxctcssdecode;   /*!< status from pmr channel */
+
+	char    rxkeytype;
+	char    rxkeyed;         /*!< indicates rx signal present */
+
+	char    lasttx;
+	char    txkeyed;         /*! tx key request from upper layers  */
+	char    txchankey;
+	char    txtestkey;
+
+	time_t  lasthidtime;
     struct ast_dsp *dsp;
 
-	t_pmr_chan	*pmrChan;
+	t_pmr_chan *pmrChan;
 
 	char    rxcpusaver;
 	char    txcpusaver;
 
-	char	rxdemod;
-	float	rxgain;
-	char 	rxcdtype;
-	char 	rxsdtype;
-	int	rxsquelchadj;   /*!< this copy needs to be here for initialization */
-	char	txtoctype;
+	char    rxdemod;
+	float   rxgain;
+	char    rxcdtype;
+	char    rxsdtype;
+	int     rxsquelchadj;    /*!< this copy needs to be here for initialization */
+	char    txtoctype;
 
 	char    txprelim;
-	float	txctcssgain;
-	char 	txmixa;
-	char 	txmixb;
-
-	char	invertptt;
-
-	char	rxctcssrelax;
-	float	rxctcssgain;
-	float 	rxctcssfreq;
-	float 	txctcssfreq;
-
-	int	rxmixerset;	   	
-	int 	rxboostset;
-	float	rxvoiceadj;
-	float	rxctcssadj;
-	int 	txmixaset;
-	int 	txmixbset;
+	float   txctcssgain;
+	char    txmixa;
+	char    txmixb;
+
+	char    invertptt;
+
+	char    rxctcssrelax;
+	float   rxctcssgain;
+	float   rxctcssfreq;
+	float   txctcssfreq;
+
+	int     rxmixerset;
+	int     rxboostset;
+	float   rxvoiceadj;
+	float   rxctcssadj;
+	int     txmixaset;
+	int     txmixbset;
 	int     txctcssadj;
 
 	int    	hdwtype;
-	int	hid_gpio_ctl;		
-	int	hid_gpio_ctl_loc;	
-	int	hid_io_cor; 		
-	int	hid_io_cor_loc; 	
-	int	hid_io_ctcss;		
-	int	hid_io_ctcss_loc; 	
-	int	hid_io_ptt; 		
-	int	hid_gpio_loc; 		
+	int     hid_gpio_ctl;
+	int     hid_gpio_ctl_loc;
+	int     hid_io_cor;
+	int     hid_io_cor_loc;
+	int     hid_io_ctcss;
+	int     hid_io_ctcss_loc;
+	int     hid_io_ptt;
+	int     hid_gpio_loc;
 
 	struct {
-	    	unsigned rxcapraw:1;
+		unsigned rxcapraw:1;
 		unsigned txcapraw:1;
 		unsigned txcap2:1;
 		unsigned rxcap2:1;
-	}b;
+	} b;
 };
 
 /* maw add additional defaults !!! */
@@ -505,8 +505,8 @@
 /*	DECLARE FUNCTION PROTOTYPES	*/
 
 static void store_txtoctype(struct chan_usbradio_pvt *o, const char *s);
-static int	hidhdwconfig(struct chan_usbradio_pvt *o);
-static int set_txctcss_level(struct chan_usbradio_pvt *o);
+static int  hidhdwconfig(struct chan_usbradio_pvt *o);
+static int  set_txctcss_level(struct chan_usbradio_pvt *o);
 static void pmrdump(struct chan_usbradio_pvt *o);
 static void mult_set(struct chan_usbradio_pvt *o);
 static int  mult_calc(int value);
@@ -519,7 +519,7 @@
 
 static char *usbradio_active;	 /* the active device */
 
-static int setformat(struct chan_usbradio_pvt *o, int mode);
+static int  setformat(struct chan_usbradio_pvt *o, int mode);
 
 static struct ast_channel *usbradio_request(const char *type, int format, void *data
 , int *cause);
@@ -566,15 +566,15 @@
 static int amixer_max(int devnum,char *param)
 {
 	int	rv,type;
-	char	str[100];
+	char str[15];
 	snd_hctl_t *hctl;
 	snd_ctl_elem_id_t *id;
 	snd_hctl_elem_t *elem;
 	snd_ctl_elem_info_t *info;
 
-	sprintf(str,"hw:%d",devnum);
+	snprintf(str, sizeof(str), "hw:%d", devnum);
 	if (snd_hctl_open(&hctl, str, 0))
-		return(-1);
+		return -1;
 	snd_hctl_load(hctl);
 	id = alloca(snd_ctl_elem_id_sizeof());
 	memset(id, 0, snd_ctl_elem_id_sizeof());
@@ -583,18 +583,18 @@
 	elem = snd_hctl_find_elem(hctl, id);
 	if (!elem) {
 		snd_hctl_close(hctl);
-		return(-1);
+		return -1;
 	}
 	info = alloca(snd_ctl_elem_info_sizeof());
 	memset(info, 0, snd_ctl_elem_info_sizeof());
 	snd_hctl_elem_info(elem,info);
 	type = snd_ctl_elem_info_get_type(info);
 	rv = 0;
-	switch(type) {
-	    case SND_CTL_ELEM_TYPE_INTEGER:
+	switch (type) {
+	case SND_CTL_ELEM_TYPE_INTEGER:
 		rv = snd_ctl_elem_info_get_max(info);
 		break;
-	    case SND_CTL_ELEM_TYPE_BOOLEAN:
+	case SND_CTL_ELEM_TYPE_BOOLEAN:
 		rv = 1;
 		break;
 	}
@@ -608,19 +608,19 @@
 
 Note: must add -lasound to end of linkage */
 
-static int setamixer(int devnum,char *param, int v1, int v2)
+static int setamixer(int devnum, char *param, int v1, int v2)
 {
 	int	type;
-	char	str[100];
+	char str[15];
 	snd_hctl_t *hctl;
 	snd_ctl_elem_id_t *id;
 	snd_ctl_elem_value_t *control;
 	snd_hctl_elem_t *elem;
 	snd_ctl_elem_info_t *info;
 
-	sprintf(str,"hw:%d",devnum);
+	snprintf(str, sizeof(str), "hw:%d", devnum);
 	if (snd_hctl_open(&hctl, str, 0))
-		return(-1);
+		return -1;
 	snd_hctl_load(hctl);
 	id = alloca(snd_ctl_elem_id_sizeof());
 	memset(id, 0, snd_ctl_elem_id_sizeof());
@@ -629,7 +629,7 @@
 	elem = snd_hctl_find_elem(hctl, id);
 	if (!elem) {
 		snd_hctl_close(hctl);
-		return(-1);
+		return -1;
 	}
 	info = alloca(snd_ctl_elem_info_sizeof());
 	memset(info, 0, snd_ctl_elem_info_sizeof());
@@ -638,12 +638,12 @@
 	control = alloca(snd_ctl_elem_value_sizeof());
 	memset(control, 0, snd_ctl_elem_value_sizeof());
 	snd_ctl_elem_value_set_id(control, id);    
-	switch(type) {
-	    case SND_CTL_ELEM_TYPE_INTEGER:
+	switch (type) {
+	case SND_CTL_ELEM_TYPE_INTEGER:
 		snd_ctl_elem_value_set_integer(control, 0, v1);
 		if (v2 > 0) snd_ctl_elem_value_set_integer(control, 1, v2);
 		break;
-	    case SND_CTL_ELEM_TYPE_BOOLEAN:
+	case SND_CTL_ELEM_TYPE_BOOLEAN:
 		snd_ctl_elem_value_set_integer(control, 0, (v1 != 0));
 		break;
 	}
@@ -652,29 +652,29 @@
 		return(-1);
 	}
 	snd_hctl_close(hctl);
-	return(0);
+	return 0;
 }
 
 static void hid_set_outputs(struct usb_dev_handle *handle,
          unsigned char *outputs)
 {
 	usb_control_msg(handle,
-	      USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE,
-	      HID_REPORT_SET,
-	      0 + (HID_RT_OUTPUT << 8),
-	      C108_HID_INTERFACE,
-	      (char*)outputs, 4, 5000);
+		USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE,
+		HID_REPORT_SET,
+		0 + (HID_RT_OUTPUT << 8),
+		C108_HID_INTERFACE,
+		(char *)outputs, 4, 5000);
 }
 
 static void hid_get_inputs(struct usb_dev_handle *handle,
          unsigned char *inputs)
 {
 	usb_control_msg(handle,
-	      USB_ENDPOINT_IN + USB_TYPE_CLASS + USB_RECIP_INTERFACE,
-	      HID_REPORT_GET,
-	      0 + (HID_RT_INPUT << 8),
-	      C108_HID_INTERFACE,
-	      (char*)inputs, 4, 5000);
+		USB_ENDPOINT_IN + USB_TYPE_CLASS + USB_RECIP_INTERFACE,
+		HID_REPORT_GET,
+		0 + (HID_RT_INPUT << 8),
+		C108_HID_INTERFACE,
+		(char *)inputs, 4, 5000);
 }
 
 static struct usb_device *hid_device_init(void)
@@ -696,38 +696,33 @@
 
 static int hidhdwconfig(struct chan_usbradio_pvt *o)
 {

[... 2727 lines stripped ...]



More information about the asterisk-commits mailing list