tcptraceroute is broken on big-endian LP64, some (but not all)
libnet-1.0 functions also have problems on LP64.

tcptraceroute 1.4 depends on libnet-1.0, but 1.5beta added support
for 1.1. Here is an update to 1.5beta7 (released > 1 year ago) with
additional patches to fix big-endian LP64.

I've tested it on sparc64, amd64, i386 (and have sent the fixes
which aren't OpenBSD-specific upstream for possible inclusion).

This fixes ports/5462, the PR submitter has also tested this
on sparc64 - no response from tcptraceroute maintainer.

also at http://spacehopper.org/openbsd/tcptraceroute-1.5beta7.txt

Index: Makefile
===================================================================
RCS file: /cvs/ports/net/tcptraceroute/Makefile,v
retrieving revision 1.11
diff -u -p -u -r1.11 Makefile
--- Makefile    24 May 2005 00:10:44 -0000      1.11
+++ Makefile    29 Apr 2007 14:53:02 -0000
@@ -2,8 +2,8 @@
 
 COMMENT=               "traceroute implementation using TCP packets"
 
-DISTNAME=              tcptraceroute-1.4
-PKGNAME=               ${DISTNAME}p1
+DISTNAME=              tcptraceroute-1.5beta7
+PKGNAME=               ${DISTNAME}
 CATEGORIES=                    net
 
 HOMEPAGE=              http://michael.toren.net/code/tcptraceroute/
@@ -17,9 +17,13 @@ PERMIT_DISTFILES_CDROM=      Yes
 PERMIT_DISTFILES_FTP=  Yes
 WANTLIB=               c pcap 
 
+CONFIGURE_STYLE=       gnu
+CONFIGURE_ARGS=                --with-libnet=${PREFIX} \
+                       --enable-noselect-default
+
 MASTER_SITES=          http://michael.toren.net/code/tcptraceroute/
 
-LIB_DEPENDS=           lib/libnet-1.0/net.=0:libnet-1.0*:net/libnet/1.0
+LIB_DEPENDS=           lib/libnet-1.1/net.=11:libnet-1.1*:net/libnet/1.1
 
 MAKE_FLAGS=            CC="${CC}" \
                        CFLAGS="${CFLAGS}"
@@ -27,11 +31,6 @@ MAKE_FLAGS=          CC="${CC}" \
 ALL_TARGET=
 
 NO_REGRESS=            Yes
