[asterisk-commits] mmichelson: branch mmichelson/outbound_auth r383393 - /team/mmichelson/outbou...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Mar 19 15:13:24 CDT 2013
Author: mmichelson
Date: Tue Mar 19 15:13:20 2013
New Revision: 383393
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383393
Log:
Set up outbound auth for out-of-dialog requests.
It works!
Modified:
team/mmichelson/outbound_auth/res/res_sip.c
Modified: team/mmichelson/outbound_auth/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/res/res_sip.c?view=diff&rev=383393&r1=383392&r2=383393
==============================================================================
--- team/mmichelson/outbound_auth/res/res_sip.c (original)
+++ team/mmichelson/outbound_auth/res/res_sip.c Tue Mar 19 15:13:20 2013
@@ -479,6 +479,22 @@
return 0;
}
+static void send_request_cb(void *token, pjsip_event *e)
+{
+ RAII_VAR(struct ast_sip_endpoint *, endpoint, token, ao2_cleanup);
+ pjsip_transaction *tsx = e->body.tsx_state.tsx;
+ pjsip_rx_data *challenge = e->body.tsx_state.src.rdata;
+ pjsip_tx_data *tdata;
+
+ if (tsx->status_code != 401 && tsx->status_code != 407) {
+ return;
+ }
+
+ ast_sip_create_auth_challenge_response(endpoint, challenge, tsx, &tdata);
+
+ pjsip_endpt_send_request(ast_sip_get_pjsip_endpoint(), tdata, -1, NULL, NULL);
+}
+
static int send_out_of_dialog_request(const pjsip_method *method, const struct ast_sip_body *body, struct ast_sip_endpoint *endpoint)
{
RAII_VAR(struct ast_sip_contact *, contact, NULL, ao2_cleanup);
@@ -530,9 +546,11 @@
*/
pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
- if (pjsip_endpt_send_request(ast_sip_get_pjsip_endpoint(), tdata, -1, NULL, NULL) != PJ_SUCCESS) {
+ ao2_ref(endpoint, +1);
+ if (pjsip_endpt_send_request(ast_sip_get_pjsip_endpoint(), tdata, -1, endpoint, send_request_cb) != PJ_SUCCESS) {
ast_log(LOG_ERROR, "Error attempting to send outbound %.*s request to endpoint %s\n",
(int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint));
+ ao2_ref(endpoint, -1);
return -1;
}
More information about the asterisk-commits
mailing list