]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Fixes for multicast and broadcast and IPv6 interfaces.
authorDanny Mayer <mayer@ntp.org>
Mon, 24 Feb 2003 04:25:50 +0000 (23:25 -0500)
committerDanny Mayer <mayer@ntp.org>
Mon, 24 Feb 2003 04:25:50 +0000 (23:25 -0500)
bk: 3e599ecelrZJSv1AJNTS3bai_6GWRA

libisc/ifiter_ioctl.c
libisc/ifiter_sysctl.c
libisc/net.c
ntpd/ntp_io.c
ports/winnt/libisc/interfaceiter.c
ports/winnt/libisc/net.c

index 1e8b99c99088d3ea80987a326816bbbbc694d688..f78c35177aed1b6f4d3234a9f6ef9ed9f008a95c 100644 (file)
@@ -449,6 +449,14 @@ internal_current4(isc_interfaceiter_t *iter) {
        if ((ifreq.ifr_flags & IFF_LOOPBACK) != 0)
                iter->current.flags |= INTERFACE_F_LOOPBACK;
 
+       if ((lifreq.lifr_flags & IFF_BROADCAST) != 0) {
+               iter->current.flags |= INTERFACE_F_BROADCAST;
+       }
+
+       if ((lifreq.lifr_flags & IFF_MULTICAST) != 0) {
+               iter->current.flags |= INTERFACE_F_MULTICAST;
+       }
+
 #if !defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
        if (family == AF_INET) 
                goto inet;
@@ -512,6 +520,27 @@ internal_current4(isc_interfaceiter_t *iter) {
                         (struct sockaddr *)&ifreq.ifr_dstaddr);
        }
 
+       if ((iter->current.flags & INTERFACE_F_BROADCAST) != 0) {
+               /*
+                * Ignore the HP/UX warning about "interger overflow during
+                * conversion.  It comes from its own macro definition,
+                * and is really hard to shut up.
+                */
+               if (ioctl(iter->socket, SIOCGLIFBRDADDR, (char *)&ifreq)
+                   < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                               isc_msgcat_get(isc_msgcat,
+                                              ISC_MSGSET_IFITERIOCTL,
+                                              ISC_MSG_GETDESTADDR,
+                                              "%s: getting "
+                                              "broadcast address: %s"),
+                                        ifreq.ifr_name, strbuf);
+                       return (ISC_R_IGNORE);
+               }
+               get_addr(family, &iter->current.broadcast,
+                        (struct sockaddr *)&ifreq.lifr_broadaddr);
+       }
        /*
         * Get the network mask.
         */
@@ -618,6 +647,14 @@ internal_current6(isc_interfaceiter_t *iter) {
        if ((lifreq.lifr_flags & IFF_LOOPBACK) != 0)
                iter->current.flags |= INTERFACE_F_LOOPBACK;
 
+       if ((lifreq.lifr_flags & IFF_BROADCAST) != 0) {
+               iter->current.flags |= INTERFACE_F_BROADCAST;
+       }
+
+       if ((lifreq.lifr_flags & IFF_MULTICAST) != 0) {
+               iter->current.flags |= INTERFACE_F_MULTICAST;
+       }
+
        /*
         * If the interface is point-to-point, get the destination address.
         */
@@ -643,6 +680,28 @@ internal_current6(isc_interfaceiter_t *iter) {
                         (struct sockaddr *)&lifreq.lifr_dstaddr);
        }
 
+       if ((iter->current.flags & INTERFACE_F_BROADCAST) != 0) {
+               /*
+                * Ignore the HP/UX warning about "interger overflow during
+                * conversion.  It comes from its own macro definition,
+                * and is really hard to shut up.
+                */
+               if (ioctl(iter->socket, SIOCGLIFBRDADDR, (char *)&ifreq)
+                   < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                               isc_msgcat_get(isc_msgcat,
+                                              ISC_MSGSET_IFITERIOCTL,
+                                              ISC_MSG_GETDESTADDR,
+                                              "%s: getting "
+                                              "broadcast address: %s"),
+                                        ifreq.ifr_name, strbuf);
+                       return (ISC_R_IGNORE);
+               }
+               get_addr(family, &iter->current.broadcast,
+                        (struct sockaddr *)&ifreq.lifr_broadaddr);
+       }
+
        /*
         * Get the network mask.
         */
