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()
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()
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.)