[asterisk-commits] rmudgett: branch rmudgett/external_mwi r404373 - in /team/rmudgett/external_m...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 19 12:01:51 CST 2013


Author: rmudgett
Date: Thu Dec 19 12:01:47 2013
New Revision: 404373

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404373
Log:
Resolve conflicts.  Restart automerge.

Modified:
    team/rmudgett/external_mwi/   (props changed)
    team/rmudgett/external_mwi/CHANGES
    team/rmudgett/external_mwi/UPGRADE-12.txt
    team/rmudgett/external_mwi/addons/chan_ooh323.c
    team/rmudgett/external_mwi/apps/app_voicemail.c
    team/rmudgett/external_mwi/channels/chan_dahdi.h
    team/rmudgett/external_mwi/channels/chan_mgcp.c
    team/rmudgett/external_mwi/channels/chan_sip.c
    team/rmudgett/external_mwi/channels/chan_skinny.c
    team/rmudgett/external_mwi/channels/h323/chan_h323.h
    team/rmudgett/external_mwi/include/asterisk/app.h
    team/rmudgett/external_mwi/include/asterisk/autochan.h
    team/rmudgett/external_mwi/include/asterisk/channel.h
    team/rmudgett/external_mwi/include/asterisk/udptl.h
    team/rmudgett/external_mwi/main/channel.c
    team/rmudgett/external_mwi/main/db.c
    team/rmudgett/external_mwi/main/udptl.c
    team/rmudgett/external_mwi/res/res_fax.c
    team/rmudgett/external_mwi/res/res_pjsip.c

Propchange: team/rmudgett/external_mwi/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/rmudgett/external_mwi/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Propchange: team/rmudgett/external_mwi/
------------------------------------------------------------------------------
--- external_mwi-integrated (original)
+++ external_mwi-integrated Thu Dec 19 12:01:47 2013
@@ -1,1 +1,1 @@
-/trunk:1-404341
+/trunk:1-404368

Modified: team/rmudgett/external_mwi/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/CHANGES?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/CHANGES (original)
+++ team/rmudgett/external_mwi/CHANGES Thu Dec 19 12:01:47 2013
@@ -410,6 +410,12 @@
 
 VoiceMail
 ------------------
+ * Mailboxes defined by app_voicemail MUST be referenced by the rest of the
+   system as mailbox at context.  The rest of the system cannot add @default
+   to mailbox identifiers for app_voicemail that do not specify a context
+   any longer.  It is a mailbox identifier format that should only be
+   interpreted by app_voicemail.
+
  * The voicemail.conf configuration file now has an 'alias' configuration
    parameter for use with the Directory application. The voicemail realtime
    database table schema has also been updated with an 'alias' column.
@@ -893,6 +899,8 @@
  * Added the CLI command 'dahdi create channels'. A range of channels can be
    specified to be created, or the keyword 'new' can be used to add channels
    not yet created.
+
+ * Added mwi_vm_boxes that also must be configured for ISDN MWI to be enabled.
 
 chan_iax2
 ------------------
@@ -1039,6 +1047,14 @@
 ------------------
  * The SPEECH_ENGINE function now supports read operations. When read from, it
    will return the current value of the requested attribute.
+
+VMCOUNT:
+------------------
+ * Mailboxes defined by app_voicemail MUST be referenced by the rest of the
+   system as mailbox at context.  The rest of the system cannot add @default
+   to mailbox identifiers for app_voicemail that do not specify a context
+   any longer.  It is a mailbox identifier format that should only be
+   interpreted by app_voicemail.
 
 
 Resources

Modified: team/rmudgett/external_mwi/UPGRADE-12.txt
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/UPGRADE-12.txt?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/UPGRADE-12.txt (original)
+++ team/rmudgett/external_mwi/UPGRADE-12.txt Thu Dec 19 12:01:47 2013
@@ -181,6 +181,12 @@
  - This application is deprecated in favor of CHANNEL(amaflags).
 
 VoiceMail:
+ - Mailboxes defined by app_voicemail MUST be referenced by the rest of the
+   system as mailbox at context.  The rest of the system cannot add @default
+   to mailbox identifiers for app_voicemail that do not specify a context
+   any longer.  It is a mailbox identifier format that should only be
+   interpreted by app_voicemail.
+
  - The voicemail.conf configuration file now has an 'alias' configuration
    parameter for use with the Directory application. The voicemail realtime
    database table schema has also been updated with an 'alias' column. Systems
@@ -207,6 +213,12 @@
  - The CLI command 'dahdi destroy channel' is now 'dahdi destroy channels'.
    A range of channels can be specified to be destroyed. Note that this command
    should only be used if you understand the risks it entails.
+
+ - The script specified by the chan_dahdi.conf mwimonitornotify option now gets
+   the exact configured mailbox name.  For app_voicemail mailboxes this is
+   mailbox at context.
+
+ - Added mwi_vm_boxes that also must be configured for ISDN MWI to be enabled.
 
 chan_local:
  - The /b option has been removed.
@@ -442,6 +454,13 @@
  - The 's' option has been removed, as LOCKED semantics no longer exist in the
    CDR engine.
 
