[asterisk-commits] pcadach: branch pcadach/chan_h323-live r43090 - in /team/pcadach/chan_h323-li...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Sep 17 08:34:27 MST 2006


Author: pcadach
Date: Sun Sep 17 10:34:27 2006
New Revision: 43090

URL: http://svn.digium.com/view/asterisk?rev=43090&view=rev
Log:
Don't fallthrough to default context

Modified:
    team/pcadach/chan_h323-live/channels/chan_h323.c
    team/pcadach/chan_h323-live/channels/h323/TODO

Modified: team/pcadach/chan_h323-live/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/chan_h323.c?rev=43090&r1=43089&r2=43090&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/chan_h323.c (original)
+++ team/pcadach/chan_h323-live/channels/chan_h323.c Sun Sep 17 10:34:27 2006
@@ -2176,6 +2176,8 @@
 {
 	struct oh323_pvt *pvt;
 	struct ast_channel *c = NULL;
+	enum {ext_original, ext_s, ext_i, ext_notexists} try_exten;
+	char tmp_exten[sizeof(pvt->exten)];
 
 	if (h323debug)
 		ast_log(LOG_DEBUG, "Preparing Asterisk to answer for %s\n", token);
@@ -2186,6 +2188,52 @@
 		ast_log(LOG_ERROR, "Something is wrong: answer_call\n");
 		return 0;
 	}
+	/* Check if requested extension at context pair exists in the dialplan */
+	strncpy(tmp_exten, pvt->exten, sizeof(tmp_exten));
+
+	/* Try to find best extension in specified context */
+	if ((tmp_exten[0] != '\0') && (tmp_exten[1] == '\0')) {
+		if (tmp_exten[0] == 's')
+			try_exten = ext_s;
+		else if (tmp_exten[0] == 'i')
+			try_exten = ext_i;
+		else
+			try_exten = ext_original;
+	} else
+		try_exten = ext_original;
+	do {
+		if (ast_exists_extension(NULL, pvt->context, tmp_exten, 1, NULL))
+			break;
+		switch (try_exten) {
+		case ext_original:
+			tmp_exten[0] = 's';
+			tmp_exten[1] = '\0';
+			try_exten = ext_s;
+			break;
+		case ext_s:
+			tmp_exten[0] = 'i';
+			try_exten = ext_i;
+			break;
+		case ext_i:
+			try_exten = ext_notexists;
+			break;
+		default:
+			break;
+		}
+	} while (try_exten != ext_notexists);
+
+	/* Drop the call if we don't have <exten>, s and i extensions */
+	if (try_exten == ext_notexists) {
+		ast_log(LOG_NOTICE, "Dropping call because extensions '%s', 's' and 'i' doesn't exists in context [%s]\n", pvt->exten, pvt->context);
+		ast_mutex_unlock(&pvt->lock);
+		h323_clear_call(token, AST_CAUSE_UNALLOCATED);
+		return 0;
+	} else if ((try_exten != ext_original) && (strcmp(pvt->exten, tmp_exten) != 0)) {
+		if (h323debug)
+			ast_log(LOG_DEBUG, "Going to extension %s@%s because %s@%s isn't exists\n", tmp_exten, pvt->context, pvt->exten, pvt->context);
+		strncpy(pvt->exten, tmp_exten, sizeof(pvt->exten));
+	}
+
 	/* allocate a channel and tell asterisk about it */
 	c = __oh323_new(pvt, AST_STATE_RINGING, pvt->cd.call_token);
 

Modified: team/pcadach/chan_h323-live/channels/h323/TODO
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/TODO?rev=43090&r1=43089&r2=43090&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/TODO (original)
+++ team/pcadach/chan_h323-live/channels/h323/TODO Sun Sep 17 10:34:27 2006
@@ -1,9 +1,6 @@
 The NuFone Network's Open H.323 Channel Driver for Asterisk 
 	     
 	TODO:
-
-		- Track down why calls to invalid extensions always
-		  get sent to 's' in context 'default'
 
 		- H.323 Native Bridging
 



More information about the asterisk-commits mailing list