From: Danny Mayer Date: Mon, 24 Feb 2003 04:25:50 +0000 (-0500) Subject: Fixes for multicast and broadcast and IPv6 interfaces. X-Git-Tag: NTP_4_1_80_RC1~69^2~3^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b5870bd342d9b4e4bc1a48b5048deafd7b7541fe;p=thirdparty%2Fntp.git Fixes for multicast and broadcast and IPv6 interfaces. bk: 3e599ecelrZJSv1AJNTS3bai_6GWRA --- diff --git a/libisc/ifiter_ioctl.c b/libisc/ifiter_ioctl.c index 1e8b99c990..f78c35177a 100644 --- a/libisc/ifiter_ioctl.c +++ b/libisc/ifiter_ioctl.c @@ -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. */ diff --git a/libisc/ifiter_sysctl.c b/libisc/ifiter_sysctl.c index ab809945a2..953edbffa5 100644 --- a/libisc/ifiter_sysctl.c +++ b/libisc/ifiter_sysctl.c @@ -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 { diff --git a/libisc/net.c b/libisc/net.c index acfb053408..6c51f1c973 100644 --- a/libisc/net.c +++ b/libisc/net.c @@ -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 diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index b66a4b891f..7669be3f00 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -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); } diff --git a/ports/winnt/libisc/interfaceiter.c b/ports/winnt/libisc/interfaceiter.c index cda6070652..d12800b374 100644 --- a/ports/winnt/libisc/interfaceiter.c +++ b/ports/winnt/libisc/interfaceiter.c @@ -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; } /* diff --git a/ports/winnt/libisc/net.c b/ports/winnt/libisc/net.c index e30350abd0..dd23549674 100644 --- a/ports/winnt/libisc/net.c +++ b/ports/winnt/libisc/net.c @@ -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