+VMCOUNT:
+ - Mailboxes defined by app_voicemail MUST be referenced by the rest of the
+   system as mailbox at context.  The rest of the system cannot add @default
+   to mailbox identifiers for app_voicemail that do not specify a context
+   any longer.  It is a mailbox identifier format that should only be
+   interpreted by app_voicemail.
+
 res_rtp_asterisk:
  - ICE/STUN/TURN support in res_rtp_asterisk has been made optional. To enable
    them, an Asterisk-specific version of PJSIP needs to be installed.

Modified: team/rmudgett/external_mwi/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/addons/chan_ooh323.c?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/addons/chan_ooh323.c (original)
+++ team/rmudgett/external_mwi/addons/chan_ooh323.c Thu Dec 19 12:01:47 2013
@@ -91,9 +91,6 @@
           struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, const struct ast_format_cap *codecs, int nat_active);
 static void ooh323_get_codec(struct ast_channel *chan, struct ast_format_cap *result);
 void setup_rtp_remote(ooCallData *call, const char *remoteIp, int remotePort);
-
-static struct ast_udptl *ooh323_get_udptl_peer(struct ast_channel *chan);
-static int ooh323_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl);
 
 static void print_codec_to_cli(int fd, struct ast_codec_pref *pref);
 
@@ -129,13 +126,6 @@
 	.update_peer = ooh323_set_rtp_peer,
 	.get_codec = ooh323_get_codec,
 };
-
-static struct ast_udptl_protocol ooh323_udptl = {
-	.type = "H323",
-	.get_udptl_info = ooh323_get_udptl_peer,
-	.set_udptl_peer = ooh323_set_udptl_peer,
-};
-
 
 
 struct ooh323_user;
@@ -3796,7 +3786,6 @@
 			return 0;
 		}
 		ast_rtp_glue_register(&ooh323_rtp);
-		ast_udptl_proto_register(&ooh323_udptl);
 		ast_cli_register_multiple(cli_ooh323, sizeof(cli_ooh323) / sizeof(struct ast_cli_entry));
 
 		 /* fire up the H.323 Endpoint */		 
@@ -4233,7 +4222,6 @@
 	/* First, take us out of the channel loop */
 	ast_cli_unregister_multiple(cli_ooh323, sizeof(cli_ooh323) / sizeof(struct ast_cli_entry));
 	ast_rtp_glue_unregister(&ooh323_rtp);
-	ast_udptl_proto_unregister(&ooh323_udptl);
 	ast_channel_unregister(&ooh323_tech);
 #if 0
 	ast_unregister_atexit(&ast_ooh323c_exit);
@@ -4784,41 +4772,6 @@
 /*
  udptl handling functions
  */
-
-static struct ast_udptl *ooh323_get_udptl_peer(struct ast_channel *chan)
-{
-	struct ooh323_pvt *p;
-	struct ast_udptl *udptl = NULL;
-
-	p = ast_channel_tech_pvt(chan);
-	if (!p)
-		return NULL;
-
-	ast_mutex_lock(&p->lock);
-	if (p->udptl)
-		udptl = p->udptl;
-	ast_mutex_unlock(&p->lock);
-	return udptl;
-}
-
-static int ooh323_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
-{
-	struct ooh323_pvt *p;
-
-	p = ast_channel_tech_pvt(chan);
-	if (!p)
-		return -1;
-	ast_mutex_lock(&p->lock);
-
-	if (udptl) {
-		ast_udptl_get_peer(udptl, &p->udptlredirip);
-	} else
-		memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
-
-	ast_mutex_unlock(&p->lock);
-	/* free(callToken); */
-	return 0;
-}
 
 void setup_udptl_connection(ooCallData *call, const char *remoteIp, 
 								  int remotePort)

Modified: team/rmudgett/external_mwi/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/apps/app_voicemail.c?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/apps/app_voicemail.c (original)
+++ team/rmudgett/external_mwi/apps/app_voicemail.c Thu Dec 19 12:01:47 2013
@@ -1112,6 +1112,34 @@
 static int vm_test_create_user(const char *context, const char *mailbox);
 #endif
 
+/*!
+ * \internal
+ * \brief Parse the given mailbox_id into mailbox and context.
+ * \since 12.0.0
+ *
+ * \param mailbox_id The mailbox at context string to separate.
+ * \param mailbox Where the mailbox part will start.
+ * \param context Where the context part will start.  ("default" if not present)
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int separate_mailbox(char *mailbox_id, char **mailbox, char **context)
+{
+	if (ast_strlen_zero(mailbox_id) || !mailbox || !context) {
+		return -1;
+	}
+	*context = mailbox_id;
+	*mailbox = strsep(context, "@");
+	if (ast_strlen_zero(*mailbox)) {
+		return -1;
+	}
+	if (ast_strlen_zero(*context)) {
+		*context = "default";
+	}
+	return 0;
+}
+
 struct ao2_container *inprocess_container;
 
 struct inprocess {
@@ -2514,16 +2542,9 @@
 	char *context;
 	char *mailbox;
 
-	if (ast_strlen_zero(mailbox_id)) {
+	if (ast_strlen_zero(mailbox_id)
+		|| separate_mailbox(ast_strdupa(mailbox_id), &mailbox, &context)) {
 		return 0;
-	}
-	context = ast_strdupa(mailbox_id);
-	mailbox = strsep(&context, "@");
-	if (ast_strlen_zero(mailbox)) {
-		return 0;
-	}
-	if (ast_strlen_zero(context)) {
-		context = "default";
 	}
 
 	if (ast_strlen_zero(folder) || !strcmp(folder, "INBOX")) {
@@ -5649,16 +5670,9 @@
 	struct generic_prepare_struct gps = { .sql = sql, .argc = 0 };
 
 	/* If no mailbox, return immediately */
