[asterisk-commits] jpeeler: branch jpeeler/feature14882 r285005 - in /team/jpeeler/feature14882:...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 3 17:19:53 CDT 2010


Author: jpeeler
Date: Fri Sep  3 17:19:44 2010
New Revision: 285005

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=285005
Log:
only allow parking if parking extension is included in current context

Modified:
    team/jpeeler/feature14882/channels/chan_dahdi.c
    team/jpeeler/feature14882/channels/chan_iax2.c
    team/jpeeler/feature14882/channels/chan_sip.c
    team/jpeeler/feature14882/channels/sig_analog.c
    team/jpeeler/feature14882/include/asterisk/features.h
    team/jpeeler/feature14882/main/features.c

Modified: team/jpeeler/feature14882/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/channels/chan_dahdi.c?view=diff&rev=285005&r1=285004&r2=285005
==============================================================================
--- team/jpeeler/feature14882/channels/chan_dahdi.c (original)
+++ team/jpeeler/feature14882/channels/chan_dahdi.c Fri Sep  3 17:19:44 2010
@@ -9739,7 +9739,7 @@
 				tone_zone_play_tone(p->subs[idx].dfd, -1);
 			else
 				tone_zone_play_tone(p->subs[idx].dfd, DAHDI_TONE_DIALTONE);
