[asterisk-users] sip_chan - how to use value of the SIP 'To:' header field for extension logic

Tony Mountifield tony at softins.clara.co.uk
Mon Nov 12 08:28:53 CST 2007


In article <5fd52d7a0711120513j244af85hba91e37b32ad48e1 at mail.gmail.com>,
Tomasz Zieleniewski <tzieleniewski at gmail.com> wrote:
> 
> I have the following situation.
> I have one account created in my VoIP provider.
> Asterisk registers this account with the usage of
> 'register = ' command in the sip.conf file.
> I have a number of aliases assigned to my user which
> correspond to different public/PSTN numbers through which I am
> accessible. When there is an incoming call from my sip provider
> 'some_extension' which corresponds to my registered user 'rings'.
> this is because of such registration:
> register => user:secret at myprovider.com/some_extension.
> How can I now evaluate the value of the To header and perform
> further routing logic.
> What will happen if I don't specify the /extension value in the
> register command?

I think it sill use the 's' extension in your incoming context.

> Will it in such situation analyze the 'To' header to find matching extension??

Asterisk never uses the To header itself, expect to set the variable
SIP_HEADER(TO).

You can extract the number from the To header like this:

exten => some_extension,1,Set(DEST=${CUT(CUT(SIP_HEADER(TO),:,2),@,1)})

And then use ${DEST} in some way to route the call.

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-users mailing list