-	if (ast_strlen_zero(mailbox_id)) {
+	if (ast_strlen_zero(mailbox_id)
+		|| separate_mailbox(ast_strdupa(mailbox_id), &mailbox, &context)) {
 		return 0;
-	}
-	context = ast_strdupa(mailbox_id);
-	mailbox = strsep(&context, "@");
-	if (ast_strlen_zero(mailbox)) {
-		return 0;
-	}
-	if (ast_strlen_zero(context)) {
-		context = "default";
 	}
 
 	if (ast_strlen_zero(folder)) {
@@ -5810,16 +5824,9 @@
 	char *context;
 	char *mailbox;
 
-	if (ast_strlen_zero(mailbox_id)) {
+	if (ast_strlen_zero(mailbox_id)
+		|| separate_mailbox(ast_strdupa(mailbox_id), &mailbox, &context)) {
 		return 0;
-	}
-	context = ast_strdupa(mailbox_id);
-	mailbox = strsep(&context, "@");
-	if (ast_strlen_zero(mailbox)) {
-		return 0;
-	}
-	if (ast_strlen_zero(context)) {
-		context = "default";
 	}
 
 	return __has_voicemail(context, mailbox, folder, 0) + (folder && strcmp(folder, "INBOX") ? 0 : __has_voicemail(context, mailbox, "Urgent", 0));
@@ -7784,13 +7791,11 @@
 
 static void queue_mwi_event(const char *channel_id, const char *box, int urgent, int new, int old)
 {
-	char *mailbox, *context;
-
-	/* Strip off @default */
-	context = mailbox = ast_strdupa(box);
-	strsep(&context, "@");
-	if (ast_strlen_zero(context)) {
-		context = "default";
+	char *mailbox;
+	char *context;
+
+	if (separate_mailbox(ast_strdupa(box), &mailbox, &context)) {
+		return;
 	}
 
 	ast_publish_mwi_state_channel(mailbox, context, new + urgent, old, channel_id);
@@ -12041,7 +12046,9 @@
 {
 	struct ast_vm_user svm;
 	struct ast_vm_user *vmu = NULL;
-	char *tmp, *mailbox, *context, *parse;
+	char *parse;
+	char *mailbox;
+	char *context;
 	int res = 0;
 
 	AST_DECLARE_APP_ARGS(arg,
@@ -12060,17 +12067,11 @@
 	parse = ast_strdupa(args);
 	AST_STANDARD_APP_ARGS(arg, parse);
 
-	if (ast_strlen_zero(arg.mailbox_context) || ast_strlen_zero(arg.attribute)) {
+	if (ast_strlen_zero(arg.mailbox_context)
+		|| ast_strlen_zero(arg.attribute)
+		|| separate_mailbox(ast_strdupa(arg.mailbox_context), &mailbox, &context)) {
 		ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
 		return -1;
-	}
-
-	tmp = ast_strdupa(arg.mailbox_context);
-	mailbox = strsep(&tmp, "@");
-	context = strsep(&tmp, "");
-
-	if (ast_strlen_zero(context)) {
-		 context = "default";
 	}
 
 	vmu = find_user(&svm, context, mailbox);
@@ -12639,14 +12640,17 @@
 static void mwi_sub_event_cb(struct stasis_subscription_change *change)
 {
 	struct mwi_sub_task *mwist;
-	char *context = ast_strdupa(stasis_topic_name(change->topic));
+	char *context;
 	char *mailbox;
 
-	if ((mwist = ast_calloc(1, (sizeof(*mwist)))) == NULL) {
+	mwist = ast_calloc(1, (sizeof(*mwist)));
+	if (!mwist) {
 		return;
 	}
 
-	mailbox = strsep(&context, "@");
+	if (separate_mailbox(ast_strdupa(stasis_topic_name(change->topic)), &mailbox, &context)) {
+		return;
+	}
 
 	mwist->mailbox = ast_strdup(mailbox);
 	mwist->context = ast_strdup(context);
@@ -13715,26 +13719,20 @@
 static int vmsayname_exec(struct ast_channel *chan, const char *data)
 {
 	char *context;
-	char *args_copy;
+	char *mailbox;
 	int res;
 
-	if (ast_strlen_zero(data)) {
+	if (ast_strlen_zero(data)
+		|| separate_mailbox(ast_strdupa(data), &mailbox, &context)) {
 		ast_log(LOG_WARNING, "VMSayName requires argument mailbox at context\n");
 		return -1;
 	}
 
-	args_copy = ast_strdupa(data);
-	if ((context = strchr(args_copy, '@'))) {
-		*context++ = '\0';
-	} else {
-		context = "default";
-	}
-
-	if ((res = sayname(chan, args_copy, context)) < 0) {
-		ast_debug(3, "Greeting not found for '%s@%s', falling back to mailbox number.\n", args_copy, context);
+	if ((res = sayname(chan, mailbox, context)) < 0) {
+		ast_debug(3, "Greeting not found for '%s@%s', falling back to mailbox number.\n", mailbox, context);
 		res = ast_stream_and_wait(chan, "vm-extension", AST_DIGIT_ANY);
 		if (!res) {
-			res = ast_say_character_str(chan, args_copy, AST_DIGIT_ANY, ast_channel_language(chan), AST_SAY_CASE_NONE);
+			res = ast_say_character_str(chan, mailbox, AST_DIGIT_ANY, ast_channel_language(chan), AST_SAY_CASE_NONE);
 		}
 	}
 

Modified: team/rmudgett/external_mwi/channels/chan_dahdi.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/chan_dahdi.h?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/channels/chan_dahdi.h (original)
+++ team/rmudgett/external_mwi/channels/chan_dahdi.h Thu Dec 19 12:01:47 2013
@@ -38,6 +38,7 @@
 
 #include "asterisk/channel.h"
 #include "asterisk/dsp.h"
+#include "asterisk/app.h"
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
@@ -621,7 +622,7 @@
 	 * \brief Voice mailbox location.
 	 * \note Set from the "mailbox" string read in from chan_dahdi.conf
 	 */
-	char mailbox[AST_MAX_EXTENSION];
+	char mailbox[AST_MAX_MAILBOX_UNIQUEID];
 	/*! \brief Opaque event subscription parameters for message waiting indication support. */
 	struct stasis_subscription *mwi_event_sub;
 	/*! \brief Delayed dialing for E911.  Overlap digits for ISDN. */

Modified: team/rmudgett/external_mwi/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/chan_mgcp.c?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/channels/chan_mgcp.c (original)
+++ team/rmudgett/external_mwi/channels/chan_mgcp.c Thu Dec 19 12:01:47 2013
@@ -202,7 +202,7 @@
 
 static char accountcode[AST_MAX_ACCOUNT_CODE] = "";
 
-static char mailbox[AST_MAX_EXTENSION];
+static char mailbox[AST_MAX_MAILBOX_UNIQUEID];
 
 static int amaflags = 0;
 

Modified: team/rmudgett/external_mwi/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/chan_sip.c?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/channels/chan_sip.c (original)
+++ team/rmudgett/external_mwi/channels/chan_sip.c Thu Dec 19 12:01:47 2013
@@ -1535,8 +1535,6 @@
 
 /*------ T38 Support --------- */
 static int transmit_response_with_t38_sdp(struct sip_pvt *p, char *msg, struct sip_request *req, int retrans);
-static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan);
-static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl);
 static void change_t38_state(struct sip_pvt *p, int state);
 
 /*------ Session-Timers functions --------- */
@@ -3570,13 +3568,6 @@
 	ast_debug(3, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount + 1);
 	return ASTOBJ_REF(reg);	/* Add pointer to registry in packet */
 }
-
-/*! \brief Interface structure with callbacks used to connect to UDPTL module*/
-static struct ast_udptl_protocol sip_udptl = {
-	.type = "SIP",
-	.get_udptl_info = sip_get_udptl_peer,
-	.set_udptl_peer = sip_set_udptl_peer,
-};
 
 static void append_history_full(struct sip_pvt *p, const char *fmt, ...)
 	__attribute__((format(printf, 2, 3)));
@@ -30832,7 +30823,7 @@
 					if (strchr(name, '@')) {
 						add_peer_mailboxes(peer, name);
 					} else {
-						char mailbox[80];
+						char mailbox[AST_MAX_MAILBOX_UNIQUEID];
 
 						snprintf(mailbox, sizeof(mailbox), "%s at default", name);
 						add_peer_mailboxes(peer, mailbox);
@@ -32457,67 +32448,6 @@
 	return 0;
 }
 
-static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan)
-{
-	struct sip_pvt *p;
-	struct ast_udptl *udptl = NULL;
-
-	p = ast_channel_tech_pvt(chan);
-	if (!p) {
-		return NULL;
-	}
-
-	sip_pvt_lock(p);
-	if (p->udptl && ast_test_flag(&p->flags[0], SIP_DIRECT_MEDIA)) {
-		udptl = p->udptl;
-	}
-	sip_pvt_unlock(p);
-	return udptl;
-}
-
-static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
-{
-	struct sip_pvt *p;
-
-	/* Lock the channel and the private safely. */
-	ast_channel_lock(chan);
-	p = ast_channel_tech_pvt(chan);
-	if (!p) {
-		ast_channel_unlock(chan);
-		return -1;
-	}
-	sip_pvt_lock(p);
-	if (p->owner != chan) {
-		/* I suppose it could be argued that if this happens it is a bug. */
-		ast_debug(1, "The private is not owned by channel %s anymore.\n", ast_channel_name(chan));
-		sip_pvt_unlock(p);
-		ast_channel_unlock(chan);
-		return 0;
-	}
-
-	if (udptl) {
-		ast_udptl_get_peer(udptl, &p->udptlredirip);
-	} else {
-		memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
-	}
-	if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
-		if (!p->pendinginvite) {
-			ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s\n",
-					p->callid, ast_sockaddr_stringify(udptl ? &p->udptlredirip : &p->ourip));
-			transmit_reinvite_with_sdp(p, TRUE, FALSE);
-		} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
-			ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s\n",
-					p->callid, ast_sockaddr_stringify(udptl ? &p->udptlredirip : &p->ourip));
-			ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
-		}
-	}
-	/* Reset lastrtprx timer */
-	p->lastrtprx = p->lastrtptx = time(NULL);
-	sip_pvt_unlock(p);
-	ast_channel_unlock(chan);
-	return 0;
-}
-
 static int sip_allow_anyrtp_remote(struct ast_channel *chan1, struct ast_rtp_instance *instance, const char *rtptype)
 {
 	struct sip_pvt *p;
@@ -34511,9 +34441,6 @@
 	/* Register all CLI functions for SIP */
 	ast_cli_register_multiple(cli_sip, ARRAY_LEN(cli_sip));
 
-	/* Tell the UDPTL subdriver that we're here */
-	ast_udptl_proto_register(&sip_udptl);
-
 	/* Tell the RTP engine about our RTP glue */
 	ast_rtp_glue_register(&sip_rtp_glue);
 
@@ -34644,9 +34571,6 @@
 	/* Unregister CLI commands */
 	ast_cli_unregister_multiple(cli_sip, ARRAY_LEN(cli_sip));
 
-	/* Disconnect from UDPTL */
-	ast_udptl_proto_unregister(&sip_udptl);
-
 	/* Disconnect from RTP engine */
 	ast_rtp_glue_unregister(&sip_rtp_glue);
 

Modified: team/rmudgett/external_mwi/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/chan_skinny.c?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/channels/chan_skinny.c (original)
+++ team/rmudgett/external_mwi/channels/chan_skinny.c Thu Dec 19 12:01:47 2013
@@ -1429,7 +1429,7 @@
 	char call_forward_all[AST_MAX_EXTENSION];	\
 	char call_forward_busy[AST_MAX_EXTENSION];	\
 	char call_forward_noanswer[AST_MAX_EXTENSION];	\
-	char mailbox[AST_MAX_EXTENSION];		\
+	char mailbox[AST_MAX_MAILBOX_UNIQUEID];		\
 	char vmexten[AST_MAX_EXTENSION];		\
 	char regexten[AST_MAX_EXTENSION];		\
 	char regcontext[AST_MAX_CONTEXT];		\

Modified: team/rmudgett/external_mwi/channels/h323/chan_h323.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/h323/chan_h323.h?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/channels/h323/chan_h323.h (original)
+++ team/rmudgett/external_mwi/channels/h323/chan_h323.h Thu Dec 19 12:01:47 2013
@@ -31,6 +31,7 @@
 
 #include <arpa/inet.h>
 #include "asterisk/format.h"
+#include "asterisk/app.h"
 
 /*
  * Enable support for sending/reception of tunnelled Q.SIG messages and
@@ -94,7 +95,7 @@
    All peers are registered to a GK if there is one */
 struct oh323_peer {
 	ASTOBJ_COMPONENTS(struct oh323_peer);
-	char mailbox[80];
+	char mailbox[AST_MAX_MAILBOX_UNIQUEID];
 	int delme;
 	struct sockaddr_in addr;
 	struct ast_ha *ha;

Modified: team/rmudgett/external_mwi/include/asterisk/app.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/include/asterisk/app.h?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/include/asterisk/app.h (original)
+++ team/rmudgett/external_mwi/include/asterisk/app.h Thu Dec 19 12:01:47 2013
@@ -567,7 +567,7 @@
 
 /*!
  * \brief Determine if a voicemail provider is registered.
- * \since 13.0.0
+ * \since 12.0.0
  *
  * \retval 0 if no privider registered.
  * \retval 1 if a privider is registered.

Modified: team/rmudgett/external_mwi/include/asterisk/autochan.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/include/asterisk/autochan.h?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/include/asterisk/autochan.h (original)
+++ team/rmudgett/external_mwi/include/asterisk/autochan.h Thu Dec 19 12:01:47 2013
@@ -98,8 +98,9 @@
  * \details
  * Traverses the list of autochans. All autochans which point to
  * old_chan will be updated to point to new_chan instead. Currently
- * this is only called from ast_do_masquerade in channel.c.
- * 
+ * this is only called during an ast_channel_move() operation in
+ * channel.c.
+ *
  * \pre Both channels must be locked before calling this function.
  *
  * \param old_chan The channel that autochans may currently point to

Modified: team/rmudgett/external_mwi/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/include/asterisk/channel.h?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/include/asterisk/channel.h (original)
+++ team/rmudgett/external_mwi/include/asterisk/channel.h Thu Dec 19 12:01:47 2013
@@ -2014,26 +2014,6 @@
 int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
 
 /*!
- * \brief Weird function made for call transfers
- *
- * \param original channel to make a copy of
- * \param clone copy of the original channel
- *
- * \details
- * This is a very strange and freaky function used primarily for transfer.  Suppose that
- * "original" and "clone" are two channels in random situations.  This function takes
- * the guts out of "clone" and puts them into the "original" channel, then alerts the
- * channel driver of the change, asking it to fixup any private information (like the
- * p->owner pointer) that is affected by the change.  The physical layer of the original
- * channel is hung up.
- *
- * \note Neither channel passed here should be locked before
- * calling this function.  This function performs deadlock
- * avoidance involving these two channels.
- */
-int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone);
-
-/*!
  * \brief Gives the string form of a given cause code.
  *
  * \param state cause to get the description of
@@ -2305,18 +2285,6 @@
  * \param dest destination extension for transfer
  */
 int ast_transfer(struct ast_channel *chan, char *dest);
-
-/*!
- * \brief Start masquerading a channel
- * \note absolutely _NO_ channel locks should be held before calling this function.
- * \details
- * XXX This is a seriously whacked out operation.  We're essentially putting the guts of
- *     the clone channel into the original channel.  Start by killing off the original
- *     channel's backend.   I'm not sure we're going to keep this function, because
- *     while the features are nice, the cost is very high in terms of pure nastiness. XXX
- * \param chan Channel to masquerade
- */
-void ast_do_masquerade(struct ast_channel *chan);
 
 /*!
  * \brief Inherits channel variable from parent to child channel

Modified: team/rmudgett/external_mwi/include/asterisk/udptl.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/include/asterisk/udptl.h?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/include/asterisk/udptl.h (original)
+++ team/rmudgett/external_mwi/include/asterisk/udptl.h Thu Dec 19 12:01:47 2013
@@ -43,15 +43,6 @@
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
-
-struct ast_udptl_protocol {
-	/*! \brief Get UDPTL struct, or NULL if unwilling to transfer */
-	struct ast_udptl *(*get_udptl_info)(struct ast_channel *chan);
-	/*! \brief Set UDPTL peer */
-	int (* const set_udptl_peer)(struct ast_channel *chan, struct ast_udptl *peer);
-	const char * const type;
-	AST_RWLIST_ENTRY(ast_udptl_protocol) list;
-};
 
 struct ast_udptl;
 
@@ -133,13 +124,6 @@
 
 void ast_udptl_setnat(struct ast_udptl *udptl, int nat);
 
-int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
-		     struct ast_frame **fo, struct ast_channel **rc);
-
-int ast_udptl_proto_register(struct ast_udptl_protocol *proto);
-
-void ast_udptl_proto_unregister(struct ast_udptl_protocol *proto);
-
 void ast_udptl_stop(struct ast_udptl *udptl);
 
 void ast_udptl_init(void);

Modified: team/rmudgett/external_mwi/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/main/channel.c?view=diff&rev=404373&r1=404372&r2=404373
==============================================================================
--- team/rmudgett/external_mwi/main/channel.c (original)
+++ team/rmudgett/external_mwi/main/channel.c Thu Dec 19 12:01:47 2013
@@ -2682,30 +2682,8 @@
 
 	ast_channel_lock(chan);
 
-	/*
-	 * Do the masquerade if someone is setup to masquerade into us.
-	 *
-	 * NOTE: We must hold the channel lock after testing for a
-	 * pending masquerade and setting the channel as a zombie to
-	 * prevent ast_channel_masquerade() from setting up a
-	 * masquerade with a dead channel.
-	 */
-	while (ast_channel_masq(chan)) {
-		ast_channel_unlock(chan);
-		ast_do_masquerade(chan);
-		ast_channel_lock(chan);
-	}
-
-	if (ast_channel_masqr(chan)) {
-		/*
-		 * This channel is one which will be masqueraded into something.
-		 * Mark it as a zombie already so ast_do_masquerade() will know
-		 * to free it later.
-		 */
-		ast_set_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE);
-		destroy_hooks(chan);
-		ast_channel_unlock(chan);
-		return;
+	while (ast_channel_masq(chan) || ast_channel_masqr(chan))  {
+		CHANNEL_DEADLOCK_AVOIDANCE(chan);
 	}
 
 	/* Mark as a zombie so a masquerade cannot be setup on this channel. */
@@ -3087,12 +3065,7 @@
 		return NULL;
 	}
 
-	/* Perform any pending masquerades */
 	for (x = 0; x < n; x++) {
-		while (ast_channel_masq(c[x])) {
-			ast_do_masquerade(c[x]);
-		}
-
 		ast_channel_lock(c[x]);
 		if (!ast_tvzero(*ast_channel_whentohangup(c[x]))) {
 			if (ast_tvzero(whentohangup))
@@ -3232,12 +3205,6 @@
 	struct ast_channel *winner = NULL;
 	struct ast_epoll_data *aed = NULL;
 
-
-	/* See if this channel needs to be masqueraded */
-	while (ast_channel_masq(chan)) {
-		ast_do_masquerade(chan);
-	}
-
 	ast_channel_lock(chan);
 	/* Figure out their timeout */
 	if (!ast_tvzero(*ast_channel_whentohangup(chan))) {
@@ -3319,10 +3286,6 @@
 	struct ast_channel *winner = NULL;
 
 	for (i = 0; i < n; i++) {
-		while (ast_channel_masq(c[i])) {
-			ast_do_masquerade(c[i]);
-		}
-
 		ast_channel_lock(c[i]);
 		if (!ast_tvzero(*ast_channel_whentohangup(c[i]))) {
 			if (whentohangup == 0) {
@@ -3767,13 +3730,6 @@
 	/* this function is very long so make sure there is only one return
 	 * point at the end (there are only two exceptions to this).
 	 */
-
-	if (ast_channel_masq(chan)) {
-		ast_do_masquerade(chan);
-		return &ast_null_frame;
-	}
-
-	/* if here, no masq has happened, lock the channel and proceed */
 	ast_channel_lock(chan);
 
 	/* Stop if we're a zombie or need a soft hangup */
@@ -4991,17 +4947,6 @@
 	if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) || ast_check_hangup(chan))
 		goto done;
 
-	/* Handle any pending masquerades */
-	while (ast_channel_masq(chan)) {
-		ast_channel_unlock(chan);
-		ast_do_masquerade(chan);
-		ast_channel_lock(chan);
-	}
-	if (ast_channel_masqr(chan)) {
-		res = 0;	/* XXX explain, why 0 ? */
-		goto done;
-	}
-
 	/* Perform the framehook write event here. After the frame enters the framehook list
 	 * there is no telling what will happen, how awesome is that!!! */
 	if (!(fr = ast_framehook_list_write_event(ast_channel_framehooks(chan), fr))) {
@@ -6262,60 +6207,6 @@
 	return 0;
 }
 
-int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clonechan)
-{
-	int res = -1;
-
-	if (original == clonechan) {
-		ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n",
-			ast_channel_name(original));
-		return -1;
-	}
-
-	ast_channel_lock_both(original, clonechan);
-
-	if (ast_test_flag(ast_channel_flags(original), AST_FLAG_ZOMBIE)
-		|| ast_test_flag(ast_channel_flags(clonechan), AST_FLAG_ZOMBIE)) {
-		/* Zombies! Run! */
-		ast_log(LOG_WARNING,
-			"Can't setup masquerade. One or both channels is dead. (%s <-- %s)\n",
-			ast_channel_name(original), ast_channel_name(clonechan));
-		ast_channel_unlock(clonechan);
-		ast_channel_unlock(original);
-		return -1;
-	}
-
-	ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n",
-		ast_channel_name(clonechan), ast_channel_name(original));
-
-	if (!ast_channel_masqr(original) && !ast_channel_masq(original) && !ast_channel_masq(clonechan) && !ast_channel_masqr(clonechan)) {
-		ast_channel_masq_set(original, clonechan);
-		ast_channel_masqr_set(clonechan, original);
-		ast_queue_frame(original, &ast_null_frame);
-		ast_queue_frame(clonechan, &ast_null_frame);
-		ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", ast_channel_name(clonechan), ast_channel_name(original));
-		res = 0;
-	} else if (ast_channel_masq(original)) {
-		ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
-			ast_channel_name(ast_channel_masq(original)), ast_channel_name(original));
-	} else if (ast_channel_masqr(original)) {
-		/* not yet as a previously planned masq hasn't yet happened */
-		ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
-			ast_channel_name(original), ast_channel_name(ast_channel_masqr(original)));
-	} else if (ast_channel_masq(clonechan)) {
-		ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
-			ast_channel_name(ast_channel_masq(clonechan)), ast_channel_name(clonechan));
-	} else { /* (clonechan->masqr) */
-		ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
-		ast_channel_name(clonechan), ast_channel_name(ast_channel_masqr(clonechan)));
-	}
-
-	ast_channel_unlock(clonechan);
-	ast_channel_unlock(original);
-
-	return res;
-}
-
 /*! \brief this function simply changes the name of the channel and issues a manager_event
  *         with out unlinking and linking the channel from the ao2_container.  This should
  *         only be used when the channel has already been unlinked from the ao2_container.
@@ -6481,14 +6372,13 @@
  *       this function, it invalidates our channel container locking order.  All channels
  *       must be unlocked before it is permissible to lock the channels' ao2 container.
  */
