From 15e4dafc911589ee158e2d6dfa8e6e34c3992b7b Mon Sep 17 00:00:00 2001 From: Hajimu UMEMOTO Date: Tue, 2 Jul 2002 11:05:31 +0000 Subject: [PATCH] Make NI_WITHSCOPEID a default (always on), to synchronize with recent 2553bis. Obtained from: KAME MFC after: 3 weeks --- lib/libc/net/getnameinfo.c | 50 +++++++++++++++----------------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/lib/libc/net/getnameinfo.c b/lib/libc/net/getnameinfo.c index 2acef3e2329d..1a1c6dff8a9c 100644 --- a/lib/libc/net/getnameinfo.c +++ b/lib/libc/net/getnameinfo.c @@ -37,8 +37,10 @@ * modified). ipngwg rough consensus seems to follow RFC2553. * - What is "local" in NI_FQDN? * - NI_NAMEREQD and NI_NUMERICHOST conflict with each other. - * - (KAME extension) NI_WITHSCOPEID when called with global address, - * and sin6_scope_id filled + * - (KAME extension) always attach textual scopeid (fe80::1%lo0), if + * sin6_scope_id is filled - standardization status? + * XXX breaks backward compat for code that expects no scopeid. + * beware on merge. */ #include @@ -308,36 +310,24 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags) return ENI_MEMORY; strcpy(host, numaddr); -#ifdef NI_WITHSCOPEID - if ( -#ifdef DONT_OPAQUE_SCOPEID - (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) || - IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) && -#endif - ((const struct sockaddr_in6 *)sa)->sin6_scope_id) { -#ifndef ALWAYS_WITHSCOPE - if (flags & NI_WITHSCOPEID) -#endif /* !ALWAYS_WITHSCOPE */ - { - char scopebuf[MAXHOSTNAMELEN]; - int scopelen; + if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) { + char zonebuf[MAXHOSTNAMELEN]; + int zonelen; - /* ip6_sa2str never fails */ - scopelen = ip6_sa2str((const struct sockaddr_in6 *)sa, - scopebuf, sizeof(scopebuf), - flags); - if (scopelen + 1 + numaddrlen + 1 > hostlen) - return ENI_MEMORY; - /* - * construct - */ - memcpy(host + numaddrlen + 1, scopebuf, - scopelen); - host[numaddrlen] = SCOPE_DELIMITER; - host[numaddrlen + 1 + scopelen] = '\0'; - } + /* ip6_sa2str never fails */ + zonelen = ip6_sa2str( + (const struct sockaddr_in6 *)(const void *)sa, + zonebuf, sizeof(zonebuf), flags); + if (zonelen < 0) + return EAI_MEMORY; + if (zonelen + 1 + numaddrlen + 1 > hostlen) + return ENI_MEMORY; + /* construct */ + memcpy(host + numaddrlen + 1, zonebuf, + (size_t)zonelen); + host[numaddrlen] = SCOPE_DELIMITER; + host[numaddrlen + 1 + zonelen] = '\0'; } -#endif /* NI_WITHSCOPEID */ return 0; }