From dc4fedbe2b386a88da7727814a903773b759b706 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Mon, 28 Jul 2008 18:57:36 +0000 Subject: Ticket #580: Incoming target refresh request does not update the Contact header (thanks Joel Dodson for the report) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2179 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip/sip_dialog.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'pjsip') diff --git a/pjsip/src/pjsip/sip_dialog.c b/pjsip/src/pjsip/sip_dialog.c index 07ab34bc..969d0b3d 100644 --- a/pjsip/src/pjsip/sip_dialog.c +++ b/pjsip/src/pjsip/sip_dialog.c @@ -1500,6 +1500,30 @@ void pjsip_dlg_on_rx_request( pjsip_dialog *dlg, pjsip_rx_data *rdata ) ++dlg->tsx_count; } + /* Update the target URI if this is a target refresh request. + * We have passed the basic checking for the request, I think we + * should update the target URI regardless of whether the request + * is accepted or not (e.g. when re-INVITE is answered with 488, + * we would still need to update the target URI, otherwise our + * target URI would be wrong, wouldn't it). + */ + if (pjsip_method_creates_dialog(&rdata->msg_info.cseq->method)) { + pjsip_contact_hdr *contact; + + contact = (pjsip_contact_hdr*) + pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, + NULL); + if (contact && (dlg->remote.contact==NULL || + pjsip_uri_cmp(PJSIP_URI_IN_REQ_URI, + dlg->remote.contact->uri, + contact->uri))) + { + dlg->remote.contact = (pjsip_contact_hdr*) + pjsip_hdr_clone(dlg->pool, contact); + dlg->target = dlg->remote.contact->uri; + } + } + /* Report the request to dialog usages. */ for (i=0; iusage_cnt; ++i) { @@ -1689,7 +1713,11 @@ void pjsip_dlg_on_rx_response( pjsip_dialog *dlg, pjsip_rx_data *rdata ) contact = (pjsip_contact_hdr*) pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL); - if (contact) { + if (contact && (dlg->remote.contact==NULL || + pjsip_uri_cmp(PJSIP_URI_IN_REQ_URI, + dlg->remote.contact->uri, + contact->uri))) + { dlg->remote.contact = (pjsip_contact_hdr*) pjsip_hdr_clone(dlg->pool, contact); dlg->target = dlg->remote.contact->uri; @@ -1735,7 +1763,11 @@ void pjsip_dlg_on_rx_response( pjsip_dialog *dlg, pjsip_rx_data *rdata ) contact = (pjsip_contact_hdr*) pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL); - if (contact) { + if (contact && (dlg->remote.contact==NULL || + pjsip_uri_cmp(PJSIP_URI_IN_REQ_URI, + dlg->remote.contact->uri, + contact->uri))) + { dlg->remote.contact = (pjsip_contact_hdr*) pjsip_hdr_clone(dlg->pool, contact); dlg->target = dlg->remote.contact->uri; -- cgit v1.2.3