[asterisk-users] Dynamically setting from domain when calling friends

Rusty Newton rnewton at digium.com
Wed Feb 19 09:08:30 CST 2014


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



More information about the asterisk-users mailing list