summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-07-28 18:57:36 +0000
committerBenny Prijono <bennylp@teluu.com>2008-07-28 18:57:36 +0000
commitdc4fedbe2b386a88da7727814a903773b759b706 (patch)
tree813ba197ba459c581089e0ccfccacd7f33398db3
parent6a8f1469293e786ecbdc40f119a7f21f5b005f94 (diff)
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
-rw-r--r--pjsip/src/pjsip/sip_dialog.c36
1 files changed, 34 insertions, 2 deletions
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; i<dlg->usage_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;