]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Fix Multicast to not set the flag until used.
authorDanny Mayer <mayer@ntp.org>
Fri, 11 Jul 2003 18:27:56 +0000 (14:27 -0400)
committerDanny Mayer <mayer@ntp.org>
Fri, 11 Jul 2003 18:27:56 +0000 (14:27 -0400)
Remove the unnecessary socket-querying code in findinterface and just
look up the interface.

bk: 3f0f01ac1QPucbglnPumUfw1loTz2w

ntpd/ntp_io.c

index 50261d130b7788dc202a64eb8d771c9a7912fc7d..53e32e0bdf63981bcef12184ace17ebbd4fc544a 100644 (file)
@@ -365,8 +365,6 @@ convert_isc_if(isc_interface_t *isc_if, struct interface *itf, u_short port) {
                itf->flags |= INT_UP;
        if((isc_if->flags & INTERFACE_F_LOOPBACK) != 0)
                itf->flags |= INT_LOOPBACK;
-       if((isc_if->flags & INTERFACE_F_MULTICAST) != 0)
-               itf->flags |= INT_MULTICAST;
        if((isc_if->flags & INTERFACE_F_POINTTOPOINT) != 0)
                itf->flags |= INT_PPP;
 }
@@ -1852,57 +1850,18 @@ findinterface(
        struct sockaddr_storage *addr
        )
 {
-       SOCKET s;
-       int rtn, i;
-       struct sockaddr_storage saddr;
-       int saddrlen = SOCKLEN(addr);
-       /*
-        * This is considerably hoke. We open a socket, connect to it
-        * and slap a getsockname() on it. If anything breaks, as it
-        * probably will in some j-random knockoff, we just return the
-        * wildcard interface.
-        */
-       memset(&saddr, 0, sizeof(saddr));
-       saddr.ss_family = addr->ss_family;
-       if(addr->ss_family == AF_INET)
-               memcpy(&((struct sockaddr_in*)&saddr)->sin_addr, &((struct sockaddr_in*)addr)->sin_addr, sizeof(struct in_addr));
-       else if(addr->ss_family == AF_INET6)
-               memcpy(&((struct sockaddr_in6*)&saddr)->sin6_addr, &((struct sockaddr_in6*)addr)->sin6_addr, sizeof(struct in6_addr));
-       ((struct sockaddr_in*)&saddr)->sin_port = htons(2000);
-       s = socket(addr->ss_family, SOCK_DGRAM, 0);
-       if (s == INVALID_SOCKET)
-               return ANY_INTERFACE_CHOOSE(addr);
-
-       rtn = connect(s, (struct sockaddr *)&saddr, SOCKLEN(&saddr));
-#ifndef SYS_WINNT
-       if (rtn < 0)
-#else
-       if (rtn == SOCKET_ERROR)
-#endif
-       {
-               closesocket(s);
-               return ANY_INTERFACE_CHOOSE(addr);
-       }
-
-       rtn = getsockname(s, (struct sockaddr *)&saddr, &saddrlen);
-       closesocket(s);
-#ifndef SYS_WINNT
-       if (rtn < 0)
-#else
-       if (rtn == SOCKET_ERROR)
-#endif
-               return ANY_INTERFACE_CHOOSE(addr);
+       int i;
 
        for (i = nwilds; i < ninterfaces; i++) {
                /*
                * First look if is the the correct family
                */
-               if(inter_list[i].sin.ss_family != saddr.ss_family)
+               if(inter_list[i].sin.ss_family != addr->ss_family)
                        continue;
                /*
                 * We match the unicast address only.
                 */
-               if (SOCKCMP(&inter_list[i].sin, &saddr))
+               if (SOCKCMP(&inter_list[i].sin, addr))
                        return (&inter_list[i]);
        }
        return ANY_INTERFACE_CHOOSE(addr);