make NI_WITHSCOPEID a default (always on), to synchronize with recent 2553bis.

sync with kame.
This commit is contained in:
itojun 2001-11-15 04:49:01 +00:00
parent 72a8eddd96
commit 6c9440f374
1 changed files with 20 additions and 25 deletions

View File

@ -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 <sys/cdefs.h>
#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 <numeric-addr><delim><scopeid>
*/
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 <numeric-addr><delim><zoneid> */
memcpy(host + numaddrlen + 1, zonebuf,
(size_t)zonelen);
host[numaddrlen] = SCOPE_DELIMITER;
host[numaddrlen + 1 + zonelen] = '\0';
}
#endif /* NI_WITHSCOPEID */
return 0;
}