$NetBSD: patch-ab,v 1.4 2006/03/23 13:50:12 joerg Exp $ --- tcptraceroute.c.orig 2002-07-30 21:51:27.000000000 +0000 +++ tcptraceroute.c @@ -209,7 +209,7 @@ Updates are available from http://michae #define AF_LINK AF_INET /* BSD defines some AF_INET network interfaces as AF_LINK */ #endif -#if defined (__OpenBSD__) || defined(__FreeBSD__) || defined(__bsdi__) +#if defined (__OpenBSD__) || defined(__FreeBSD__) || defined(__bsdi__) || defined(__NetBSD__) #define HASSALEN /* Awful, awful hack to make subinterfaces work on BSD. */ #endif @@ -340,7 +340,6 @@ typedef struct { extern char *optarg; extern int optind, opterr, optopt; extern char pcap_version[]; -extern int errno; /* * fatal() and pfatal() are useful stdarg functions from @@ -391,10 +390,10 @@ void pfatal(char *err) void usage(void) { printf("\n%s\n%s\n", VERSION, BANNER); - fatal("Usage: %s [-nNFSAE] [-i ] [-f ] - [-l ] [-q ] [-t ] - [-m ] [-pP] ] [-s ] - [-w ] [destination port] [packet length]\n\n", name); + fatal("Usage: %s [-nNFSAE] [-i ] [-f ]\n" +" [-l ] [-q ] [-t ]\n" +" [-m ] [-pP] ] [-s ]\n" +" [-w ] [destination port] [packet length]\n\n", name); } void about(void) @@ -724,8 +723,7 @@ void getinterfaces(void) } #endif - if (ifrp->ifr_addr.sa_family != AF_INET && - ifrp->ifr_addr.sa_family != AF_LINK) + if (ifrp->ifr_addr.sa_family != AF_INET) { debug("Ignoring non-AF_INET address on interface %s\n", sprintable(ifr.ifr_name)); @@ -1182,9 +1180,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, + "(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)", iptos(dst_ip), dst_prt, iptos(src_ip), iptos(src_ip)); if (o_nofilter) @@ -1783,9 +1781,14 @@ int main(int argc, char **argv) o_dontfrag = 0; o_timeout = 3; o_nofilter = 0; - o_noselect = 0; o_nogetinterfaces = 0; +#if defined(__NetBSD__) + o_noselect = 1; +#else + o_noselect = 0; +#endif + #if defined (__SVR4) && defined (__sun) o_trackport = 1; /* --track-port should be the default for Solaris */ #else @@ -2003,6 +2006,6 @@ int main(int argc, char **argv) defaults(); initcapture(); - seteuid(getuid()); + setuid(getuid()); return trace(); }