Author: cazfi
Date: Wed Oct 14 17:31:25 2015
New Revision: 30076

URL: http://svn.gna.org/viewcvs/freeciv?rev=30076&view=rev
Log:
Use ip_mreqn structure as option for IP_ADD_MEMBERSIP setsockopt() if available.

See patch #6409

Modified:
    branches/S2_5/client/servers.c
    branches/S2_5/configure.ac
    branches/S2_5/server/sernet.c

Modified: branches/S2_5/client/servers.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/servers.c?rev=30076&r1=30075&r2=30076&view=diff
==============================================================================
--- branches/S2_5/client/servers.c      (original)
+++ branches/S2_5/client/servers.c      Wed Oct 14 17:31:25 2015
@@ -375,7 +375,11 @@
 #else  /* HAVE_WINSOCK */
   char buffer[MAX_LEN_PACKET];
 #endif /* HAVE_WINSOCK */
+#ifdef HAVE_IP_MREQN
+  struct ip_mreqn mreq4;
+#else
   struct ip_mreq mreq4;
+#endif
   const char *group;
   size_t size;
   int family;
@@ -481,7 +485,12 @@
   } else {
     inet_pton(AF_INET, group, &mreq4.imr_multiaddr.s_addr);
 #endif /* IPv6 support */
+#ifdef HAVE_IP_MREQN
+    mreq4.imr_address.s_addr = htonl(INADDR_ANY);
+    mreq4.imr_ifindex = 0;
+#else
     mreq4.imr_interface.s_addr = htonl(INADDR_ANY);
+#endif
 
     if (setsockopt(scan->sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
                    (const char*)&mreq4, sizeof(mreq4)) < 0) {

Modified: branches/S2_5/configure.ac
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/configure.ac?rev=30076&r1=30075&r2=30076&view=diff
==============================================================================
--- branches/S2_5/configure.ac  (original)
+++ branches/S2_5/configure.ac  Wed Oct 14 17:31:25 2015
@@ -1166,6 +1166,10 @@
 AC_MSG_CHECKING(for working gettimeofday)
   FC_CHECK_GETTIMEOFDAY_RUNTIME(,AC_DEFINE([HAVE_GETTIMEOFDAY], [1],
        [Define if the gettimeofday function works and is sane.]),)
+
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>]],
+[[struct ip_mreqn req; req.imr_ifindex = 0;]])],
+[AC_DEFINE([HAVE_IP_MREQN], [1], [struct ip_mreqn available])])
 
 dnl Check for extra socket libraries.
 dnl If the AC_CHECK_FUNCS check finds the function, we don't look any

Modified: branches/S2_5/server/sernet.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/sernet.c?rev=30076&r1=30075&r2=30076&view=diff
==============================================================================
--- branches/S2_5/server/sernet.c       (original)
+++ branches/S2_5/server/sernet.c       Wed Oct 14 17:31:25 2015
@@ -1068,7 +1068,11 @@
 {
   /* setup socket address */
   union fc_sockaddr addr;
+#ifdef HAVE_IP_MREQN
+  struct ip_mreqn mreq4;
+#else
   struct ip_mreq mreq4;
+#endif
   const char *cause, *group;
   int j, on, s;
   int lan_family;
@@ -1259,7 +1263,12 @@
   } else if (addr.saddr.sa_family == AF_INET) {
     inet_pton(AF_INET, group, &mreq4.imr_multiaddr.s_addr);
 #endif /* IPv6 support */
+#ifdef HAVE_IP_MREQN
+    mreq4.imr_address.s_addr = htonl(INADDR_ANY);
+    mreq4.imr_ifindex = 0;
+#else
     mreq4.imr_interface.s_addr = htonl(INADDR_ANY);
+#endif
 
     if (setsockopt(socklan, IPPROTO_IP, IP_ADD_MEMBERSHIP,
                    (const char*)&mreq4, sizeof(mreq4)) < 0) {


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to