From a038a8d46d50775b7e954af5c63bcf49eaf5cd67 Mon Sep 17 00:00:00 2001 From: Peter Kjellerstedt Date: Wed, 25 Feb 2009 11:31:02 +0100 Subject: [PATCH] rtsp, multifdsink: Unify the use of union gst_sockaddr. --- gst-libs/gst/rtsp/gstrtspconnection.c | 11 ++++++----- gst/tcp/gstmultifdsink.c | 13 ++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gst-libs/gst/rtsp/gstrtspconnection.c b/gst-libs/gst/rtsp/gstrtspconnection.c index f5ba068..15e8e4a 100644 --- a/gst-libs/gst/rtsp/gstrtspconnection.c +++ b/gst-libs/gst/rtsp/gstrtspconnection.c @@ -1769,17 +1769,18 @@ gst_rtsp_connection_set_qos_dscp (GstRTSPConnection * conn, guint qos_dscp) { union gst_sockaddr { - struct sockaddr_storage sa_s; - struct sockaddr_in6 saddr6; + struct sockaddr sa; + struct sockaddr_in6 sa_in6; + struct sockaddr_storage sa_stor; } sa; - socklen_t sa_sl = sizeof (sa); + socklen_t slen = sizeof (sa); gint af; gint tos; g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL); g_return_val_if_fail (conn->fd.fd >= 0, GST_RTSP_EINVAL); - if (getsockname (conn->fd.fd, (struct sockaddr *) &sa.sa_s, &sa_sl) < 0) + if (getsockname (conn->fd.fd, &sa.sa, &slen) < 0) goto no_getsockname; af = sa.sa_s.ss_family; @@ -1787,7 +1788,7 @@ gst_rtsp_connection_set_qos_dscp (GstRTSPConnection * conn, guint qos_dscp) /* if this is an IPv4-mapped address then do IPv4 QoS */ if (af == AF_INET6) { - if (IN6_IS_ADDR_V4MAPPED (&sa.saddr6.sin6_addr)) + if (IN6_IS_ADDR_V4MAPPED (&sa.sa_in6.sin6_addr)) af = AF_INET; } diff --git a/gst/tcp/gstmultifdsink.c b/gst/tcp/gstmultifdsink.c index f6bb27a..af43790 100644 --- a/gst/tcp/gstmultifdsink.c +++ b/gst/tcp/gstmultifdsink.c @@ -703,8 +703,9 @@ setup_dscp_client (GstMultiFdSink * sink, GstTCPClient * client) gint ret; union gst_sockaddr { - struct sockaddr_storage ssaddr; - struct sockaddr_in6 saddr6; + struct sockaddr sa; + struct sockaddr_in6 sa_in6; + struct sockaddr_storage sa_stor; } sa; socklen_t slen = sizeof (sa); gint af; @@ -713,20 +714,18 @@ setup_dscp_client (GstMultiFdSink * sink, GstTCPClient * client) if (sink->qos_dscp < 0) return 0; - if ((ret = - getsockname (client->fd.fd, (struct sockaddr *) &sa.ssaddr, - &slen)) < 0) { + if ((ret = getsockname (client->fd.fd, &sa.sa, &slen)) < 0) { GST_DEBUG_OBJECT (sink, "could not get sockname: %s", g_strerror (errno)); return ret; } - af = sa.ssaddr.ss_family; + af = sa.sa.sa_family; /* if this is an IPv4-mapped address then do IPv4 QoS */ if (af == AF_INET6) { GST_DEBUG_OBJECT (sink, "check IP6 socket"); - if (IN6_IS_ADDR_V4MAPPED (&(sa.saddr6.sin6_addr))) { + if (IN6_IS_ADDR_V4MAPPED (&(sa.sa_in6.sin6_addr))) { GST_DEBUG_OBJECT (sink, "mapped to IPV4"); af = AF_INET; } -- 2.7.4