[asterisk-users] [CLOSED] Asterisk + OpenSIPs Integration - Rewrite URI on Trunk Numbers of a SIP Trunk

Marc Leurent lftsy at leurent.eu
Thu Apr 2 03:36:29 CDT 2009


Hello, all.
This is just an email to inform you I have added a SIP header in Asterisk SIP 
message that is handled by the proxy:
On Asterisk extensions.conf:

SIPAddHeader(X-number-to-dial: ${NUMBERTOREACH})
Dial(SIP/${MAINPEER}|100|t)

and on OpenSIPS:

if (is_present_hf("X-number-to-dial")) {
   xlog("L_DBG", "GOING TO replace URI username with X-number-to-dial\r\n");
   xlog("L_DBG", "Print $(hdr(X-number-to-dial)) \r\n");

    subst_user('/(.*)/$(hdr(X-number-to-dial))/');    # Substitute the URI 
phone number with the one in X-number-to-dial SIP Header
   subst('/^(To|t):(.*)sip:[^@]*@(.*)$/\1:\2sip:
$(hdr(X-number-to-dial))@\3/ig');  
}

Have a nice day!

-- --
Marc LEURENT

Le Monday 23 March 2009 13.41:59 Marc Leurent, vous avez écrit :
> I have spoken to quickly,
> Usually Asterisk on an incoming call sends an 		INVITE "Reg.Contact
> Number"@"Reg Contact IP"  to the Peer IP. With the command you gave me, it
> is possible to send an 		INVITE "othernumber"@"Peer IP" to the Peer IP.
> What I would like to do is to send 			INVITE "othernumber"@"Reg Contact IP"
>  to the Peer IP in order for the request to be forwarded by the proxy!
>
> Is it possible to do something like:
> Dial(SIP/"<sip:1005 at 192.168.10.125:5060>"@1003 )
> in Order to send INVITE "1005 at 1005 IP" to 1003 device IP
>
> Thanks!
>
> Le Monday 23 March 2009 12.03:55 Marc Leurent, vous avez écrit :
> > Thank you, this is exactly what I needed!!
> > In order to Dial any number to a registered peer, I just have to enter
> > Dial(SIP/ANYNUMBER at SIPPEERNAME) Best Regards!
> >
> > Le Monday 23 March 2009 11.31:31 Alex Balashov, vous avez écrit :
> > > The Request URI generated in an INVITE originated by Asterisk is
> > > governed entirely by the parameters passed to Dial().
> > >
> > > For example:
> > >
> > >    Dial(SIP/1234 at peer_name)
> > >
> > > ... will generate a Request URI of
> > > 1234 at host.or.ip.of.sip.conf.peer.named.peer_name.
> > >
> > > It is also possible to send requests to hosts that are not explicitly
> > > defined in sip.conf, with the caveat that only background [general]
> > > sip.conf settings will then apply:
> > >
> > >    Dial(SIP/1234 at ip.of.peer.not.in.sip.conf)
> > >
> > > Marc Leurent wrote:
> > > > Hello,
> > > > it is not an OpenSIPs problem I have, it's an Asterisk one,
> > > > I would like to change the URI in message generated by Asterisk.
> > > > Thanks
> > > >
> > > > Le Monday 23 March 2009 10.35:09 Alex Balashov, vous avez écrit :
> > > >> Modify the $ru pseudovariable or use rewritehostport() out of core.
> > > >>
> > > >> This is not the right mailing list.  This belongs on the
> > > >> OpenSIPS/OpenSER lists.
> > > >>
> > > >> There is also a mailing list we operate called
> > > >> SER-Asterisk-Interwork that is specifically intended to address SER*
> > > >> / Asterisk integration issues:
> > > >>
> > > >> http://lists.evaristesys.com/mailman/listinfo/ser-asterisk-interwork
> > > >>
> > > >> * Anything from the [Open]SER family.
> > > >>
> > > >> lftsy wrote:
> > > >>> Hye everybody, anyone has any idea how to help me?
> > > >>> To resume, I just want to know how to change the IP in the URI sent
> > > >>> by Asterisk (first line of SIP packets)
> > > >>>
> > > >>> Thanks for your time!
> > > >>> ++
> > > >>>
> > > >>> On Fri, 20 Mar 2009 15:09:55 +0100, Marc Leurent <lftsy at leurent.eu> 
wrote:
> > > >>>> Hello All,
> > > >>>> I have a little complicated question about the Dial command.
> > > >>>> I use OpenSIPs to loadbalance Asterisk Servers, and Users are
> > > >>>> registered on Asterisk servers.
> > > >>>> Asterisk use the Reg. Contact entry to reach the UAC via the
> > > >>>> OpenSIPs server. Everything works except for trunk numbers:
> > > >>>>
> > > >>>> For each peer on Asterisk, "Addr->IP" is IP of the Proxy and "Reg.
> > > >>>> Contact" is the IP where the proxy will relay the packet to reach
> > > >>>> the
> > > >>>
> > > >>> UAC.
> > > >>>
> > > >>>> Ex: with a trunk 0123400010 -> 0123400019 with 0123400010 as the
> > > >>>> sip
> > > >>>
> > > >>> peer.
> > > >>>
> > > >>>> When a number from a trunk is called, like 0123400019  the "Reg.
> > > >>>> Contact" of the main number is not used.
> > > >>>>
> > > >>>> For the time being, I use Dial(SIP/0123400010/0123400019) but it
> > > >>>> It sends an
> > > >>>> INVITE sip:0123400019 at proxyIP to the proxy
> > > >>>>
> > > >>>> whereas it should send
> > > >>>> INVITE sip:0123400019@"Reg. Contact of the main number" to the
> > > >>>> proxy
> > > >>>>
> > > >>>> So I'm trying use the Dial Command with
> > > >>>> Dial(SIP/0123400010/0123400019@"Reg. Contact of the main number")
> > > >>>> but it doesn't work
> > > >>>>
> > > >>>> Have you got any idea how to rewrite the IP of the URI sent?
> > > >>>> Thanks!
> > > >>>>
> > > >>>> --
> > > >>>> -- --
> > > >>>> Marc LEURENT
> > > >>>> lftsy at leurent.eu
> > > >>>>
> > > >>>> _______________________________________________
> > > >>>> -- 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
> > > >>>
> > > >>> _______________________________________________
> > > >>> -- 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
-- 
-- --
Marc LEURENT
lftsy at leurent.eu



More information about the asterisk-users mailing list