aboutsummaryrefslogtreecommitdiff
path: root/external/miniupnpc/minissdpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'external/miniupnpc/minissdpc.c')
-rw-r--r--external/miniupnpc/minissdpc.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/external/miniupnpc/minissdpc.c b/external/miniupnpc/minissdpc.c
index 7b1c317b2..a6380dfd4 100644
--- a/external/miniupnpc/minissdpc.c
+++ b/external/miniupnpc/minissdpc.c
@@ -1,5 +1,6 @@
/* $Id: minissdpc.c,v 1.28 2015/09/18 13:05:39 nanard Exp $ */
-/* Project : miniupnp
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * Project : miniupnp
* Web : http://miniupnp.free.fr/
* Author : Thomas BERNARD
* copyright (c) 2005-2015 Thomas Bernard
@@ -67,6 +68,10 @@ struct sockaddr_un {
#define HAS_IP_MREQN
#endif
+#if !defined(HAS_IP_MREQN) && !defined(_WIN32)
+#include <sys/ioctl.h>
+#endif
+
#if defined(HAS_IP_MREQN) && defined(NEED_STRUCT_IP_MREQN)
/* Several versions of glibc don't define this structure,
* define it here and compile with CFLAGS NEED_STRUCT_IP_MREQN */
@@ -647,11 +652,25 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
{
PRINT_SOCKET_ERROR("setsockopt");
}
-#else
+#elif !defined(_WIN32)
+ struct ifreq ifr;
+ int ifrlen = sizeof(ifr);
+ strncpy(ifr.ifr_name, multicastif, IFNAMSIZ);
+ ifr.ifr_name[IFNAMSIZ-1] = '\0';
+ if(ioctl(sudp, SIOCGIFADDR, &ifr, &ifrlen) < 0)
+ {
+ PRINT_SOCKET_ERROR("ioctl(...SIOCGIFADDR...)");
+ }
+ mc_if.s_addr = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
+ if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0)
+ {
+ PRINT_SOCKET_ERROR("setsockopt");
+ }
+#else /* _WIN32 */
#ifdef DEBUG
printf("Setting of multicast interface not supported with interface name.\n");
#endif
-#endif
+#endif /* #ifdef HAS_IP_MREQN / !defined(_WIN32) */
}
}
}