The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6a6c5572c3411d3b4d5a423d3bb8d53026cb4355

commit 6a6c5572c3411d3b4d5a423d3bb8d53026cb4355
Author:     Lexi Winter <l...@le-fay.org>
AuthorDate: 2024-02-03 13:19:03 +0000
Commit:     Warner Losh <i...@freebsd.org>
CommitDate: 2024-02-08 16:52:42 +0000

    traceroute: remove configuration #defines
    
    traceroute used a series of #defines to specify what features are
    available on the host platform.  As traceroute is now in source, these
    are unnecessary and complicate the code, so remove them.
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1100
---
 usr.sbin/traceroute/Makefile           |  6 ---
 usr.sbin/traceroute/findsaddr-socket.c | 30 ---------------
 usr.sbin/traceroute/ifaddrlist.c       |  8 ----
 usr.sbin/traceroute/traceroute.c       | 67 ----------------------------------
 4 files changed, 111 deletions(-)

diff --git a/usr.sbin/traceroute/Makefile b/usr.sbin/traceroute/Makefile
index fd013be9ba9a..45a80174f5ab 100644
--- a/usr.sbin/traceroute/Makefile
+++ b/usr.sbin/traceroute/Makefile
@@ -8,12 +8,6 @@ SRCS=  as.c traceroute.c ifaddrlist.c findsaddr-udp.c
 BINOWN=        root
 BINMODE=4555
 
-CFLAGS+= -DHAVE_SYS_SELECT_H=1 -DHAVE_SYS_SOCKIO_H=1 \
-        -DHAVE_NET_ROUTE_H=1 -DHAVE_NET_IF_DL_H=1 \
-        -DHAVE_STRERROR=1 -DHAVE_USLEEP=1 \
-        -DHAVE_SYS_SYSCTL_H=1 -DBYTESWAP_IP_HDR=1 \
-        -DHAVE_SETLINEBUF=1 -DHAVE_RAW_OPTIONS=1 \
-        -DHAVE_SOCKADDR_SA_LEN=1 -DHAVE_ICMP_NEXTMTU=1
 .if !defined(TRACEROUTE_NO_IPSEC)
 CFLAGS+= -DIPSEC
 .endif
diff --git a/usr.sbin/traceroute/findsaddr-socket.c 
b/usr.sbin/traceroute/findsaddr-socket.c
index b15c2e43a407..a3f830e6aab7 100644
--- a/usr.sbin/traceroute/findsaddr-socket.c
+++ b/usr.sbin/traceroute/findsaddr-socket.c
@@ -42,9 +42,7 @@ static const char rcsid[] =
 #include <sys/file.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
-#ifdef HAVE_SYS_SOCKIO_H
 #include <sys/sockio.h>
-#endif
 #include <sys/time.h>                          /* concession to AIX */
 
 #if __STDC__
@@ -64,17 +62,11 @@ struct rtentry;
 #include <unistd.h>
 
 #include "gnuc.h"
-#ifdef HAVE_OS_PROTO_H
 #include "os-proto.h"
-#endif
 
 #include "findsaddr.h"
 
-#ifdef HAVE_SOCKADDR_SA_LEN
 #define SALEN(sa) ((sa)->sa_len)
-#else
-#define SALEN(sa) salen(sa)
-#endif
 
 #ifndef roundup
 #define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))  /* to any y */
@@ -92,10 +84,6 @@ static struct rtmsg rtmsg = {
        { 0 }
 };
 
-#ifndef HAVE_SOCKADDR_SA_LEN
-static int salen(struct sockaddr *);
-#endif
-
 /*
  * Return the source address for the given destination address
  */
@@ -199,21 +187,3 @@ findsaddr(register const struct sockaddr_in *to,
 
        return ("failed!");
 }
