[calls/wip/ipv6] sip: Enable IPv6 for signalling and media handling
- From: Evangelos Ribeiro Tzaras <devrtz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [calls/wip/ipv6] sip: Enable IPv6 for signalling and media handling
- Date: Sat, 14 Aug 2021 19:29:11 +0000 (UTC)
commit 99c9cb0ad97a96724a1908aec66024c219acd85a
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date: Wed Jul 21 01:28:44 2021 +0200
sip: Enable IPv6 for signalling and media handling
This commit removes a lot of unnecessary code.
For the media pipeline we decide if our listening socket should use IPv6
by looking at the offered SDP message.
Closes #278
plugins/sip/calls-sip-call.c | 7 ++++--
plugins/sip/calls-sip-call.h | 3 ++-
plugins/sip/calls-sip-media-pipeline.c | 28 ++++++++++++++++++++---
plugins/sip/calls-sip-origin.c | 42 +++++++++-------------------------
plugins/sip/calls-sip-util.c | 8 -------
plugins/sip/calls-sip-util.h | 1 -
6 files changed, 43 insertions(+), 46 deletions(-)
---
diff --git a/plugins/sip/calls-sip-call.c b/plugins/sip/calls-sip-call.c
index 268bcd49..865aad80 100644
--- a/plugins/sip/calls-sip-call.c
+++ b/plugins/sip/calls-sip-call.c
@@ -69,6 +69,7 @@ struct _CallsSipCall
guint rport_rtp;
guint rport_rtcp;
gchar *remote;
+ gboolean use_ipv6;
nua_handle_t *nh;
GList *codecs;
@@ -103,6 +104,7 @@ try_setting_up_media_pipeline (CallsSipCall *self)
g_object_set (G_OBJECT (self->pipeline),
"lport-rtp", self->lport_rtp,
"lport-rtcp", self->lport_rtcp,
+ "use-ipv6", self->use_ipv6,
NULL);
g_debug ("Setting remote ports: RTP/RTCP %u/%u",
@@ -185,7 +187,6 @@ calls_sip_call_answer (CallsCall *call)
nua_respond (self->nh, 200, NULL,
SOATAG_USER_SDP_STR (local_sdp),
- SOATAG_AF (SOA_AF_IP4_IP6),
TAG_END ());
calls_sip_call_set_state (self, CALLS_CALL_STATE_ACTIVE);
@@ -355,7 +356,8 @@ void
calls_sip_call_setup_remote_media_connection (CallsSipCall *self,
const char *remote,
guint port_rtp,
- guint port_rtcp)
+ guint port_rtcp,
+ gboolean use_ipv6)
{
g_return_if_fail (CALLS_IS_SIP_CALL (self));
@@ -363,6 +365,7 @@ calls_sip_call_setup_remote_media_connection (CallsSipCall *self,
self->remote = g_strdup (remote);
self->rport_rtp = port_rtp;
self->rport_rtcp = port_rtcp;
+ self->use_ipv6 = use_ipv6;
try_setting_up_media_pipeline (self);
}
diff --git a/plugins/sip/calls-sip-call.h b/plugins/sip/calls-sip-call.h
index ea12b046..6e14b041 100644
--- a/plugins/sip/calls-sip-call.h
+++ b/plugins/sip/calls-sip-call.h
@@ -41,7 +41,8 @@ CallsSipCall *calls_sip_call_new (const g
void calls_sip_call_setup_remote_media_connection (CallsSipCall *self,
const char *remote,
guint port_rtp,
- guint port_rtcp);
+ guint port_rtcp,
+ gboolean use_ipv6);
void calls_sip_call_setup_local_media_connection (CallsSipCall *self,
guint port_rtp,
guint port_rtcp);
diff --git a/plugins/sip/calls-sip-media-pipeline.c b/plugins/sip/calls-sip-media-pipeline.c
index 723f3879..47f7487b 100644
--- a/plugins/sip/calls-sip-media-pipeline.c
+++ b/plugins/sip/calls-sip-media-pipeline.c
@@ -53,6 +53,7 @@ enum {
PROP_RPORT_RTP,
PROP_LPORT_RTCP,
PROP_RPORT_RTCP,
+ PROP_USE_IPV6,
PROP_DEBUG,
PROP_LAST_PROP,
};
@@ -65,6 +66,7 @@ struct _CallsSipMediaPipeline {
gboolean debug;
/* Connection details */
char *remote;
+ gboolean use_ipv6;
gint rport_rtp;
gint lport_rtp;
@@ -217,6 +219,10 @@ get_property (GObject *object,
g_value_set_uint (value, self->rport_rtcp);
break;
+ case PROP_USE_IPV6:
+ g_value_set_boolean (value, self->use_ipv6);
+ break;
+
case PROP_DEBUG:
g_value_set_boolean (value, self->debug);
break;
@@ -262,6 +268,10 @@ set_property (GObject *object,
self->rport_rtcp = g_value_get_uint (value);
break;
+ case PROP_USE_IPV6:
+ self->use_ipv6 = g_value_get_boolean (value);
+ break;
+
case PROP_DEBUG:
self->debug = g_value_get_boolean (value);
break;
@@ -338,6 +348,12 @@ calls_sip_media_pipeline_class_init (CallsSipMediaPipelineClass *klass)
1025, 65535, 5003,
G_PARAM_READWRITE);
+ props[PROP_USE_IPV6] = g_param_spec_boolean ("use-ipv6",
+ "Use IPv6",
+ "Use IPv6 for the pipeline",
+ TRUE,
+ G_PARAM_READWRITE);
+
props[PROP_DEBUG] = g_param_spec_boolean ("debug",
"Debug",
"Enable debugging information",
@@ -753,26 +769,32 @@ void
calls_sip_media_pipeline_start (CallsSipMediaPipeline *self)
{
GSocket *socket;
+
g_return_if_fail (CALLS_IS_SIP_MEDIA_PIPELINE (self));
g_debug ("Starting media pipeline");
self->is_running = TRUE;
+ g_object_set (self->rtp_src,
+ "address", self->use_ipv6 ? "::" : "0.0.0.0",
+ NULL);
/* First start the receiver pipeline so that
we may reuse the socket in the sender pipeline */
/* TODO can we do something similar for RTCP? */
gst_element_set_state (self->recv_pipeline, GST_STATE_PLAYING);
- g_object_get (self->rtp_src, "used-socket", &socket, NULL);
+ g_object_get (self->rtp_src,
+ "used-socket", &socket,
+ NULL);
if (socket) {
g_object_set (self->rtp_sink,
"close-socket", FALSE,
"socket", socket,
NULL);
- }
- else
+ } else {
g_warning ("Could not get used socket of udpsrc element");
+ }
/* Now start the sender pipeline */
gst_element_set_state (self->send_pipeline, GST_STATE_PLAYING);
diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c
index 1fc78308..7c749b6b 100644
--- a/plugins/sip/calls-sip-origin.c
+++ b/plugins/sip/calls-sip-origin.c
@@ -246,9 +246,7 @@ add_call (CallsSipOrigin *self,
/* TODO transform tel URI according to https://tools.ietf.org/html/rfc3261#section-19.1.6 */
- /* 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),
SIPTAG_TO_STR (address),
TAG_IF (!!self->contact_header, SIPTAG_CONTACT_STR (self->contact_header)),
@@ -311,9 +309,6 @@ static void
update_nua (CallsSipOrigin *self)
{
gboolean use_sips = FALSE;
- gboolean use_ipv6 = FALSE; /* TODO make configurable or use DNS to figure out if ipv6 is supported*/
- char *ipv6_bind = "*";
- char *ipv4_bind = "0.0.0.0";
g_autofree char *sip_url = NULL;
g_autofree char *sips_url = NULL;
g_autofree char *from_str = NULL;
@@ -328,20 +323,13 @@ update_nua (CallsSipOrigin *self)
from_str = g_strconcat (self->protocol_prefix, ":", self->address, NULL);
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);
+ sip_url = g_strdup_printf ("sip:*:%d", self->local_port);
+ sips_url = g_strdup_printf ("sips:*:%d", 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);
+ sip_url = g_strdup("sip:*:*");
+ sips_url = g_strdup ("sips:*:*");
}
nua_set_params (self->nua,
@@ -530,12 +518,14 @@ sip_i_state (int status,
GList *codecs =
calls_sip_media_manager_get_codecs_from_sdp (origin->media_manager,
r_sdp->sdp_media);
+ gboolean use_ipv6 = r_sdp->sdp_connection->c_addrtype == sdp_addr_ip6;
calls_sip_call_set_codecs (call, codecs);
calls_sip_call_setup_remote_media_connection (call,
r_sdp->sdp_connection->c_address,
r_sdp->sdp_media->m_port,
- r_sdp->sdp_media->m_port + 1);
+ r_sdp->sdp_media->m_port + 1,
+ use_ipv6);
}
switch (call_state) {
@@ -775,9 +765,6 @@ setup_nua (CallsSipOrigin *self)
{
nua_t *nua;
gboolean use_sips = FALSE;
- gboolean use_ipv6 = FALSE; /* TODO make configurable or use DNS to figure out if ipv6 is supported*/
- const char *ipv6_bind = "*";
- const char *ipv4_bind = "0.0.0.0";
const char *uuid = NULL;
g_autofree char *urn_uuid = NULL;
g_autofree char *sip_url = NULL;
@@ -793,20 +780,13 @@ setup_nua (CallsSipOrigin *self)
from_str = g_strconcat (self->protocol_prefix, ":", self->address, NULL);
use_sips = check_sips (self->address);
- 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);
+ sip_url = g_strdup_printf ("sip:*:%d", self->local_port);
+ sips_url = g_strdup_printf ("sips:*:%d", 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);
+ sip_url = g_strdup("sip:*:*");
+ sips_url = g_strdup ("sips:*:*");
}
nua = nua_create (self->ctx->root,
diff --git a/plugins/sip/calls-sip-util.c b/plugins/sip/calls-sip-util.c
index d5ea2a39..0eface1e 100644
--- a/plugins/sip/calls-sip-util.c
+++ b/plugins/sip/calls-sip-util.c
@@ -24,14 +24,6 @@
#include "calls-sip-util.h"
-gboolean
-check_ipv6 (const char *host)
-{
- /* TODO DNS SRV records to determine whether or not to use IPv6 */
- return FALSE;
-}
-
-
gboolean
check_sips (const char *addr)
{
diff --git a/plugins/sip/calls-sip-util.h b/plugins/sip/calls-sip-util.h
index a0ebb02a..f11c5937 100644
--- a/plugins/sip/calls-sip-util.h
+++ b/plugins/sip/calls-sip-util.h
@@ -59,7 +59,6 @@ typedef enum
gboolean check_sips (const char *addr);
-gboolean check_ipv6 (const char *host);
const char *get_protocol_prefix (const char *protocol);
gboolean protocol_is_valid (const char *protocol);
guint get_port_for_rtp (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]