[asterisk-commits] mmichelson: branch mmichelson/outbound_auth r383117 - in /team/mmichelson/out...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 14 18:17:20 CDT 2013


Author: mmichelson
Date: Thu Mar 14 18:17:17 2013
New Revision: 383117

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383117
Log:
Use the new setup function with callback in the session module.

Works like a charm, but I did find that I needed to change a little
around and had forgotten to update the exports file properly.


Modified:
    team/mmichelson/outbound_auth/include/asterisk/res_sip.h
    team/mmichelson/outbound_auth/res/res_sip.exports.in
    team/mmichelson/outbound_auth/res/res_sip/sip_outbound_auth.c
    team/mmichelson/outbound_auth/res/res_sip_session.c

Modified: team/mmichelson/outbound_auth/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/include/asterisk/res_sip.h?view=diff&rev=383117&r1=383116&r2=383117
==============================================================================
--- team/mmichelson/outbound_auth/include/asterisk/res_sip.h (original)
+++ team/mmichelson/outbound_auth/include/asterisk/res_sip.h Thu Mar 14 18:17:17 2013
@@ -483,7 +483,7 @@
  */
 int ast_sip_initialize_outbound_authentication(void);
 
-typedef int (*outbound_auth_cb)(pjsip_tx_data *tdata, void *user_data);
+typedef int (*outbound_auth_cb)(pjsip_dialog *dlg, pjsip_tx_data *tdata, void *user_data);
 
 int ast_sip_setup_outbound_authentication(pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint,
 		outbound_auth_cb cb, void *user_data);

Modified: team/mmichelson/outbound_auth/res/res_sip.exports.in
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/res/res_sip.exports.in?view=diff&rev=383117&r1=383116&r2=383117
==============================================================================
--- team/mmichelson/outbound_auth/res/res_sip.exports.in (original)
+++ team/mmichelson/outbound_auth/res/res_sip.exports.in Thu Mar 14 18:17:17 2013
@@ -15,6 +15,7 @@
 		LINKER_SYMBOL_PREFIXast_sip_get_authentication_credentials;
 		LINKER_SYMBOL_PREFIXast_sip_check_authentication;
 		LINKER_SYMBOL_PREFIXast_sip_set_outbound_authentication_credentials;
+		LINKER_SYMBOL_PREFIXast_sip_setup_outbound_authentication;
 		LINKER_SYMBOL_PREFIXast_sip_add_digest_to_challenge;
 		LINKER_SYMBOL_PREFIXast_sip_identify_endpoint;
 		LINKER_SYMBOL_PREFIXast_sip_add_header;

Modified: team/mmichelson/outbound_auth/res/res_sip/sip_outbound_auth.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/res/res_sip/sip_outbound_auth.c?view=diff&rev=383117&r1=383116&r2=383117
==============================================================================
--- team/mmichelson/outbound_auth/res/res_sip/sip_outbound_auth.c (original)
+++ team/mmichelson/outbound_auth/res/res_sip/sip_outbound_auth.c Thu Mar 14 18:17:17 2013
@@ -43,7 +43,7 @@
 	pjsip_auth_clt_reinit_req(&dlg->auth_sess, rdata, tsx->last_tx, &tdata);
 
 	if (cb_data) {
-		cb_data->cb(tdata, cb_data->user_data);
+		cb_data->cb(dlg, tdata, cb_data->user_data);
 		return;
 	}
 

Modified: team/mmichelson/outbound_auth/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/res/res_sip_session.c?view=diff&rev=383117&r1=383116&r2=383117
==============================================================================
--- team/mmichelson/outbound_auth/res/res_sip_session.c (original)
+++ team/mmichelson/outbound_auth/res/res_sip_session.c Thu Mar 14 18:17:17 2013
@@ -581,38 +581,13 @@
 	return 0;
 }
 
-static pj_bool_t outbound_auth_on_rx_response(pjsip_rx_data *rdata)
-{
-	pjsip_dialog *dlg = pjsip_rdata_get_dlg(rdata);
-	pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
+static int session_outbound_auth(pjsip_dialog *dlg, pjsip_tx_data *tdata, void *user_data)
+{
 	pjsip_inv_session *inv = pjsip_dlg_get_inv_session(dlg);
-	pjsip_tx_data *tdata;
-
-	if (rdata->msg_info.msg->line.status.code != 401 &&
-			rdata->msg_info.msg->line.status.code != 407) {
-		return PJ_FALSE;
-	}
-
+	ast_log(LOG_NOTICE, "TEST TEST\n");
 	pjsip_inv_uac_restart(inv, PJ_TRUE);
-	pjsip_auth_clt_reinit_req(&dlg->auth_sess, rdata, tsx->last_tx, &tdata);
 	pjsip_inv_send_msg(inv, tdata);
-
-	return PJ_TRUE;
-}
-
-static pjsip_module session_outbound_auth_module = {
-	.name = {"Session Outbound Auth Module", 28},
-	.priority = PJSIP_MOD_PRIORITY_DIALOG_USAGE,
-	.on_rx_response = outbound_auth_on_rx_response,
-};
-
-static int setup_outbound_auth(pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint)
-{
-	dlg->sess_count++;
-	pjsip_dlg_add_usage(dlg, &session_outbound_auth_module, NULL);
-	dlg->sess_count--;
-
-	return ast_sip_set_outbound_authentication_credentials(&dlg->auth_sess, endpoint);
+	return 0;
 }
 
 struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint, const char *uri)
@@ -630,7 +605,7 @@
 		return NULL;
 	}
 
-	if (setup_outbound_auth(dlg, endpoint)) {
+	if (ast_sip_setup_outbound_authentication(dlg, endpoint, session_outbound_auth, NULL)) {
 		pjsip_dlg_terminate(dlg);
 		return NULL;
 	}
@@ -1195,10 +1170,6 @@
 	if (ast_sip_register_service(&session_module)) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	if (ast_sip_register_service(&session_outbound_auth_module)) {
-		ast_sip_unregister_service(&session_module);
-		return AST_MODULE_LOAD_DECLINE;
-	}
 	return AST_MODULE_LOAD_SUCCESS;
 }
 




More information about the asterisk-commits mailing list