Any way to get [context] of number to be dialed?

I am trying to clean up a mess of many includes in my Dialplan in order to prevent [contextA] from dialing anyone in [contextF].

Can I do this with Dialplan logic where I get the destination context and then skip dialing if it matches ? I would need some way to get the context of the destination

Sorta like this:

[contextA]
exten => _xxx, 1, GotoIf($[${destcontext} ==contextF]?lblnoop:lbldial)
same => n(lbldial), Dial(${EXTEN})
same => n(lblnoop), Noop()

Thanks

Bill

Bill, can you be more specific with your issue? It is bit difficult to understand your requirement.

–Satish Barot
Ahmedabad, India
+919978599700

And if you mean a context parameter configured in sip.conf for that SIP extension(Or iax.conf for IAX extension for that matter) then yes there is a way.
Check SIPPEER function in Asterisk. (wiki.asterisk.org/wiki/display/ … on_SIPPEER)
Have something like this,

[contextA]
exten => _xxx, 1,Set(destcontext=${SIPPEER(${EXTEN},context)})
same => n,GotoIf($["${destcontext}" = “contextF”]?lblnoop:lbldial)
same => n(lbldial), Dial(${EXTEN})
same => n(lblnoop), Noop()

–Satish Barot
Ahmedabad,India
+919978599700

I think what he wants to do is read the context setting for the sip.conf entry for the device that would be used for the dialed extension if the call were to go ahead.

To do this, he will have to use whatever algorithm he uses to map an extension to a device name, and then use the ${SIPPEER()} function on that. Finding the right parameter is left as an exercise for the reader (although it is fairly obvious). (Hint, use core show function SIPPEER.)

just what I needed.

Now I can use simple pattern matching for dialing

eg exten => _XXX, 1,Dial (SIP/${ENTEN})

and use the code provided by Satish to block calls to peers in certain contexts.

Thanks
Bill