From: David van Moolenbroek Date: Thu, 29 Sep 2016 23:19:31 +0000 (+0000) Subject: ping(8), traceroute(8): adapt to new LWIP service X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=bb9622b5ed41bec48062bf9c6806832c8984f025;p=minix.git ping(8), traceroute(8): adapt to new LWIP service Change-Id: I0aae7199dfd9075201975e133cdaeab6bc2bd24f --- diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 915c67734..5cdae652c 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -197,9 +197,7 @@ static double tsum = 0.0; /* sum of all times */ static double tsumsq = 0.0; static double maxwait = 0.0; -#if !defined(__minix) static int bufspace = IP_MAXPACKET; -#endif /* !defined(__minix) */ static struct timespec now, clear_cache, last_tx, next_tx, first_tx; static struct timespec last_rx, first_rx; @@ -261,14 +259,12 @@ main(int argc, char *argv[]) if ((sloop = prog_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) err(EXIT_FAILURE, "Cannot create socket"); -#if !defined(__minix) /* * sloop is never read on. This prevents packets from * queueing in its recv buffer. */ if (prog_shutdown(sloop, SHUT_RD) == -1) warn("Cannot shutdown for read"); -#endif /* !defined(__minix) */ if (prog_setuid(prog_getuid()) == -1) err(EXIT_FAILURE, "setuid"); @@ -539,11 +535,9 @@ main(int argc, char *argv[]) - optlen); (void) memcpy(opack_ip + 1, optspace, optlen); -#if !defined(__minix) if (prog_setsockopt(s, IPPROTO_IP, IP_HDRINCL, (char *) &on, sizeof(on)) < 0) err(EXIT_FAILURE, "Can't set special IP header"); -#endif /* !defined(__minix) */ opack_ip->ip_v = IPVERSION; opack_ip->ip_hl = (sizeof(struct ip)+optlen) >> 2; @@ -656,7 +650,6 @@ main(int argc, char *argv[]) (void)printf("PING %s (%s): %d data bytes\n", hostname, inet_ntoa(whereto.sin_addr), datalen); -#if !defined(__minix) /* When pinging the broadcast address, you can get a lot * of answers. Doing something so evil is useful if you * are trying to stress the ethernet, or just want to @@ -673,7 +666,6 @@ main(int argc, char *argv[]) */ (void)prog_setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char*)&bufspace, sizeof(bufspace)); -#endif /* !defined(__minix) */ (void)signal(SIGINT, prefinish); diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c index 7bbc091f0..f6020da6a 100644 --- a/usr.sbin/traceroute/traceroute.c +++ b/usr.sbin/traceroute/traceroute.c @@ -240,11 +240,6 @@ __RCSID("$NetBSD: traceroute.c,v 1.81 2012/08/16 00:40:28 zafer Exp $"); #include #endif -#if defined(__minix) -#include -#include -#endif /* defined(__minix) */ - #include "gnuc.h" #ifdef HAVE_OS_PROTO_H #include "os-proto.h" @@ -499,11 +494,7 @@ main(int argc, char **argv) * running our traceroute code will forgive us. */ #ifndef __hpux -#if defined(__minix) - sndsock = prog_socket(AF_INET, SOCK_RAW, IPPROTO_UDP); -#else sndsock = prog_socket(AF_INET, SOCK_RAW, IPPROTO_RAW); -#endif /* defined(__minix) */ #else sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW useicmp ? IPPROTO_ICMP : IPPROTO_UDP); @@ -829,7 +820,6 @@ main(int argc, char **argv) } #endif -#if !defined(__minix) #ifdef SO_SNDBUF if (prog_setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&packlen, sizeof(packlen)) < 0) @@ -854,7 +844,6 @@ main(int argc, char **argv) if (prog_setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE, &on, sizeof(on)) < 0) err(1, "setsockopt dontroute %d", tos); -#endif /* !defined(__minix) */ /* Get the interface address list */ n = ifaddrlist(&al, errbuf, sizeof errbuf); @@ -1357,23 +1346,11 @@ again: Printf("]\n"); } -#if !defined(__minix) #if !defined(IP_HDRINCL) && defined(IP_TTL) if (prog_setsockopt(sndsock, IPPROTO_IP, IP_TTL, (char *)&ttl, sizeof(ttl)) < 0) err(1, "setsockopt ttl %d", ttl); #endif -#else - { - nwio_ipopt_t ipopts; - memset(&ipopts, 0, sizeof(ipopts)); - ipopts.nwio_flags = NWIO_HDR_O_SPEC; - ipopts.nwio_ttl = ttl; - if(ioctl(sndsock, NWIOSIPOPT, &ipopts) < 0) { - err(1, "ttl ioctl"); - } - } -#endif /* !defined(__minix) */ if (dump) dump_packet();