diff --git a/plugins/provider/sip/calls-sip-origin.c b/plugins/provider/sip/calls-sip-origin.c index d9929e6..f7f4ca9 100644 --- a/plugins/provider/sip/calls-sip-origin.c +++ b/plugins/provider/sip/calls-sip-origin.c @@ -953,8 +953,8 @@ setup_nua (CallsSipOrigin *self) const char *ipv4_bind = "0.0.0.0"; const char *uuid = NULL; g_autofree char *urn_uuid = NULL; - g_autofree char *sip_url = NULL; - g_autofree char *sips_url = NULL; + g_autofree char *url = NULL; + g_autofree char *protocol_lower = NULL; g_autofree char *from_str = NULL; if (!STR_IS_NULL_OR_EMPTY (sip_test_env)) { @@ -969,6 +969,7 @@ setup_nua (CallsSipOrigin *self) urn_uuid = g_strdup_printf ("urn:uuid:%s", uuid); self->protocol_prefix = get_protocol_prefix (self->transport_protocol); + protocol_lower = g_ascii_strdown (self->transport_protocol, -1); self->address = g_strconcat (self->user, "@", self->host, NULL); from_str = g_strconcat (self->protocol_prefix, ":", self->address, NULL); @@ -978,37 +979,24 @@ setup_nua (CallsSipOrigin *self) use_sips = check_sips (from_str); use_ipv6 = check_ipv6 (self->host); - if (self->local_port > 0) { - sip_url = g_strdup_printf ("sip:%s:%d", - use_ipv6 ? ipv6_bind : ipv4_bind, - self->local_port); - sips_url = g_strdup_printf ("sips:%s:%d", - use_ipv6 ? ipv6_bind : ipv4_bind, - self->local_port); - } else { - sip_url = g_strdup_printf ("sip:%s:*", - use_ipv6 ? ipv6_bind : ipv4_bind); - sips_url = g_strdup_printf ("sips:%s:*", - use_ipv6 ? ipv6_bind : ipv4_bind); - } - - /** For TLS nua_create() will error if NUTAG_URL includes ";transport=tls" - * In that case NUTAG_SIPS_URL should be used and NUTAG_URL should be as usual - * Since UDP is the default we only need to append the suffix in the TCP case - */ - if (g_ascii_strcasecmp (self->transport_protocol, "TCP") == 0) { - char *temp = sip_url; - - sip_url = g_strdup_printf ("%s;transport=%s", temp, self->transport_protocol); - g_free (temp); - } + if (self->local_port > 0) + url = g_strdup_printf ("%s:%s:%d;transport=%s", + self->protocol_prefix, + use_ipv6 ? ipv6_bind : ipv4_bind, + self->local_port, + protocol_lower); + else + url = g_strdup_printf ("%s:%s:*;transport=%s", + self->protocol_prefix, + use_ipv6 ? ipv6_bind : ipv4_bind, + protocol_lower); nua = nua_create (self->ctx->root, sip_callback, self, NUTAG_USER_AGENT (APP_DATA_NAME), - TAG_IF (!use_sips, NUTAG_URL (sip_url)), - TAG_IF (use_sips, NUTAG_SIPS_URL (sips_url)), + TAG_IF (!use_sips, NUTAG_URL (url)), + TAG_IF (use_sips, NUTAG_SIPS_URL (url)), SIPTAG_FROM_STR (from_str), NUTAG_ALLOW ("INVITE, ACK, BYE, CANCEL, OPTIONS, UPDATE"), NUTAG_SUPPORTED ("replaces, gruu, outbound"),