commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-182-gd3771


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-182-gd3771eb
Date: Thu, 04 Oct 2012 20:26:01 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  d3771eb02dee934f0f38abb944a8b53a5233999a (commit)
      from  066ab951480bcdf9599da7e8a1f2822b116fa5ef (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=d3771eb02dee934f0f38abb944a8b53a5233999a


commit d3771eb02dee934f0f38abb944a8b53a5233999a
Author: Mats Erik Andersson <address@hidden>
Date:   Thu Oct 4 22:24:15 2012 +0200

    ping, traceroute: IDN for glibc.

diff --git a/ChangeLog b/ChangeLog
index a6cc7af..dd37c65 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-10-04  Mats Erik Andersson  <address@hidden>
+
+       * ping/libping.c (ping_set_dest) [HAVE_DECL_GETADDRINFO]:
+       Alternative and preferred resolver using getaddrinfo().
+       * ping/ping6.c (print_echo) [NI_IDN]: Add flag NI_IDN
+       to getnameinfo() if option OPT_NUMERIC is not set.
+       (ping_set_dest) [AI_IDN]: Add flag AI_IDN to HINTS.
+       * ping/ping_common.c (ipaddr2str) [NI_IDN]: Add flag
+       NI_IDN to getnameinfo().
+       * src/traceroute.c (main) [AI_IDN]: Add flag AI_IDN to HINTS.
+       [AI_IDN && AI_CANONIDN]: Add flag AI_CANONIDN to HINTS.
+
 2012-10-02  Mats Erik Andersson  <address@hidden>
 
        * libinetutils/logwtmp.c [HAVE_STRUCT_UTMPX_UT_SYSLEN]:
diff --git a/ping/libping.c b/ping/libping.c
index ac99b9d..d269150 100644
--- a/ping/libping.c
+++ b/ping/libping.c
@@ -267,17 +267,55 @@ ping_set_packetsize (PING * ping, size_t size)
 int
 ping_set_dest (PING * ping, char *host)
 {
+#if HAVE_DECL_GETADDRINFO
+  int rc;
+  struct addrinfo hints, *res;
+  char *p;
+
+# ifdef HAVE_IDN
+  rc = idna_to_ascii_lz (host, &p, 0); /* P is allocated.  */
+  if (rc)
+    return 1;
+# else /* !HAVE_IDN */
+  p = host;
+# endif
+
+  memset (&hints, 0, sizeof (hints));
+  hints.ai_family = AF_INET;
+  hints.ai_flags = AI_CANONNAME;
+# ifdef AI_IDN
+  hints.ai_flags |= AI_IDN;
+#  ifdef AI_CANONIDN
+  hints.ai_flags |= AI_CANONIDN;
+#  endif
+# endif
+
+  rc = getaddrinfo (p, NULL, &hints, &res);
+# ifdef HAVE_IDN
+  free (p);
+# endif
+
+  if (rc)
+    return 1;
+
+  memcpy (&ping->ping_dest.ping_sockaddr, res->ai_addr, res->ai_addrlen);
+  ping->ping_hostname = strdup (res->ai_canonname);
+  freeaddrinfo (res);
+
+  return 0;
+#else /* !HAVE_DECL_GETADDRINFO */
+
   struct sockaddr_in *s_in = &ping->ping_dest.ping_sockaddr;
   s_in->sin_family = AF_INET;
-#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
+# ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
   s_in->sin_len = sizeof (*s_in);
-#endif
+# endif
   if (inet_aton (host, &s_in->sin_addr))
     ping->ping_hostname = strdup (host);
   else
     {
       struct hostent *hp;
-#ifdef HAVE_IDN
+# ifdef HAVE_IDN
       char *p;
       int rc;
 
@@ -286,9 +324,9 @@ ping_set_dest (PING * ping, char *host)
        return 1;
       hp = gethostbyname (p);
       free (p);
-#else /* !HAVE_IDN */
+# else /* !HAVE_IDN */
       hp = gethostbyname (host);
-#endif
+# endif
       if (!hp)
        return 1;
 
@@ -300,4 +338,5 @@ ping_set_dest (PING * ping, char *host)
       ping->ping_hostname = strdup (hp->h_name);
     }
   return 0;
+#endif /* !HAVE_DECL_GETADDRINFO */
 }
diff --git a/ping/ping6.c b/ping/ping6.c
index 5364a99..2035ec2 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -531,7 +531,13 @@ print_echo (int dupflag, int hops, struct ping_stat 
*ping_stat,
 
   err = getnameinfo ((struct sockaddr *) from, sizeof (*from),
                     buf, sizeof (buf), NULL, 0,
-                    (options & OPT_NUMERIC) ? NI_NUMERICHOST : 0);
+                    (options & OPT_NUMERIC) ? NI_NUMERICHOST
+#ifdef NI_IDN
+                    : NI_IDN
+#else
+                    : 0
+#endif
+                    );
   if (err)
     {
       const char *errmsg;
@@ -902,6 +908,9 @@ ping_set_dest (PING * ping, char *host)
 
   memset (&hints, 0, sizeof (hints));
   hints.ai_family = AF_INET6;
+#ifdef AI_IDN
+  hints.ai_flags = AI_IDN;
+#endif
 
   err = getaddrinfo (rhost, NULL, &hints, &result);
 #if HAVE_IDN
diff --git a/ping/ping_common.c b/ping/ping_common.c
index 59afb86..623fd9c 100644
--- a/ping/ping_common.c
+++ b/ping/ping_common.c
@@ -281,7 +281,13 @@ ipaddr2str (struct sockaddr *from, socklen_t fromlen)
     return xstrdup (ipstr);
 
   err = getnameinfo (from, fromlen, hoststr, sizeof (hoststr),
-                    NULL, 0, NI_NAMEREQD);
+                    NULL, 0,
+#ifdef NI_IDN
+                    NI_IDN | NI_NAMEREQD
+#else
+                    NI_NAMEREQD
+#endif
+                    );
   if (err)
     return xstrdup (ipstr);
 
diff --git a/src/traceroute.c b/src/traceroute.c
index 0a3ad38..8819336 100644
--- a/src/traceroute.c
+++ b/src/traceroute.c
@@ -227,6 +227,12 @@ main (int argc, char **argv)
   memset (&hints, 0, sizeof (hints));
   hints.ai_family = AF_INET;
   hints.ai_flags = AI_CANONNAME;
+#ifdef AI_IDN
+  hints.ai_flags |= AI_IDN;
+# ifdef AI_CANONIDN
+  hints.ai_flags |= AI_CANONIDN;
+# endif
+#endif
 
 #ifdef HAVE_IDN
   rc = idna_to_ascii_lz (hostname, &rhost, 0);

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |   12 ++++++++++++
 ping/libping.c     |   49 ++++++++++++++++++++++++++++++++++++++++++++-----
 ping/ping6.c       |   11 ++++++++++-
 ping/ping_common.c |    8 +++++++-
 src/traceroute.c   |    6 ++++++
 5 files changed, 79 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]