From: Thorsten Kukuk <kukuk@suse.de>
To: Ulrich Drepper <drepper@redhat.com>
Cc: libc-hacker@sources.redhat.com
Subject: Re: AI_V4MAPPED/AI_ALL
Date: Sun, 30 Mar 2003 22:08:00 -0000 [thread overview]
Message-ID: <20030330201138.GA25740@suse.de> (raw)
In-Reply-To: <3E868213.8030803@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1237 bytes --]
On Sat, Mar 29, Ulrich Drepper wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Thorsten Kukuk wrote:
>
> > POSIX and rfc2553 mentions AI_V4MAPPED and AI_ALL as flags for
> > getaddrinfo(), but we removed them from the public header because
> > we don't want people to use them. What where the reasons for this?
>
> The RFCs are changed far too frequently for my taste. I'm not positive
> about adding anything not already in POSIX unless it's really proven to
> be stable and not changed in a couple of months.
Ok, AI_V4MAPPED and AI_ALL are specified in POSIX, rfc2553 and
rfc3493. So I doubt that it will be changed in the near future
again, I think something specified in POSIX should be stable
enought to include in glibc.
I append a patch which adds both defines to resolv/netdb.h and
implements it in getaddrinfo(). (Looking at the ugly getaddrinfo
code, it seems we really need a new, clean implementation :( ).
Thorsten
--
Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de
SuSE Linux AG Deutschherrnstr. 15-19 D-90429 Nuernberg
--------------------------------------------------------------------
Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B
[-- Attachment #2: getaddrinfo.v4mapped.diff --]
[-- Type: text/plain, Size: 3089 bytes --]
2003-03-29 Thorsten Kukuk <kukuk@suse.de>
* sysdeps/posix/getaddrinfo.c: Add support for AI_V4MAPPED/AI_ALL
as described by POSIX and in rfc3493
* resolv/netdb.h: Add AI_V4MAPPED/AI_ALL
--- resolv/netdb.h 2002-08-11 09:57:16.000000000 +0200
+++ resolv/netdb.h 2003-03-30 19:47:20.000000000 +0200
@@ -424,6 +424,8 @@
# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
# define AI_CANONNAME 0x0002 /* Request for canonical name. */
# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
+# define AI_V4MAPPED 0x0008 /* IPv4-mapped addresses are acceptable. */
+# define AI_ALL 0x0010 /* Return both IPv4 and IPv6 addresses. */
/* Error values for `getaddrinfo' function. */
# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
--- sysdeps/posix/getaddrinfo.c 2002-12-21 14:39:05.000000000 +0100
+++ sysdeps/posix/getaddrinfo.c 2003-03-30 19:51:35.000000000 +0200
@@ -52,6 +52,9 @@
#include <net/if.h>
#include <nsswitch.h>
+/* Get implementation for some internal functions. */
+#include <resolv/mapv4v6addr.h>
+
#define GAIH_OKIFUNSPEC 0x0100
#define GAIH_EAI ~(GAIH_OKIFUNSPEC)
@@ -368,6 +371,7 @@
struct gaih_servtuple *st = (struct gaih_servtuple *) &nullserv;
struct gaih_addrtuple *at = NULL;
int rc;
+ int v4mapped = (req->ai_family == AF_INET6) && (req->ai_flags & AI_V4MAPPED);
if (req->ai_protocol || req->ai_socktype)
{
@@ -488,7 +492,7 @@
if (inet_pton (AF_INET, name, at->addr) > 0)
{
- if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
+ if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET || v4mapped)
at->family = AF_INET;
else
return -EAI_ADDRFAMILY;
@@ -609,7 +613,10 @@
gethosts (AF_INET6, struct in6_addr);
no_inet6_data = no_data;
}
- else if (req->ai_family == AF_INET)
+
+ if (req->ai_family == AF_INET ||
+ (v4mapped && (no_inet6_data != 0 || h == NULL
+ || (req->ai_flags & AI_ALL))))
gethosts (AF_INET, struct in_addr);
if (no_data != 0 && no_inet6_data != 0)
@@ -745,7 +751,7 @@
else
namelen = 0;
- if (at2->family == AF_INET6)
+ if (at2->family == AF_INET6 || v4mapped)
{
family = AF_INET6;
socklen = sizeof (struct sockaddr_in6);
@@ -779,8 +785,13 @@
(struct sockaddr_in6 *) (*pai)->ai_addr;
sin6p->sin6_flowinfo = 0;
- memcpy (&sin6p->sin6_addr,
- at2->addr, sizeof (struct in6_addr));
+ if (at2->family == AF_INET6)
+ memcpy (&sin6p->sin6_addr,
+ at2->addr, sizeof (struct in6_addr));
+ else
+ map_v4v6_address ((char *)&at2->addr,
+ (char *)&sin6p->sin6_addr);
+
sin6p->sin6_port = st2->port;
sin6p->sin6_scope_id = at2->scopeid;
}
@@ -844,7 +854,8 @@
if (hints == NULL)
hints = &default_hints;
- if (hints->ai_flags & ~(AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST))
+ if (hints->ai_flags & ~(AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST|
+ AI_V4MAPPED|AI_ALL))
return EAI_BADFLAGS;
if ((hints->ai_flags & AI_CANONNAME) && name == NULL)
next prev parent reply other threads:[~2003-03-30 20:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-24 17:59 AI_V4MAPPED/AI_ALL Thorsten Kukuk
2003-03-30 20:11 ` AI_V4MAPPED/AI_ALL Ulrich Drepper
2003-03-30 22:08 ` Thorsten Kukuk [this message]
2003-03-30 23:33 ` AI_V4MAPPED/AI_ALL Roland McGrath
2003-03-31 9:46 ` AI_V4MAPPED/AI_ALL Thorsten Kukuk
2003-03-31 13:29 ` AI_V4MAPPED/AI_ALL Roland McGrath
2003-03-31 21:36 ` AI_V4MAPPED/AI_ALL Thorsten Kukuk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030330201138.GA25740@suse.de \
--to=kukuk@suse.de \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).