ping(8), traceroute(8): adapt to new LWIP service

Change-Id: I0aae7199dfd9075201975e133cdaeab6bc2bd24f
This commit is contained in:
David van Moolenbroek 2016-09-29 23:19:31 +00:00
parent ef8d499e2d
commit bb9622b5ed
2 changed files with 0 additions and 31 deletions

View File

@ -197,9 +197,7 @@ static double tsum = 0.0; /* sum of all times */
static double tsumsq = 0.0; static double tsumsq = 0.0;
static double maxwait = 0.0; static double maxwait = 0.0;
#if !defined(__minix)
static int bufspace = IP_MAXPACKET; static int bufspace = IP_MAXPACKET;
#endif /* !defined(__minix) */
static struct timespec now, clear_cache, last_tx, next_tx, first_tx; static struct timespec now, clear_cache, last_tx, next_tx, first_tx;
static struct timespec last_rx, first_rx; 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) if ((sloop = prog_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
err(EXIT_FAILURE, "Cannot create socket"); err(EXIT_FAILURE, "Cannot create socket");
#if !defined(__minix)
/* /*
* sloop is never read on. This prevents packets from * sloop is never read on. This prevents packets from
* queueing in its recv buffer. * queueing in its recv buffer.
*/ */
if (prog_shutdown(sloop, SHUT_RD) == -1) if (prog_shutdown(sloop, SHUT_RD) == -1)
warn("Cannot shutdown for read"); warn("Cannot shutdown for read");
#endif /* !defined(__minix) */
if (prog_setuid(prog_getuid()) == -1) if (prog_setuid(prog_getuid()) == -1)
err(EXIT_FAILURE, "setuid"); err(EXIT_FAILURE, "setuid");
@ -539,11 +535,9 @@ main(int argc, char *argv[])
- optlen); - optlen);
(void) memcpy(opack_ip + 1, optspace, optlen); (void) memcpy(opack_ip + 1, optspace, optlen);
#if !defined(__minix)
if (prog_setsockopt(s, IPPROTO_IP, IP_HDRINCL, if (prog_setsockopt(s, IPPROTO_IP, IP_HDRINCL,
(char *) &on, sizeof(on)) < 0) (char *) &on, sizeof(on)) < 0)
err(EXIT_FAILURE, "Can't set special IP header"); err(EXIT_FAILURE, "Can't set special IP header");
#endif /* !defined(__minix) */
opack_ip->ip_v = IPVERSION; opack_ip->ip_v = IPVERSION;
opack_ip->ip_hl = (sizeof(struct ip)+optlen) >> 2; 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, (void)printf("PING %s (%s): %d data bytes\n", hostname,
inet_ntoa(whereto.sin_addr), datalen); inet_ntoa(whereto.sin_addr), datalen);
#if !defined(__minix)
/* When pinging the broadcast address, you can get a lot /* When pinging the broadcast address, you can get a lot
* of answers. Doing something so evil is useful if you * of answers. Doing something so evil is useful if you
* are trying to stress the ethernet, or just want to * 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, (void)prog_setsockopt(s, SOL_SOCKET, SO_SNDBUF,
(char*)&bufspace, sizeof(bufspace)); (char*)&bufspace, sizeof(bufspace));
#endif /* !defined(__minix) */
(void)signal(SIGINT, prefinish); (void)signal(SIGINT, prefinish);

View File

@ -240,11 +240,6 @@ __RCSID("$NetBSD: traceroute.c,v 1.81 2012/08/16 00:40:28 zafer Exp $");
#include <netipsec/ipsec.h> #include <netipsec/ipsec.h>
#endif #endif
#if defined(__minix)
#include <net/gen/in.h>
#include <net/gen/ip_io.h>
#endif /* defined(__minix) */
#include "gnuc.h" #include "gnuc.h"
#ifdef HAVE_OS_PROTO_H #ifdef HAVE_OS_PROTO_H
#include "os-proto.h" #include "os-proto.h"
@ -499,11 +494,7 @@ main(int argc, char **argv)
* running our traceroute code will forgive us. * running our traceroute code will forgive us.
*/ */
#ifndef __hpux #ifndef __hpux
#if defined(__minix)
sndsock = prog_socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
#else
sndsock = prog_socket(AF_INET, SOCK_RAW, IPPROTO_RAW); sndsock = prog_socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
#endif /* defined(__minix) */
#else #else
sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW
useicmp ? IPPROTO_ICMP : IPPROTO_UDP); useicmp ? IPPROTO_ICMP : IPPROTO_UDP);
@ -829,7 +820,6 @@ main(int argc, char **argv)
} }
#endif #endif
#if !defined(__minix)
#ifdef SO_SNDBUF #ifdef SO_SNDBUF
if (prog_setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&packlen, if (prog_setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&packlen,
sizeof(packlen)) < 0) sizeof(packlen)) < 0)
@ -854,7 +844,6 @@ main(int argc, char **argv)
if (prog_setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE, &on, if (prog_setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE, &on,
sizeof(on)) < 0) sizeof(on)) < 0)
err(1, "setsockopt dontroute %d", tos); err(1, "setsockopt dontroute %d", tos);
#endif /* !defined(__minix) */
/* Get the interface address list */ /* Get the interface address list */
n = ifaddrlist(&al, errbuf, sizeof errbuf); n = ifaddrlist(&al, errbuf, sizeof errbuf);
@ -1357,23 +1346,11 @@ again:
Printf("]\n"); Printf("]\n");
} }
#if !defined(__minix)
#if !defined(IP_HDRINCL) && defined(IP_TTL) #if !defined(IP_HDRINCL) && defined(IP_TTL)
if (prog_setsockopt(sndsock, IPPROTO_IP, IP_TTL, if (prog_setsockopt(sndsock, IPPROTO_IP, IP_TTL,
(char *)&ttl, sizeof(ttl)) < 0) (char *)&ttl, sizeof(ttl)) < 0)
err(1, "setsockopt ttl %d", ttl); err(1, "setsockopt ttl %d", ttl);
#endif #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) if (dump)
dump_packet(); dump_packet();