diff options
-rw-r--r-- | channels/chan_sip.c | 40 | ||||
-rw-r--r-- | channels/chan_unistim.c | 11 | ||||
-rwxr-xr-x | configure | 4 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | res/res_pjsip/pjsip_resolver.c | 73 | ||||
-rw-r--r-- | res/res_pjsip_sdp_rtp.c | 6 |
6 files changed, 89 insertions, 49 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 32b2a3611..d6d2df69b 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -199,23 +199,29 @@ The session-timers parameter in sip.conf defines the mode of operation of SIP session-timers feature in Asterisk. The Asterisk can be configured in one of the following three modes: - 1. Accept :: In the "accept" mode, the Asterisk server honors session-timers requests - made by remote end-points. A remote end-point can request Asterisk to engage - session-timers by either sending it an INVITE request with a "Supported: timer" - header in it or by responding to Asterisk's INVITE with a 200 OK that contains - Session-Expires: header in it. In this mode, the Asterisk server does not - request session-timers from remote end-points. This is the default mode. - 2. Originate :: In the "originate" mode, the Asterisk server requests the remote - end-points to activate session-timers in addition to honoring such requests - made by the remote end-pints. In order to get as much protection as possible - against hanging SIP channels due to network or end-point failures, Asterisk - resends periodic re-INVITEs even if a remote end-point does not support - the session-timers feature. - 3. Refuse :: In the "refuse" mode, Asterisk acts as if it does not support session- - timers for inbound or outbound requests. If a remote end-point requests - session-timers in a dialog, then Asterisk ignores that request unless it's - noted as a requirement (Require: header), in which case the INVITE is - rejected with a 420 Bad Extension response. + 1. Accept :: In the "accept" mode, the Asterisk server honors + session-timers requests made by remote end-points. A remote + end-point can request Asterisk to engage session-timers by either + sending it an INVITE request with a "Supported: timer" header in + it or by responding to Asterisk's INVITE with a 200 OK that + contains Session-Expires: header in it. In this mode, the Asterisk + server does not request session-timers from remote + end-points. This is the default mode. + + 2. Originate :: In the "originate" mode, the Asterisk server + requests the remote end-points to activate session-timers in + addition to honoring such requests made by the remote + end-points. In order to get as much protection as possible against + hanging SIP channels due to network or end-point failures, + Asterisk resends periodic re-INVITEs even if a remote end-point + does not support the session-timers feature. + + 3. Refuse :: In the "refuse" mode, Asterisk acts as if it does not + support session- timers for inbound or outbound requests. If a + remote end-point requests session-timers in a dialog, then + Asterisk ignores that request unless it's noted as a requirement + (Require: header), in which case the INVITE is rejected with a 420 + Bad Extension response. */ diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index 4ad17dc66..b8ccdbb2a 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -4127,7 +4127,7 @@ static void show_main_page(struct unistimsession *pte) send_date_time2(pte); send_idle_clock(pte); if (strlen(pte->device->maintext0)) { - send_text(TEXT_LINE0, TEXT_NORMAL, pte, pte->device->maintext0); + send_text(TEXT_LINE0, TEXT_NORMAL, pte, ustmtext(pte->device->maintext0, pte)); } } else { if (pte->device->missed_call == 1) { @@ -4146,11 +4146,11 @@ static void show_main_page(struct unistimsession *pte) strcat(tmpbuf, ast_inet_ntoa(pte->sin.sin_addr)); send_text(TEXT_LINE2, TEXT_NORMAL, pte, tmpbuf); } else { - send_text(TEXT_LINE2, TEXT_NORMAL, pte, pte->device->maintext2); + send_text(TEXT_LINE2, TEXT_NORMAL, pte, ustmtext(pte->device->maintext2, pte)); } } - send_texttitle(pte, pte->device->titledefault); + send_texttitle(pte, ustmtext(pte->device->titledefault, pte)); change_favorite_icon(pte, FAV_LINE_ICON); } @@ -4405,7 +4405,7 @@ static void init_phone_step2(struct unistimsession *pte) strcat(tmp, pte->macaddr); send_text(TEXT_LINE2, TEXT_NORMAL, pte, tmp); send_text_status(pte, ""); - send_texttitle(pte, "UNISTIM for*"); + send_texttitle(pte, ustmtext("UNISTIM for*", pte)); return; } } @@ -4895,14 +4895,15 @@ static int unistim_hangup_clean(struct ast_channel *ast, struct unistim_subchann ast_channel_tech_pvt_set(ast, NULL); unistim_set_owner(sub, NULL); sub->alreadygone = 0; - ast_mutex_unlock(&sub->lock); if (sub->rtp) { if (unistimdebug) { ast_verb(0, "Destroying RTP session\n"); } + ast_rtp_instance_stop(sub->rtp); ast_rtp_instance_destroy(sub->rtp); sub->rtp = NULL; } + ast_mutex_unlock(&sub->lock); return 0; } @@ -18673,7 +18673,7 @@ if ac_fn_c_try_compile "$LINENO"; then : $as_echo "yes" >&6; } AST_ADDRESS_SANITIZER=1 else - AST_ADDRESS_SANITIZER= + AST_ADDRESS_SANITIZER=0 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -18705,7 +18705,7 @@ if ac_fn_c_try_compile "$LINENO"; then : $as_echo "yes" >&6; } AST_THREAD_SANITIZER=1 else - AST_THREAD_SANITIZER= + AST_THREAD_SANITIZER=0 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } diff --git a/configure.ac b/configure.ac index 0f2148b06..ea55df416 100644 --- a/configure.ac +++ b/configure.ac @@ -1115,7 +1115,7 @@ AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [int x = 1;])], AC_MSG_RESULT(yes) [AST_ADDRESS_SANITIZER=1], - [AST_ADDRESS_SANITIZER=] + [AST_ADDRESS_SANITIZER=0] AC_MSG_RESULT(no) ) CFLAGS="${saved_sanitize_CFLAGS}" @@ -1131,7 +1131,7 @@ AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [int x = 1;])], AC_MSG_RESULT(yes) [AST_THREAD_SANITIZER=1], - [AST_THREAD_SANITIZER=] + [AST_THREAD_SANITIZER=0] AC_MSG_RESULT(no) ) CFLAGS="${saved_sanitize_CFLAGS}" diff --git a/res/res_pjsip/pjsip_resolver.c b/res/res_pjsip/pjsip_resolver.c index 4d4d36e27..5a902466e 100644 --- a/res/res_pjsip/pjsip_resolver.c +++ b/res/res_pjsip/pjsip_resolver.c @@ -231,8 +231,13 @@ static int sip_resolve_handle_naptr(struct sip_resolve *resolve, const struct as return -1; } + /* It is possible for us to receive an explicit transport that is already IPv6, in that case + * we can't turn it into an IPv6 transport and check. If it's not IPv6 though we need to check + * for both IPv4 and IPv6 as PJSIP does not provide enough differentiation to know that we + * want only IPv4. + */ if (!sip_transport_is_available(transport) && - !sip_transport_is_available(transport + PJSIP_TRANSPORT_IPV6)) { + (!(transport & PJSIP_TRANSPORT_IPV6) && !sip_transport_is_available(transport + PJSIP_TRANSPORT_IPV6))) { ast_debug(2, "[%p] NAPTR service %s skipped as transport is unavailable\n", resolve, service); return -1; @@ -343,13 +348,19 @@ static void sip_resolve_callback(const struct ast_dns_query_set *query_set) /* SRV records just create new queries for AAAA+A, nothing fancy */ ast_debug(2, "[%p] SRV record received on target '%s'\n", resolve, ast_dns_query_get_name(query)); - if (sip_transport_is_available(target->transport + PJSIP_TRANSPORT_IPV6)) { + /* If an explicit IPv6 target transport has been requested look for only AAAA records */ + if (target->transport & PJSIP_TRANSPORT_IPV6) { + sip_resolve_add(resolve, ast_dns_srv_get_host(record), ns_t_aaaa, ns_c_in, target->transport, + ast_dns_srv_get_port(record)); + have_srv = 1; + } else if (sip_transport_is_available(target->transport + PJSIP_TRANSPORT_IPV6)) { sip_resolve_add(resolve, ast_dns_srv_get_host(record), ns_t_aaaa, ns_c_in, target->transport + PJSIP_TRANSPORT_IPV6, ast_dns_srv_get_port(record)); have_srv = 1; } - if (sip_transport_is_available(target->transport)) { + if (!(target->transport & PJSIP_TRANSPORT_IPV6) && + sip_transport_is_available(target->transport)) { sip_resolve_add(resolve, ast_dns_srv_get_host(record), ns_t_a, ns_c_in, target->transport, ast_dns_srv_get_port(record)); have_srv = 1; @@ -365,14 +376,20 @@ static void sip_resolve_callback(const struct ast_dns_query_set *query_set) continue; } - if (target->transport == PJSIP_TRANSPORT_UNSPECIFIED || target->transport == PJSIP_TRANSPORT_UDP) { - added = sip_resolve_handle_naptr(resolve, record, "sip+d2u", PJSIP_TRANSPORT_UDP); + if (target->transport == PJSIP_TRANSPORT_UNSPECIFIED || target->transport == PJSIP_TRANSPORT_UDP || + target->transport == PJSIP_TRANSPORT_UDP6) { + added = sip_resolve_handle_naptr(resolve, record, "sip+d2u", + target->transport == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP : target->transport); } - if (target->transport == PJSIP_TRANSPORT_UNSPECIFIED || target->transport == PJSIP_TRANSPORT_TCP) { - added = sip_resolve_handle_naptr(resolve, record, "sip+d2t", PJSIP_TRANSPORT_TCP); + if (target->transport == PJSIP_TRANSPORT_UNSPECIFIED || target->transport == PJSIP_TRANSPORT_TCP || + target->transport == PJSIP_TRANSPORT_TCP6) { + added = sip_resolve_handle_naptr(resolve, record, "sip+d2t", + target->transport == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_TCP : target->transport); } - if (target->transport == PJSIP_TRANSPORT_UNSPECIFIED || target->transport == PJSIP_TRANSPORT_TLS) { - added = sip_resolve_handle_naptr(resolve, record, "sips+d2t", PJSIP_TRANSPORT_TLS); + if (target->transport == PJSIP_TRANSPORT_UNSPECIFIED || target->transport == PJSIP_TRANSPORT_TLS || + target->transport == PJSIP_TRANSPORT_TLS6) { + added = sip_resolve_handle_naptr(resolve, record, "sips+d2t", + target->transport == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_TLS : target->transport); } /* If this record was successfully handled then we need to limit ourselves to this order */ @@ -533,25 +550,39 @@ static void sip_resolve(pjsip_resolver_t *resolver, pj_pool_t *pool, const pjsip if (!target->addr.port) { char srv[NI_MAXHOST]; + /* When resolving addresses PJSIP can request an explicit transport type. It will explicitly + * request an IPv6 transport if a message has been tagged to use an explicitly IPv6 transport. + * For other cases it can be left unspecified OR an explicit non-IPv6 transport can be requested. + * In the case where a non-IPv6 transport is requested there is no way to differentiate between + * a transport being requested as part of a SIP URI (sip:test.com;transport=tcp) and a message + * being tagged with a specific IPv4 transport. In this case we look for both IPv4 and IPv6 addresses. + * If a message has been tagged with a specific IPv4 transport the IPv6 addresses will simply + * be discarded. The code below and elsewhere handles the case where we know they requested IPv6 + * explicitly and only looks for IPv6 records. + */ + res |= sip_resolve_add(resolve, host, ns_t_naptr, ns_c_in, type, 0); - if ((type == PJSIP_TRANSPORT_TLS || type == PJSIP_TRANSPORT_UNSPECIFIED) && - (sip_transport_is_available(PJSIP_TRANSPORT_TLS) || - sip_transport_is_available(PJSIP_TRANSPORT_TLS6))) { + if (type == PJSIP_TRANSPORT_UNSPECIFIED || + (type == PJSIP_TRANSPORT_TLS && sip_transport_is_available(PJSIP_TRANSPORT_TLS)) || + (type == PJSIP_TRANSPORT_TLS6 && sip_transport_is_available(PJSIP_TRANSPORT_TLS6))) { snprintf(srv, sizeof(srv), "_sips._tcp.%s", host); - res |= sip_resolve_add(resolve, srv, ns_t_srv, ns_c_in, PJSIP_TRANSPORT_TLS, 0); + res |= sip_resolve_add(resolve, srv, ns_t_srv, ns_c_in, + type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_TLS : type, 0); } - if ((type == PJSIP_TRANSPORT_TCP || type == PJSIP_TRANSPORT_UNSPECIFIED) && - (sip_transport_is_available(PJSIP_TRANSPORT_TCP) || - sip_transport_is_available(PJSIP_TRANSPORT_TCP6))) { + if (type == PJSIP_TRANSPORT_UNSPECIFIED || + (type == PJSIP_TRANSPORT_TCP && sip_transport_is_available(PJSIP_TRANSPORT_TCP)) || + (type == PJSIP_TRANSPORT_TCP6 && sip_transport_is_available(PJSIP_TRANSPORT_TCP6))) { snprintf(srv, sizeof(srv), "_sip._tcp.%s", host); - res |= sip_resolve_add(resolve, srv, ns_t_srv, ns_c_in, PJSIP_TRANSPORT_TCP, 0); + res |= sip_resolve_add(resolve, srv, ns_t_srv, ns_c_in, + type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_TCP : type, 0); } - if ((type == PJSIP_TRANSPORT_UDP || type == PJSIP_TRANSPORT_UNSPECIFIED) && - (sip_transport_is_available(PJSIP_TRANSPORT_UDP) || - sip_transport_is_available(PJSIP_TRANSPORT_UDP6))) { + if (type == PJSIP_TRANSPORT_UNSPECIFIED || + (type == PJSIP_TRANSPORT_UDP && sip_transport_is_available(PJSIP_TRANSPORT_UDP)) || + (type == PJSIP_TRANSPORT_UDP6 && sip_transport_is_available(PJSIP_TRANSPORT_UDP6))) { snprintf(srv, sizeof(srv), "_sip._udp.%s", host); - res |= sip_resolve_add(resolve, srv, ns_t_srv, ns_c_in, PJSIP_TRANSPORT_UDP, 0); + res |= sip_resolve_add(resolve, srv, ns_t_srv, ns_c_in, + type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP : type, 0); } } diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index 3df9df030..7fd4f9abc 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -909,9 +909,11 @@ static int negotiate_incoming_sdp_stream(struct ast_sip_session *session, struct res = setup_media_encryption(session, session_media, sdp, stream); if (res) { - if (!session->endpoint->media.rtp.encryption_optimistic) { + if (!session->endpoint->media.rtp.encryption_optimistic || + !pj_strncmp2(&stream->desc.transport, "RTP/SAVP", 8)) { /* If optimistic encryption is disabled and crypto should have been enabled - * but was not this session must fail. + * but was not this session must fail. This must also fail if crypto was + * required in the offer but could not be set up. */ return -1; } |