Add NI_NUMERICSCOPE.

POSIX also declares NI_NUMERICSCOPE, which makes getnameinfo() return a
numerical scope identifier. The interesting thing is that support for
this is already present in code, but #ifdef disabled. Expose this
functionality by placing a definition for it in <netdb.h>.

While there, remove references to NI_WITHSCOPEID, as that got removed 11
years ago.
This commit is contained in:
ed 2016-07-28 10:05:41 +00:00
parent 53168ffb1b
commit 43835a137d
3 changed files with 5 additions and 7 deletions

View File

@ -214,9 +214,7 @@ struct addrinfo {
#define NI_NAMEREQD 0x00000004 #define NI_NAMEREQD 0x00000004
#define NI_NUMERICSERV 0x00000008 #define NI_NUMERICSERV 0x00000008
#define NI_DGRAM 0x00000010 #define NI_DGRAM 0x00000010
#if 0 /* obsolete */ #define NI_NUMERICSCOPE 0x00000020
#define NI_WITHSCOPEID 0x00000020
#endif
/* /*
* Scope delimit character * Scope delimit character

View File

@ -18,7 +18,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd September 20, 2015 .Dd July 28, 2016
.Dt GETNAMEINFO 3 .Dt GETNAMEINFO 3
.Os .Os
.Sh NAME .Sh NAME
@ -111,7 +111,7 @@ The
argument is formed by argument is formed by
.Tn OR Ns 'ing .Tn OR Ns 'ing
the following values: the following values:
.Bl -tag -width "NI_NUMERICHOSTXX" .Bl -tag -width "NI_NUMERICSCOPEXX"
.It Dv NI_NOFQDN .It Dv NI_NOFQDN
A fully qualified domain name is not required for local hosts. A fully qualified domain name is not required for local hosts.
The local part of the fully qualified domain name is returned instead. The local part of the fully qualified domain name is returned instead.
@ -127,6 +127,8 @@ If the host name is not found and the flag is not set, the
address is returned in numeric form. address is returned in numeric form.
.It NI_NUMERICSERV .It NI_NUMERICSERV
The service name is returned as a digit string representing the port number. The service name is returned as a digit string representing the port number.
.It NI_NUMERICSCOPE
The scope identifier is returned as a digit string.
.It NI_DGRAM .It NI_DGRAM
Specifies that the service being looked up is a datagram Specifies that the service being looked up is a datagram
service, and causes service, and causes

View File

@ -378,7 +378,6 @@ ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf, size_t bufsiz, int flags)
ifindex = (unsigned int)sa6->sin6_scope_id; ifindex = (unsigned int)sa6->sin6_scope_id;
a6 = &sa6->sin6_addr; a6 = &sa6->sin6_addr;
#ifdef NI_NUMERICSCOPE
if ((flags & NI_NUMERICSCOPE) != 0) { if ((flags & NI_NUMERICSCOPE) != 0) {
n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id); n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
if (n < 0 || n >= bufsiz) if (n < 0 || n >= bufsiz)
@ -386,7 +385,6 @@ ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf, size_t bufsiz, int flags)
else else
return n; return n;
} }
#endif
/* if_indextoname() does not take buffer size. not a good api... */ /* if_indextoname() does not take buffer size. not a good api... */
if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6) || if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6) ||