On Sat, Jan 8, 2011 at 3:28 AM, mayamatakeshi <mayamatakeshi at gmail.com>wrote: > Hello, > I'm testing handling of redirection with pjsua but it is not working. I > have this scenario: > pjsua make a call to a redirect server at 192.168.2.105. The call is > redirected to 192.168.2.5, but pjsua sends the request again to > 192.168.2.105 instead of sending it to the redirection target. > I start pjsua with this: > ./pjsua-i686-pc-linux-gnu --accept-redirect=1 --null-audio > > And the redirect server (192.168.2.105) response is this: > > SIP/2.0 302 Moved Temporarily > Via: SIP/2.0/UDP 192.168.2.125:5060 > ;rport=5060;branch=z9hG4bKPjd6af4146-0458-4264-9f86-91a6bcb1b4f8 > From: <sip:192.168.2.125>;tag=c445b877-0020-4787-878c-5bda1c5f81c4 > To: sip:10001111 at 192.168.2.105 <sip%3A10001111 at 192.168.2.105> > ;tag=30730317344f3b33472c94a860aa4381.f2d9 > Call-ID: d5d2902d-474b-4aa2-bd0d-55d15916e2fe > CSeq: 24548 INVITE > Contact: sip:10001111 at 192.168.2.5 <sip%3A10001111 at 192.168.2.5> > Server: kamailio (3.1.1 (x86_64/linux)) > Content-Length: 0 > > The above reply looks OK to me. > So, does pjsip follow redirect targets (different server) or it only sends > the call to the initial UAS? I have checked pjsip code and I see that it is skipping target resolution at sip_util.c:pjsip_endpt_send_request_stateless: if (tdata->dest_info.addr.count == 0) { /* Copy the destination host name to TX data */ pj_strdup(tdata->pool, &tdata->dest_info.name, &dest_info.addr.host); pjsip_endpt_resolve( endpt, tdata->pool, &dest_info, stateless_data, &stateless_send_resolver_callback); } else { PJ_LOG(5,(THIS_FILE, "%s: skipping target resolution because " "address is already set", pjsip_tx_data_get_info(tdata))); ... } This point is reached by the following call stack: pjsip_inv_process_redirect pjsip_inv_send_msg pjsip_dlg_send_request pjsip_endpt_send_request_stateless So I believe we must clear tdata->dest_info at pjsip_inv_process_redirect. I have tested doing this (see attached file) and it works but I don't know if it is the proper way to do it. regards, takeshi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20110108/c80f2104/attachment.html> -------------- next part -------------- Index: pjsip/src/pjsip-ua/sip_inv.c =================================================================== --- pjsip/src/pjsip-ua/sip_inv.c (revision 3403) +++ pjsip/src/pjsip-ua/sip_inv.c (working copy) @@ -2282,6 +2282,13 @@ tdata = inv->invite_req; pjsip_tx_data_add_ref(tdata); + + + /* Clear dest_info so that it can be resolved for the redirection target */ + tdata->dest_info.addr.count = 0; + + + /* Restore strict route set. * See http://trac.pjsip.org/repos/ticket/492 */