From de44a17fe596773c6f1c048f967128908e198002 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Mon, 8 Mar 2021 11:26:55 +0100 Subject: [PATCH] sip: use ipv4 exclusively for now IPv6 should work, but sofia's outbound engine keep printing errors involving the outbound engine. Working theory: Failing ICMPv6 (pings) can make sofia think we don't have connectivity. Note that we also don't get any answers from the SIP servers we tried so far. --- plugins/sip/calls-sip-origin.c | 20 ++++++++++++++++---- plugins/sip/calls-sip-util.c | 8 ++++++++ plugins/sip/calls-sip-util.h | 1 + src/calls-origin.c | 6 +++--- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c index 1ba2159..b884a11 100644 --- a/plugins/sip/calls-sip-origin.c +++ b/plugins/sip/calls-sip-origin.c @@ -430,6 +430,9 @@ setup_nua (CallsSipOrigin *self) g_autofree gchar *address = NULL; nua_t *nua; gboolean use_sips; + gboolean use_ipv6 = FALSE; /* TODO make configurable or use DNS to figure out if ipv6 is supported*/ + gchar *ipv6_bind = "*"; + gchar *ipv4_bind = "0.0.0.0"; g_autofree gchar * sip_url = NULL; g_autofree gchar * sips_url = NULL; @@ -438,13 +441,21 @@ setup_nua (CallsSipOrigin *self) address = g_strconcat (self->protocol_prefix, ":", self->user, "@", self->host, NULL); use_sips = check_sips (address); + use_ipv6 = check_ipv6 (self->host); + if (self->local_port > 0) { - sip_url = g_strdup_printf ("sip:*:%d", self->local_port); - sips_url = g_strdup_printf ("sips:*:%d", self->local_port); + 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 ("sip:*:*"); - sips_url = g_strdup_printf ("sips:*:*"); + 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); } nua = nua_create (self->ctx->root, @@ -698,6 +709,7 @@ add_call (CallsSipOrigin *self, g_debug ("Setting local SDP for outgoing call to %s:\n%s", address, local_sdp); + /* TODO handle IPv4 vs IPv6 for nua_invite (SOATAG_TAG) */ nua_invite (self->oper->call_handle, SOATAG_AF (SOA_AF_IP4_IP6), SOATAG_USER_SDP_STR (local_sdp), diff --git a/plugins/sip/calls-sip-util.c b/plugins/sip/calls-sip-util.c index 2033397..355633e 100644 --- a/plugins/sip/calls-sip-util.c +++ b/plugins/sip/calls-sip-util.c @@ -24,6 +24,14 @@ #include "calls-sip-util.h" +gboolean +check_ipv6 (const gchar *host) +{ + /* TODO DNS SRV records to determine whether or not to use IPv6 */ + return FALSE; +} + + gboolean check_sips (const gchar *addr) { diff --git a/plugins/sip/calls-sip-util.h b/plugins/sip/calls-sip-util.h index 9767e7a..21b5345 100644 --- a/plugins/sip/calls-sip-util.h +++ b/plugins/sip/calls-sip-util.h @@ -80,6 +80,7 @@ typedef enum gboolean check_sips (const gchar *addr); +gboolean check_ipv6 (const gchar *host); const gchar *get_protocol_prefix (const gchar *protocol); gboolean protocol_is_valid (const gchar *protocol); guint get_port_for_rtp (void); diff --git a/src/calls-origin.c b/src/calls-origin.c index 231a07d..107d2ba 100644 --- a/src/calls-origin.c +++ b/src/calls-origin.c @@ -58,9 +58,9 @@ calls_origin_default_init (CallsOriginInterface *iface) g_object_interface_install_property ( iface, g_param_spec_pointer ("calls", - "Calls", - "The list of current calls", - G_PARAM_READABLE)); + "Calls", + "The list of current calls", + G_PARAM_READABLE)); signals[SIGNAL_CALL_ADDED] = g_signal_newv ("call-added",