index ab809945a2c8ba75b69730437abb371e699fbb9a..953edbffa50482ea70bc58df7f89b83e721b8b77 100644 (file)
@@ -182,6 +182,13 @@ internal_current(isc_interfaceiter_t *iter) {
                if ((ifam->ifam_flags & IFF_LOOPBACK) != 0)
                        iter->current.flags |= INTERFACE_F_LOOPBACK;
 
+               if ((ifam->ifam_flags & IFF_BROADCAST) != 0) {
+                       iter->current.flags |= INTERFACE_F_BROADCAST;
+               }
+
+               if ((ifam->ifam_flags & IFF_MULTICAST) != 0) {
+                       iter->current.flags |= INTERFACE_F_MULTICAST;
+               }
                /*
                 * This is not an interface address.
                 * Force another iteration.
@@ -250,6 +257,9 @@ internal_current(isc_interfaceiter_t *iter) {
                if (dst_sa != NULL &&
                    (iter->current.flags & IFF_POINTOPOINT) != 0)
                        get_addr(family, &iter->current.dstaddress, dst_sa);
+               if (dst_sa != NULL &&
+                   (iter->current.flags & IFF_BROADCAST) != 0)
+                       get_addr(family, &iter->current.broadcast, dst_sa);
 
                return (ISC_R_SUCCESS);
        } else {
index acfb0534080ce927ed0eeb52de31cb925f650d51..6c51f1c973fdd4f7241813b32f009b45ebe0aa1d 100644 (file)
@@ -64,7 +64,6 @@ try_proto(int domain) {
        }
 
 #ifdef ISC_PLATFORM_HAVEIPV6
-#ifdef WANT_IPV6
 #ifdef ISC_PLATFORM_HAVEIN6PKTINFO
        if (domain == PF_INET6) {
                struct sockaddr_in6 sin6;
@@ -86,7 +85,6 @@ try_proto(int domain) {
                }
        }
 #endif
-#endif
 #endif
 
        (void)close(s);
@@ -98,12 +96,10 @@ static void
 initialize_action(void) {
        ipv4_result = try_proto(PF_INET);
 #ifdef ISC_PLATFORM_HAVEIPV6
-#ifdef WANT_IPV6
 #ifdef ISC_PLATFORM_HAVEIN6PKTINFO
        ipv6_result = try_proto(PF_INET6);
 #endif
 #endif
-#endif
 }
 
 static void
index b66a4b891f13611fd771cc9467e99fdd13272819..7669be3f004d18cbcdf56a21787d00aa9f04fe3e 100644 (file)
@@ -1333,6 +1333,7 @@ sendpkt(
                inter->notsent++;
                packets_notsent++;
 #if defined(HAVE_IO_COMPLETION_PORT)
+               err = WSAGetLastError();
                if (err != WSAEWOULDBLOCK && err != WSAENOBUFS && slot < 0)
 #else
                if (errno != EWOULDBLOCK && errno != ENOBUFS && slot < 0)
@@ -1827,7 +1828,6 @@ findbcastinter(
        struct sockaddr_storage *addr
        )
 {
-#if !defined(MPE) && (defined(SIOCGIFCONF) || defined(SYS_WINNT))
        register int i;
 
        for (i = 0; i < ninterfaces; i++) {
@@ -1859,7 +1859,6 @@ findbcastinter(
                                return (&inter_list[i]);
                     }
        }
-#endif /* SIOCGIFCONF */
        return ANY_INTERFACE_CHOOSE(addr);
 }
 
index cda607065279a0b070d7cb445ea837b001b0730b..d12800b37462017c661f9a1b5be963dda40c7aa9 100644 (file)
@@ -259,16 +259,10 @@ internal_current(isc_interfaceiter_t *iter, int family) {
 
        if ((flags & IFF_BROADCAST) != 0) {
                iter->current.flags |= INTERFACE_F_BROADCAST;
-//             sprintf(iter->current.name, "Broadcast Interface %d",
-//                     iter->numIF);
-//             ifNamed = TRUE;
        }
 
        if ((flags & IFF_MULTICAST) != 0) {
                iter->current.flags |= INTERFACE_F_MULTICAST;
-//             sprintf(iter->current.name, "Multicast Interface %d",
-//                     iter->numIF);
-//             ifNamed = TRUE;
        }
 
        /*
index e30350abd0ffcae84f8133bf1e2131e88ef05ddb..dd23549674dda89ec316ce74b38dfb39b85ed2fd 100644 (file)
@@ -60,7 +60,6 @@ try_proto(int domain) {
        }
 
 #ifdef ISC_PLATFORM_HAVEIPV6
-#ifdef WANT_IPV6
 #ifdef ISC_PLATFORM_HAVEIN6PKTINFO
        if (domain == PF_INET6) {
                struct sockaddr_in6 sin6;
@@ -82,7 +81,6 @@ try_proto(int domain) {
                }
        }
 #endif
-#endif
 #endif
 
        closesocket(s);
@@ -94,12 +92,10 @@ static void
 initialize_action(void) {
        ipv4_result = try_proto(PF_INET);
 #ifdef ISC_PLATFORM_HAVEIPV6
-#ifdef WANT_IPV6
 #ifdef ISC_PLATFORM_HAVEIN6PKTINFO
        ipv6_result = try_proto(PF_INET6);
 #endif
 #endif
-#endif
 }
 
 static void