From bde7591cc9ed4bdb69c6380df9051e1b22698b7f Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 26 May 2014 23:27:16 +0200 Subject: [PATCH 1/3] osx: fix interface selection for ipv4 multicast joins --- src/udp.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/udp.c b/src/udp.c index 79963740..9d5617ca 100644 --- a/src/udp.c +++ b/src/udp.c @@ -103,6 +103,27 @@ udp_get_ifindex( const char *ifname ) return r; } +#if defined(PLATFORM_DARWIN) +static int +udp_get_ifaddr( int fd, const char *ifname, struct in_addr *addr ) +{ + struct ifreq ifreq; + + if (ifname == NULL || *ifname == '\0') + return -1; + + memset(&ifreq, 0, sizeof(ifreq)); + strncpy(ifreq.ifr_name, ifname, IFNAMSIZ); + + if (ioctl(fd, SIOCGIFADDR, &ifreq) < 0) + return -1; + + memcpy(addr, &((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr, + sizeof(struct in_addr)); + return 0; +} +#endif + static int udp_get_solip( void ) { @@ -160,7 +181,11 @@ udp_bind ( const char *subsystem, const char *name, /* IPv4 */ if (uc->ip.ss_family == AF_INET) { +#if defined(PLATFORM_DARWIN) + struct ip_mreq m; +#else struct ip_mreqn m; +#endif memset(&m, 0, sizeof(m)); /* Bind */ @@ -174,8 +199,16 @@ udp_bind ( const char *subsystem, const char *name, if (uc->multicast) { /* Join group */ m.imr_multiaddr = IP_AS_V4(uc->ip, addr); +#if !defined(PLATFORM_DARWIN) m.imr_address.s_addr = 0; m.imr_ifindex = ifindex; +#else + if (udp_get_ifaddr(fd, ifname, &m.imr_interface) == -1) { + tvherror(subsystem, "%s - cannot find ip address for interface %s [e=%s]", + name, ifname, strerror(errno)); + goto error; + } +#endif if (setsockopt(fd, udp_get_solip(), IP_ADD_MEMBERSHIP, &m, sizeof(m))) { inet_ntop(AF_INET, &m.imr_multiaddr, buf, sizeof(buf)); @@ -308,9 +341,18 @@ udp_connect ( const char *subsystem, const char *name, if (uc->multicast) { if (uc->ip.ss_family == AF_INET) { +#if !defined(PLATFORM_DARWIN) struct ip_mreqn m; memset(&m, 0, sizeof(m)); m.imr_ifindex = ifindex; +#else + struct in_addr m; + if (udp_get_ifaddr(fd, ifname, &m) == -1) { + tvherror(subsystem, "%s - cannot find ip address for interface %s [e=%s]", + name, ifname, strerror(errno)); + goto error; + } +#endif if (setsockopt(fd, udp_get_solip(), IP_MULTICAST_IF, &m, sizeof(m))) tvhwarn(subsystem, "%s - cannot set source interface %s [%s]", name, ifname, strerror(errno)); From 992da6c374f16787b6337afc5e658caa4bda72b3 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Tue, 27 May 2014 23:15:21 +0200 Subject: [PATCH 2/3] osx: fix install Use POSIX compliant -R parameter instead of obsolete -r. On linux they are equivalent, on OS X -r is not supported. --- support/posix.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/posix.mk b/support/posix.mk index 404245a9..0e463c89 100644 --- a/support/posix.mk +++ b/support/posix.mk @@ -12,7 +12,7 @@ install: ${PROG} ${MAN} for bundle in ${BUNDLES}; do \ mkdir -p ${DESTDIR}${datadir}/tvheadend/$$bundle ;\ - cp -Lr $(ROOTDIR)/$$bundle/* ${DESTDIR}${datadir}/tvheadend/$$bundle ;\ + cp -LR $(ROOTDIR)/$$bundle/* ${DESTDIR}${datadir}/tvheadend/$$bundle ;\ done find ${DESTDIR}${datadir}/tvheadend -name .git -exec rm -rf {} \; &>/dev/null || /bin/true From a46a6d0dd39db8e3ad546a73c57ece91f92ee5b5 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Tue, 27 May 2014 23:45:15 +0200 Subject: [PATCH 3/3] build: download dvbscan files even if linuxdvb is disabled --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 0072a53d..a637379f 100755 --- a/configure +++ b/configure @@ -303,7 +303,7 @@ fi # # DVB scan # -if enabled linuxdvb && enabled dvbscan; then +if enabled dvbscan; then printf "${TAB}" "fetching dvb-scan files ..." "${ROOTDIR}/support/getmuxlist" if [ $? -ne 0 ]; then