Torbjörn Abrahamsson
2014-Feb-18 09:40 UTC
[asterisk-users] Dynamically setting from domain when calling friends
Hello I have a problem where I would like to be able to send an arbitrary SIP domain when sending a call to a registered friend. By default the from domain is set to the IP of the Asterisk server, but I would like to set it to something else. The case is that when a call from a foreign domain comes in to the Asterisk, it will connect it to the callee (but with the domain changed). When the callee wants to make a redial from call history, the domain will not be correct. I could probably do something with the fromdomain setting of the friend, but I would like it to be dynamic, ie not having to update the friend definition every time a different domain is used. I understand that I would need to use outbound proxy in the client to prevent it from dialing the domain directly. Is this possible? Any alternatives? BR, Torbj?rn Abrahamsson -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20140218/bbb463b8/attachment.html>
Rusty Newton
2014-Feb-19 15:08 UTC
[asterisk-users] Dynamically setting from domain when calling friends
On Tue, Feb 18, 2014 at 3:40 AM, Torbj?rn Abrahamsson <torbjorn.abrahamsson at gmail.com> wrote:> I have a problem where I would like to be able to send an arbitrary SIP > domain when sending a call to a registered friend. By default the from > domain is set to the IP of the Asterisk server, but I would like to set it > to something else. > The case is that when a call from a foreign domain comes in to the Asterisk, > it will connect it to the callee (but with the domain changed). When the > callee wants to make a redial from call history, the domain will not be > correct. > I could probably do something with the fromdomain setting of the friend, but > I would like it to be dynamic, ie not having to update the friend definition > every time a different domain is used. > I understand that I would need to use outbound proxy in the client to > prevent it from dialing the domain directly. > Is this possible? Any alternatives?I'm a little confused about what you want to do, however I'll throw some information at you in hopes that it will help out. I did a little research and found that you can set the outbound From header domain and From header user through two channel variables: SIPFROMDOMAIN, SIPFROMUSER They are sparsely documented, but there is an example in extensions.conf same => n(from),Set(__SIPFROMUSER=${CALLERID(num)}) same => n,GotoIf($["${GLOBAL(FREENUMDOMAIN)}" = ""]?dial) ; check if we set the FREENUMDOMAIN global variable in [global] same => n,Set(__SIPFROMDOMAIN=${GLOBAL(FREENUMDOMAIN)}) ; if we did set it, then we'll use it for our outbound dialing domain It looks like they were added in 1.6.2.X of Asterisk, so if you are using 1.8.X or above, you should have them. On your inbound call, you could use the function SIP_HEADER[1] to gather the domain and store it for later use when you want to set it on the outbound call. Though I'm not sure how you could tell that the call was a redial. [1]: https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Function_SIP_HEADER I'm assuming when your SIP client redials that it calls through Asterisk and is not dialing the previously caller directly. Hope any of that helps. *Goes off to document SIPFROMDOMAIN and SIPFROMUSER on the wiki* -- Rusty Newton Digium, Inc. | Community Support Manager 445 Jan Davis Drive NW - Huntsville, AL 35806 - US direct: +1 256 428 6200 Check us out at: http://digium.com & http://asterisk.org