summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsip/sip_dialog.c
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-02-19 16:55:42 +0000
committerBenny Prijono <bennylp@teluu.com>2007-02-19 16:55:42 +0000
commit9dee4f9cbb0ac97840dca9d70bd3815b0a985a12 (patch)
treedf4564ab20c228634c9132552126b11477378ef1 /pjsip/src/pjsip/sip_dialog.c
parent15a5b2f82f58a846ffe80926966212f1ffeca7c7 (diff)
Fixed ticket #111: workaround for forking dialog
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@979 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsip/sip_dialog.c')
-rw-r--r--pjsip/src/pjsip/sip_dialog.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/pjsip/src/pjsip/sip_dialog.c b/pjsip/src/pjsip/sip_dialog.c
index e22091d9..7efefc26 100644
--- a/pjsip/src/pjsip/sip_dialog.c
+++ b/pjsip/src/pjsip/sip_dialog.c
@@ -1518,11 +1518,26 @@ void pjsip_dlg_on_rx_response( pjsip_dialog *dlg, pjsip_rx_data *rdata )
/* When we receive response that establishes dialog, update To tag,
* route set and dialog target.
+ *
+ * The second condition of the "if" is a workaround for forking.
+ * Originally, the dialog takes the first To tag seen and set it as
+ * the remote tag. If the tag in 2xx response is different than this
+ * tag, ACK will be sent with wrong To tag and incoming request with
+ * this tag will be rejected with 481.
+ *
+ * The workaround for this is to take the To tag received in the
+ * 2xx response and set it as remote tag.
*/
- if (dlg->state == PJSIP_DIALOG_STATE_NULL &&
- pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) &&
- (res_code > 100 && res_code < 300) &&
- rdata->msg_info.to->tag.slen)
+ if ((dlg->state == PJSIP_DIALOG_STATE_NULL &&
+ pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) &&
+ (res_code > 100 && res_code < 300) &&
+ rdata->msg_info.to->tag.slen)
+ ||
+ (dlg->role==PJSIP_ROLE_UAC &&
+ !dlg->uac_has_2xx &&
+ res_code/100 == 2 &&
+ pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) &&
+ pj_strcmp(&dlg->remote.info->tag, &rdata->msg_info.to->tag)))
{
pjsip_hdr *hdr, *end_hdr;
pjsip_contact_hdr *contact;
@@ -1563,6 +1578,15 @@ void pjsip_dlg_on_rx_response( pjsip_dialog *dlg, pjsip_rx_data *rdata )
}
dlg->state = PJSIP_DIALOG_STATE_ESTABLISHED;
+
+ /* Prevent dialog from being updated just in case more 2xx
+ * gets through this dialog (it shouldn't happen).
+ */
+ if (dlg->role==PJSIP_ROLE_UAC && !dlg->uac_has_2xx &&
+ res_code/100==2)
+ {
+ dlg->uac_has_2xx = PJ_TRUE;
+ }
}
/* Update remote target (again) when receiving 2xx response messages