From 0620cc0c0049993df6521420d3a6f9b2933aaa55 Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Sun, 1 Dec 2013 19:58:08 +0000 Subject: res_pjsip_transport_websocket: Fix security events and simplify implementation. Transport type determination for security events has been simplified to use the type present on the message itself instead of searching through configured transports to find the transport used. The actual WebSocket transport has also been simplified. It now leverages the existing PJSIP transport manager for finding the active WebSocket transport for outgoing messages. This removes the need for res_pjsip_transport_websocket to store a mapping itself. (closes issue ASTERISK-22897) Reported by: Max E. Reyes Vera J. Review: https://reviewboard.asterisk.org/r/3036/ ........ Merged revisions 403256 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403257 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_pjsip.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'res/res_pjsip.c') diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 37762e6cf..80cef06e5 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -1369,7 +1369,10 @@ static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *u /* Get the local bound address for the transport that will be used when communicating with the provided URI */ if (pjsip_tpmgr_find_local_addr(pjsip_endpt_get_tpmgr(ast_sip_get_pjsip_endpoint()), pool, type, selector, &local_addr, &local_port) != PJ_SUCCESS) { - return -1; + + /* If no local address can be retrieved using the transport manager use the host one */ + pj_strdup(pool, &local_addr, pj_gethostname()); + local_port = pjsip_transport_get_default_port_for_type(PJSIP_TRANSPORT_UDP); } /* If IPv6 was specified in the transport, set the proper type */ @@ -1423,22 +1426,6 @@ static int sip_get_tpselector_from_endpoint(const struct ast_sip_endpoint *endpo return 0; } -static int sip_get_tpselector_from_uri(const char *uri, pjsip_tpselector *selector) -{ - RAII_VAR(struct ast_sip_contact_transport *, contact_transport, NULL, ao2_cleanup); - - contact_transport = ast_sip_location_retrieve_contact_transport_by_uri(uri); - - if (!contact_transport) { - return -1; - } - - selector->type = PJSIP_TPSELECTOR_TRANSPORT; - selector->u.transport = contact_transport->transport; - - return 0; -} - pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, const char *uri, const char *request_user) { char enclosed_uri[PJSIP_MAX_URL_SIZE]; @@ -1457,7 +1444,7 @@ pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, return NULL; } - if (sip_get_tpselector_from_uri(uri, &selector) && sip_get_tpselector_from_endpoint(endpoint, &selector)) { + if (sip_get_tpselector_from_endpoint(endpoint, &selector)) { pjsip_dlg_terminate(dlg); return NULL; } @@ -2104,8 +2091,6 @@ static int load_module(void) ast_res_pjsip_init_options_handling(0); - ast_res_pjsip_init_contact_transports(); - ast_module_ref(ast_module_info->self); return AST_MODULE_LOAD_SUCCESS; -- cgit v1.2.3