Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in net-misc/iputils/files: iputils-20070202-idn.patch
Date: Sun, 20 Apr 2008 20:56:49
Message-Id: E1Jngac-0000eu-NJ@stork.gentoo.org
1 vapier 08/04/20 20:56:46
2
3 Added: iputils-20070202-idn.patch
4 Log:
5 Add support for USE=idn #218638 by Hanno Boeck.
6 (Portage version: 2.2_pre5)
7
8 Revision Changes Path
9 1.1 net-misc/iputils/files/iputils-20070202-idn.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-misc/iputils/files/iputils-20070202-idn.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-misc/iputils/files/iputils-20070202-idn.patch?rev=1.1&content-type=text/plain
13
14 Index: iputils-20070202-idn.patch
15 ===================================================================
16 sniped from Fedora and made to not suck
17
18 http://bugs.gentoo.org/218638
19
20 --- iputils-s20070202/Makefile
21 +++ iputils-s20070202/Makefile
22 @@ -22,6 +22,11 @@
23
24 all: $(TARGETS)
25
26 +ifeq ($(IDN),yes)
27 +CPPFLAGS += -DIDN
28 +ping: LDLIBS += -lidn
29 +ping6: LDLIBS += -lidn
30 +endif
31
32 tftpd: tftpd.o tftpsubs.o
33 ping: ping.o ping_common.o
34 --- iputils-s20070202/ping.c
35 +++ iputils-s20070202/ping.c
36 @@ -58,6 +58,11 @@
37 * This program has to run SUID to ROOT to access the ICMP socket.
38 */
39
40 +#ifdef IDN
41 +#include <idna.h>
42 +#include <locale.h>
43 +#endif
44 +
45 #include "ping_common.h"
46
47 #include <netinet/ip.h>
48 @@ -122,6 +128,12 @@
49 char *target, hnamebuf[MAXHOSTNAMELEN];
50 char rspace[3 + 4 * NROUTES + 1]; /* record route space */
51
52 +#ifdef IDN
53 + char *idn;
54 + int rc = 0;
55 + setlocale(LC_ALL, "");
56 +#endif
57 +
58 icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
59 socket_errno = errno;
60
61 @@ -242,13 +254,35 @@
62 if (argc == 1)
63 options |= F_NUMERIC;
64 } else {
65 +#ifdef IDN
66 + rc = idna_to_ascii_lz (target, &idn, 0);
67 + if (rc == IDNA_SUCCESS)
68 + hp = gethostbyname (idn);
69 + else {
70 + fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", target, rc);
71 + exit(2);
72 + }
73 + free(idn);
74 +#else
75 hp = gethostbyname(target);
76 +#endif
77 if (!hp) {
78 fprintf(stderr, "ping: unknown host %s\n", target);
79 exit(2);
80 }
81 memcpy(&whereto.sin_addr, hp->h_addr, 4);
82 +#ifdef IDN
83 + rc = idna_to_unicode_lzlz (hp->h_name, &idn, 0);
84 + if (rc == IDNA_SUCCESS)
85 + strncpy(hnamebuf, idn, sizeof(hnamebuf) - 1);
86 + else {
87 + fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", hp->h_name, rc);
88 + exit(2);
89 + }
90 + free(idn);
91 +#else
92 strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
93 +#endif
94 hnamebuf[sizeof(hnamebuf) - 1] = 0;
95 hostname = hnamebuf;
96 }
97 --- iputils-s20070202/ping6.c
98 +++ iputils-s20070202/ping6.c
99 @@ -66,6 +66,13 @@
100 * More statistics could always be gathered.
101 * This program has to run SUID to ROOT to access the ICMP socket.
102 */
103 +#ifdef IDN
104 +#ifndef _GNU_SOURCE
105 +#define _GNU_SOURCE
106 +#endif
107 +#include <locale.h>
108 +#endif
109 +
110 #include "ping_common.h"
111
112 #include <linux/filter.h>
113 @@ -210,6 +216,10 @@
114 int err, csum_offset, sz_opt;
115 static uint32_t scope_id = 0;
116
117 +#ifdef IDN
118 + setlocale(LC_ALL, "");
119 +#endif
120 +
121 icmp_sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
122 socket_errno = errno;
123
124 @@ -296,6 +306,9 @@
125
126 memset(&hints, 0, sizeof(hints));
127 hints.ai_family = AF_INET6;
128 +#ifdef IDN
129 + hints.ai_flags = AI_IDN;
130 +#endif
131 gai = getaddrinfo(target, NULL, &hints, &ai);
132 if (gai) {
133 fprintf(stderr, "unknown host\n");
134 @@ -328,6 +341,9 @@
135
136 memset(&hints, 0, sizeof(hints));
137 hints.ai_family = AF_INET6;
138 +#ifdef IDN
139 + hints.ai_flags = AI_IDN;
140 +#endif
141 gai = getaddrinfo(target, NULL, &hints, &ai);
142 if (gai) {
143 fprintf(stderr, "unknown host\n");
144 --- iputils-s20070202/ping_common.c
145 +++ iputils-s20070202/ping_common.c
146 @@ -1,3 +1,7 @@
147 +#ifdef IDN
148 +#include <locale.h>
149 +#endif
150 +
151 #include "ping_common.h"
152 #include <ctype.h>
153 #include <sched.h>
154 @@ -97,6 +102,9 @@
155
156 void common_options(int ch)
157 {
158 +#ifdef IDN
159 + setlocale(LC_ALL, "C");
160 +#endif
161 switch(ch) {
162 case 'a':
163 options |= F_AUDIBLE;
164 @@ -222,6 +230,9 @@
165 default:
166 abort();
167 }
168 +#ifdef IDN
169 + setlocale(LC_ALL, "");
170 +#endif
171 }
172
173
174
175
176
177 --
178 gentoo-commits@l.g.o mailing list