From 39b3b659380b435d06ba070bbb0bf66a42046407 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 23 Nov 2007 12:04:40 +0000 Subject: Fixed ticket #426: Respond incoming CANCEL with no matching INVITE with 481 (thanks Sergey Bakulin) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1597 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip-ua/sip_inv.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'pjsip') diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c index 48ddc6cf..e5f9d120 100644 --- a/pjsip/src/pjsip-ua/sip_inv.c +++ b/pjsip/src/pjsip-ua/sip_inv.c @@ -2044,9 +2044,9 @@ static void inv_respond_incoming_cancel(pjsip_inv_session *inv, if (invite_tsx == NULL) { /* Invite transaction not found! - * Respond CANCEL with 491 (RFC 3261 Section 9.2 page 42) + * Respond CANCEL with 481 (RFC 3261 Section 9.2 page 55) */ - status = pjsip_dlg_create_response( inv->dlg, rdata, 200, NULL, + status = pjsip_dlg_create_response( inv->dlg, rdata, 481, NULL, &tdata); } else { @@ -2566,8 +2566,11 @@ static void inv_on_state_calling( pjsip_inv_session *inv, pjsip_event *e) * Handle case when outgoing request is answered with 481 (Call/ * Transaction Does Not Exist), 408, or when it's timed out. In these * cases, disconnect session (i.e. dialog usage only). + * Note that 481 response to CANCEL does not terminate dialog usage, + * but only the transaction. */ - if (tsx->status_code == PJSIP_SC_CALL_TSX_DOES_NOT_EXIST || + if ((tsx->status_code == PJSIP_SC_CALL_TSX_DOES_NOT_EXIST && + tsx->method.id != PJSIP_CANCEL_METHOD) || tsx->status_code == PJSIP_SC_REQUEST_TIMEOUT || tsx->status_code == PJSIP_SC_TSX_TIMEOUT || tsx->status_code == PJSIP_SC_TSX_TRANSPORT_ERROR) @@ -2784,8 +2787,11 @@ static void inv_on_state_early( pjsip_inv_session *inv, pjsip_event *e) * Handle case when outgoing request is answered with 481 (Call/ * Transaction Does Not Exist), 408, or when it's timed out. In these * cases, disconnect session (i.e. dialog usage only). + * Note that 481 response to CANCEL does not terminate dialog usage, + * but only the transaction. */ - if (tsx->status_code == PJSIP_SC_CALL_TSX_DOES_NOT_EXIST || + if ((tsx->status_code == PJSIP_SC_CALL_TSX_DOES_NOT_EXIST && + tsx->method.id != PJSIP_CANCEL_METHOD) || tsx->status_code == PJSIP_SC_REQUEST_TIMEOUT || tsx->status_code == PJSIP_SC_TSX_TIMEOUT || tsx->status_code == PJSIP_SC_TSX_TRANSPORT_ERROR) @@ -2923,8 +2929,11 @@ static void inv_on_state_connecting( pjsip_inv_session *inv, pjsip_event *e) * Handle case when outgoing request is answered with 481 (Call/ * Transaction Does Not Exist), 408, or when it's timed out. In these * cases, disconnect session (i.e. dialog usage only). + * Note that 481 response to CANCEL does not terminate dialog usage, + * but only the transaction. */ - if (tsx->status_code == PJSIP_SC_CALL_TSX_DOES_NOT_EXIST || + if ((tsx->status_code == PJSIP_SC_CALL_TSX_DOES_NOT_EXIST && + tsx->method.id != PJSIP_CANCEL_METHOD) || tsx->status_code == PJSIP_SC_REQUEST_TIMEOUT || tsx->status_code == PJSIP_SC_TSX_TIMEOUT || tsx->status_code == PJSIP_SC_TSX_TRANSPORT_ERROR) @@ -3231,8 +3240,11 @@ static void inv_on_state_confirmed( pjsip_inv_session *inv, pjsip_event *e) * Handle case when outgoing request is answered with 481 (Call/ * Transaction Does Not Exist), 408, or when it's timed out. In these * cases, disconnect session (i.e. dialog usage only). + * Note that 481 response to CANCEL does not terminate dialog usage, + * but only the transaction. */ - if (tsx->status_code == PJSIP_SC_CALL_TSX_DOES_NOT_EXIST || + if ((tsx->status_code == PJSIP_SC_CALL_TSX_DOES_NOT_EXIST && + tsx->method.id != PJSIP_CANCEL_METHOD) || tsx->status_code == PJSIP_SC_REQUEST_TIMEOUT || tsx->status_code == PJSIP_SC_TSX_TIMEOUT || tsx->status_code == PJSIP_SC_TSX_TRANSPORT_ERROR) -- cgit v1.2.3