]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Bug [1041] manycastclient fails with 4.2.5p120.
authorDave Hart <hart@ntp.org>
Sat, 23 May 2009 02:02:18 +0000 (02:02 +0000)
committerDave Hart <hart@ntp.org>
Sat, 23 May 2009 02:02:18 +0000 (02:02 +0000)
  (fixed by Dave Mills' prior delta to ntp_peer.c xmt -> aorg)
Bug [1196] VC6 winsock2.h does not define SO_EXLUSIVEADDRUSE.

bk: 4a17592aQ9uzDy_lGlZt2_YqU1O2Rw

ChangeLog
ntpd/ntp_io.c
ports/winnt/include/config.h

index 40727a4c2faf5a71349f98b48c9f36cd41952d27..271970d4282ab62d3d5b26739959c01579fd91cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
-* Bug [1193] Compile error: conflicting types for emalloc
+* Bug [1041] manycastclient fails with 4.2.5p120.
+* Bug [1193] Compile error: conflicting types for emalloc.
+* Bug [1196] VC6 winsock2.h does not define SO_EXLUSIVEADDRUSE.
 * xmt -> aorg timestamp cleanup from Dave Mills, reported by Dave Hart.
 * Leap/expire cleanup from Dave Mills.
 (4.2.5p178) 2009/05/21 Released by Harlan Stenn <stenn@ntp.org>
index 981f8460699574d31e28574143d07ad5e6787c58..08c912b1641fdadb7dd067f401c676f7e026ddd3 100644 (file)
@@ -3435,7 +3435,9 @@ findinterface(
 }
 
 /*
- * findlocalinterface - find local interface index corresponding to address
+ * findlocalinterface - find local interface corresponding to addr,
+ * which does not have any of flags set.  If bast is nonzero, addr is
+ * a broadcast address.
  *
  * This code attempts to find the local sending address for an outgoing
  * address by connecting a new socket to destinationaddress:NTP_PORT
@@ -3451,7 +3453,7 @@ static struct interface *
 findlocalinterface(
        struct sockaddr_storage *addr,
        int flags,
-       int bflag
+       int bcast
        )
 {
        SOCKET s;
@@ -3488,9 +3490,9 @@ findlocalinterface(
         * If we are looking for broadcast interface we need to set this
         * socket to allow broadcast
         */
-       if (bflag & INT_BROADCAST)
+       if (bcast)
                setsockopt(s, SOL_SOCKET, SO_BROADCAST,
-                         (char *)&on, sizeof(on));
+                          (char *)&on, sizeof(on));
 
        rtn = connect(s, (struct sockaddr *)&saddr, SOCKLEN(&saddr));
        if (rtn == SOCKET_ERROR)
@@ -3507,6 +3509,15 @@ findlocalinterface(
        DPRINTF(4, ("findlocalinterface: kernel maps %s to %s\n", stoa(addr), stoa(&saddr)));
        
        iface = getinterface(&saddr, flags);
+
+       /* 
+        * if we didn't find an exact match on saddr check for an
+        * interface on the same subnet as saddr.  This handles the
+        * case of the address suggested by the kernel being
+        * excluded by the user's -I and -L options to ntpd, when
+        * another address is enabled on the same subnet.
+        * See http://bugs.ntp.org/1184 for more detail.
+        */
        if (NULL == iface)
                iface = getsamenetinterface(&saddr, flags);
 
@@ -3660,11 +3671,11 @@ findbcastinter(
        DPRINTF(4, ("Finding broadcast/multicast interface for addr %s in list of addresses\n",
                    stoa(addr)));
 
-       interface = findlocalinterface(addr, INT_LOOPBACK|INT_WILDCARD, INT_BROADCAST);
+       interface = findlocalinterface(addr, INT_LOOPBACK | INT_WILDCARD, 1);
        
        if (interface != NULL)
        {
-               DPRINTF(4, ("Found bcast-/mcast- interface index #%d %s\n", interface->ifnum, interface->name));
+               DPRINTF(4, ("Easily found bcast-/mcast- interface index #%d %s\n", interface->ifnum, interface->name));
                return interface;
        }
 
index b1dc8cb445218ee81929e4e33f1caae9e6626abc..ce72b5a3ef305fb1766aa3320bebf53a5c0f04db 100644 (file)
@@ -143,6 +143,13 @@ typedef int socklen_t;
  */
 #define GETSOCKNAME_SOCKLEN_TYPE socklen_t
 
+/*
+ * Older SDKs do not define SO_EXCLUSIVEADDRUSE in winsock2.h
+ */
+#ifndef SO_EXCLUSIVEADDRUSE
+#define SO_EXCLUSIVEADDRUSE ((int)(~SO_REUSEADDR))
+#endif
+
 #if defined _MSC_VER && _MSC_VER < 1400
 /*
  * Use 32-bit time definitions for versions prior to VS 2005