diff --git a/lib/libc/net/getnameinfo.c b/lib/libc/net/getnameinfo.c index 3e05932af205..b49ada75a37d 100644 --- a/lib/libc/net/getnameinfo.c +++ b/lib/libc/net/getnameinfo.c @@ -1,4 +1,4 @@ -/* $NetBSD: getnameinfo.c,v 1.33 2001/11/15 04:38:32 itojun Exp $ */ +/* $NetBSD: getnameinfo.c,v 1.34 2001/11/15 04:49:01 itojun Exp $ */ /* $KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $ */ /* @@ -39,13 +39,15 @@ * 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 #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getnameinfo.c,v 1.33 2001/11/15 04:38:32 itojun Exp $"); +__RCSID("$NetBSD: getnameinfo.c,v 1.34 2001/11/15 04:49:01 itojun Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -350,30 +352,23 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags) return EAI_MEMORY; strcpy(host, numaddr); -#ifdef NI_WITHSCOPEID if (((const struct sockaddr_in6 *)(const void *)sa)->sin6_scope_id) { - if (flags & NI_WITHSCOPEID) - { - char scopebuf[MAXHOSTNAMELEN]; - int scopelen; + char zonebuf[MAXHOSTNAMELEN]; + int zonelen; - scopelen = ip6_sa2str( - (const struct sockaddr_in6 *)(const void *)sa, - scopebuf, sizeof(scopebuf), 0); - if (scopelen < 0) - return EAI_MEMORY; - if (scopelen + 1 + numaddrlen + 1 > hostlen) - return EAI_MEMORY; - /* - * construct - */ - memcpy(host + numaddrlen + 1, scopebuf, - (size_t)scopelen); - host[numaddrlen] = SCOPE_DELIMITER; - host[numaddrlen + 1 + scopelen] = '\0'; - } + 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 EAI_MEMORY; + /* construct */ + memcpy(host + numaddrlen + 1, zonebuf, + (size_t)zonelen); + host[numaddrlen] = SCOPE_DELIMITER; + host[numaddrlen + 1 + zonelen] = '\0'; } -#endif /* NI_WITHSCOPEID */ return 0; }