-void ast_do_masquerade(struct ast_channel *original)
+static void channel_do_masquerade(struct ast_channel *original, struct ast_channel *clonechan)
 {
 	int x;
 	int origstate;
 	unsigned int orig_disablestatecache;
 	unsigned int clone_disablestatecache;
 	int visible_indication;
-	int clone_was_zombie = 0;/*!< TRUE if the clonechan was a zombie before the masquerade. */
 	int clone_hold_state;
 	struct ast_frame *current;
 	const struct ast_channel_tech *t;
@@ -6500,7 +6390,6 @@
 		struct ast_party_connected_line connected;
 		struct ast_party_redirecting redirecting;
 	} exchange;
-	struct ast_channel *clonechan;
 	struct ast_channel *bridged;
 	struct ast_format rformat;
 	struct ast_format wformat;
@@ -6516,50 +6405,18 @@
 	 * reason we're keeping it, it's still awesomely weird. XXX */
 
 	/*
-	 * The reasoning for the channels ao2_container lock here is
-	 * complex.
-	 *
-	 * There is a race condition that exists for this function.
-	 * Since all pvt and channel locks must be let go before calling
-	 * ast_do_masquerade, it is possible that it could be called
-	 * multiple times for the same channel.  In order to prevent the
-	 * race condition with competing threads to do the masquerade
-	 * and new masquerade attempts, the channels container must be
-	 * locked for the entire masquerade.  The original and clonechan
-	 * need to be unlocked earlier to avoid potential deadlocks with
-	 * the unreal/local channel deadlock avoidance method.
-	 *
-	 * The container lock blocks competing masquerade attempts from
-	 * starting as well as being necessary for proper locking order
-	 * because the channels must to be unlinked to change their
+	 * The container lock is necessary for proper locking order
+	 * because the channels must be unlinked to change their
 	 * names.
 	 *
 	 * The original and clonechan locks must be held while the
 	 * channel contents are shuffled around for the masquerade.
 	 *
-	 * The masq and masqr pointers need to be left alone until the
-	 * masquerade has restabilized the channels to prevent another
-	 * masquerade request until the AST_FLAG_ZOMBIE can be set on
-	 * the clonechan.
+	 * The masq and masqr pointers need to be left alone until the masquerade
+	 * has restabilized the channels to hold off ast_hangup() and until
+	 * AST_FLAG_ZOMBIE can be set on the clonechan.
 	 */
 	ao2_lock(channels);
