[asterisk-users] Rejecting a call as if the extension does not exist.

A J Stiles asterisk_list at earthshod.co.uk
Fri Feb 7 03:16:02 CST 2014

On Friday 07 February 2014, John Kiniston wrote:
> I'm trying to address a problem with users transferring to invalid
> destinations.
> In my sip peer I'm setting both __FORWARD_CONTEXT and __TRANSFER_CONTEXT to
> a context with a extension defined below to set some CDR variables before
> the call is transferred.
> [customer-forward]
> exten => _X.,1,Progress()
> exten => _X.,n,Gosub(do-billing,s,1${EXTEN}))
> exten => _X,n,Goto(customer-internal,${EXTEN},1)
> Now if my user Dials an invalid extension, Say '9595' from their sip phone
> they get back an 'Address Incomplete' message from their phone because it's
> not a valid extension defined in my dialplan.
> If my user  Transfers a call to '9595' the call gets transferred and then
> hung up on as there's no '9595' destination.
> I'd like to reject the calls in my customer-foward context that do not
> exist in my customer-internal context.
> I've tried doing something like:
> exten => _X.,1,Progress()
> same => n,ExecIf($[${DIALPLAN_EXISTS(customer-internal,${EXTEN},1)} =
> 0]?Hangup(28))
> But that's still accepting the call as the _X makes it a Valid extension.
> I'm looking for suggestions or ideas on a better way to do this.

You are suffering from classic Namespace Pollution.

You need to put the extensions for which you are testing into their own 
separate context, e.g. "customer-realexts"; and include -that- context into 
your customer-internal context.  That way, your DIALPLAN_EXISTS() function 
call won't see the _X.  (which necessarily must be in customer-internal)  to 
match against.


Answers come *after* questions.

More information about the asterisk-users mailing list