[asterisk-users] Asterisk variable for SIP context

John Todd jtodd at digium.com
Tue Dec 9 15:37:04 CST 2008


On Dec 9, 2008, at 11:17 AM, Mike wrote:

> Hi,
>
> Say I wanted to know what context a SIP registration is using to  
> dial out in my dialplan, what would I do?
>
> For example, I have phones on a "local-calls-only" context (as  
> defined in sip.conf), others in "unrestricted-calls".  In my  
> dialplan, I`d like to act on that knowledge.
>
> Mike


Perhaps the easiest way is to set a variable in the SIP peer that is  
equal to the same value as you have set in the "context=xxx..." setting.

[snom33942]
type=peer
secret=blahblahblah
qualify=200
nat=yes
context=my-internal-context
setvar=SIPCONTEXT=internal-context

Then can evaluate ${SIPCONTEXT} in your dialplan.

It is often useful to set other variables in this way as well, so you  
can have some "static" values that don't change depending on how the  
call is handled.  For instance, I often set the "human-readable"  
caller ID name (like "Joe Smith") as a variable in the SIP peer for  
small systems that aren't database-driven.  This lets me ignore what  
the phone says.  It's a bit crude when compared to more sophisticated  
solutions using realtime or other database systems, but often that is  
overkill for smaller PBX or PBX-like systems and setting variables in  
sip.conf is sufficient.  "There's more than one way to do it."

Or am I over-simplifying your question?

JT


---
John Todd
jtodd at digium.com        +1-256-428-6083
Asterisk Open Source Community Director







More information about the asterisk-users mailing list