-
-#ifndef HAVE_SOCKADDR_SA_LEN
-static int
-salen(struct sockaddr *sa)
-{
-       switch (sa->sa_family) {
-
-       case AF_INET:
-               return (sizeof(struct sockaddr_in));
-
-       case AF_LINK:
-               return (sizeof(struct sockaddr_dl));
-
-       default:
-               return (sizeof(struct sockaddr));
-       }
-}
-#endif
diff --git a/usr.sbin/traceroute/ifaddrlist.c b/usr.sbin/traceroute/ifaddrlist.c
index 0523a47ce61d..1b4b9db00c7f 100644
--- a/usr.sbin/traceroute/ifaddrlist.c
+++ b/usr.sbin/traceroute/ifaddrlist.c
@@ -40,9 +40,7 @@ static const char rcsid[] =
 #include <sys/file.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
-#ifdef HAVE_SYS_SOCKIO_H
 #include <sys/sockio.h>
-#endif
 #include <sys/time.h>                          /* concession to AIX */
 
 #if __STDC__
@@ -70,9 +68,7 @@ int
 ifaddrlist(register struct ifaddrlist **ipaddrp, register char *errbuf)
 {
        register int fd, nipaddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
        size_t n;
-#endif
        register struct ifreq *ifrp, *ifend, *ifnext;
        register struct sockaddr_in *sin;
        register struct ifaddrlist *al;
@@ -108,7 +104,6 @@ ifaddrlist(register struct ifaddrlist **ipaddrp, register 
char *errbuf)
        al = ifaddrlist;
        nipaddr = 0;
        for (; ifrp < ifend; ifrp = ifnext) {
-#ifdef HAVE_SOCKADDR_SA_LEN
                n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name);
                if (n < sizeof(*ifrp))
                        ifnext = ifrp + 1;
@@ -116,9 +111,6 @@ ifaddrlist(register struct ifaddrlist **ipaddrp, register 
char *errbuf)
                        ifnext = (struct ifreq *)((char *)ifrp + n);
                if (ifrp->ifr_addr.sa_family != AF_INET)
                        continue;
-#else
-               ifnext = ifrp + 1;
-#endif
                /*
                 * Need a template to preserve address info that is
                 * used below to locate the next entry.  (Otherwise,
diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c
index b8dcc423ebde..594eedca8081 100644
--- a/usr.sbin/traceroute/traceroute.c
+++ b/usr.sbin/traceroute/traceroute.c
@@ -204,13 +204,9 @@ static const char rcsid[] =
 #include <sys/capsicum.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
-#ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
-#endif
 #include <sys/socket.h>
-#ifdef HAVE_SYS_SYSCTL_H
 #include <sys/sysctl.h>
-#endif
 #include <sys/time.h>
 
 #include <netinet/in_systm.h>
@@ -241,9 +237,7 @@ static const char rcsid[] =
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
-#ifdef HAVE_MALLOC_H
 #include <malloc.h>
-#endif
 #include <memory.h>
 #include <netdb.h>
 #include <stdio.h>
@@ -305,14 +299,6 @@ struct outdata {
        struct timeval tv;      /* time packet left */
 };
 
-#ifndef HAVE_ICMP_NEXTMTU
-/* Path MTU Discovery (RFC1191) */
-struct my_pmtu {
-       u_short ipm_void;
-       u_short ipm_nextmtu;
-};
-#endif
-
 u_char packet[512];            /* last inbound (icmp) packet */
 
 struct ip *outip;              /* last output ip packet */
@@ -396,9 +382,6 @@ void        tvsub(struct timeval *, struct timeval *);
 void usage(void);
 int    wait_for_reply(int, struct sockaddr_in *, const struct timeval *);
 void pkt_compare(const u_char *, int, const u_char *, int);
-#ifndef HAVE_USLEEP
-int    usleep(u_int);
-#endif
 
 void   udp_prep(struct outdata *);
 int    udp_check(const u_char *, int);
@@ -764,11 +747,7 @@ main(int argc, char **argv)
                usage();
        }
 
