summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-09-11 08:00:47 +0000
committerBenny Prijono <bennylp@teluu.com>2008-09-11 08:00:47 +0000
commit0713abf7556bacb5c4c32545996907548c179fdf (patch)
tree2b72b3d97a707cc3370b2949f9d4444d0d481002 /pjsip
parent5e976eec4b731070a2d04ff4eff54a0ad91926e7 (diff)
Ticket #620: PRACK is sent to the wrong UAS when 100rel is used and the dialog forks (thanks Ruud Klaver for the report)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2271 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsip-ua/sip_100rel.c18
-rw-r--r--pjsip/src/pjsip/sip_dialog.c7
2 files changed, 21 insertions, 4 deletions
diff --git a/pjsip/src/pjsip-ua/sip_100rel.c b/pjsip/src/pjsip-ua/sip_100rel.c
index 657b298c..d8bb402c 100644
--- a/pjsip/src/pjsip-ua/sip_100rel.c
+++ b/pjsip/src/pjsip-ua/sip_100rel.c
@@ -417,14 +417,26 @@ PJ_DEF(pj_status_t) pjsip_100rel_on_rx_prack( pjsip_inv_session *inv,
pj_str_t method;
pj_status_t status;
- dd = (dlg_data*) inv->dlg->mod_data[mod_100rel.mod.id];
- PJ_ASSERT_RETURN(dd != NULL, PJSIP_ENOTINITIALIZED);
-
tsx = pjsip_rdata_get_tsx(rdata);
pj_assert(tsx != NULL);
msg = rdata->msg_info.msg;
+ dd = (dlg_data*) inv->dlg->mod_data[mod_100rel.mod.id];
+ if (dd == NULL) {
+ /* UAC sends us PRACK while we didn't send reliable provisional
+ * response. Respond with 400 (?)
+ */
+ const pj_str_t reason = pj_str("Unexpected PRACK");
+
+ status = pjsip_dlg_create_response(inv->dlg, rdata, 400,
+ &reason, &tdata);
+ if (status == PJ_SUCCESS) {
+ status = pjsip_dlg_send_response(inv->dlg, tsx, tdata);
+ }
+ return PJSIP_ENOTINITIALIZED;
+ }
+
/* Always reply with 200/OK for PRACK */
status = pjsip_dlg_create_response(inv->dlg, rdata, 200, NULL, &tdata);
if (status == PJ_SUCCESS) {
diff --git a/pjsip/src/pjsip/sip_dialog.c b/pjsip/src/pjsip/sip_dialog.c
index 8df82b7d..2b3203f4 100644
--- a/pjsip/src/pjsip/sip_dialog.c
+++ b/pjsip/src/pjsip/sip_dialog.c
@@ -1696,6 +1696,11 @@ void pjsip_dlg_on_rx_response( pjsip_dialog *dlg, pjsip_rx_data *rdata )
*
* The workaround for this is to take the To tag received in the
* 2xx response and set it as remote tag.
+ *
+ * New update:
+ * We also need to update the dialog for 1xx responses, to handle the
+ * case when 100rel is used, otherwise PRACK will be sent to the
+ * wrong target.
*/
if ((dlg->state == PJSIP_DIALOG_STATE_NULL &&
pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) &&
@@ -1704,7 +1709,7 @@ void pjsip_dlg_on_rx_response( pjsip_dialog *dlg, pjsip_rx_data *rdata )
||
(dlg->role==PJSIP_ROLE_UAC &&
!dlg->uac_has_2xx &&
- res_code/100 == 2 &&
+ res_code/100 <= 2 &&
pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) &&
pj_strcmp(&dlg->remote.info->tag, &rdata->msg_info.to->tag)))
{