Initial commit: Uploaded everything from abs/core
[arch-rock.git] / base / iputils / iputils-big-patches.patch
blob29bc310ec9614736b4efb3d66f96bae7df05d07e
1 diff -Naur iputils.orig/Makefile iputils/Makefile
2 --- iputils.orig/Makefile 2002-11-09 03:01:11.000000000 +0000
3 +++ iputils/Makefile 2005-06-09 16:15:32.000000000 +0000
4 @@ -17,11 +17,6 @@
5 GLIBCFIX=-Iinclude-glibc -include include-glibc/glibc-bugs.h
6 endif
8 -ifeq ($(KERNEL_INCLUDE)/linux/pfkeyv2.h,$(wildcard $(KERNEL_INCLUDE)/linux/pfkeyv2.h))
9 - SUBDIRS=libipsec setkey
10 - LDLIBS+=-Llibipsec -lipsec
11 - IPSECDEF=-DDO_IPSEC -Ilibipsec
12 -endif
15 #options if you compile with libc5, and without a bind>=4.9.4 libresolv
16 @@ -31,7 +26,7 @@
17 # What a pity, all new gccs are buggy and -Werror does not work. Sigh.
18 #CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g -Werror
19 CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g
20 -CFLAGS=$(CCOPT) $(GLIBCFIX) -I$(KERNEL_INCLUDE) -I../include $(IPSECDEF) $(DEFINES)
21 +CFLAGS=$(CCOPT) -I../include $(IPSECDEF) $(DEFINES)
23 IPV4_TARGETS=tracepath ping clockdiff rdisc arping tftpd rarpd
24 IPV6_TARGETS=tracepath6 traceroute6 ping6
25 @@ -42,7 +37,11 @@
27 tftpd: tftpd.o tftpsubs.o
28 ping: ping.o ping_common.o
29 + $(LINK.o) $^ $(LDLIBS) -o $@ -Wl,-z,now -Wl,-z,relro
30 ping6: ping6.o ping_common.o
31 + $(LINK.o) $^ $(LDLIBS) -o $@ -Wl,-z,now -Wl,-z,relro
32 +traceroute6: traceroute6.o
33 + $(LINK.o) $^ $(LDLIBS) -o $@ -Wl,-z,now -Wl,-z,relro
34 ping.o ping6.o ping_common.o: ping_common.h
35 tftpd.o tftpsubs.o: tftp.h
37 diff -Naur iputils.orig/arping.c iputils/arping.c
38 --- iputils.orig/arping.c 2001-10-05 22:42:47.000000000 +0000
39 +++ iputils/arping.c 2005-06-09 16:15:24.000000000 +0000
40 @@ -9,6 +9,7 @@
41 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
44 +#include <asm/byteorder.h>
45 #include <stdlib.h>
46 #include <sys/param.h>
47 #include <sys/socket.h>
48 @@ -19,6 +20,8 @@
49 #include <sys/ioctl.h>
50 #include <linux/if.h>
51 #include <linux/if_arp.h>
52 +#include <linux/if_ether.h>
53 +#include <linux/if_packet.h>
54 #include <sys/uio.h>
56 #include <netdb.h>
57 diff -Naur iputils.orig/clockdiff.c iputils/clockdiff.c
58 --- iputils.orig/clockdiff.c 2002-02-23 00:10:59.000000000 +0000
59 +++ iputils/clockdiff.c 2005-06-09 16:15:24.000000000 +0000
60 @@ -1,7 +1,9 @@
61 +#include <asm/byteorder.h>
62 #include <time.h>
63 #include <sys/types.h>
64 #include <sys/param.h>
65 #include <stdio.h>
66 +#include <linux/types.h>
67 #include <unistd.h>
68 #include <stdlib.h>
69 #include <math.h>
70 diff -Naur iputils.orig/include-glibc/netinet/in.h iputils/include-glibc/netinet/in.h
71 --- iputils.orig/include-glibc/netinet/in.h 2002-11-09 00:22:25.000000000 +0000
72 +++ iputils/include-glibc/netinet/in.h 2005-06-09 16:15:00.000000000 +0000
73 @@ -65,4 +65,45 @@
74 && (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3]))
77 -#endif /* netinet/in.h */
78 +/* Functions to convert between host and network byte order.
80 + Please note that these functions normally take `unsigned long int' or
81 + `unsigned short int' values as arguments and also return them. But
82 + this was a short-sighted decision since on different systems the types
83 + may have different representations but the values are always the same. */
85 +extern u_int32_t ntohl (u_int32_t __netlong) __THROW __attribute__ ((__const__));
86 +extern u_int16_t ntohs (u_int16_t __netshort)
87 + __THROW __attribute__ ((__const__));
88 +extern u_int32_t htonl (u_int32_t __hostlong)
89 + __THROW __attribute__ ((__const__));
90 +extern u_int16_t htons (u_int16_t __hostshort)
91 + __THROW __attribute__ ((__const__));
93 +#include <endian.h>
95 +/* Get machine dependent optimized versions of byte swapping functions. */
96 +#include <bits/byteswap.h>
98 +#ifdef __OPTIMIZE__
99 +/* We can optimize calls to the conversion functions. Either nothing has
100 + to be done or we are using directly the byte-swapping functions which
101 + often can be inlined. */
102 +# if __BYTE_ORDER == __BIG_ENDIAN
103 +/* The host byte order is the same as network byte order,
104 + so these functions are all just identity. */
105 +# define ntohl(x) (x)
106 +# define ntohs(x) (x)
107 +# define htonl(x) (x)
108 +# define htons(x) (x)
109 +# else
110 +# if __BYTE_ORDER == __LITTLE_ENDIAN
111 +# define ntohl(x) __bswap_32 (x)
112 +# define ntohs(x) __bswap_16 (x)
113 +# define htonl(x) __bswap_32 (x)
114 +# define htons(x) __bswap_16 (x)
115 +# endif
116 +# endif
117 +#endif
119 +#endif /* netinet/in.h */
120 diff -Naur iputils.orig/ipg iputils/ipg
121 --- iputils.orig/ipg 2001-08-02 22:37:32.000000000 +0000
122 +++ iputils/ipg 2005-06-09 16:14:49.000000000 +0000
123 @@ -1,21 +1,31 @@
124 -#! /bin/bash
125 +#!/bin/bash
127 -modprobe pg3
128 +modprobe pg3 >& /dev/null
129 +modprobe pktgen >& /dev/null
131 +PGDEV=/proc/net/pg
132 +if [[ ! -e ${PGDEV} ]] ; then
133 + PGDEV=/proc/net/pktgen/pg0
134 + if [[ ! -e ${PGDEV} ]] ; then
135 + echo "Couldn't not locate pg in /proc/net :("
136 + exit 1
137 + fi
140 function pgset() {
141 local result
143 - echo $1 > /proc/net/pg
144 + echo $1 > ${PGDEV}
146 - result=`cat /proc/net/pg | fgrep "Result: OK:"`
147 + result=`cat ${PGDEV} | fgrep "Result: OK:"`
148 if [ "$result" = "" ]; then
149 - cat /proc/net/pg | fgrep Result:
150 + cat ${PGDEV} | fgrep Result:
154 function pg() {
155 - echo inject > /proc/net/pg
156 - cat /proc/net/pg
157 + echo inject > ${PGDEV}
158 + cat ${PGDEV}
161 pgset "odev eth0"
162 diff -Naur iputils.orig/ping.c iputils/ping.c
163 --- iputils.orig/ping.c 2002-11-07 22:53:21.000000000 +0000
164 +++ iputils/ping.c 2005-06-09 16:15:00.000000000 +0000
165 @@ -60,8 +60,8 @@
167 #include "ping_common.h"
169 +#include <linux/icmp.h>
170 #include <netinet/ip.h>
171 -#include <netinet/ip_icmp.h>
172 #ifdef DO_IPSEC
173 #include <libipsec.h>
174 #endif
175 @@ -1213,7 +1213,7 @@
176 once = 1;
178 /* Patch bpflet for current identifier. */
179 - insns[2] = (struct sock_filter)BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __constant_htons(ident), 0, 1);
180 + insns[2] = (struct sock_filter)BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(ident), 0, 1);
182 if (setsockopt(icmp_sock, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter)))
183 perror("WARNING: failed to install socket filter\n");
184 diff -Naur iputils.orig/ping6.c iputils/ping6.c
185 --- iputils.orig/ping6.c 2002-09-20 15:08:11.000000000 +0000
186 +++ iputils/ping6.c 2005-06-09 16:15:00.000000000 +0000
187 @@ -68,8 +68,44 @@
189 #include "ping_common.h"
191 -#include <linux/in6.h>
192 -#include <linux/ipv6.h>
193 +struct ipv6_rt_hdr {
194 + __u8 nexthdr;
195 + __u8 hdrlen;
196 + __u8 type;
197 + __u8 segments_left;
199 + /*
200 + * type specific data
201 + * variable length field
202 + */
205 +struct rt0_hdr {
206 + struct ipv6_rt_hdr rt_hdr;
207 + __u32 bitmap; /* strict/loose bit map */
208 + struct in6_addr addr[0];
210 +#define rt0_type rt_hdr.type;
212 +#define IPV6_SRCRT_TYPE_0 0 /* IPv6 type 0 Routing Header */
213 +struct ipv6hdr {
214 +#if defined(__LITTLE_ENDIAN)
215 + __u8 priority:4,
216 + version:4;
217 +#elif defined(__BIG_ENDIAN)
218 + __u8 version:4,
219 + priority:4;
220 +#endif
221 + __u8 flow_lbl[3];
223 + __u16 payload_len;
224 + __u8 nexthdr;
225 + __u8 hop_limit;
227 + struct in6_addr saddr;
228 + struct in6_addr daddr;
231 #include <linux/icmpv6.h>
233 #define BIT_CLEAR(nr, addr) do { ((__u32 *)(addr))[(nr) >> 5] &= ~(1U << ((nr) & 31)); } while(0)
234 @@ -879,7 +915,7 @@
235 once = 1;
237 /* Patch bpflet for current identifier. */
238 - insns[1] = (struct sock_filter)BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __constant_htons(ident), 0, 1);
239 + insns[1] = (struct sock_filter)BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(ident), 0, 1);
241 if (setsockopt(icmp_sock, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter)))
242 perror("WARNING: failed to install socket filter\n");
243 diff -Naur iputils.orig/ping_common.h iputils/ping_common.h
244 --- iputils.orig/ping_common.h 2002-09-20 15:08:11.000000000 +0000
245 +++ iputils/ping_common.h 2005-06-09 16:15:24.000000000 +0000
246 @@ -1,3 +1,4 @@
247 +#include <asm/byteorder.h>
248 #include <stdio.h>
249 #include <stdlib.h>
250 #include <unistd.h>
251 @@ -19,6 +20,7 @@
253 #include <netinet/in.h>
254 #include <arpa/inet.h>
255 +#include <linux/types.h>
256 #include <linux/errqueue.h>
258 #include "SNAPSHOT.h"
259 diff -Naur iputils.orig/rarpd.c iputils/rarpd.c
260 --- iputils.orig/rarpd.c 2001-12-02 18:45:06.000000000 +0000
261 +++ iputils/rarpd.c 2005-06-09 16:15:24.000000000 +0000
262 @@ -9,6 +9,7 @@
263 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
266 +#include <asm/byteorder.h>
267 #include <stdio.h>
268 #include <syslog.h>
269 #include <dirent.h>
270 @@ -26,6 +27,7 @@
271 #include <sys/signal.h>
272 #include <linux/if.h>
273 #include <linux/if_arp.h>
274 +#include <linux/if_ether.h>
275 #include <netinet/in.h>
276 #include <linux/if_packet.h>
277 #include <linux/filter.h>
278 @@ -42,7 +44,9 @@
279 char *ifname;
280 char *tftp_dir = "/etc/tftpboot";
282 +#ifndef __UCLIBC__
283 extern int ether_ntohost(char *name, unsigned char *ea);
284 +#endif
285 void usage(void) __attribute__((noreturn));
287 struct iflink
288 @@ -52,12 +56,12 @@
289 int hatype;
290 unsigned char lladdr[16];
291 unsigned char name[IFNAMSIZ];
292 - struct ifaddr *ifa_list;
293 + struct l_ifaddr *ifa_list;
294 } *ifl_list;
296 -struct ifaddr
297 +struct l_ifaddr
299 - struct ifaddr *next;
300 + struct l_ifaddr *next;
301 __u32 prefix;
302 __u32 mask;
303 __u32 local;
304 @@ -89,7 +93,7 @@
305 int fd;
306 struct ifreq *ifrp, *ifend;
307 struct iflink *ifl;
308 - struct ifaddr *ifa;
309 + struct l_ifaddr *ifa;
310 struct ifconf ifc;
311 struct ifreq ibuf[256];
313 @@ -180,7 +184,7 @@
314 if (ifa == NULL) {
315 if (mask == 0 || prefix == 0)
316 continue;
317 - ifa = (struct ifaddr*)malloc(sizeof(*ifa));
318 + ifa = (struct l_ifaddr*)malloc(sizeof(*ifa));
319 memset(ifa, 0, sizeof(*ifa));
320 ifa->local = addr;
321 ifa->prefix = prefix;
322 @@ -236,10 +240,10 @@
323 return dent != NULL;
326 -struct ifaddr *select_ipaddr(int ifindex, __u32 *sel_addr, __u32 **alist)
327 +struct l_ifaddr *select_ipaddr(int ifindex, __u32 *sel_addr, __u32 **alist)
329 struct iflink *ifl;
330 - struct ifaddr *ifa;
331 + struct l_ifaddr *ifa;
332 int retry = 0;
333 int i;
335 @@ -295,7 +299,7 @@
337 if (r == NULL) {
338 if (hatype == ARPHRD_ETHER && halen == 6) {
339 - struct ifaddr *ifa;
340 + struct l_ifaddr *ifa;
341 struct hostent *hp;
342 char ename[256];
343 static struct rarp_map emap = {
344 @@ -305,7 +309,11 @@
348 +#ifndef __UCLIBC__
349 if (ether_ntohost(ename, lladdr) != 0 ||
350 +#else
351 + if (
352 +#endif
353 (hp = gethostbyname(ename)) == NULL) {
354 if (verbose)
355 syslog(LOG_INFO, "not found in /etc/ethers");
356 @@ -364,7 +372,7 @@
358 __u32 laddr = 0;
359 struct iflink *ifl;
360 - struct ifaddr *ifa;
361 + struct l_ifaddr *ifa;
363 for (ifl=ifl_list; ifl; ifl = ifl->next)
364 if (ifl->index == ifindex)
365 diff -Naur iputils.orig/rdisc.c iputils/rdisc.c
366 --- iputils.orig/rdisc.c 2001-08-24 17:39:00.000000000 +0000
367 +++ iputils/rdisc.c 2005-06-09 16:15:24.000000000 +0000
368 @@ -25,6 +25,7 @@
369 * 2550 Garcia Avenue
370 * Mountain View, California 94043
372 +#include <asm/byteorder.h>
373 #include <stdio.h>
374 #include <errno.h>
375 #include <signal.h>
376 @@ -1504,5 +1505,5 @@
377 if (logging)
378 syslog(LOG_ERR, "%s: %m", str);
379 else
380 - (void) fprintf(stderr, "%s: %s\n", str, sys_errlist[errno]);
381 + (void) fprintf(stderr, "%s: %s\n", str, strerror(errno));
383 diff -Naur iputils.orig/tftpd.c iputils/tftpd.c
384 --- iputils.orig/tftpd.c 2002-01-24 00:31:41.000000000 +0000
385 +++ iputils/tftpd.c 2005-06-09 16:15:24.000000000 +0000
386 @@ -48,6 +48,7 @@
387 * This version includes many modifications by Jim Guyton <guyton@rand-unix>
390 +#include <asm/byteorder.h>
391 #include <sys/types.h>
392 #include <sys/ioctl.h>
393 #include <sys/stat.h>
394 @@ -57,7 +58,6 @@
396 #include <sys/socket.h>
397 #include <netinet/in.h>
398 -#include <linux/in6.h>
399 #include <netdb.h>
401 #include <setjmp.h>
402 diff -Naur iputils.orig/tracepath.c iputils/tracepath.c
403 --- iputils.orig/tracepath.c 2002-11-09 04:54:46.000000000 +0000
404 +++ iputils/tracepath.c 2005-06-09 16:15:24.000000000 +0000
405 @@ -9,10 +9,12 @@
406 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
409 +#include <asm/byteorder.h>
410 #include <stdio.h>
411 #include <stdlib.h>
412 #include <unistd.h>
413 #include <sys/socket.h>
414 +#include <linux/types.h>
415 #include <linux/errqueue.h>
416 #include <errno.h>
417 #include <string.h>
418 @@ -76,7 +78,7 @@
419 int progress = -1;
420 int broken_router;
422 -restart:
423 + while (1) {
424 memset(&rcvbuf, -1, sizeof(rcvbuf));
425 iov.iov_base = &rcvbuf;
426 iov.iov_len = sizeof(rcvbuf);
427 @@ -93,7 +95,7 @@
428 if (res < 0) {
429 if (errno == EAGAIN)
430 return progress;
431 - goto restart;
432 + continue;
435 progress = mtu;
436 @@ -216,7 +218,7 @@
437 perror("NET ERROR");
438 return 0;
440 - goto restart;
444 int probe_ttl(int fd, int ttl)
445 @@ -227,7 +229,6 @@
447 memset(sndbuf,0,mtu);
449 -restart:
450 for (i=0; i<10; i++) {
451 int res;
453 @@ -243,7 +244,8 @@
454 if (res==0)
455 return 0;
456 if (res > 0)
457 - goto restart;
458 + i = 0;
459 + continue;
461 hisptr = (hisptr + 1)&63;
463 diff -Naur iputils.orig/tracepath6.c iputils/tracepath6.c
464 --- iputils.orig/tracepath6.c 2001-09-02 02:03:46.000000000 +0000
465 +++ iputils/tracepath6.c 2005-06-09 16:15:24.000000000 +0000
466 @@ -9,13 +9,13 @@
467 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
470 +#include <asm/byteorder.h>
471 #include <stdio.h>
472 #include <stdlib.h>
473 #include <unistd.h>
474 #include <sys/socket.h>
475 #include <netinet/in.h>
477 -#include <linux/in6.h>
478 +#include <linux/types.h>
479 #include <linux/errqueue.h>
480 #include <errno.h>
481 #include <string.h>
482 @@ -66,7 +66,7 @@
483 int progress = -1;
484 int broken_router;
486 -restart:
487 + while (1) {
488 memset(&rcvbuf, -1, sizeof(rcvbuf));
489 iov.iov_base = &rcvbuf;
490 iov.iov_len = sizeof(rcvbuf);
491 @@ -83,7 +83,7 @@
492 if (res < 0) {
493 if (errno == EAGAIN)
494 return progress;
495 - goto restart;
496 + continue;
499 progress = 2;
500 @@ -222,34 +222,29 @@
501 perror("NET ERROR");
502 return 0;
504 - goto restart;
508 int probe_ttl(int fd, int ttl)
510 - int i;
511 + int i=0, res;
512 char sndbuf[mtu];
513 struct probehdr *hdr = (struct probehdr*)sndbuf;
515 -restart:
517 - for (i=0; i<10; i++) {
518 - int res;
520 - hdr->ttl = ttl;
521 - gettimeofday(&hdr->tv, NULL);
522 - if (send(fd, sndbuf, mtu-overhead, 0) > 0)
523 - break;
524 - res = recverr(fd, ttl);
525 - if (res==0)
526 - return 0;
527 - if (res > 0)
528 - goto restart;
531 - if (i<10) {
532 - int res;
534 + while (i<10) {
535 + for (i=0; i<10; i++) {
536 + hdr->ttl = ttl;
537 + gettimeofday(&hdr->tv, NULL);
538 + if (send(fd, sndbuf, mtu-overhead, 0) > 0)
539 + break;
540 + res = recverr(fd, ttl);
541 + if (res==0)
542 + return 0;
543 + if (res > 0) {
544 + i = 0;
545 + continue;
548 data_wait(fd);
549 if (recv(fd, sndbuf, sizeof(sndbuf), MSG_DONTWAIT) > 0) {
550 printf("%2d?: reply received 8)\n", ttl);
551 @@ -257,7 +252,7 @@
553 res = recverr(fd, ttl);
554 if (res == 1)
555 - goto restart;
556 + continue;
557 return res;
560 diff -Naur iputils.orig/traceroute6.c iputils/traceroute6.c
561 --- iputils.orig/traceroute6.c 2002-10-03 03:29:23.000000000 +0000
562 +++ iputils/traceroute6.c 2005-06-09 16:14:49.000000000 +0000
563 @@ -244,11 +244,30 @@
564 #include <netinet/in.h>
565 #include <netinet/ip.h>
566 #include <netinet/ip_icmp.h>
567 +#if __linux__
568 +#include <linux/udp.h>
569 +#else
570 #include <netinet/udp.h>
571 +#endif
573 +#include <linux/types.h>
574 +struct ipv6hdr {
575 +#if defined(__LITTLE_ENDIAN)
576 + __u8 priority:4,
577 + version:4;
578 +#elif defined(__BIG_ENDIAN)
579 + __u8 version:4,
580 + priority:4;
581 +#endif
582 + __u8 flow_lbl[3];
584 -#include <linux/ipv6.h>
585 -#include <linux/in6.h>
586 + __u16 payload_len;
587 + __u8 nexthdr;
588 + __u8 hop_limit;
590 + struct in6_addr saddr;
591 + struct in6_addr daddr;
593 #include <linux/icmpv6.h>
595 #include <arpa/inet.h>