--- Makefile.orig 2002-11-08 19:01:11.000000000 -0800 +++ Makefile 2006-08-25 07:50:33.000000000 -0700 @@ -17,32 +17,31 @@ GLIBCFIX=-Iinclude-glibc -include include-glibc/glibc-bugs.h endif -ifeq ($(KERNEL_INCLUDE)/linux/pfkeyv2.h,$(wildcard $(KERNEL_INCLUDE)/linux/pfkeyv2.h)) - SUBDIRS=libipsec setkey - LDLIBS+=-Llibipsec -lipsec - IPSECDEF=-DDO_IPSEC -Ilibipsec -endif #options if you compile with libc5, and without a bind>=4.9.4 libresolv # NOT AVAILABLE. Please, use libresolv. -CC=gcc + # 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 $(IPSECDEF) $(DEFINES) +CCOPT=-D_GNU_SOURCE -Wstrict-prototypes -Wall -g +CFLAGS=$(CCOPT) $(GLIBCFIX) -I../include $(IPSECDEF) $(DEFINES) IPV4_TARGETS=tracepath ping clockdiff rdisc arping tftpd rarpd IPV6_TARGETS=tracepath6 traceroute6 ping6 TARGETS=$(IPV4_TARGETS) $(IPV6_TARGETS) -all: check-kernel subdirs $(TARGETS) +all: subdirs $(TARGETS) tftpd: tftpd.o tftpsubs.o ping: ping.o ping_common.o + $(LINK.o) $^ $(LDLIBS) -o $@ -Wl,-z,now -Wl,-z,relro ping6: ping6.o ping_common.o + $(LINK.o) $^ $(LDLIBS) -o $@ -Wl,-z,now -Wl,-z,relro +traceroute6: traceroute6.o + $(LINK.o) $^ $(LDLIBS) -o $@ -Wl,-z,now -Wl,-z,relro ping.o ping6.o ping_common.o: ping_common.h tftpd.o tftpsubs.o: tftp.h --- arping.c.orig 2001-10-05 15:42:47.000000000 -0700 +++ arping.c 2006-08-25 07:50:33.000000000 -0700 @@ -434,7 +434,7 @@ } } else if (!dad) { int on = 1; - int alen = sizeof(saddr); + socklen_t alen = sizeof(saddr); saddr.sin_port = htons(1025); saddr.sin_addr = dst; @@ -463,7 +463,7 @@ } if (1) { - int alen = sizeof(me); + socklen_t alen = sizeof(me); if (getsockname(s, (struct sockaddr*)&me, &alen) == -1) { perror("getsockname"); exit(2); @@ -495,9 +495,9 @@ while(1) { sigset_t sset, osset; - char packet[4096]; + unsigned char packet[4096]; struct sockaddr_ll from; - int alen = sizeof(from); + socklen_t alen = sizeof(from); int cc; if ((cc = recvfrom(s, packet, sizeof(packet), 0, --- clockdiff.c.orig 2002-02-22 16:10:59.000000000 -0800 +++ clockdiff.c 2006-08-25 07:50:33.000000000 -0700 @@ -120,7 +120,7 @@ int measure(struct sockaddr_in * addr) { - int length; + socklen_t length; int msgcount; int cc, count; fd_set ready; @@ -299,7 +299,7 @@ int measure_opt(struct sockaddr_in * addr) { - int length; + socklen_t length; int msgcount; int cc, count; fd_set ready; @@ -597,7 +597,7 @@ } if (ip_opt_len) { struct sockaddr_in myaddr; - int addrlen = sizeof(myaddr); + socklen_t addrlen = sizeof(myaddr); unsigned char rspace[ip_opt_len]; bzero(rspace, sizeof(rspace)); --- ipg.orig 2001-08-02 15:37:32.000000000 -0700 +++ ipg 2006-08-25 07:50:33.000000000 -0700 @@ -1,21 +1,31 @@ -#! /bin/bash +#!/bin/bash -modprobe pg3 +modprobe pg3 >& /dev/null +modprobe pktgen >& /dev/null + +PGDEV=/proc/net/pg +if [[ ! -e ${PGDEV} ]] ; then + PGDEV=/proc/net/pktgen/pg0 + if [[ ! -e ${PGDEV} ]] ; then + echo "Couldn't not locate pg in /proc/net :(" + exit 1 + fi +fi function pgset() { local result - echo $1 > /proc/net/pg + echo $1 > ${PGDEV} - result=`cat /proc/net/pg | fgrep "Result: OK:"` + result=`cat ${PGDEV} | fgrep "Result: OK:"` if [ "$result" = "" ]; then - cat /proc/net/pg | fgrep Result: + cat ${PGDEV} | fgrep Result: fi } function pg() { - echo inject > /proc/net/pg - cat /proc/net/pg + echo inject > ${PGDEV} + cat ${PGDEV} } pgset "odev eth0" --- ping.c.orig 2002-11-07 14:53:21.000000000 -0800 +++ ping.c 2006-08-25 07:50:33.000000000 -0700 @@ -260,7 +260,7 @@ } if (source.sin_addr.s_addr == 0) { - int alen; + socklen_t alen; struct sockaddr_in dst = whereto; int probe_fd = socket(AF_INET, SOCK_DGRAM, 0); --- ping6.c.orig 2002-09-20 08:08:11.000000000 -0700 +++ ping6.c 2006-08-25 07:50:33.000000000 -0700 @@ -153,7 +153,7 @@ cmsg->cmsg_len = sizeof(struct cmsghdr) + sizeof(struct rt0_hdr); cmsg->cmsg_level = SOL_IPV6; - cmsg->cmsg_type = IPV6_RTHDR; + cmsg->cmsg_type = IPV6_2292RTHDR; return cmsg; } @@ -313,7 +313,7 @@ hostname = target; if (ipv6_addr_any(&source.sin6_addr)) { - int alen; + socklen_t alen; int probe_fd = socket(AF_INET6, SOCK_DGRAM, 0); if (probe_fd < 0) { @@ -372,7 +372,7 @@ cmsglen += CMSG_SPACE(sizeof(*ipi)); cmsg->cmsg_len = CMSG_LEN(sizeof(*ipi)); cmsg->cmsg_level = SOL_IPV6; - cmsg->cmsg_type = IPV6_PKTINFO; + cmsg->cmsg_type = IPV6_2292PKTINFO; ipi = (struct in6_pktinfo*)CMSG_DATA(cmsg); memset(ipi, 0, sizeof(*ipi)); @@ -483,7 +483,7 @@ if (1) { int on = 1; - if (setsockopt(icmp_sock, IPPROTO_IPV6, IPV6_HOPLIMIT, + if (setsockopt(icmp_sock, IPPROTO_IPV6, IPV6_2292HOPLIMIT, &on, sizeof(on)) == -1) { perror ("can't receive hop limit"); exit(2); @@ -701,7 +701,7 @@ for (c = CMSG_FIRSTHDR(msg); c; c = CMSG_NXTHDR(msg, c)) { if (c->cmsg_level != SOL_IPV6 || - c->cmsg_type != IPV6_HOPLIMIT) + c->cmsg_type != IPV6_2292HOPLIMIT) continue; if (c->cmsg_len < CMSG_LEN(sizeof(int))) continue; --- ping_common.c.orig 2002-09-20 09:02:32.000000000 -0700 +++ ping_common.c 2006-08-25 07:50:33.000000000 -0700 @@ -67,7 +67,7 @@ int ii, jj, kk; int pat[16]; char *cp; - char *bp = outpack+8; + u_char *bp = outpack+8; for (cp = patp; *cp; cp++) { if (!isxdigit(*cp)) { @@ -393,7 +393,7 @@ void sock_setbufs(int icmp_sock, int alloc) { int rcvbuf, hold; - int tmplen = sizeof(hold); + socklen_t tmplen = sizeof(hold); if (!sndbuf) sndbuf = alloc; @@ -464,7 +464,7 @@ if (!(options & F_PINGFILLED)) { int i; - char *p = outpack+8; + u_char *p = outpack+8; /* Do not forget about case of small datalen, * fill timestamp area too! --- ping_common.h.orig 2002-09-20 08:08:11.000000000 -0700 +++ ping_common.h 2006-08-25 07:50:33.000000000 -0700 @@ -37,6 +37,17 @@ #define CLR(bit) (A(bit) &= (~B(bit))) #define TST(bit) (A(bit) & B(bit)) +/* handle updates to IPV6 defines */ +#ifndef IPV6_2292PKTINFO +# define IPV6_2292PKTINFO IPV6_PKTINFO +#endif +#ifndef IPV6_2292RTHDR +# define IPV6_2292RTHDR IPV6_RTHDR +#endif +#ifndef IPV6_2292HOPLIMIT +# define IPV6_2292HOPLIMIT IPV6_HOPLIMIT +#endif + /* various options */ extern int options; #define F_FLOOD 0x001 --- rarpd.c.orig 2001-12-02 10:45:06.000000000 -0800 +++ rarpd.c 2006-08-25 07:50:33.000000000 -0700 @@ -42,7 +42,9 @@ char *ifname; char *tftp_dir = "/etc/tftpboot"; +#ifndef __UCLIBC__ extern int ether_ntohost(char *name, unsigned char *ea); +#endif void usage(void) __attribute__((noreturn)); struct iflink @@ -305,7 +307,11 @@ 6, }; +#ifndef __UCLIBC__ if (ether_ntohost(ename, lladdr) != 0 || +#else + if ( +#endif (hp = gethostbyname(ename)) == NULL) { if (verbose) syslog(LOG_INFO, "not found in /etc/ethers"); @@ -417,7 +423,7 @@ { unsigned char buf[1024]; struct sockaddr_ll sll; - int sll_len = sizeof(sll); + socklen_t sll_len = sizeof(sll); struct arphdr *a = (struct arphdr*)buf; struct rarp_map *rmap; unsigned char *ptr; --- rdisc.c.orig 2001-08-24 10:39:00.000000000 -0700 +++ rdisc.c 2006-08-25 07:50:33.000000000 -0700 @@ -451,7 +451,7 @@ for (;;) { u_char packet[MAXPACKET]; int len = sizeof (packet); - int fromlen = sizeof (from); + socklen_t fromlen = sizeof (from); int cc; cc=recvfrom(s, (char *)packet, len, 0, @@ -1504,5 +1504,5 @@ if (logging) syslog(LOG_ERR, "%s: %m", str); else - (void) fprintf(stderr, "%s: %s\n", str, sys_errlist[errno]); + (void) fprintf(stderr, "%s: %s\n", str, strerror(errno)); } --- tftpd.c.orig 2002-01-23 16:31:41.000000000 -0800 +++ tftpd.c 2006-08-25 07:50:33.000000000 -0700 @@ -89,7 +89,7 @@ struct sockaddr_in sin; struct sockaddr_in6 sin6; } from; -int fromlen; +socklen_t fromlen; #define MAXARG 1 char *dirs[MAXARG+1]; @@ -149,7 +149,8 @@ */ { int pid; - int i, j; + int i; + socklen_t j; for (i = 1; i < 20; i++) { pid = fork(); --- tracepath.c.orig 2002-11-08 20:54:46.000000000 -0800 +++ tracepath.c 2006-08-25 07:50:33.000000000 -0700 @@ -76,7 +76,7 @@ int progress = -1; int broken_router; -restart: + while (1) { memset(&rcvbuf, -1, sizeof(rcvbuf)); iov.iov_base = &rcvbuf; iov.iov_len = sizeof(rcvbuf); @@ -93,7 +93,7 @@ if (res < 0) { if (errno == EAGAIN) return progress; - goto restart; + continue; } progress = mtu; @@ -216,7 +216,7 @@ perror("NET ERROR"); return 0; } - goto restart; + } } int probe_ttl(int fd, int ttl) @@ -227,7 +227,6 @@ memset(sndbuf,0,mtu); -restart: for (i=0; i<10; i++) { int res; @@ -243,7 +242,8 @@ if (res==0) return 0; if (res > 0) - goto restart; + i = 0; + continue; } hisptr = (hisptr + 1)&63; --- tracepath6.c.orig 2001-09-01 19:03:46.000000000 -0700 +++ tracepath6.c 2006-08-25 07:50:33.000000000 -0700 @@ -25,6 +25,8 @@ #include #include +#include "ping_common.h" + int overhead = 48; int mtu = 128000; int hops_to = -1; @@ -66,7 +68,7 @@ int progress = -1; int broken_router; -restart: + while (1) { memset(&rcvbuf, -1, sizeof(rcvbuf)); iov.iov_base = &rcvbuf; iov.iov_len = sizeof(rcvbuf); @@ -83,7 +85,7 @@ if (res < 0) { if (errno == EAGAIN) return progress; - goto restart; + continue; } progress = 2; @@ -111,7 +113,7 @@ if (cmsg->cmsg_level == SOL_IPV6) { if (cmsg->cmsg_type == IPV6_RECVERR) { e = (struct sock_extended_err *)CMSG_DATA(cmsg); - } else if (cmsg->cmsg_type == IPV6_HOPLIMIT) { + } else if (cmsg->cmsg_type == IPV6_2292HOPLIMIT) { rethops = *(int*)CMSG_DATA(cmsg); } } else if (cmsg->cmsg_level == SOL_IP) { @@ -222,34 +224,29 @@ perror("NET ERROR"); return 0; } - goto restart; + } } int probe_ttl(int fd, int ttl) { - int i; + int i=0, res; char sndbuf[mtu]; struct probehdr *hdr = (struct probehdr*)sndbuf; -restart: - - for (i=0; i<10; i++) { - int res; - - hdr->ttl = ttl; - gettimeofday(&hdr->tv, NULL); - if (send(fd, sndbuf, mtu-overhead, 0) > 0) - break; - res = recverr(fd, ttl); - if (res==0) - return 0; - if (res > 0) - goto restart; - } - - if (i<10) { - int res; - + while (i<10) { + for (i=0; i<10; i++) { + hdr->ttl = ttl; + gettimeofday(&hdr->tv, NULL); + if (send(fd, sndbuf, mtu-overhead, 0) > 0) + break; + res = recverr(fd, ttl); + if (res==0) + return 0; + if (res > 0) { + i = 0; + continue; + } + } data_wait(fd); if (recv(fd, sndbuf, sizeof(sndbuf), MSG_DONTWAIT) > 0) { printf("%2d?: reply received 8)\n", ttl); @@ -257,7 +254,7 @@ } res = recverr(fd, ttl); if (res == 1) - goto restart; + continue; return res; } @@ -354,8 +351,8 @@ perror("IP_RECVERR"); exit(1); } - if (setsockopt(fd, SOL_IPV6, IPV6_HOPLIMIT, &on, sizeof(on))) { - perror("IPV6_HOPLIMIT"); + if (setsockopt(fd, SOL_IPV6, IPV6_2292HOPLIMIT, &on, sizeof(on))) { + perror("IPV6_2292HOPLIMIT"); exit(1); } if (mapped && setsockopt(fd, SOL_IP, IP_RECVTTL, &on, sizeof(on))) { --- traceroute6.c.orig 2002-10-02 20:29:23.000000000 -0700 +++ traceroute6.c 2006-08-25 07:50:33.000000000 -0700 @@ -244,7 +244,11 @@ #include #include #include +#if __linux__ +#include +#else #include +#endif #include #include @@ -497,7 +501,7 @@ (char *)&on, sizeof(on)); if (source == NULL) { - int alen; + socklen_t alen; int probe_fd = socket(AF_INET6, SOCK_DGRAM, 0); if (probe_fd < 0) { @@ -618,7 +622,7 @@ fd_set fds; static struct timeval wait; int cc = 0; - int fromlen = sizeof (*from); + socklen_t fromlen = sizeof (*from); FD_ZERO(&fds); FD_SET(sock, &fds);