From 4e3b0cedba16db80cd9910e64db0763258a0ed5f Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Tue, 7 Mar 2017 13:37:52 +0000 Subject: res_pjsip_transport_websocket: Add support for IPv6. This change adds a PJSIP patch (which has been contributed upstream) to allow the registration of IPv6 transport types. Using this the res_pjsip_transport_websocket module now registers an IPv6 Websocket transport and uses it for the corresponding traffic. ASTERISK-26685 Change-Id: Id1f9126f995b31dc38db8fdb58afd289b4ad1647 --- res/res_pjsip.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'res/res_pjsip.c') diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 810b6d329..e1800e2de 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -2757,7 +2757,7 @@ static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *u pj_str_t tmp, local_addr; pjsip_uri *uri; pjsip_sip_uri *sip_uri; - pjsip_transport_type_e type = PJSIP_TRANSPORT_UNSPECIFIED; + pjsip_transport_type_e type; int local_port; char default_user[PJSIP_MAX_URL_SIZE]; @@ -2777,21 +2777,21 @@ static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *u sip_uri = pjsip_uri_get_uri(uri); /* Determine the transport type to use */ + type = pjsip_transport_get_type_from_name(&sip_uri->transport_param); if (PJSIP_URI_SCHEME_IS_SIPS(sip_uri)) { - type = PJSIP_TRANSPORT_TLS; + if (type == PJSIP_TRANSPORT_UNSPECIFIED + || !(pjsip_transport_get_flag_from_type(type) & PJSIP_TRANSPORT_SECURE)) { + type = PJSIP_TRANSPORT_TLS; + } } else if (!sip_uri->transport_param.slen) { type = PJSIP_TRANSPORT_UDP; - } else { - type = pjsip_transport_get_type_from_name(&sip_uri->transport_param); - } - - if (type == PJSIP_TRANSPORT_UNSPECIFIED) { + } else if (type == PJSIP_TRANSPORT_UNSPECIFIED) { return -1; } /* If the host is IPv6 turn the transport into an IPv6 version */ - if (pj_strchr(&sip_uri->host, ':') && type < PJSIP_TRANSPORT_START_OTHER) { - type = (pjsip_transport_type_e)(((int)type) + PJSIP_TRANSPORT_IPV6); + if (pj_strchr(&sip_uri->host, ':')) { + type |= PJSIP_TRANSPORT_IPV6; } if (!ast_strlen_zero(domain)) { @@ -2815,8 +2815,8 @@ static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *u } /* If IPv6 was specified in the transport, set the proper type */ - if (pj_strchr(&local_addr, ':') && type < PJSIP_TRANSPORT_START_OTHER) { - type = (pjsip_transport_type_e)(((int)type) + PJSIP_TRANSPORT_IPV6); + if (pj_strchr(&local_addr, ':')) { + type |= PJSIP_TRANSPORT_IPV6; } from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE); -- cgit v1.2.3