This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: IDN support in getaddrinfo().


I'm not finished yet, but I won't be able to work on this more until
the weekend, so if you want to pick up, I thought I'd leave a snapshot
of what I did tonight...  The remaining problem is to rewrite
profiles.c (and possibly touch rfc3454stub.c and stringprep.c too) to
not use static arrays but rather pointers, so it is simple to replace
them with "dlsym" pointers instead.  There is a dlopen stub loader in
rfc3454stub.c and the Makefile is set up for creating a DSO
libcidn.so.

Apply patch below, unpack http://josefsson.org/libidn.tar.gz into
libc/ and configure with --enable-add-ons=linuxthreads,libidn.

If you don't have time, don't worry, I'll get to it eventually..

Thanks,
Simon

Index: resolv/netdb.h
===================================================================
RCS file: /cvs/glibc/libc/resolv/netdb.h,v
retrieving revision 1.42
diff -u -p -r1.42 netdb.h
--- resolv/netdb.h	24 Apr 2003 23:40:02 -0000	1.42
+++ resolv/netdb.h	26 Nov 2003 21:27:52 -0000
@@ -573,6 +573,13 @@ struct gaicb
 # define AI_ALL		0x0010	/* Return IPv4 mapped and IPv6 addresses.  */
 # define AI_ADDRCONFIG	0x0020	/* Use configuration of this host to choose
 				   returned address type..  */
+# ifdef __USE_GNU
+#  define AI_IDN	0x0040	/* IDN encode input (assuming it is encoded
+				   in the current locale's character set)
+				   before looking it up. */
+#  define AI_CANONIDN	0x0080	/* IDN decode ai_canonname field (into the
+				   current locale's character set). */
+# endif
 
 /* Error values for `getaddrinfo' function.  */
 # define EAI_BADFLAGS	  -1	/* Invalid value for `ai_flags' field.  */
@@ -592,6 +599,8 @@ struct gaicb
 #  define EAI_NOTCANCELED -102	/* Request not canceled.  */
 #  define EAI_ALLDONE	  -103	/* All requests done.  */
 #  define EAI_INTR	  -104	/* Interrupted by a signal.  */
+#  define EAI_IDN_ENCODE  -105	/* IDN encoding failed.  */
+#  define EAI_IDN_DECODE  -106	/* IDN decoding failed.  */
 # endif
 
 # define NI_MAXHOST      1025
Index: sysdeps/posix/getaddrinfo.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/posix/getaddrinfo.c,v
retrieving revision 1.53
diff -u -p -r1.53 getaddrinfo.c
--- sysdeps/posix/getaddrinfo.c	18 Nov 2003 07:03:26 -0000	1.53
+++ sysdeps/posix/getaddrinfo.c	26 Nov 2003 21:27:54 -0000
@@ -55,6 +55,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
 #include <nsswitch.h>
 #include <not-cancel.h>
 
+extern int idna_to_ascii_lz (const char *input, char **output, int flags);
+#define IDNA_SUCCESS 0
+
 #define GAIH_OKIFUNSPEC 0x0100
 #define GAIH_EAI        ~(GAIH_OKIFUNSPEC)
 
@@ -539,6 +542,16 @@ gaih_inet (const char *name, const struc
       at->scopeid = 0;
       at->next = NULL;
 
+      if (req->ai_flags & AI_IDN)
+	{
+	  char *p;
+	  rc = idna_to_ascii_lz (name, &p, 0);
+	  if (rc != IDNA_SUCCESS)
+	    return -EAI_IDN_ENCODE;
+	  name = strdupa (p);
+	  free (p);
+	}
+
       if (inet_pton (AF_INET, name, at->addr) > 0)
 	{
 	  if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
@@ -1250,10 +1263,10 @@ getaddrinfo (const char *name, const cha
 
   if (hints->ai_flags
       & ~(AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST|AI_ADDRCONFIG|AI_V4MAPPED
-	  |AI_ALL))
+	  |AI_ALL|AI_IDN|AI_CANONIDN))
     return EAI_BADFLAGS;
 
-  if ((hints->ai_flags & AI_CANONNAME) && name == NULL)
+  if ((hints->ai_flags & (AI_CANONNAME|AI_CANONIDN)) && name == NULL)
     return EAI_BADFLAGS;
 
   if (hints->ai_flags & AI_ADDRCONFIG)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]