Skip to content

Commit

Permalink
ping(8), traceroute(8): adapt to new LWIP service
Browse files Browse the repository at this point in the history
Change-Id: I0aae7199dfd9075201975e133cdaeab6bc2bd24f
  • Loading branch information
dcvmoole committed Apr 30, 2017
1 parent ef8d499 commit bb9622b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 31 deletions.
8 changes: 0 additions & 8 deletions sbin/ping/ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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);

Expand Down
23 changes: 0 additions & 23 deletions usr.sbin/traceroute/traceroute.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ __RCSID("$NetBSD: traceroute.c,v 1.81 2012/08/16 00:40:28 zafer Exp $");
#include <netipsec/ipsec.h>
#endif

#if defined(__minix)
#include <net/gen/in.h>
#include <net/gen/ip_io.h>
#endif /* defined(__minix) */

#include "gnuc.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -1357,23 +1346,11 @@ send_probe(int seq, int ttl, struct timeval *tp)
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();

Expand Down

0 comments on commit bb9622b

Please sign in to comment.