2010-05-17 12:28:06 +00:00
|
|
|
diff -up iputils-s20100418/Makefile.idn iputils-s20100418/Makefile
|
|
|
|
--- iputils-s20100418/Makefile.idn 2010-04-20 16:07:59.018479157 +0200
|
|
|
|
+++ iputils-s20100418/Makefile 2010-04-20 16:10:06.389481427 +0200
|
|
|
|
@@ -28,8 +28,13 @@ all: $(TARGETS)
|
|
|
|
|
|
|
|
tftpd: tftpd.o tftpsubs.o
|
|
|
|
-arping: arping.o -lsysfs
|
|
|
|
+arping: arping.o
|
|
|
|
+
|
|
|
|
ping: ping.o ping_common.o
|
|
|
|
-ping6: ping6.o ping_common.o -lresolv -lcrypto
|
2010-11-08 09:03:47 +00:00
|
|
|
+ $(CC) $(CFLAGS) $(LDFLAGS) ping.o ping_common.o -lidn -o ping
|
2010-05-17 12:28:06 +00:00
|
|
|
+
|
|
|
|
+ping6: ping6.o ping_common.o
|
2010-11-08 09:03:47 +00:00
|
|
|
+ $(CC) $(CFLAGS) $(LDFLAGS) ping6.o ping_common.o -lresolv -lcrypto -o ping6
|
2010-05-17 12:28:06 +00:00
|
|
|
+
|
|
|
|
ping.o ping6.o ping_common.o: ping_common.h
|
|
|
|
tftpd.o tftpsubs.o: tftp.h
|
|
|
|
|
|
|
|
diff -up iputils-s20100418/ping.c.idn iputils-s20100418/ping.c
|
|
|
|
--- iputils-s20100418/ping.c.idn 2010-04-20 16:07:59.038484302 +0200
|
|
|
|
+++ iputils-s20100418/ping.c 2010-04-20 16:07:59.077485007 +0200
|
|
|
|
@@ -58,6 +58,9 @@ char copyright[] =
|
2007-03-27 11:34:20 +00:00
|
|
|
* This program has to run SUID to ROOT to access the ICMP socket.
|
|
|
|
*/
|
|
|
|
|
|
|
|
+#include <idna.h>
|
|
|
|
+#include <locale.h>
|
|
|
|
+
|
|
|
|
#include "ping_common.h"
|
|
|
|
|
2007-08-07 09:14:36 +00:00
|
|
|
#include <netinet/ip.h>
|
2010-05-17 12:28:06 +00:00
|
|
|
@@ -123,6 +126,10 @@ main(int argc, char **argv)
|
|
|
|
char *target, hnamebuf[MAX_HOSTNAMELEN];
|
2007-03-27 11:34:20 +00:00
|
|
|
char rspace[3 + 4 * NROUTES + 1]; /* record route space */
|
|
|
|
|
|
|
|
+ char *idn;
|
|
|
|
+ int rc = 0;
|
|
|
|
+ setlocale(LC_ALL, "");
|
|
|
|
+
|
|
|
|
icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
|
|
|
|
socket_errno = errno;
|
|
|
|
|
2010-05-17 12:28:06 +00:00
|
|
|
@@ -250,13 +257,27 @@ main(int argc, char **argv)
|
2007-03-27 11:34:20 +00:00
|
|
|
if (argc == 1)
|
|
|
|
options |= F_NUMERIC;
|
|
|
|
} else {
|
2010-05-17 12:28:06 +00:00
|
|
|
- hp = gethostbyname(target);
|
2007-03-27 11:34:20 +00:00
|
|
|
+ rc = idna_to_ascii_lz (target, &idn, 0);
|
|
|
|
+ if (rc == IDNA_SUCCESS)
|
|
|
|
+ hp = gethostbyname (idn);
|
|
|
|
+ else {
|
|
|
|
+ fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", target, rc);
|
|
|
|
+ exit(2);
|
|
|
|
+ }
|
|
|
|
+ free(idn);
|
|
|
|
if (!hp) {
|
|
|
|
fprintf(stderr, "ping: unknown host %s\n", target);
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
memcpy(&whereto.sin_addr, hp->h_addr, 4);
|
2010-05-17 12:28:06 +00:00
|
|
|
- strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
|
2007-03-27 11:34:20 +00:00
|
|
|
+ rc = idna_to_unicode_lzlz (hp->h_name, &idn, 0);
|
|
|
|
+ if (rc == IDNA_SUCCESS)
|
|
|
|
+ strncpy(hnamebuf, idn, sizeof(hnamebuf) - 1);
|
|
|
|
+ else {
|
|
|
|
+ fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", hp->h_name, rc);
|
|
|
|
+ exit(2);
|
|
|
|
+ }
|
|
|
|
+ free(idn);
|
|
|
|
hnamebuf[sizeof(hnamebuf) - 1] = 0;
|
|
|
|
hostname = hnamebuf;
|
|
|
|
}
|
2010-05-17 12:28:06 +00:00
|
|
|
diff -up iputils-s20100418/ping_common.c.idn iputils-s20100418/ping_common.c
|
|
|
|
--- iputils-s20100418/ping_common.c.idn 2010-04-20 16:07:59.039478452 +0200
|
|
|
|
+++ iputils-s20100418/ping_common.c 2010-04-20 16:07:59.069478660 +0200
|
2008-06-03 11:04:03 +00:00
|
|
|
@@ -1,3 +1,5 @@
|
2007-08-07 09:14:36 +00:00
|
|
|
+#include <locale.h>
|
|
|
|
+
|
|
|
|
#include "ping_common.h"
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sched.h>
|
2010-05-17 12:28:06 +00:00
|
|
|
@@ -98,6 +100,7 @@ static void fill(char *patp)
|
2007-08-07 09:14:36 +00:00
|
|
|
|
|
|
|
void common_options(int ch)
|
|
|
|
{
|
|
|
|
+ setlocale(LC_ALL, "C");
|
|
|
|
switch(ch) {
|
|
|
|
case 'a':
|
|
|
|
options |= F_AUDIBLE;
|
2010-05-17 12:28:06 +00:00
|
|
|
@@ -242,6 +245,7 @@ void common_options(int ch)
|
2007-08-07 09:14:36 +00:00
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
+ setlocale(LC_ALL, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
|