-
-	/*
-	 * Lock the original channel to determine if the masquerade is
-	 * still required.
-	 */
-	ast_channel_lock(original);
-
-	clonechan = ast_channel_masq(original);
-	if (!clonechan) {
-		/*
-		 * The masq is already completed by another thread or never
-		 * needed to be done to begin with.
-		 */
-		ast_channel_unlock(original);
-		ao2_unlock(channels);
-		return;
-	}
 
 	/* Bump the refs to ensure that they won't dissapear on us. */
 	ast_channel_ref(original);
@@ -6573,6 +6430,7 @@
 	 * Stop any visible indication on the original channel so we can
 	 * transfer it to the clonechan taking the original's place.
 	 */
+	ast_channel_lock(original);
 	visible_indication = ast_channel_visible_indication(original);
 	ast_channel_unlock(original);
 	ast_indicate(original, -1);
@@ -6813,30 +6671,14 @@
 
 	/*
 	 * Now, at this point, the "clone" channel is totally F'd up.
-	 * We mark it as a zombie so nothing tries to touch it.  If it's
-	 * already been marked as a zombie, then we must free it (since
-	 * it already is considered invalid).
+	 * We mark it as a zombie so nothing tries to touch it.
 	 *
 	 * This must be done before we unlock clonechan to prevent
 	 * setting up another masquerade on the clonechan.
 	 */
