Hi Guys,
Anybody knows how to get the ip of the new contact of the redirect? I need it to update one xavp variable that contains the INVITE destination.
6 2017-01-20 12:44:55.138473 172.16.213.38 *172.16.208.121* SIP/SDP 85 Request: INVITE sip:01152780776@172.16.208.121:5060 | 9 2017-01-20 12:44:55.142296 172.16.208.121 172.16.213.38 SIP 661 Status: 302 Moved temporarily | 10 2017-01-20 12:44:55.156268 172.16.213.38 172.16.208.121 SIP 423 Request: ACK sip:01152780776@172.16.208.121:5060 | 16 2017-01-20 12:44:55.293349 172.16.213.38 *172.16.208.111* SIP/SDP 95 Request: INVITE sip:1152780776@172.16.208.111:5060;user=phone |
My cfg:
# Manage failure routing cases failure_route[MANAGE_FAILURE] { ....
if (t_check_status("302")) { xlog("Got a 302 - redirecting"); get_redirects("*:1"); * $xavp(ip_b[$avp(current_route)]=>name) = "172.16.208.111";#Hardcoded for testing* xlog("Got a 302 - redirecting $hdr(Contact)"); route(RELAY); #t_relay(); }
Thanks in advance.
Diego.
On Fri, Jan 20, 2017 at 01:04:00PM -0300, Diego Nadares wrote:
Anybody knows how to get the ip of the new contact of the redirect? I need it to update one xavp variable that contains the INVITE destination.
Don't know about an IP, but you get the contact in the (failure) response with: $T_rpl($ct) The host part of this contact is: $(T_rpl($ct){nameaddr.uri}); You'd have to do some DNS lookups to get the IP.
On Fri, Jan 20, 2017 at 05:11:32PM +0100, Daniel Tryba wrote:
The host part of this contact is: $(T_rpl($ct){nameaddr.uri});
Which is not correct, {uri.host} should to the job (according to https://www.kamailio.org/wiki/cookbooks/4.1.x/transformations#urihost )
Thanks Daniel. It was very useful but I had to do the transformation in two parts maybe because I'm very new with this.
Is correct like this?
if (t_check_status("302")) { #New contact is sip:xx@172.16.208.111:5060 ;user=phone;q=0.5,sip:xx@172.16.208.112:5060;user=phone;q=0.25; $var(redirect_uri) = $(T_rpl($ct){nameaddr.uri}); xlog("Got a 302 - redirecting to $(var(redirect_uri){uri.host})" ); get_redirects("*:1"); $xavp(ip_b[$avp(current_route)]=>name) = $(var(redirect_uri){uri.host}); xlog("Got a 302 - redirecting $hdr(Contact)"); route(RELAY); #t_relay(); }
Is there a way to do it in one line?
Thanks again!
Diego
2017-01-20 13:16 GMT-03:00 Daniel Tryba d.tryba@pocos.nl:
On Fri, Jan 20, 2017 at 05:11:32PM +0100, Daniel Tryba wrote:
The host part of this contact is: $(T_rpl($ct){nameaddr.uri});
Which is not correct, {uri.host} should to the job (according to https://www.kamailio.org/wiki/cookbooks/4.1.x/transformations#urihost )
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users