]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
udp: do not get unused ifindex for Darwin & IPv4
authorJaroslav Kysela <perex@perex.cz>
Thu, 29 May 2014 08:55:15 +0000 (10:55 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 29 May 2014 08:55:15 +0000 (10:55 +0200)
src/udp.c

index 9d5617ca99834997500fda809f2c64c8744474f9..239c444f5639b95a3c8f234d56cdab0ff531ecd7 100644 (file)
--- a/src/udp.c
+++ b/src/udp.c
@@ -90,6 +90,18 @@ udp_resolve( udp_connection_t *uc, int receiver )
   return 0;
 }
 
+static inline int
+udp_ifindex_required( udp_connection_t *uc )
+{
+  if (!uc->multicast)
+    return 0;
+#if defined(PLATFORM_DARWIN)
+  if (uc->ip.ss_family == AF_INET)
+    return 0;
+#endif
+  return 1;
+}
+
 static int
 udp_get_ifindex( const char *ifname )
 {
@@ -172,7 +184,7 @@ udp_bind ( const char *subsystem, const char *name,
   setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
 
   /* Bind to interface */
-  ifindex = uc->multicast ? udp_get_ifindex(ifname) : 0;
+  ifindex = udp_ifindex_required(uc) ? udp_get_ifindex(ifname) : 0;
   if (ifindex < 0) {
     tvherror(subsystem, "%s - could not find interface %s",
              name, ifname);
@@ -332,7 +344,7 @@ udp_connect ( const char *subsystem, const char *name,
   }
 
   /* Bind to interface */
-  ifindex = uc->multicast ? udp_get_ifindex(ifname) : 0;
+  ifindex = udp_ifindex_required(uc) ? udp_get_ifindex(ifname) : 0;
   if (ifindex < 0) {
     tvherror(subsystem, "%s - could not find interface %s",
              name, ifname);