[asterisk-commits] rmudgett: branch rmudgett/dahdi_deflection r224027 - /team/rmudgett/dahdi_def...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Oct 13 18:26:47 CDT 2009


Author: rmudgett
Date: Tue Oct 13 18:26:43 2009
New Revision: 224027

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=224027
Log:
Redo the asterisk portion of the keypad digits in SETUP support.

*  Make use CHANNEL(keypad_digits) instead of channel variable PRI_KEYPAD.
*  Allow the possibility of also sending out a called number at the same
time with this syntax:  Dial(DAHDI/g1[[/K<keypad_digits>]/extension]).

Modified:
    team/rmudgett/dahdi_deflection/channels/chan_dahdi.c
    team/rmudgett/dahdi_deflection/channels/sig_pri.c
    team/rmudgett/dahdi_deflection/channels/sig_pri.h

Modified: team/rmudgett/dahdi_deflection/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/dahdi_deflection/channels/chan_dahdi.c?view=diff&rev=224027&r1=224026&r2=224027
==============================================================================
--- team/rmudgett/dahdi_deflection/channels/chan_dahdi.c (original)
+++ team/rmudgett/dahdi_deflection/channels/chan_dahdi.c Tue Oct 13 18:26:43 2009
@@ -6073,6 +6073,7 @@
 		ast_mutex_lock(&p->lock);
 		snprintf(buf, len, "%f", p->txgain);
 		ast_mutex_unlock(&p->lock);
+#if defined(HAVE_PRI)
 #if defined(HAVE_PRI_REVERSE_CHARGE)
 	} else if (!strcasecmp(data, "reversecharge")) {
 		ast_mutex_lock(&p->lock);
@@ -6087,6 +6088,22 @@
 		}
 		ast_mutex_unlock(&p->lock);
 #endif
