From: Harlan Stenn Date: Sun, 4 Sep 2005 20:32:05 +0000 (-0500) Subject: scopeid and WANT_IPV6 cleanup X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce6c93ef53d4cb4c2e7d660dc86773ead5f85b24;p=thirdparty%2Fntp.git scopeid and WANT_IPV6 cleanup bk: 431b59c5dH0XjwfQGHdv6Ja2djG0cg --- diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index a7aba41eb1..d66a60d30e 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -42,14 +42,16 @@ * Set up some macros to look for IPv6 and IPv6 multicast */ -#if defined(ISC_PLATFORM_HAVEIPV6) && !defined(DISABLE_IPV6) +#if defined(ISC_PLATFORM_HAVEIPV6) +# ifdef WANT_IPV6 -#define INCLUDE_IPV6_SUPPORT +# define INCLUDE_IPV6_SUPPORT -#if defined(INCLUDE_IPV6_SUPPORT) && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP) -#define INCLUDE_IPV6_MULTICAST_SUPPORT +# if defined(INCLUDE_IPV6_SUPPORT) && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP) +# define INCLUDE_IPV6_MULTICAST_SUPPORT -#endif /* IPV6 Multicast Support */ +# endif /* IPV6 Multicast Support */ +# endif /* Want IPv6 Support */ #endif /* IPv6 Support */ extern int listen_to_virtual_ips; @@ -416,7 +418,9 @@ create_wildcards(u_short port) { inter_list[idx].sin.ss_family = AF_INET6; ((struct sockaddr_in6*)&inter_list[idx].sin)->sin6_addr = in6addr_any; ((struct sockaddr_in6*)&inter_list[idx].sin)->sin6_port = port; +# ifdef ISC_PLATFORM_HAVESCOPEID ((struct sockaddr_in6*)&inter_list[idx].sin)->sin6_scope_id = 0; +# endif (void) strncpy(inter_list[idx].name, "wildcard", sizeof(inter_list[idx].name)); inter_list[idx].mask.ss_family = AF_INET6; memset(&((struct sockaddr_in6*)&inter_list[idx].mask)->sin6_addr.s6_addr, 0xff, sizeof(struct in6_addr)); @@ -1235,13 +1239,15 @@ io_multicast_add( #endif memset(&((struct sockaddr_in6*)&inter_list[ind].mask)->sin6_addr.s6_addr, 0xff, sizeof(struct in6_addr)); #endif +#ifdef ISC_PLATFORM_HAVESCOPEID i = findlocalcastinterface(&addr, INT_MULTICAST); if (i >= 0) lscope = ((struct sockaddr_in6*)&inter_list[i].sin)->sin6_scope_id; -#ifdef DEBUG +# ifdef DEBUG if (debug > 1) printf("Found interface index %d, scope: %d for address %s\n", i, lscope, stoa(&addr)); +# endif #endif break; } @@ -1502,7 +1508,11 @@ open_socket( sprintf(buff, "bind() fd %d, family %d, port %d, scope %d, addr %s, in6_is_addr_multicast=%d flags=%d fails: %%m", fd, addr->ss_family, (int)ntohs(((struct sockaddr_in6*)addr)->sin6_port), +# ifdef ISC_PLATFORM_HAVESCOPEID ((struct sockaddr_in6*)addr)->sin6_scope_id, stoa(addr), +# else + -1, +# endif IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)addr)->sin6_addr), flags); #endif else @@ -2363,7 +2373,9 @@ findlocalinterface( 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_in6*)&saddr)->sin6_port = htons(2000); +# ifdef ISC_PLATFORM_HAVESCOPEID ((struct sockaddr_in6*)&saddr)->sin6_scope_id = ((struct sockaddr_in6*)addr)->sin6_scope_id; +# endif } #endif s = socket(addr->ss_family, SOCK_DGRAM, 0);