From 0713abf7556bacb5c4c32545996907548c179fdf Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Thu, 11 Sep 2008 08:00:47 +0000 Subject: 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 --- pjsip/src/pjsip-ua/sip_100rel.c | 18 +++++++++++++++--- pjsip/src/pjsip/sip_dialog.c | 7 ++++++- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'pjsip') 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))) { -- cgit v1.2.3