[svn-commits] file: trunk r421957 - in /trunk: ./ res/res_pjsip_transport_websocket.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Aug 24 14:37:03 CDT 2014


Author: file
Date: Sun Aug 24 14:37:00 2014
New Revision: 421957

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=421957
Log:
res_pjsip_transport_websocket: Attach the Websocket module on outgoing INVITEs.

In order to alter the Contact header on in-dialog requests and responses the
Websocket module must be attached on outgoing INVITEs. The Contact header is
modified so that the PJSIP transport layer can find and use the existing
Websocket connection based on the source IP address, port, and transport.

ASTERISK-24143 #close
Reported by: Aleksei Kulakov
........

Merged revisions 421955 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 421956 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/res/res_pjsip_transport_websocket.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/res/res_pjsip_transport_websocket.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_transport_websocket.c?view=diff&rev=421957&r1=421956&r2=421957
==============================================================================
--- trunk/res/res_pjsip_transport_websocket.c (original)
+++ trunk/res/res_pjsip_transport_websocket.c Sun Aug 24 14:37:00 2014
@@ -341,6 +341,22 @@
 	.id = -1,
 	.priority = PJSIP_MOD_PRIORITY_TRANSPORT_LAYER,
 	.on_rx_request = websocket_on_rx_msg,
+	.on_rx_response = websocket_on_rx_msg,
+};
+
+/*! \brief Function called when an INVITE goes out */
+static void websocket_outgoing_invite_request(struct ast_sip_session *session, struct pjsip_tx_data *tdata)
+{
+	if (session->inv_session->state == PJSIP_INV_STATE_NULL) {
+		pjsip_dlg_add_usage(session->inv_session->dlg, &websocket_module, NULL);
+	}
+}
+
+/*! \brief Supplement for adding Websocket functionality to dialog */
+static struct ast_sip_session_supplement websocket_supplement = {
+	.method = "INVITE",
+	.priority = AST_SIP_SUPPLEMENT_PRIORITY_FIRST + 1,
+	.outgoing_request = websocket_outgoing_invite_request,
 };
 
 static int load_module(void)
@@ -352,17 +368,24 @@
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
-	if (ast_websocket_add_protocol("sip", websocket_cb)) {
+	if (ast_sip_session_register_supplement(&websocket_supplement)) {
 		ast_sip_unregister_service(&websocket_module);
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
+	if (ast_websocket_add_protocol("sip", websocket_cb)) {
+		ast_sip_session_unregister_supplement(&websocket_supplement);
+		ast_sip_unregister_service(&websocket_module);
+		return AST_MODULE_LOAD_DECLINE;
+	}
+
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int unload_module(void)
 {
 	ast_sip_unregister_service(&websocket_module);
+	ast_sip_session_unregister_supplement(&websocket_supplement);
 	ast_websocket_remove_protocol("sip", websocket_cb);
 
 	return 0;




More information about the svn-commits mailing list