[asterisk-commits] mmichelson: branch mmichelson/outbound_auth r383107 - in /team/mmichelson/out...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 14 15:13:53 CDT 2013
Author: mmichelson
Date: Thu Mar 14 15:13:49 2013
New Revision: 383107
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383107
Log:
Get outbound auth working for sesssions.
This works! I've come to the conclusion that we can't have
outbound auth done automatically the way I'd like for it to
be done, but I can at least take steps to make the process
as easy as I can make it for people. That's what future commits
will strive to do.
Modified:
team/mmichelson/outbound_auth/channels/chan_gulp.c
team/mmichelson/outbound_auth/res/res_sip_session.c
Modified: team/mmichelson/outbound_auth/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/channels/chan_gulp.c?view=diff&rev=383107&r1=383106&r2=383107
==============================================================================
--- team/mmichelson/outbound_auth/channels/chan_gulp.c (original)
+++ team/mmichelson/outbound_auth/channels/chan_gulp.c Thu Mar 14 15:13:49 2013
@@ -664,6 +664,9 @@
ast_parse_allow_disallow(&endpoint->prefs, endpoint->codecs, "ulaw", 1);
endpoint->min_se = 90;
endpoint->sess_expires = 1800;
+ endpoint->sip_outbound_auths = ast_calloc(1, sizeof(char *));
+ endpoint->sip_outbound_auths[0] = ast_strdup("bob-auth");
+ endpoint->num_outbound_auths = 1;
if (!(session = ast_sip_session_create_outgoing(endpoint, req_data->dest))) {
return -1;
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=383107&r1=383106&r2=383107
==============================================================================
--- team/mmichelson/outbound_auth/res/res_sip_session.c (original)
+++ team/mmichelson/outbound_auth/res/res_sip_session.c Thu Mar 14 15:13:49 2013
@@ -581,6 +581,40 @@
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);
+ 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;
+ }
+
+ 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);
+}
+
struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint, const char *uri)
{
pj_str_t local_uri = pj_str("sip:temp at localhost"), remote_uri = pj_str((char*)uri);
@@ -596,7 +630,7 @@
return NULL;
}
- if (ast_sip_set_outbound_authentication_credentials(&dlg->auth_sess, endpoint)) {
+ if (setup_outbound_auth(dlg, endpoint)) {
pjsip_dlg_terminate(dlg);
return NULL;
}
@@ -1163,6 +1197,10 @@
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