-#ifdef HAVE_SETLINEBUF
        setlinebuf(stdout);
-#else
-       setvbuf(stdout, NULL, _IOLBF, 0);
-#endif
 
        protlen = packlen - sizeof(*outip) - optlen;
        if ((proto->num == IPPROTO_SCTP) && (packlen & 3)) {
@@ -791,16 +770,10 @@ main(int argc, char **argv)
                outip->ip_tos &= ~IPTOS_ECN_MASK;
                outip->ip_tos |= IPTOS_ECN_ECT1;
        }
-#ifdef BYTESWAP_IP_HDR
        outip->ip_len = htons(packlen);
        outip->ip_off = htons(off);
-#else
-       outip->ip_len = packlen;
-       outip->ip_off = off;
-#endif
        outip->ip_p = proto->num;
        outp = (u_char *)(outip + 1);
-#ifdef HAVE_RAW_OPTIONS
        if (lsrr > 0) {
                register u_char *optlist;
 
@@ -822,7 +795,6 @@ main(int argc, char **argv)
                optlist[3] = IPOPT_MINOFF;
                memcpy(optlist + 4, gwlist + 1, i);
        } else
-#endif
                outip->ip_dst = to->sin_addr;
 
        outip->ip_hl = (outp - (u_char *)outip) >> 2;
@@ -858,39 +830,6 @@ main(int argc, char **argv)
                exit(1);
        }
 
-#if defined(IP_OPTIONS) && !defined(HAVE_RAW_OPTIONS)
-       if (lsrr > 0) {
-               u_char optlist[MAX_IPOPTLEN];
-
-               cp = "ip";
-               if ((pe = getprotobyname(cp)) == NULL) {
-                       Fprintf(stderr, "%s: unknown protocol %s\n", prog, cp);
-                       exit(1);
-               }
-
-               /* final hop */
-               gwlist[lsrr] = to->sin_addr.s_addr;
-               ++lsrr;
-
-               /* force 4 byte alignment */
-               optlist[0] = IPOPT_NOP;
-               /* loose source route option */
-               optlist[1] = IPOPT_LSRR;
-               i = lsrr * sizeof(gwlist[0]);
-               optlist[2] = i + 3;
-               /* Pointer to LSRR addresses */
-               optlist[3] = IPOPT_MINOFF;
-               memcpy(optlist + 4, gwlist, i);
-
-               if ((setsockopt(sndsock, pe->p_proto, IP_OPTIONS,
-                   (char *)optlist, i + sizeof(gwlist[0]))) < 0) {
-                       Fprintf(stderr, "%s: IP_OPTIONS: %s\n",
-                           prog, strerror(errno));
-                       exit(1);
-                   }
-       }
-#endif
-
 #ifdef SO_SNDBUF
        if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&packlen,
            sizeof(packlen)) < 0) {
@@ -1449,11 +1388,7 @@ packet_ok(register u_char *buf, int cc, register struct 
sockaddr_in *from,
        if (code != ICMP_UNREACH_NEEDFRAG)
                pmtu = 0;
        else {
-#ifdef HAVE_ICMP_NEXTMTU
                pmtu = ntohs(icp->icmp_nextmtu);
-#else
-               pmtu = ntohs(((struct my_pmtu *)&icp->icmp_void)->ipm_nextmtu);
-#endif
        }
        if (type == ICMP_ECHOREPLY
            && proto->num == IPPROTO_ICMP
@@ -2055,9 +1990,7 @@ setsin(register struct sockaddr_in *sin, register 
u_int32_t addr)
 {
 
        memset(sin, 0, sizeof(*sin));
-#ifdef HAVE_SOCKADDR_SA_LEN
        sin->sin_len = sizeof(*sin);
-#endif
        sin->sin_family = AF_INET;
        sin->sin_addr.s_addr = addr;
 }

Reply via email to