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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20081209/3fb247ee/attachment.htm
Core show channels will show you this. Here is an example Channel Location State Application(Data) Zap/1-1 2975000 at DID_trunk_1: Dialing AppDial((Outgoing Line)) SIP/104-085ff278 2975000 at DLPN_DialPla Ring Dial(Zap/g1/ww2975000|60) 2 active channels SIP/104 is making a call on Zap/1 using DLPN_Dialplan1 from the dialplan _____ From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Mike Sent: Tuesday, December 09, 2008 1:17 PM To: 'Asterisk Users Mailing List - Non-Commercial Discussion' Subject: [asterisk-users] Asterisk variable for SIP context 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20081209/7df73a4a/attachment.htm
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 >The SIPPEER function should allow you to extract what context is defined in sip.conf. -Dave
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. > > MikePerhaps 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
On Tuesday 09 December 2008 13:17:18 Mike wrote:> 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.I suspect others are making this far more complicated than it needs to be. The typical setup is to create included contexts in your dialplan, like in: [local-calls-only] include => local-calls [unrestricted-calls] include => local-calls include => long-distance include => international If you're wanting to find out the top context, even though you're in an included context, then just use ${CONTEXT}. Your context doesn't actually change when you're using an included context, which is why this works. There's no need to make it any more complicated. -- Tilghman
Great, just what I needed. Thanks! Mike -----Original Message----- From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Dave Fullerton Sent: Tuesday, December 09, 2008 15:06 To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [asterisk-users] Asterisk variable for SIP context Mike wrote:> Hi, > > Say I wanted to know what context a SIP registration is using to dial outin> 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 toact> on that knowledge. > > Mike >The SIPPEER function should allow you to extract what context is defined in sip.conf. -Dave _______________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users