diff options
author | Joshua Colp <jcolp@digium.com> | 2013-12-01 19:58:08 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2013-12-01 19:58:08 +0000 |
commit | 0620cc0c0049993df6521420d3a6f9b2933aaa55 (patch) | |
tree | 293542a1b5aa293cccd7c318216f76752bdd57ea /res/res_pjsip/security_events.c | |
parent | e93fbf41e639bc1d3b17c81dab4a3c0812124dcc (diff) |
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
Diffstat (limited to 'res/res_pjsip/security_events.c')
-rw-r--r-- | res/res_pjsip/security_events.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/res/res_pjsip/security_events.c b/res/res_pjsip/security_events.c index 6bdb6cb39..0135d3351 100644 --- a/res/res_pjsip/security_events.c +++ b/res/res_pjsip/security_events.c @@ -33,35 +33,24 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/res_pjsip.h" #include "asterisk/security_events.h" -static int find_transport_in_use(void *obj, void *arg, int flags) -{ - struct ast_sip_transport *transport = obj; - pjsip_rx_data *rdata = arg; - - if ((transport->state->transport == rdata->tp_info.transport) || - (transport->state->factory && !pj_strcmp(&transport->state->factory->addr_name.host, &rdata->tp_info.transport->local_name.host) && - transport->state->factory->addr_name.port == rdata->tp_info.transport->local_name.port)) { - return CMP_MATCH | CMP_STOP; - } - - return 0; -} - static enum ast_transport security_event_get_transport(pjsip_rx_data *rdata) { - RAII_VAR(struct ao2_container *, transports, NULL, ao2_cleanup); - RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup); - - /* It should be impossible for these to fail as the transport has to exist for the message to exist */ - transports = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), "transport", AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL); - - ast_assert(transports != NULL); - - transport = ao2_callback(transports, 0, find_transport_in_use, rdata); - - ast_assert(transport != NULL); - - return transport->type; + if (rdata->tp_info.transport->key.type == PJSIP_TRANSPORT_UDP || + rdata->tp_info.transport->key.type == PJSIP_TRANSPORT_UDP6) { + return AST_TRANSPORT_UDP; + } else if (rdata->tp_info.transport->key.type == PJSIP_TRANSPORT_TCP || + rdata->tp_info.transport->key.type == PJSIP_TRANSPORT_TCP6) { + return AST_TRANSPORT_TCP; + } else if (rdata->tp_info.transport->key.type == PJSIP_TRANSPORT_TLS || + rdata->tp_info.transport->key.type == PJSIP_TRANSPORT_TLS6) { + return AST_TRANSPORT_TLS; + } else if (!strcmp(rdata->tp_info.transport->type_name, "WS")) { + return AST_TRANSPORT_WS; + } else if (!strcmp(rdata->tp_info.transport->type_name, "WSS")) { + return AST_TRANSPORT_WSS; + } else { + return 0; + } } static void security_event_populate(pjsip_rx_data *rdata, char *call_id, size_t call_id_size, struct ast_sockaddr *local, struct ast_sockaddr *remote) |