--- Begin Message ---
Package: iputils-ping
Version: 3:20020927-2
Severity: wishlist
Tags: patch
It would be nice if you can use IDNs without converting them beforehand.
IDNs are internationalized domain names, that can not only contain ASCII
characters but nearly all unicode characters and for compatibility they
are mapped to ASCII domain labels prefixed with "xn--".
Simple conversation from the (locale dependant string) to ascii strings
is necessary to support IDNs.
diff -Naur iputils-20020927/arping.c iputils-20020927-idn/arping.c
--- iputils-20020927/arping.c 2001-10-06 00:42:47.000000000 +0200
+++ iputils-20020927-idn/arping.c 2004-04-04 18:51:26.000000000 +0200
@@ -30,6 +30,9 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <locale.h>
+#include <idna.h>
+
#include "SNAPSHOT.h"
static void usage(void) __attribute__((noreturn));
@@ -301,6 +304,8 @@
int ch;
uid_t uid = getuid();
+ setlocale(LC_ALL, "");
+
s = socket(PF_PACKET, SOCK_DGRAM, 0);
socket_errno = errno;
@@ -396,6 +401,15 @@
if (inet_aton(target, &dst) != 1) {
struct hostent *hp;
+ char *ascii = NULL;
+
+ if (idna_to_ascii_lz(target, &ascii, 0) == IDNA_SUCCESS) {
+ if (strcmp(target, ascii) != 0)
+ target = ascii;
+ else
+ free(ascii);
+ }
+
hp = gethostbyname2(target, AF_INET);
if (!hp) {
fprintf(stderr, "arping: unknown host %s\n", target);
diff -Naur iputils-20020927/debian/control iputils-20020927-idn/debian/control
--- iputils-20020927/debian/control 2004-04-04 18:27:49.000000000 +0200
+++ iputils-20020927-idn/debian/control 2004-04-04 18:31:39.000000000 +0200
@@ -3,14 +3,14 @@
Priority: extra
Maintainer: Noah Meyerhans <[email protected]>
Standards-Version: 3.5.7.0
-Build-Depends: debhelper (>> 2), sp, sgmlspl, docbook
+Build-Depends: debhelper (>> 2), sp, sgmlspl, docbook, pkg-config, libidn11-dev
Package: iputils-ping
Architecture: any
Provides: ping
Priority: important
Conflicts: ping, suidmanager (<< 0.50)
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends} libidn11
Replaces: netbase (<< 4.00)
Description: Tools to test the reachability of network hosts
The ping command sends ICMP ECHO_REQUEST packets to a host in order to
@@ -23,7 +23,7 @@
Architecture: any
Suggests: traceroute
Priority: optional
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends} libidn11
Conflicts: suidmanager (<< 0.50)
Replaces: netbase (<< 4.00)
Description: Tools to trace the network path to a remote host
@@ -35,7 +35,7 @@
Package: iputils-arping
Architecture: any
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends} libidn11
Conflicts: suidmanager (<< 0.50), arping, iputils-ping (<<20001110-6)
Replaces: netbase (<< 4.00)
Description: Tool to send ICMP echo requests to an ARP address
diff -Naur iputils-20020927/debian/files iputils-20020927-idn/debian/files
diff -Naur iputils-20020927/Makefile iputils-20020927-idn/Makefile
--- iputils-20020927/Makefile 2004-04-04 18:27:49.000000000 +0200
+++ iputils-20020927-idn/Makefile 2004-04-04 18:37:44.000000000 +0200
@@ -5,7 +5,7 @@
DEFINES=
#options if you have a bind>=4.9.4 libresolv (or, maybe, glibc)
-LDLIBS=-lresolv
+LDLIBS=-lresolv `pkg-config libidn --libs-only-l`
ADDLIB=
ifeq ($(LIBC_INCLUDE)/socketbits.h,$(wildcard $(LIBC_INCLUDE)/socketbits.h))
@@ -25,7 +25,7 @@
# What a pity, all new gccs are buggy and -Werror does not work. Sigh.
#CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g -Werror
CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g
-CFLAGS=$(CCOPT) $(GLIBCFIX) -I$(KERNEL_INCLUDE) -I../include $(DEFINES)
+CFLAGS=$(CCOPT) $(GLIBCFIX) -I$(KERNEL_INCLUDE) -I../include $(DEFINES)
`pkg-config libidn --cflags`
IPV4_TARGETS=tracepath ping arping
IPV6_TARGETS=tracepath6 traceroute6 ping6
diff -Naur iputils-20020927/ping6.c iputils-20020927-idn/ping6.c
--- iputils-20020927/ping6.c 2004-04-04 18:27:49.000000000 +0200
+++ iputils-20020927-idn/ping6.c 2004-04-04 18:38:52.000000000 +0200
@@ -68,6 +68,9 @@
*/
#include "ping_common.h"
+#include <idna.h>
+#include <locale.h>
+
#include <linux/in6.h>
#include <linux/ipv6.h>
#include <linux/icmpv6.h>
@@ -183,6 +186,8 @@
struct icmp6_filter filter;
int err, csum_offset, sz_opt;
+ setlocale(LC_ALL, "");
+
icmp_sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
socket_errno = errno;
@@ -266,6 +271,14 @@
if (inet_pton(AF_INET6, target, &addr) <= 0) {
struct hostent *hp;
+ char *ascii = NULL;
+
+ if (idna_to_ascii_lz(target, &ascii, 0) ==
IDNA_SUCCESS) {
+ if (strcmp(target, ascii) != 0)
+ target = ascii;
+ else
+ free(ascii);
+ }
hp = gethostbyname2(target, AF_INET6);
@@ -295,6 +308,14 @@
if (inet_pton(AF_INET6, target, &whereto.sin6_addr) <= 0) {
struct hostent *hp;
+ char *ascii = NULL;
+
+ if (idna_to_ascii_lz(target, &ascii, 0) == IDNA_SUCCESS) {
+ if (strcmp(target, ascii) != 0)
+ target = ascii;
+ else
+ free(ascii);
+ }
hp = gethostbyname2(target, AF_INET6);
diff -Naur iputils-20020927/ping.c iputils-20020927-idn/ping.c
--- iputils-20020927/ping.c 2002-09-20 17:08:11.000000000 +0200
+++ iputils-20020927-idn/ping.c 2004-04-04 18:43:22.000000000 +0200
@@ -63,6 +63,8 @@
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
+#include <locale.h>
+#include <idna.h>
#define MAXIPLEN 60
#define MAXICMPLEN 76
@@ -115,6 +117,8 @@
char *target, hnamebuf[MAXHOSTNAMELEN];
char rspace[3 + 4 * NROUTES + 1]; /* record route space */
+ setlocale(LC_ALL, "");
+
icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
socket_errno = errno;
@@ -232,6 +236,14 @@
if (argc == 1)
options |= F_NUMERIC;
} else {
+ char *ascii;
+
+ if (idna_to_ascii_lz(target, &ascii, 0) ==
IDNA_SUCCESS) {
+ if (strcmp(target, ascii) != 0)
+ target = ascii;
+ else
+ free(ascii);
+ }
hp = gethostbyname(target);
if (!hp) {
fprintf(stderr, "ping: unknown host %s\n",
target);
diff -Naur iputils-20020927/tracepath6.c iputils-20020927-idn/tracepath6.c
--- iputils-20020927/tracepath6.c 2001-09-02 04:03:46.000000000 +0200
+++ iputils-20020927-idn/tracepath6.c 2004-04-04 18:57:20.000000000 +0200
@@ -25,6 +25,9 @@
#include <sys/uio.h>
#include <arpa/inet.h>
+#include <locale.h>
+#include <idna.h>
+
int overhead = 48;
int mtu = 128000;
int hops_to = -1;
@@ -283,6 +286,9 @@
char *p;
struct hostent *he;
int ch;
+ char *ascii = NULL;
+
+ setlocale(LC_ALL, "");
while ((ch = getopt(argc, argv, "nbh?")) != EOF) {
switch(ch) {
@@ -317,7 +323,15 @@
sin.sin6_port = htons(atoi(p+1));
} else
sin.sin6_port = htons(0x8000 | getpid());
- he = gethostbyname2(argv[0], AF_INET6);
+
+ if (idna_to_ascii_lz(argv[0], &ascii, 0) == IDNA_SUCCESS)
+ he = gethostbyname2(ascii, AF_INET6);
+ else
+ he = gethostbyname2(argv[0], AF_INET6);
+
+ if (ascii != NULL)
+ free(ascii);
+
if (he == NULL) {
herror("gethostbyname2");
exit(1);
diff -Naur iputils-20020927/tracepath.c iputils-20020927-idn/tracepath.c
--- iputils-20020927/tracepath.c 2002-02-23 01:10:59.000000000 +0100
+++ iputils-20020927-idn/tracepath.c 2004-04-04 18:55:39.000000000 +0200
@@ -22,6 +22,8 @@
#include <sys/time.h>
#include <sys/uio.h>
#include <arpa/inet.h>
+#include <locale.h>
+#include <idna.h>
struct hhistory
{
@@ -277,6 +279,9 @@
int ttl;
char *p;
int ch;
+ char *ascii = NULL;
+
+ setlocale(LC_ALL, "");
while ((ch = getopt(argc, argv, "nh?")) != EOF) {
switch(ch) {
@@ -307,7 +312,15 @@
base_port = atoi(p+1);
} else
base_port = 44444;
- he = gethostbyname(argv[0]);
+
+ if (idna_to_ascii_lz(argv[0], &ascii, 0) == IDNA_SUCCESS)
+ he = gethostbyname(ascii);
+ else
+ he = gethostbyname(argv[0]);
+
+ if (ascii != NULL)
+ free(ascii);
+
if (he == NULL) {
herror("gethostbyname");
exit(1);
diff -Naur iputils-20020927/traceroute6.c iputils-20020927-idn/traceroute6.c
--- iputils-20020927/traceroute6.c 2004-04-04 18:27:49.000000000 +0200
+++ iputils-20020927-idn/traceroute6.c 2004-04-04 18:59:43.000000000 +0200
@@ -260,6 +260,9 @@
#include <string.h>
#include <unistd.h>
+#include <locale.h>
+#include <idna.h>
+
#include "SNAPSHOT.h"
#define MAXPACKET 65535
@@ -334,6 +337,8 @@
int ch, i, on, probe, seq, tos, ttl;
int socket_errno;
+ setlocale(LC_ALL, "");
+
icmp_sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
socket_errno = errno;
@@ -424,7 +429,14 @@
if (inet_pton(AF_INET6, *argv, &to->sin6_addr) > 0) {
hostname = *argv;
} else {
- hp = gethostbyname2(*argv, AF_INET6);
+ char *ascii = NULL;
+
+ if (idna_to_ascii_lz(*argv, &ascii, 0) == IDNA_SUCCESS)
+ hp = gethostbyname2(ascii, AF_INET6);
+ else
+ hp = gethostbyname2(*argv, AF_INET6);
+ if (ascii != NULL)
+ free(ascii);
if (hp) {
memmove((caddr_t)&to->sin6_addr, hp->h_addr,
sizeof(to->sin6_addr));
hostname = (char *)hp->h_name;
--- End Message ---