[asterisk-commits] file: branch file/gulp_fax r394437 - /team/file/gulp_fax/res/res_sip_session.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 16 08:58:03 CDT 2013


Author: file
Date: Tue Jul 16 08:58:02 2013
New Revision: 394437

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394437
Log:
Handle retransmissions and new re-invites while a deferred reinvite exists.

Modified:
    team/file/gulp_fax/res/res_sip_session.c

Modified: team/file/gulp_fax/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/file/gulp_fax/res/res_sip_session.c?view=diff&rev=394437&r1=394436&r2=394437
==============================================================================
--- team/file/gulp_fax/res/res_sip_session.c (original)
+++ team/file/gulp_fax/res/res_sip_session.c Tue Jul 16 08:58:02 2013
@@ -859,19 +859,34 @@
 static pj_bool_t session_reinvite_on_rx_request(pjsip_rx_data *rdata)
 {
 	pjsip_dialog *dlg;
-	pjsip_inv_session *inv_session;
-	struct ast_sip_session *session;
+	RAII_VAR(struct ast_sip_session *, session, NULL, ao2_cleanup);
 	pjsip_rdata_sdp_info *sdp_info;
 
 	if (rdata->msg_info.msg->line.req.method.id != PJSIP_INVITE_METHOD ||
 		!(dlg = pjsip_ua_find_dialog(&rdata->msg_info.cid->id, &rdata->msg_info.to->tag, &rdata->msg_info.from->tag, PJ_FALSE)) ||
-		!(inv_session = pjsip_dlg_get_inv_session(dlg)) ||
-		!(session = inv_session->mod_data[session_module.id])) {
+		!(session = ast_sip_dialog_get_session(dlg))) {
 		return PJ_FALSE;
 	}
 
-	/* XXX Reject new re-invite if deferred exists and not a retransmission */
 	if (session->deferred_reinvite) {
+		pj_str_t key, deferred_key;
+		pjsip_tx_data *tdata;
+
+		/* We use memory from the new request on purpose so the deferred reinvite pool does not grow uncontrollably */
+		pjsip_tsx_create_key(rdata->tp_info.pool, &key, PJSIP_ROLE_UAS, &rdata->msg_info.cseq->method, rdata);
+		pjsip_tsx_create_key(rdata->tp_info.pool, &deferred_key, PJSIP_ROLE_UAS, &session->deferred_reinvite->msg_info.cseq->method,
+			session->deferred_reinvite);
+
+		/* If this is a retransmission ignore it */
+		if (!pj_strcmp(&key, &deferred_key)) {
+			return PJ_TRUE;
+		}
+
+		/* Otherwise this is a new re-invite, so reject it */
+		if (pjsip_dlg_create_response(dlg, rdata, 491, NULL, &tdata) == PJ_SUCCESS) {
+			pjsip_endpt_send_response2(ast_sip_get_pjsip_endpoint(), rdata, tdata, NULL, NULL);
+		}
+
 		return PJ_TRUE;
 	}
 




More information about the asterisk-commits mailing list