-	if (ast_test_flag(ast_channel_flags(clonechan), AST_FLAG_ZOMBIE)) {
-		clone_was_zombie = 1;
-	} else {
-		ast_set_flag(ast_channel_flags(clonechan), AST_FLAG_ZOMBIE);
-		ast_queue_frame(clonechan, &ast_null_frame);
-	}
-
-	/* clear the masquerade channels */
-	ast_channel_masq_set(original, NULL);
-	ast_channel_masqr_set(clonechan, NULL);
-
-	/*
-	 * When we unlock original here, it can be immediately setup to
-	 * masquerade again or hungup.  The new masquerade or hangup
-	 * will not actually happen until we release the channels
-	 * container lock.
-	 */
+	ast_set_flag(ast_channel_flags(clonechan), AST_FLAG_ZOMBIE);
+	ast_queue_frame(clonechan, &ast_null_frame);
+
 	ast_channel_unlock(original);
 	ast_channel_unlock(clonechan);
 
@@ -6901,17 +6743,18 @@
 	}
 	ast_indicate(original, AST_CONTROL_SRCCHANGE);
 
-	if (!clone_was_zombie) {
-		ao2_link(channels, clonechan);
-	}
+	/* Now that the operation is complete, we can clear the masq
+	 * and masqr fields of both channels.
+	 */
+	ast_channel_lock_both(original, clonechan);
+	ast_channel_masq_set(original, NULL);
+	ast_channel_masqr_set(clonechan, NULL);
+	ast_channel_unlock(original);
+	ast_channel_unlock(clonechan);
+
+	ao2_link(channels, clonechan);
 	ao2_link(channels, original);
 	ao2_unlock(channels);