+#if defined(HAVE_PRI_SETUP_KEYPAD)
+	} else if (!strcasecmp(data, "keypad_digits")) {
+		ast_mutex_lock(&p->lock);
+		switch (p->sig) {
+		case SIG_PRI_LIB_HANDLE_CASES:
+			ast_copy_string(buf, ((struct sig_pri_chan *) p->sig_pvt)->keypad_digits,
+				len);
+			break;
+		default:
+			*buf = '\0';
+			res = -1;
+			break;
+		}
+		ast_mutex_unlock(&p->lock);
+#endif	/* defined(HAVE_PRI_SETUP_KEYPAD) */
+#endif	/* defined(HAVE_PRI) */
 	} else {
 		*buf = '\0';
 		res = -1;

Modified: team/rmudgett/dahdi_deflection/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/dahdi_deflection/channels/sig_pri.c?view=diff&rev=224027&r1=224026&r2=224027
==============================================================================
--- team/rmudgett/dahdi_deflection/channels/sig_pri.c (original)
+++ team/rmudgett/dahdi_deflection/channels/sig_pri.c Tue Oct 13 18:26:43 2009
@@ -2253,10 +2253,9 @@
 								pri->pvts[chanpos]->reverse_charging_indication = e->ring.reversecharge;
 #endif
 #if defined(HAVE_PRI_SETUP_KEYPAD)
-								if (!ast_strlen_zero(e->ring.keypad_digits)) {
-									pbx_builtin_setvar_helper(c, "PRI_KEYPAD",
-										e->ring.keypad_digits);
-								}
+								ast_copy_string(pri->pvts[chanpos]->keypad_digits,
+									e->ring.keypad_digits,
+									sizeof(pri->pvts[chanpos]->keypad_digits));
 #endif	/* defined(HAVE_PRI_SETUP_KEYPAD) */
 
 								sig_pri_handle_subcmds(pri, chanpos, e->e, e->ring.channel,
@@ -2319,10 +2318,9 @@
 								pri->pvts[chanpos]->reverse_charging_indication = e->ring.reversecharge;
 #endif
 #if defined(HAVE_PRI_SETUP_KEYPAD)
-								if (!ast_strlen_zero(e->ring.keypad_digits)) {
-									pbx_builtin_setvar_helper(c, "PRI_KEYPAD",
-										e->ring.keypad_digits);
-								}
+								ast_copy_string(pri->pvts[chanpos]->keypad_digits,
+									e->ring.keypad_digits,
+									sizeof(pri->pvts[chanpos]->keypad_digits));
 #endif	/* defined(HAVE_PRI_SETUP_KEYPAD) */
 
 								snprintf(calledtonstr, sizeof(calledtonstr), "%d", e->ring.calledplan);
@@ -2981,7 +2979,7 @@
 	int ldp_strip;
 	int exclusive;
 #if defined(HAVE_PRI_SETUP_KEYPAD)
-	const char *keypad = NULL;
+	const char *keypad;
 #endif	/* defined(HAVE_PRI_SETUP_KEYPAD) */
 
 	ast_log(LOG_DEBUG, "CALLING CID_NAME: %s CID_NUM:: %s\n", ast->cid.cid_name, ast->cid.cid_num);
@@ -3008,6 +3006,34 @@
 	} else {
 		c = "";
 	}
+
+#if defined(HAVE_PRI_SETUP_KEYPAD)
+	/*
+	 *  v--- c points here
+	 * /[K<keypad-digits>/]extension
+	 */
+	if (c[0] == 'K') {
+		/* Extract the keypad facility digits. */
+		keypad = c + 1;
+		c = strchr(keypad, '/');
+		if (c) {
+			/* Terminate the keypad facility digits. */
+			*c++ = '\0';
+		} else {
+			c = "";
+		}
+		if (ast_strlen_zero(keypad)) {
+			/* What no keypad digits? */
+			keypad = NULL;
+		}
+	} else {
+		keypad = NULL;
+	}
+	/*
+	 *  v--- c points here
+	 * /extension
+	 */
+#endif	/* defined(HAVE_PRI_SETUP_KEYPAD) */
 
 	l = NULL;
 	n = NULL;
@@ -3124,8 +3150,7 @@
 #endif
 #if defined(HAVE_PRI_SETUP_KEYPAD)
 		case 'K':
-			/* The digits to dial are keypad facility digits. */
-			keypad = c;
+			/* Reserve this letter for keypad facility digits. */
 			break;
 #endif	/* defined(HAVE_PRI_SETUP_KEYPAD) */
 		default:
@@ -3139,12 +3164,9 @@
 	}
 #if defined(HAVE_PRI_SETUP_KEYPAD)
 	if (keypad) {
-		/* The digits to dial are keypad facility digits. */
-		keypad = c + p->stripmsd;
-	}
-	if (!ast_strlen_zero(keypad)) {
 		pri_sr_set_keypad_digits(sr, keypad);
-	} else
+	}
+	if (!keypad || !ast_strlen_zero(c + p->stripmsd + dp_strip))
 #endif	/* defined(HAVE_PRI_SETUP_KEYPAD) */
 	{
 		pri_sr_set_called(sr, c + p->stripmsd + dp_strip, pridialplan, s ? 1 : 0);

Modified: team/rmudgett/dahdi_deflection/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/dahdi_deflection/channels/sig_pri.h?view=diff&rev=224027&r1=224026&r2=224027
==============================================================================
--- team/rmudgett/dahdi_deflection/channels/sig_pri.h (original)
+++ team/rmudgett/dahdi_deflection/channels/sig_pri.h Tue Oct 13 18:26:43 2009
@@ -147,6 +147,10 @@
 	/* Internal variables -- Don't touch */
 	/* Probably will need DS0 number, DS1 number, and a few other things */
 	char dialdest[256];				/* Queued up digits for overlap dialing.  They will be sent out as information messages when setup ACK is received */
+#if defined(HAVE_PRI_SETUP_KEYPAD)
+	/*! \brief Keypad digits that came in with the SETUP message. */
+	char keypad_digits[AST_MAX_EXTENSION];
+#endif	/* defined(HAVE_PRI_SETUP_KEYPAD) */
 
 	unsigned int alerting:1;		/*!< TRUE if channel is alerting/ringing */
 	unsigned int alreadyhungup:1;	/*!< TRUE if the call has already gone/hungup */




More information about the asterisk-commits mailing list