summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/res_pjsip.c17
-rw-r--r--res/res_pjsip/include/res_pjsip_private.h18
-rw-r--r--res/res_pjsip/location.c1
-rw-r--r--res/res_pjsip/pjsip_outbound_auth.c101
-rw-r--r--res/res_pjsip_dtmf_info.c8
-rw-r--r--res/res_pjsip_session.c12
6 files changed, 16 insertions, 141 deletions
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 7bf489772..6e7bd68c0 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -3743,22 +3743,6 @@ static int load_module(void)
return AST_MODULE_LOAD_DECLINE;
}
- if (internal_sip_initialize_outbound_authentication()) {
- ast_log(LOG_ERROR, "Failed to initialize outbound authentication. Aborting load\n");
- internal_sip_unregister_service(&supplement_module);
- ast_sip_destroy_distributor();
- ast_res_pjsip_destroy_configuration();
- ast_sip_destroy_global_headers();
- stop_monitor_thread();
- ast_sip_destroy_system();
- pj_pool_release(memory_pool);
- memory_pool = NULL;
- pjsip_endpt_destroy(ast_pjsip_endpoint);
- ast_pjsip_endpoint = NULL;
- pj_caching_pool_destroy(&caching_pool);
- return AST_MODULE_LOAD_DECLINE;
- }
-
ast_res_pjsip_init_options_handling(0);
ast_cli_register_multiple(cli_commands, ARRAY_LEN(cli_commands));
@@ -3783,7 +3767,6 @@ static int unload_pjsip(void *data)
{
ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands));
ast_res_pjsip_cleanup_options_handling();
- internal_sip_destroy_outbound_authentication();
ast_sip_destroy_distributor();
ast_res_pjsip_destroy_configuration();
ast_sip_destroy_system();
diff --git a/res/res_pjsip/include/res_pjsip_private.h b/res/res_pjsip/include/res_pjsip_private.h
index a53e0c45d..2cc9feacd 100644
--- a/res/res_pjsip/include/res_pjsip_private.h
+++ b/res/res_pjsip/include/res_pjsip_private.h
@@ -194,24 +194,6 @@ int ast_res_pjsip_init_contact_transports(void);
/*!
* \internal
- * \brief Initialize outbound authentication support
- *
- * \retval 0 Success
- * \retval non-zero Failure
- */
-int internal_sip_initialize_outbound_authentication(void);
-
-/*!
- * \internal
- * \brief Destroy outbound authentication support
- *
- * \retval 0 Success
- * \retval non-zero Failure
- */
-void internal_sip_destroy_outbound_authentication(void);
-
-/*!
- * \internal
* \brief Initialize system configuration
*
* \retval 0 Success
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 9e75929d7..37f39ba30 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -889,6 +889,7 @@ static int contact_apply_handler(const struct ast_sorcery *sorcery, void *object
struct ast_sip_contact *contact = object;
status = ast_res_pjsip_find_or_create_contact_status(contact);
+ ao2_cleanup(status);
return status ? 0 : -1;
}
diff --git a/res/res_pjsip/pjsip_outbound_auth.c b/res/res_pjsip/pjsip_outbound_auth.c
deleted file mode 100644
index 8b39b000d..000000000
--- a/res/res_pjsip/pjsip_outbound_auth.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 2013, Digium, Inc.
- *
- * Mark Michelson <mmichelson@digium.com>
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE file
- * at the top of the source tree.
- */
-
-#include "asterisk.h"
-#undef bzero
-#define bzero bzero
-#include "pjsip.h"
-
-#include "asterisk/res_pjsip.h"
-#include "asterisk/module.h"
-#include "include/res_pjsip_private.h"
-
-static pj_bool_t outbound_auth(pjsip_rx_data *rdata);
-
-static pjsip_module outbound_auth_mod = {
- .name = {"Outbound Authentication", 19},
- .priority = PJSIP_MOD_PRIORITY_DIALOG_USAGE,
- .on_rx_response = outbound_auth,
-};
-
-struct outbound_auth_cb_data {
- ast_sip_dialog_outbound_auth_cb cb;
- void *user_data;
-};
-
-static pj_bool_t outbound_auth(pjsip_rx_data *rdata)
-{
- RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
- pjsip_transaction *tsx;
- pjsip_dialog *dlg;
- struct outbound_auth_cb_data *cb_data;
- pjsip_tx_data *tdata;
-
- if (rdata->msg_info.msg->line.status.code != 401 &&
- rdata->msg_info.msg->line.status.code != 407) {
- /* Doesn't pertain to us. Move on */
- return PJ_FALSE;
- }
-
- tsx = pjsip_rdata_get_tsx(rdata);
- dlg = pjsip_rdata_get_dlg(rdata);
- if (!dlg || !tsx) {
- return PJ_FALSE;
- }
-
- endpoint = ast_sip_dialog_get_endpoint(dlg);
- if (!endpoint) {
- return PJ_FALSE;
- }
-
- if (ast_sip_create_request_with_auth(&endpoint->outbound_auths, rdata, tsx->last_tx, &tdata)) {
- return PJ_FALSE;
- }
-
- cb_data = dlg->mod_data[outbound_auth_mod.id];
- if (cb_data) {
- cb_data->cb(dlg, tdata, cb_data->user_data);
- return PJ_TRUE;
- }
-
- pjsip_dlg_send_request(dlg, tdata, -1, NULL);
- return PJ_TRUE;
-}
-
-int ast_sip_dialog_setup_outbound_authentication(pjsip_dialog *dlg, const struct ast_sip_endpoint *endpoint,
- ast_sip_dialog_outbound_auth_cb cb, void *user_data)
-{
- struct outbound_auth_cb_data *cb_data = PJ_POOL_ZALLOC_T(dlg->pool, struct outbound_auth_cb_data);
- cb_data->cb = cb;
- cb_data->user_data = user_data;
-
- dlg->sess_count++;
- pjsip_dlg_add_usage(dlg, &outbound_auth_mod, cb_data);
- dlg->sess_count--;
-
- return 0;
-}
-
-int internal_sip_initialize_outbound_authentication(void) {
- return internal_sip_register_service(&outbound_auth_mod);
-}
-
-
-void internal_sip_destroy_outbound_authentication(void) {
- internal_sip_unregister_service(&outbound_auth_mod);
-}
diff --git a/res/res_pjsip_dtmf_info.c b/res/res_pjsip_dtmf_info.c
index b6a0b4a1e..78d529c30 100644
--- a/res/res_pjsip_dtmf_info.c
+++ b/res/res_pjsip_dtmf_info.c
@@ -89,7 +89,13 @@ static int dtmf_info_incoming_request(struct ast_sip_session *session, struct pj
char event = '\0';
unsigned int duration = 100;
- char is_dtmf = is_media_type(rdata, "dtmf");
+ char is_dtmf;
+
+ if (!session->channel) {
+ return 0;
+ }
+
+ is_dtmf = is_media_type(rdata, "dtmf");
if (!is_dtmf && !is_media_type(rdata, "dtmf-relay")) {
return 0;
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index ca89d76a9..bbd74eeb5 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -1467,8 +1467,8 @@ static pj_bool_t outbound_invite_auth(pjsip_rx_data *rdata)
session = inv->mod_data[session_module.id];
- if (ast_sip_create_request_with_auth(&session->endpoint->outbound_auths, rdata, tsx,
- &tdata)) {
+ if (ast_sip_create_request_with_auth(&session->endpoint->outbound_auths, rdata,
+ tsx->last_tx, &tdata)) {
return PJ_FALSE;
}
@@ -2370,7 +2370,7 @@ static void session_inv_on_tsx_state_changed(pjsip_inv_session *inv, pjsip_trans
if ((tsx->status_code == 401 || tsx->status_code == 407)
&& !ast_sip_create_request_with_auth(
&session->endpoint->outbound_auths,
- e->body.tsx_state.src.rdata, tsx, &tdata)) {
+ e->body.tsx_state.src.rdata, tsx->last_tx, &tdata)) {
/* Send authed reINVITE */
ast_sip_session_send_request_with_cb(session, tdata, cb);
return;
@@ -2407,7 +2407,7 @@ static void session_inv_on_tsx_state_changed(pjsip_inv_session *inv, pjsip_trans
if ((tsx->status_code == 401 || tsx->status_code == 407)
&& !ast_sip_create_request_with_auth(
&session->endpoint->outbound_auths,
- e->body.tsx_state.src.rdata, tsx, &tdata)) {
+ e->body.tsx_state.src.rdata, tsx->last_tx, &tdata)) {
/* Send authed version of the method */
ast_sip_session_send_request_with_cb(session, tdata, cb);
return;
@@ -2627,6 +2627,10 @@ static pjsip_redirect_op session_inv_on_redirected(pjsip_inv_session *inv, const
struct ast_sip_session *session = inv->mod_data[session_module.id];
const pjsip_sip_uri *uri;
+ if (!session->channel) {
+ return PJSIP_REDIRECT_STOP;
+ }
+
if (session->endpoint->redirect_method == AST_SIP_REDIRECT_URI_PJSIP) {
return PJSIP_REDIRECT_ACCEPT;
}