[asterisk-users] Set variables from one asterisk ta a second.

Steve Edwards asterisk.org at sedwards.com
Sun Apr 15 20:16:32 CDT 2012


On Sun, 15 Apr 2012, Olivier CALVANO wrote:

> actually, i have a asterisk server with all SIP Account.
>
> this Asterisk server sent all outgoing call to a second Asterisk
> server (and this asterisk sent to the
> telco)
>
> On the first Asterisk, i use:
>
>        exten => _x,1,Set(CDR(CodeTier)=BUS-FRAMOBI)
>        exten => _x,2,Set(CALLERID(num)=${CALLERIDNUM})
>        exten => _x,3,Dial(IAX2/Srv2/${EXTEN},180,rt)
>        exten => _x,4,Hangup
>
> i have SIP user: USRSIP001
> (user sip is in realtime)
> he use this name with a password
>
> i want that the first server sent to the second into a variable the "USRSIP001"
> for get it into a AGI script.
>
> It's possible ?

Yes.

(I'm just a 1.2 Luddite, so the exact capabilities and syntax available to 
your version may be different.)

The first question is 'Do you want to use SIP or IAX?' You've used IAX in 
your dialplan snippet, but you may want to consider SIP. The initial 
configuration is a bit more involved, but you will have a more flexible 
and maintainable solution.

Using IAX is simpler but you are limited to 'overloading' the caller ID 
'name' and 'num' fields*. If you have more than a couple of fields of data 
to pass you may find it easier to pass a 'key' (like the server name and 
the channel unique ID) and use that to retrieve data from a database 
instead of having to parse a bunch of fields from the caller ID name or 
number.

Using SIP you can also pass data by adding custom SIP headers.

Personally, I've always used IAX because it was easy and it worked in my 
environment. If I were to start over, I would seriously consider SIP.

A simple IAX example snippet...

On server1:

 	exten = *,n,			set(CALLERID(name)=olivier-calvano)
 	exten = *,n,			dial(iax2/server2/${EXTEN})
 	exten = *,n,			hangup()

On server2:

 	exten = *,n,			set(FIRST=${CUT(CALLERID(name),,1)})
 	exten = *,n,			set(LAST=${CUT(CALLERID(name),,2)})
 	exten = *,n,			agi(lookup-client,${FIRST},${LAST})
 	exten = *,n,			hangup()

*) The extension and context are also under your control and can be set in 
the IAX 'dial string' but manipulating these fields to pass multiple data 
fields can get convoluted.

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000



More information about the asterisk-users mailing list