-
-do-install:
-       ${INSTALL_PROGRAM} ${WRKSRC}/tcptraceroute ${PREFIX}/sbin
-       ${INSTALL_DATA} ${WRKSRC}/tcptraceroute.8 ${PREFIX}/man/man8
-       ${INSTALL_DATA_DIR} ${PREFIX}/share/examples/tcptraceroute
-       ${INSTALL_DATA} ${WRKSRC}/examples.txt 
${PREFIX}/share/examples/tcptraceroute
+USE_GMAKE=             Yes
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/net/tcptraceroute/distinfo,v
retrieving revision 1.5
diff -u -p -u -r1.5 distinfo
--- distinfo    5 Apr 2007 16:20:16 -0000       1.5
+++ distinfo    29 Apr 2007 14:53:02 -0000
@@ -1,5 +1,5 @@
-MD5 (tcptraceroute-1.4.tar.gz) = NcXn2WDysHPbAQngAE4TTg==
-RMD160 (tcptraceroute-1.4.tar.gz) = Zyg1XKlxs+ZI6VcE50gmy8OPqU8=
-SHA1 (tcptraceroute-1.4.tar.gz) = Hb2aChCxFpWwIEvqRgRjqd2SEzg=
-SHA256 (tcptraceroute-1.4.tar.gz) = 
HvbEc2tV9H06K7JrmZy7QJlToRL2N7y+xBBtoqCTe94=
-SIZE (tcptraceroute-1.4.tar.gz) = 31918
+MD5 (tcptraceroute-1.5beta7.tar.gz) = ZdEAFQn5ceqYb8vC3QCWQw==
+RMD160 (tcptraceroute-1.5beta7.tar.gz) = /pNzQfTvGqNYslPDr0kEGaaJAx8=
+SHA1 (tcptraceroute-1.5beta7.tar.gz) = eIR+9LpwMc7mYMVAWTJW/ThKGmI=
+SHA256 (tcptraceroute-1.5beta7.tar.gz) = 
rtWxY+1IhvBCQrRgBabLSHbvOK1yABqU+stiqZ3JnFc=
+SIZE (tcptraceroute-1.5beta7.tar.gz) = 119119
Index: patches/patch-Makefile
===================================================================
RCS file: patches/patch-Makefile
diff -N patches/patch-Makefile
--- patches/patch-Makefile      24 May 2005 00:11:51 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,16 +0,0 @@
-$OpenBSD: patch-Makefile,v 1.3 2005/05/24 00:11:51 mjc Exp $
---- Makefile.orig      Sun May 19 18:11:38 2002
-+++ Makefile   Sun May 22 13:43:22 2005
-@@ -8,9 +8,10 @@ CFLAGS = -O2 -Wall
- DESTDIR=/usr/local/bin
- 
- tcptraceroute: tcptraceroute.c
--      $(CC) $(CFLAGS) `libnet-config --defines` \
-+      $(CC) $(CFLAGS) `libnet-config-1.0 --cflags` \
-+              `libnet-config-1.0 --defines` \
-               -o tcptraceroute tcptraceroute.c \
--              `libnet-config --libs` -lpcap
-+              `libnet-config-1.0 --libs` -lpcap
- 
- static:
-       $(MAKE) tcptraceroute CFLAGS="$(CFLAGS) -static"
Index: patches/patch-configure
===================================================================
RCS file: patches/patch-configure
diff -N patches/patch-configure
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-configure     29 Apr 2007 14:53:02 -0000
@@ -0,0 +1,24 @@
+$OpenBSD$
+--- configure.orig     Wed Mar 29 02:49:55 2006
++++ configure  Sun Apr 29 15:11:06 2007
+@@ -3713,7 +3713,7 @@ echo "$as_me: using libpcap in $withval" >&6;}
+ 
+ fi;
+ 
+-LIBNET_CONFIG="libnet-config" # relative, using $PATH
++LIBNET_CONFIG="libnet-config-1.1"     # relative, using $PATH
+ 
+ # Check whether --with-libnet or --without-libnet was given.
+ if test "${with_libnet+set}" = set; then
+@@ -3727,9 +3727,11 @@ if test "${with_libnet+set}" = set; then
+ 
+               test -f "$withval/libnet.h"                     &&      
LIBNETCC="$LIBNETCC -I$withval"
+               test -f "$withval/include/libnet.h"     &&      
LIBNETCC="$LIBNETCC -I$withval/include"
++              test -f "$withval/include/libnet-1.1/libnet.h"  &&      
LIBNETCC="$LIBNETCC -I$withval/include/libnet-1.1"
+ 
+               test -f "$withval/libnet.a"                     &&      
LIBNETLD="$LIBNETLD -L$withval"
+               test -f "$withval/lib/libnet.a"         &&      
LIBNETLD="$LIBNETLD -L$withval/lib"
++              test -f "$withval/lib/libnet-1.1/libnet.a"      &&      
LIBNETLD="$LIBNETLD -L$withval/lib/libnet-1.1"
+ 
+               if test -z "$LIBNETCC" -o -z "$LIBNETLD"
+               then
Index: patches/patch-datalink_c
===================================================================
RCS file: patches/patch-datalink_c
diff -N patches/patch-datalink_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-datalink_c    29 Apr 2007 14:53:02 -0000
@@ -0,0 +1,30 @@
+$OpenBSD$
+--- datalink.c.orig    Sun Apr 29 11:49:51 2007
++++ datalink.c Sun Apr 29 11:49:54 2007
+@@ -137,7 +137,7 @@ void getinterfaces(void)
+       struct ifconf ifc;
+       struct ifreq *ifrp, ifr;
+       int numreqs, i, s;
+-      u_long addr;
++      u_int32_t addr;
+       int salen;
+       char *x;
+ 
+@@ -278,7 +278,7 @@ void getinterfaces(void)
+  * given destination address.
+  */
+ 
+-u_long findsrc(u_long dest)
++u_int32_t findsrc(u_int32_t dest)
+ {
+       struct sockaddr_in sinsrc, sindest;
+       int s, size;
+@@ -314,7 +314,7 @@ u_long findsrc(u_long dest)
+  * interface exists with an address of 127.0.0.1.
+  */
+ 
+-char *finddev(u_long with_src)
++char *finddev(u_int32_t with_src)
+ {
+       struct interface_entry *p;
+       char *device = NULL;
Index: patches/patch-datalink_h
===================================================================
RCS file: patches/patch-datalink_h
diff -N patches/patch-datalink_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-datalink_h    29 Apr 2007 14:53:02 -0000
@@ -0,0 +1,19 @@
+$OpenBSD$
+--- datalink.h.orig    Sun Apr 29 11:49:51 2007
++++ datalink.h Sun Apr 29 11:49:54 2007
+@@ -29,12 +29,12 @@ extern struct datalinktype {
+ /* interface linked list, built by getinterfaces() */
+ extern struct interface_entry {
+       char *name;
+-      u_long addr;
++      u_int32_t addr;
+       struct interface_entry *next;
+ } *interfaces;
+ 
+ int datalinkoffset(int);
+ char *datalinkname(int);
+ void getinterfaces(void);
+-u_long findsrc(u_long);
+-char *finddev(u_long);
++u_int32_t findsrc(u_int32_t);
++char *finddev(u_int32_t);
Index: patches/patch-main_c
===================================================================
RCS file: patches/patch-main_c
diff -N patches/patch-main_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-main_c        29 Apr 2007 14:53:02 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+--- main.c.orig        Sun Apr 29 11:49:51 2007
++++ main.c     Sun Apr 29 11:49:54 2007
+@@ -23,7 +23,7 @@
+ #include "tcptraceroute.h"
+ 
+ /* globals */
+-u_long dst_ip, src_ip, isn;
++u_int32_t dst_ip, src_ip, isn;
+ u_short src_prt, dst_prt;
+ char *device, *name, *dst, *src;
+ char dst_name[TEXTSIZE], dst_prt_name[TEXTSIZE], filter[TEXTSIZE];
+@@ -43,7 +43,7 @@ char errbuf [PCAP_ERRBUF_SIZE > LIBNET_ERRBUF_SIZE ?
+ void defaults(void)
+ {
+       struct servent *serv;
+-      u_long recommended_src;
++      u_int32_t recommended_src;
+ 
+       getinterfaces();
+ 
Index: patches/patch-probe_c
===================================================================
RCS file: patches/patch-probe_c
diff -N patches/patch-probe_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-probe_c       29 Apr 2007 14:53:02 -0000
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- probe.c.orig       Sun Apr 29 11:49:51 2007
++++ probe.c    Sun Apr 29 11:49:54 2007
+@@ -297,7 +297,7 @@ void showprobe(proberecord *record)
+       /* Variables to keep state between calls */
+       static char laststate[TEXTSIZE];
+       static int lastttl;
+-      static u_long lastaddr, lastdnat_ip;
++      static u_int32_t lastaddr, lastdnat_ip;
+       static u_short lastdnat_dport;
+ 
+       static int everprinthost;       // have we ever printed the hostname?
Index: patches/patch-probe_h
===================================================================
RCS file: patches/patch-probe_h
diff -N patches/patch-probe_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-probe_h       29 Apr 2007 14:53:02 -0000
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- probe.h.orig       Sun Apr 29 11:49:51 2007
++++ probe.h    Sun Apr 29 11:49:54 2007
+@@ -43,7 +43,7 @@ typedef struct {
+       u_short id, src_prt, dnat_dport;
+       struct timeval timestamp;
+       double delta;
+-      u_long addr, dnat_ip;
++      u_int32_t addr, dnat_ip;
+       char *state;
+       char *string;
+ } proberecord;
Index: patches/patch-tcptraceroute_c
===================================================================
RCS file: patches/patch-tcptraceroute_c
diff -N patches/patch-tcptraceroute_c
--- patches/patch-tcptraceroute_c       23 Mar 2004 19:22:02 -0000      1.4
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,40 +0,0 @@
-$OpenBSD: patch-tcptraceroute_c,v 1.4 2004/03/23 19:22:02 pvalchev Exp $
---- tcptraceroute.c.orig       2002-07-30 14:51:05.000000000 -0700
-+++ tcptraceroute.c    2004-03-13 09:41:15.000000000 -0800
-@@ -391,10 +391,10 @@ void pfatal(char *err)
- void usage(void)
- {
-       printf("\n%s\n%s\n", VERSION, BANNER);
--    fatal("Usage: %s [-nNFSAE] [-i <interface>] [-f <first ttl>]
--       [-l <packet length>] [-q <number of queries>] [-t <tos>]
--       [-m <max ttl>] [-pP] <source port>] [-s <source address>]
--       [-w <wait time>] <host> [destination port] [packet length]\n\n", name);
-+    fatal("Usage: %s [-nNFSAE] [-i <interface>] [-f <first ttl>]\n"
-+"       [-l <packet length>] [-q <number of queries>] [-t <tos>]\n"
-+"       [-m <max ttl>] [-pP] <source port>] [-s <source address>]\n"
-+"       [-w <wait time>] <host> [destination port] [packet length]\n\n", 
name);
- }
- 
- void about(void)
-@@ -1182,9 +1182,9 @@ void initcapture(void)
-       if (! (pcap = pcap_open_live(device, offset + SNAPLEN, 0, 10, errbuf)))
-               fatal("pcap_open_live failed: %s", errbuf);
- 
--      safe_snprintf(filter, TEXTSIZE, "
--              (tcp and src host %s and src port %d and dst host %s)
--              or ((icmp[0] == 11 or icmp[0] == 3) and dst host %s)",
-+      safe_snprintf(filter, TEXTSIZE, "\n"
-+"             (tcp and src host %s and src port %d and dst host %s)\n"
-+"             or ((icmp[0] == 11 or icmp[0] == 3) and dst host %s)",
-                       iptos(dst_ip), dst_prt, iptos(src_ip), iptos(src_ip));
- 
-       if (o_nofilter)
-@@ -1386,7 +1386,7 @@ int capture(proberecord *record)
-               FD_ZERO(&sfd);
-               FD_SET(pcap_fd, &sfd);
- 
--              ret = o_noselect ? 1 : select(pcap_fd + 1, &sfd, NULL, NULL, 
&timeleft);
-+              ret = 1;
- 
-               if (ret < 0)
-               {
Index: patches/patch-tcptraceroute_h
===================================================================
RCS file: patches/patch-tcptraceroute_h
diff -N patches/patch-tcptraceroute_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-tcptraceroute_h       29 Apr 2007 14:53:02 -0000
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- tcptraceroute.h.orig       Sun Apr 29 11:49:51 2007
++++ tcptraceroute.h    Sun Apr 29 11:49:54 2007
+@@ -76,7 +76,7 @@ Updates are available from http://michael.toren.net/co
+ #include "probe.h"
+ #include "capture.h"
+ 
+-extern u_long dst_ip, src_ip, isn;
++extern u_int32_t dst_ip, src_ip, isn;
+ extern u_short src_prt, dst_prt;
+ extern char *device, *name, *dst, *src;
+ extern char dst_name[], dst_prt_name[], filter[], errbuf[];
Index: patches/patch-util_c
===================================================================
RCS file: patches/patch-util_c
diff -N patches/patch-util_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-util_c        29 Apr 2007 14:53:02 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+--- util.c.orig        Sun Apr 29 11:49:51 2007
++++ util.c     Sun Apr 29 11:49:54 2007
+@@ -219,7 +219,7 @@ int tvsign(struct timeval *tv)
+  * I was debugging.  I really could get by with only 2 now, but *shrug*.
+  */
+ 
+-char *iptos(u_long in)
++char *iptos(u_int32_t in)
+ {
+       static char output[IPTOSBUFFERS][IPTOSBUFSIZ];
+       static short which;
+@@ -236,7 +236,7 @@ char *iptos(u_long in)
+  * RFC1918 space.
+  */
+ 
+-char *iptohost(u_long in)
++char *iptohost(u_int32_t in)
+ {
+       u_char *p = (u_char *)&in;
+ 
Index: patches/patch-util_h
===================================================================
RCS file: patches/patch-util_h
diff -N patches/patch-util_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-util_h        29 Apr 2007 14:53:02 -0000
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- util.h.orig        Sun Apr 29 11:49:51 2007
++++ util.h     Sun Apr 29 11:49:54 2007
+@@ -50,6 +50,6 @@ char *sprintable(char *);
+ int isnumeric(char *);
+ struct timeval tvdiff(struct timeval *, struct timeval *);
+ int tvsign(struct timeval *);
+-char *iptos(u_long);
+-char *iptohost(u_long);
++char *iptos(u_int32_t);
++char *iptohost(u_int32_t);
+ void debugoptions(void);
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/net/tcptraceroute/pkg/PLIST,v
retrieving revision 1.4
diff -u -p -u -r1.4 PLIST
--- pkg/PLIST   15 Sep 2004 18:17:46 -0000      1.4
+++ pkg/PLIST   29 Apr 2007 14:53:02 -0000
@@ -1,5 +1,12 @@
 @comment $OpenBSD: PLIST,v 1.4 2004/09/15 18:17:46 espie Exp $
[EMAIL PROTECTED] man/man8/tcptraceroute.8
-sbin/tcptraceroute
-share/examples/tcptraceroute/
-share/examples/tcptraceroute/examples.txt
+bin/tcptraceroute
[EMAIL PROTECTED] man/man1/tcptraceroute.1
+share/doc/tcptraceroute/
+share/doc/tcptraceroute/AUTHORS
+share/doc/tcptraceroute/COPYING
+share/doc/tcptraceroute/ChangeLog
+share/doc/tcptraceroute/NEWS
+share/doc/tcptraceroute/README
+share/doc/tcptraceroute/examples.txt
+share/doc/tcptraceroute/tcptraceroute.1.html
+share/doc/tcptraceroute/tcptraceroute.lsm

Reply via email to