-
-	if (clone_was_zombie) {
-		/* Restart the ast_hangup() that was deferred because of this masquerade. */
-		ast_debug(1, "Destroying channel clone '%s'\n", ast_channel_name(clonechan));
-		ast_hangup(clonechan);
-	}
 
 	/* Release our held safety references. */
 	ast_channel_unref(original);
@@ -10365,13 +10208,48 @@
 	return yanked_chan;
 }
 
+/*!
+ * Mutex that prevents multiple ast_channel_move() operations
+ * from occurring simultaneously. This is necessary since the
+ * involved channels have to be locked and unlocked throughout
+ * the move operation.
+ *
+ * The most important data being protected are the masq and masqr
+ * data on channels. We don't want them getting criss-crossed due
+ * to multiple moves mucking with them.
+ */
+AST_MUTEX_DEFINE_STATIC(channel_move_lock);
+
 int ast_channel_move(struct ast_channel *dest, struct ast_channel *source)
 {
-	if (ast_channel_masquerade(dest, source)) {
+	SCOPED_MUTEX(lock, &channel_move_lock);
+
+	if (dest == source) {
+		ast_log(LOG_WARNING, "Can't move channel '%s' into itself!\n",
+			ast_channel_name(dest));
 		return -1;
 	}
 
-	ast_do_masquerade(dest);
+	ast_channel_lock_both(dest, source);
+
+	if (ast_test_flag(ast_channel_flags(dest), AST_FLAG_ZOMBIE)
+		|| ast_test_flag(ast_channel_flags(source), AST_FLAG_ZOMBIE)) {
+		/* Zombies! Run! */
+		ast_log(LOG_WARNING,
+			"Can't move channel. One or both is dead (%s <-- %s)\n",
+			ast_channel_name(dest), ast_channel_name(source));
+		ast_channel_unlock(source);
+		ast_channel_unlock(dest);
+		return -1;
+	}
+
+	ast_channel_masq_set(dest, source);
+	ast_channel_masqr_set(source, dest);
+
+	ast_channel_unlock(dest);
+	ast_channel_unlock(source);
+
+	channel_do_masquerade(dest, source);
 	return 0;
 }
 

Modified: team/rmudgett/external_mwi/main/db.c

[... 261 lines stripped ...]



More information about the asterisk-commits mailing list