2006-07-24 11:48:03 +00:00
|
|
|
/* GStreamer UDP network utility functions
|
|
|
|
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
|
|
|
|
* Copyright (C) 2006 Joni Valtanen <joni.valtanen@movial.fi>
|
2009-08-31 10:16:01 +00:00
|
|
|
* Copyright (C) 2009 Jarkko Palviainen <jarkko.palviainen@sesca.com>
|
2006-07-24 11:48:03 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
2010-03-11 09:09:55 +00:00
|
|
|
#include <stdlib.h>
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
#include <memory.h>
|
|
|
|
|
2010-03-09 16:13:31 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2009-06-23 13:10:10 +00:00
|
|
|
#include "gstudpnetutils.h"
|
|
|
|
|
2008-07-14 13:11:14 +00:00
|
|
|
/* EAI_ADDRFAMILY was obsoleted in BSD at some point */
|
|
|
|
#ifndef EAI_ADDRFAMILY
|
|
|
|
#define EAI_ADDRFAMILY 1
|
|
|
|
#endif
|
|
|
|
|
2006-07-24 11:48:03 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_udp_net_utils_win32_wsa_startup (GstObject * obj)
|
|
|
|
{
|
|
|
|
WSADATA w;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = WSAStartup (0x0202, &w);
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
GST_WARNING_OBJECT (obj, "WSAStartup error: %d", error);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (w.wVersion != 0x0202) {
|
|
|
|
WSACleanup ();
|
|
|
|
GST_WARNING_OBJECT (obj, "Winsock version wrong : 0x%x", w.wVersion);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
|
2008-11-20 22:56:58 +00:00
|
|
|
int
|
|
|
|
gst_udp_get_sockaddr_length (struct sockaddr_storage *addr)
|
|
|
|
{
|
|
|
|
/* MacOS is picky about passing precisely the correct length,
|
|
|
|
* so we calculate it here for the given socket type.
|
|
|
|
*/
|
|
|
|
switch (addr->ss_family) {
|
|
|
|
case AF_INET:
|
|
|
|
return sizeof (struct sockaddr_in);
|
|
|
|
case AF_INET6:
|
|
|
|
return sizeof (struct sockaddr_in6);
|
|
|
|
default:
|
|
|
|
/* don't know, Screw MacOS and use the full length */
|
|
|
|
return sizeof (*addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
int
|
|
|
|
gst_udp_get_addr (const char *hostname, int port, struct sockaddr_storage *addr)
|
|
|
|
{
|
2009-07-08 13:17:41 +00:00
|
|
|
struct addrinfo hints, *res = NULL, *nres;
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
char service[NI_MAXSERV];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset (&hints, 0, sizeof (hints));
|
|
|
|
hints.ai_family = AF_UNSPEC;
|
|
|
|
hints.ai_socktype = SOCK_DGRAM;
|
2008-07-23 22:01:20 +00:00
|
|
|
g_snprintf (service, sizeof (service) - 1, "%d", port);
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
service[sizeof (service) - 1] = '\0';
|
|
|
|
|
|
|
|
if ((ret = getaddrinfo (hostname, (port == -1) ? NULL : service, &hints,
|
|
|
|
&res)) < 0) {
|
2008-12-13 15:34:01 +00:00
|
|
|
goto beach;
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nres = res;
|
|
|
|
while (nres) {
|
|
|
|
if (nres->ai_family == AF_INET || nres->ai_family == AF_INET6)
|
|
|
|
break;
|
|
|
|
nres = nres->ai_next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nres) {
|
|
|
|
memcpy (addr, nres->ai_addr, nres->ai_addrlen);
|
|
|
|
} else {
|
2009-01-22 14:59:40 +00:00
|
|
|
ret = EAI_ADDRFAMILY;
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
}
|
|
|
|
|
2008-12-13 15:34:01 +00:00
|
|
|
freeaddrinfo (res);
|
2009-06-18 09:54:22 +00:00
|
|
|
beach:
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-03-11 20:32:56 +00:00
|
|
|
gst_udp_set_loop (int sockfd, guint16 ss_family, gboolean loop)
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
int l = (loop == FALSE) ? 0 : 1;
|
|
|
|
|
2010-03-10 21:23:43 +00:00
|
|
|
switch (ss_family) {
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
case AF_INET:
|
|
|
|
{
|
2009-08-31 10:13:07 +00:00
|
|
|
ret = setsockopt (sockfd, IPPROTO_IP, IP_MULTICAST_LOOP, &l, sizeof (l));
|
|
|
|
if (ret < 0)
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
return ret;
|
|
|
|
|
2008-05-21 17:35:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AF_INET6:
|
|
|
|
{
|
2009-08-31 10:13:07 +00:00
|
|
|
ret =
|
|
|
|
setsockopt (sockfd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &l,
|
|
|
|
sizeof (l));
|
|
|
|
if (ret < 0)
|
2008-05-21 17:35:50 +00:00
|
|
|
return ret;
|
|
|
|
|
2009-08-31 10:13:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
WSASetLastError (WSAEAFNOSUPPORT);
|
|
|
|
#else
|
|
|
|
errno = EAFNOSUPPORT;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-03-11 20:32:56 +00:00
|
|
|
gst_udp_set_ttl (int sockfd, guint16 ss_family, int ttl, gboolean is_multicast)
|
2009-08-31 10:13:07 +00:00
|
|
|
{
|
|
|
|
int optname = -1;
|
|
|
|
int ret = -1;
|
|
|
|
|
2010-03-10 21:23:43 +00:00
|
|
|
switch (ss_family) {
|
2009-08-31 10:13:07 +00:00
|
|
|
case AF_INET:
|
|
|
|
{
|
|
|
|
optname = (is_multicast == TRUE) ? IP_MULTICAST_TTL : IP_TTL;
|
|
|
|
ret = setsockopt (sockfd, IPPROTO_IP, optname, &ttl, sizeof (ttl));
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AF_INET6:
|
|
|
|
{
|
|
|
|
optname =
|
|
|
|
(is_multicast == TRUE) ? IPV6_MULTICAST_HOPS : IPV6_UNICAST_HOPS;
|
|
|
|
ret = setsockopt (sockfd, IPPROTO_IPV6, optname, &ttl, sizeof (ttl));
|
|
|
|
if (ret < 0)
|
2008-05-21 17:35:50 +00:00
|
|
|
return ret;
|
|
|
|
|
2009-08-31 10:13:07 +00:00
|
|
|
/* When using IPV4 address with IPV6 socket, both TTL values
|
|
|
|
must be set in order to actually use the given value.
|
|
|
|
Has no effect when IPV6 address is used. */
|
|
|
|
optname = (is_multicast == TRUE) ? IP_MULTICAST_TTL : IP_TTL;
|
|
|
|
ret = setsockopt (sockfd, IPPROTO_IP, optname, &ttl, sizeof (ttl));
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-05-21 17:35:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2009-02-27 19:24:53 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
WSASetLastError (WSAEAFNOSUPPORT);
|
|
|
|
#else
|
2008-05-21 17:35:50 +00:00
|
|
|
errno = EAFNOSUPPORT;
|
2009-02-27 19:24:53 +00:00
|
|
|
#endif
|
2008-05-21 17:35:50 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-03-13 17:28:59 +00:00
|
|
|
/* FIXME: Add interface selection for windows hosts. */
|
2008-05-21 17:35:50 +00:00
|
|
|
int
|
2009-03-13 17:28:59 +00:00
|
|
|
gst_udp_join_group (int sockfd, struct sockaddr_storage *addr, gchar * iface)
|
2008-05-21 17:35:50 +00:00
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
switch (addr->ss_family) {
|
|
|
|
case AF_INET:
|
|
|
|
{
|
2009-04-20 13:46:03 +00:00
|
|
|
#ifdef HAVE_IP_MREQN
|
2009-03-13 17:28:59 +00:00
|
|
|
struct ip_mreqn mreq4;
|
2009-04-20 13:46:03 +00:00
|
|
|
#else
|
|
|
|
struct ip_mreq mreq4;
|
2009-03-13 17:28:59 +00:00
|
|
|
#endif
|
2008-05-21 17:35:50 +00:00
|
|
|
|
2009-07-20 23:12:44 +00:00
|
|
|
memset (&mreq4, 0, sizeof (mreq4));
|
2008-05-21 17:35:50 +00:00
|
|
|
mreq4.imr_multiaddr.s_addr =
|
|
|
|
((struct sockaddr_in *) addr)->sin_addr.s_addr;
|
2009-04-20 16:25:34 +00:00
|
|
|
#ifdef HAVE_IP_MREQN
|
2009-03-13 17:28:59 +00:00
|
|
|
if (iface)
|
|
|
|
mreq4.imr_ifindex = if_nametoindex (iface);
|
|
|
|
else
|
|
|
|
mreq4.imr_ifindex = 0; /* Pick any. */
|
2009-04-20 13:46:03 +00:00
|
|
|
#else
|
|
|
|
mreq4.imr_interface.s_addr = INADDR_ANY;
|
2009-03-13 17:28:59 +00:00
|
|
|
#endif
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
|
|
|
|
if ((ret =
|
|
|
|
setsockopt (sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
|
|
|
(const void *) &mreq4, sizeof (mreq4))) < 0)
|
|
|
|
return ret;
|
|
|
|
|
2008-05-21 17:35:50 +00:00
|
|
|
break;
|
|
|
|
}
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
case AF_INET6:
|
|
|
|
{
|
|
|
|
struct ipv6_mreq mreq6;
|
|
|
|
|
2009-07-20 23:12:44 +00:00
|
|
|
memset (&mreq6, 0, sizeof (mreq6));
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
memcpy (&mreq6.ipv6mr_multiaddr,
|
|
|
|
&(((struct sockaddr_in6 *) addr)->sin6_addr),
|
|
|
|
sizeof (struct in6_addr));
|
|
|
|
mreq6.ipv6mr_interface = 0;
|
2009-03-13 17:28:59 +00:00
|
|
|
#if !defined(G_OS_WIN32)
|
|
|
|
if (iface)
|
|
|
|
mreq6.ipv6mr_interface = if_nametoindex (iface);
|
|
|
|
#endif
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
|
|
|
|
if ((ret =
|
2008-05-22 11:19:03 +00:00
|
|
|
setsockopt (sockfd, IPPROTO_IPV6, IPV6_JOIN_GROUP,
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
(const void *) &mreq6, sizeof (mreq6))) < 0)
|
|
|
|
return ret;
|
|
|
|
|
2008-05-21 17:35:50 +00:00
|
|
|
break;
|
|
|
|
}
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
default:
|
2008-07-23 22:01:20 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
WSASetLastError (WSAEAFNOSUPPORT);
|
|
|
|
#else
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
errno = EAFNOSUPPORT;
|
2008-07-23 22:01:20 +00:00
|
|
|
#endif
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
gst_udp_leave_group (int sockfd, struct sockaddr_storage *addr)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
switch (addr->ss_family) {
|
|
|
|
case AF_INET:
|
|
|
|
{
|
|
|
|
struct ip_mreq mreq4;
|
|
|
|
|
2009-07-20 23:12:44 +00:00
|
|
|
memset (&mreq4, 0, sizeof (mreq4));
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
mreq4.imr_multiaddr.s_addr =
|
|
|
|
((struct sockaddr_in *) addr)->sin_addr.s_addr;
|
|
|
|
mreq4.imr_interface.s_addr = INADDR_ANY;
|
|
|
|
|
|
|
|
if ((ret =
|
|
|
|
setsockopt (sockfd, IPPROTO_IP, IP_DROP_MEMBERSHIP,
|
|
|
|
(const void *) &mreq4, sizeof (mreq4))) < 0)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AF_INET6:
|
|
|
|
{
|
|
|
|
struct ipv6_mreq mreq6;
|
|
|
|
|
2009-07-20 23:12:44 +00:00
|
|
|
memset (&mreq6, 0, sizeof (mreq6));
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
memcpy (&mreq6.ipv6mr_multiaddr,
|
|
|
|
&(((struct sockaddr_in6 *) addr)->sin6_addr),
|
|
|
|
sizeof (struct in6_addr));
|
|
|
|
mreq6.ipv6mr_interface = 0;
|
|
|
|
|
|
|
|
if ((ret =
|
2008-05-22 11:19:03 +00:00
|
|
|
setsockopt (sockfd, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
(const void *) &mreq6, sizeof (mreq6))) < 0)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-07-23 22:01:20 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
WSASetLastError (WSAEAFNOSUPPORT);
|
|
|
|
#else
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
errno = EAFNOSUPPORT;
|
2008-07-23 22:01:20 +00:00
|
|
|
#endif
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
gst_udp_is_multicast (struct sockaddr_storage *addr)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
switch (addr->ss_family) {
|
|
|
|
case AF_INET:
|
|
|
|
{
|
|
|
|
struct sockaddr_in *addr4 = (struct sockaddr_in *) addr;
|
|
|
|
|
2008-06-13 11:47:28 +00:00
|
|
|
ret = IN_MULTICAST (g_ntohl (addr4->sin_addr.s_addr));
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AF_INET6:
|
|
|
|
{
|
|
|
|
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) addr;
|
|
|
|
|
|
|
|
ret = IN6_IS_ADDR_MULTICAST (&addr6->sin6_addr);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-07-23 22:01:20 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
WSASetLastError (WSAEAFNOSUPPORT);
|
|
|
|
#else
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
errno = EAFNOSUPPORT;
|
2008-07-23 22:01:20 +00:00
|
|
|
#endif
|
gst/udp/gstudpnetutils.*: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently.
Original commit message from CVS:
Patch by: Bruno Santos <brunof at ua dot pt>
* gst/udp/gstudpnetutils.c: (gst_udp_get_addr),
(gst_udp_join_group), (gst_udp_leave_group),
(gst_udp_is_multicast):
* gst/udp/gstudpnetutils.h:
Provide a bunch of helper methods to deal with IPv4 and IPv6
transparently.
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_set_property),
(gst_multiudpsink_get_property), (join_multicast),
(gst_multiudpsink_init_send), (gst_multiudpsink_add_internal),
(gst_multiudpsink_remove):
* gst/udp/gstmultiudpsink.h:
Add multicast TTL and loopback properties.
Use the helper methods to implement ip4 and ip6.
* gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start):
* gst/udp/gstudpsrc.h:
Use the helper methods to implement ip4 and ip6.
Fixes #515962.
2008-05-21 09:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2010-03-09 16:13:31 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
gst_udp_uri_init (GstUDPUri * uri, const gchar * host, gint port)
|
|
|
|
{
|
|
|
|
uri->host = NULL;
|
|
|
|
uri->port = -1;
|
|
|
|
gst_udp_uri_update (uri, host, port);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
gst_udp_uri_update (GstUDPUri * uri, const gchar * host, gint port)
|
|
|
|
{
|
|
|
|
if (host) {
|
|
|
|
g_free (uri->host);
|
|
|
|
uri->host = g_strdup (host);
|
|
|
|
if (strchr (host, ':'))
|
|
|
|
uri->is_ipv6 = TRUE;
|
|
|
|
else
|
|
|
|
uri->is_ipv6 = FALSE;
|
|
|
|
}
|
|
|
|
if (port != -1)
|
|
|
|
uri->port = port;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
gst_udp_parse_uri (const gchar * uristr, GstUDPUri * uri)
|
|
|
|
{
|
|
|
|
gchar *protocol;
|
|
|
|
gchar *location, *location_end;
|
|
|
|
gchar *colptr;
|
|
|
|
|
|
|
|
protocol = gst_uri_get_protocol (uristr);
|
|
|
|
if (strcmp (protocol, "udp") != 0)
|
|
|
|
goto wrong_protocol;
|
|
|
|
g_free (protocol);
|
|
|
|
|
|
|
|
location = gst_uri_get_location (uristr);
|
|
|
|
if (!location)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
GST_DEBUG ("got location '%s'", location);
|
|
|
|
|
|
|
|
if (location[0] == '[') {
|
|
|
|
GST_DEBUG ("parse IPV6 address '%s'", location);
|
|
|
|
location_end = strchr (location, ']');
|
|
|
|
if (location_end == NULL)
|
|
|
|
goto wrong_address;
|
|
|
|
|
|
|
|
uri->is_ipv6 = TRUE;
|
|
|
|
g_free (uri->host);
|
|
|
|
uri->host = g_strndup (location + 1, location_end - location - 1);
|
|
|
|
colptr = strrchr (location_end, ':');
|
|
|
|
} else {
|
|
|
|
GST_DEBUG ("parse IPV4 address '%s'", location);
|
|
|
|
uri->is_ipv6 = FALSE;
|
|
|
|
colptr = strrchr (location, ':');
|
|
|
|
|
|
|
|
g_free (uri->host);
|
|
|
|
if (colptr != NULL) {
|
|
|
|
uri->host = g_strndup (location, colptr - location);
|
|
|
|
} else {
|
|
|
|
uri->host = g_strdup (location);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GST_DEBUG ("host set to '%s'", uri->host);
|
|
|
|
|
|
|
|
if (colptr != NULL) {
|
|
|
|
uri->port = atoi (colptr + 1);
|
|
|
|
}
|
|
|
|
g_free (location);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
wrong_protocol:
|
|
|
|
{
|
|
|
|
GST_ERROR ("error parsing uri %s: wrong protocol (%s != udp)", uristr,
|
|
|
|
protocol);
|
|
|
|
g_free (protocol);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
wrong_address:
|
|
|
|
{
|
|
|
|
GST_ERROR ("error parsing uri %s", uristr);
|
|
|
|
g_free (location);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
gst_udp_uri_string (GstUDPUri * uri)
|
|
|
|
{
|
|
|
|
gchar *result;
|
|
|
|
|
|
|
|
if (uri->is_ipv6) {
|
|
|
|
result = g_strdup_printf ("udp://[%s]:%d", uri->host, uri->port);
|
|
|
|
} else {
|
|
|
|
result = g_strdup_printf ("udp://%s:%d", uri->host, uri->port);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_udp_uri_free (GstUDPUri * uri)
|
|
|
|
{
|
|
|
|
g_free (uri->host);
|
|
|
|
uri->host = NULL;
|
|
|
|
uri->port = -1;
|
|
|
|
}
|