-			if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num) && !ast_parking_ext_valid(exten)) {
+			if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num) && !ast_parking_ext_valid(exten, chan)) {
 				if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
 					if (getforward) {
 						/* Record this as the forwarding extension */
@@ -9875,7 +9875,7 @@
 				getforward = 0;
 				memset(exten, 0, sizeof(exten));
 				len = 0;
-			} else if ((p->transfer || p->canpark) && ast_parking_ext_valid(exten) &&
+			} else if ((p->transfer || p->canpark) && ast_parking_ext_valid(exten, chan) &&
 						p->subs[SUB_THREEWAY].owner &&
 						ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
 				/* This is a three way call, the main call being a real channel,

Modified: team/jpeeler/feature14882/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/channels/chan_iax2.c?view=diff&rev=285005&r1=285004&r2=285005
==============================================================================
--- team/jpeeler/feature14882/channels/chan_iax2.c (original)
+++ team/jpeeler/feature14882/channels/chan_iax2.c Fri Sep  3 17:19:44 2010
@@ -9101,9 +9101,10 @@
 	char context[AST_MAX_EXTENSION];
 	char callednum[AST_MAX_EXTENSION];
 	char *callerid;
+	struct ast_channel *chan;
 };
 
-static void dp_lookup(int callno, const char *context, const char *callednum, const char *callerid, int skiplock)
+static void dp_lookup(int callno, const char *context, const char *callednum, const char *callerid, int skiplock, struct ast_channel *chan)
 {
 	unsigned short dpstatus = 0;
 	struct iax_ie_data ied1;
@@ -9112,7 +9113,7 @@
 	memset(&ied1, 0, sizeof(ied1));
 	mm = ast_matchmore_extension(NULL, context, callednum, 1, callerid);
 	/* Must be started */
-	if (ast_parking_ext_valid(callednum) || ast_exists_extension(NULL, context, callednum, 1, callerid)) {
+	if (ast_parking_ext_valid(callednum, chan) || ast_exists_extension(NULL, context, callednum, 1, callerid)) {
 		dpstatus = IAX_DPSTATUS_EXISTS;
 	} else if (ast_canmatch_extension(NULL, context, callednum, 1, callerid)) {
 		dpstatus = IAX_DPSTATUS_CANEXIST;
@@ -9139,14 +9140,14 @@
 {
 	/* Look up for dpreq */
 	struct dpreq_data *dpr = data;
-	dp_lookup(dpr->callno, dpr->context, dpr->callednum, dpr->callerid, 0);
+	dp_lookup(dpr->callno, dpr->context, dpr->callednum, dpr->callerid, 0, dpr->chan);
 	if (dpr->callerid)
 		ast_free(dpr->callerid);
 	ast_free(dpr);
 	return NULL;
 }
 
-static void spawn_dp_lookup(int callno, const char *context, const char *callednum, const char *callerid)
+static void spawn_dp_lookup(int callno, const char *context, const char *callednum, const char *callerid, struct ast_channel *chan)
 {
 	pthread_t newthread;
 	struct dpreq_data *dpr;
@@ -9157,6 +9158,7 @@
 	dpr->callno = callno;
 	ast_copy_string(dpr->context, context, sizeof(dpr->context));
 	ast_copy_string(dpr->callednum, callednum, sizeof(dpr->callednum));
+	dpr->chan = chan;
 	if (callerid)
 		dpr->callerid = ast_strdup(callerid);
 	if (ast_pthread_create_detached(&newthread, NULL, dp_lookup_thread, dpr)) {
@@ -10542,10 +10544,10 @@
 					!ast_test_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED) && ies.called_number) {
 					if (iaxcompat) {
 						/* Spawn a thread for the lookup */
-						spawn_dp_lookup(fr->callno, iaxs[fr->callno]->context, ies.called_number, iaxs[fr->callno]->cid_num);
+						spawn_dp_lookup(fr->callno, iaxs[fr->callno]->context, ies.called_number, iaxs[fr->callno]->cid_num, c);
 					} else {
 						/* Just look it up */
-						dp_lookup(fr->callno, iaxs[fr->callno]->context, ies.called_number, iaxs[fr->callno]->cid_num, 1);
+						dp_lookup(fr->callno, iaxs[fr->callno]->context, ies.called_number, iaxs[fr->callno]->cid_num, 1, c);
 					}
 				}
 				break;
@@ -10606,7 +10608,7 @@
 					}
 
 					pbx_builtin_setvar_helper(bridged_chan, "BLINDTRANSFER", iaxs[fr->callno]->owner->name);
-					if (ast_parking_ext_valid(ies.called_number)) {
+					if (ast_parking_ext_valid(ies.called_number, c)) {
 						struct ast_channel *saved_channel = iaxs[fr->callno]->owner;
 						ast_mutex_unlock(&iaxsl[fr->callno]);
 						if (iax_park(bridged_chan, saved_channel, ies.called_number)) {

Modified: team/jpeeler/feature14882/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/channels/chan_sip.c?view=diff&rev=285005&r1=285004&r2=285005
==============================================================================
--- team/jpeeler/feature14882/channels/chan_sip.c (original)
+++ team/jpeeler/feature14882/channels/chan_sip.c Fri Sep  3 17:19:44 2010
@@ -22045,9 +22045,8 @@
 		/* Fallthrough if we can't find the call leg internally */
 	}
 
-
 	/* Parking a call */
-	if (p->refer->localtransfer && ast_parking_ext_valid(p->refer->refer_to)) {
+	if (p->refer->localtransfer && ast_parking_ext_valid(p->refer->refer_to, p->owner)) {
 		/* Must release c's lock now, because it will not longer be accessible after the transfer! */
 		*nounlock = 1;
 		ast_channel_unlock(current.chan1);

Modified: team/jpeeler/feature14882/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/channels/sig_analog.c?view=diff&rev=285005&r1=285004&r2=285005
==============================================================================
--- team/jpeeler/feature14882/channels/sig_analog.c (original)
+++ team/jpeeler/feature14882/channels/sig_analog.c Fri Sep  3 17:19:44 2010
@@ -1930,7 +1930,7 @@
 			} else {
 				analog_play_tone(p, index, ANALOG_TONE_DIALTONE);
 			}
-			if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num) && !ast_parking_ext_valid(exten)) {
+			if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num) && !ast_parking_ext_valid(exten, chan)) {
 				if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
 					if (getforward) {
 						/* Record this as the forwarding extension */
@@ -2081,7 +2081,7 @@
 				getforward = 0;
 				memset(exten, 0, sizeof(exten));
 				len = 0;
-			} else if ((p->transfer || p->canpark) && ast_parking_ext_valid(exten) &&
+			} else if ((p->transfer || p->canpark) && ast_parking_ext_valid(exten, chan) &&
 						p->subs[ANALOG_SUB_THREEWAY].owner &&
 						ast_bridged_channel(p->subs[ANALOG_SUB_THREEWAY].owner)) {
 				/* This is a three way call, the main call being a real channel,

Modified: team/jpeeler/feature14882/include/asterisk/features.h
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/include/asterisk/features.h?view=diff&rev=285005&r1=285004&r2=285005
==============================================================================
--- team/jpeeler/feature14882/include/asterisk/features.h (original)
+++ team/jpeeler/feature14882/include/asterisk/features.h Fri Sep  3 17:19:44 2010
@@ -107,11 +107,11 @@
 int ast_masq_park_call(struct ast_channel *rchan, struct ast_channel *host, int timeout, int *extout);
 
 /*! 
- * \brief Determine if parking extension exists
+ * \brief Determine if parking extension exists in a given context
  * \retval 0 if extension does not exist
  * \retval 1 if extension does exist
 */
-int ast_parking_ext_valid(const char *exten);
+int ast_parking_ext_valid(const char *exten_str, struct ast_channel *chan);
 
 /*! \brief Determine system call pickup extension */
 const char *ast_pickup_ext(void);

Modified: team/jpeeler/feature14882/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/main/features.c?view=diff&rev=285005&r1=285004&r2=285005
==============================================================================
--- team/jpeeler/feature14882/main/features.c (original)
+++ team/jpeeler/feature14882/main/features.c Fri Sep  3 17:19:44 2010
@@ -468,10 +468,20 @@
 	return 0;
 }
 
-int ast_parking_ext_valid(const char *exten)
+int ast_parking_ext_valid(const char *exten_str, struct ast_channel *chan)
 {
 	struct ast_parkinglot *curlot;
-	curlot = ao2_callback(parkinglots, 0, find_parkinglot_by_exten_cb, (void *) exten);
+	struct ast_exten *exten;
+	struct pbx_find_info q = { .stacklen = 0 }; /* the rest is reset in pbx_find_extension */
+	const char *app_at_exten;
+
+	exten = pbx_find_extension(chan, NULL, &q, chan->context, exten_str, 1, NULL, NULL, E_MATCH);
+	app_at_exten = ast_get_extension_app(exten);
+	if (!app_at_exten || strcmp(PARK_APP_NAME, app_at_exten)) {
+		return 0;
+	}
+
+	curlot = ao2_callback(parkinglots, 0, find_parkinglot_by_exten_cb, (void *) exten_str);
 	if (curlot) {
 		ao2_ref(curlot, -1);
 		return 1;




More information about the asterisk-commits mailing list