1 --- iputils-s20070202/ping.c.idn 2007-08-06 14:45:36.000000000 +0200
2 +++ iputils-s20070202/ping.c 2007-08-06 14:45:36.000000000 +0200
4 * This program has to run SUID to ROOT to access the ICMP socket.
10 #include "ping_common.h"
12 #include <netinet/ip.h>
14 char *target, hnamebuf[MAXHOSTNAMELEN];
15 char rspace[3 + 4 * NROUTES + 1]; /* record route space */
19 + setlocale(LC_ALL, "");
21 icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
28 + rc = idna_to_ascii_lz (target, &idn, 0);
29 + if (rc == IDNA_SUCCESS)
30 + hp = gethostbyname (idn);
32 + fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", target, rc);
36 - hp = gethostbyname(target);
38 fprintf(stderr, "ping: unknown host %s\n", target);
41 memcpy(&whereto.sin_addr, hp->h_addr, 4);
42 + rc = idna_to_unicode_lzlz (hp->h_name, &idn, 0);
43 + if (rc == IDNA_SUCCESS)
44 + strncpy(hnamebuf, idn, sizeof(hnamebuf) - 1);
46 + fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", hp->h_name, rc);
50 - strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
51 hnamebuf[sizeof(hnamebuf) - 1] = 0;
54 --- iputils-s20070202/Makefile.idn 2007-08-06 14:45:36.000000000 +0200
55 +++ iputils-s20070202/Makefile 2007-08-06 14:45:36.000000000 +0200
59 tftpd: tftpd.o tftpsubs.o
61 ping: ping.o ping_common.o
62 + $(CC) $(CFLAGS) ping.o ping_common.o -lidn -o ping
64 ping6: ping6.o ping_common.o
65 + $(CC) $(CFLAGS) ping6.o ping_common.o -o ping6
67 ping.o ping6.o ping_common.o: ping_common.h
68 tftpd.o tftpsubs.o: tftp.h
70 --- iputils-s20070202/ping6.c.idn 2007-08-06 14:45:36.000000000 +0200
71 +++ iputils-s20070202/ping6.c 2007-08-06 14:45:36.000000000 +0200
73 * More statistics could always be gathered.
74 * This program has to run SUID to ROOT to access the ICMP socket.
79 #include "ping_common.h"
81 #include <linux/filter.h>
83 int err, csum_offset, sz_opt;
84 static uint32_t scope_id = 0;
86 + setlocale(LC_ALL, "");
88 icmp_sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
93 memset(&hints, 0, sizeof(hints));
94 hints.ai_family = AF_INET6;
95 + hints.ai_flags = AI_IDN;
96 gai = getaddrinfo(target, NULL, &hints, &ai);
98 fprintf(stderr, "unknown host\n");
101 memset(&hints, 0, sizeof(hints));
102 hints.ai_family = AF_INET6;
103 + hints.ai_flags = AI_IDN;
104 gai = getaddrinfo(target, NULL, &hints, &ai);
106 fprintf(stderr, "unknown host\n");
107 --- iputils-s20070202/ping_common.c.idn 2007-08-06 14:45:36.000000000 +0200
108 +++ iputils-s20070202/ping_common.c 2007-08-06 14:47:41.000000000 +0200
112 #include "ping_common.h"
117 void common_options(int ch)
119 + setlocale(LC_ALL, "C");
122 options |= F_AUDIBLE;
127 + setlocale(LC_ALL, "");