From: deraadt Date: Mon, 26 Oct 2015 13:07:13 +0000 (+0000) Subject: rip6query goes to the attic. Hopefully route6d (rip6d?) will get some X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d6745f5c843e33fa3d8b10845892a862bd758f2d;p=openbsd rip6query goes to the attic. Hopefully route6d (rip6d?) will get some love instead, prod prod. ok claudio jca mpi --- diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index b89a451c7c6..77aa086a204 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.188 2015/10/15 21:27:37 tedu Exp $ +# $OpenBSD: Makefile,v 1.189 2015/10/26 13:07:13 deraadt Exp $ .include @@ -13,9 +13,8 @@ SUBDIR= ac accton acpidump adduser amd apm apmd arp \ npppctl npppd nsd ntpd ospfctl ospfd ospf6d ospf6ctl \ pcidump pkg_add portmap pppd procmap pstat pwd_mkdb \ quot quotaon radiusctl radiusd rarpd rbootd \ - rcctl rdate rebound relayctl \ - relayd repquota rip6query ripctl ripd rmt route6d rpc.bootparamd \ - rpc.lockd rpc.statd rtadvd \ + rcctl rdate rebound relayctl relayd repquota ripctl ripd \ + rmt route6d rpc.bootparamd rpc.lockd rpc.statd rtadvd \ sa sasyncd sensorsd slowcgi smtpd \ snmpctl snmpd spamdb syslogc syslogd sysmerge tcpdrop tcpdump \ tftp-proxy tftpd tokenadm tokeninit traceroute trpt \ diff --git a/usr.sbin/rip6query/Makefile b/usr.sbin/rip6query/Makefile deleted file mode 100644 index 81722f04967..00000000000 --- a/usr.sbin/rip6query/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $OpenBSD: Makefile,v 1.1 2000/01/19 08:13:01 itojun Exp $ - -PROG= rip6query -MAN= rip6query.8 - -CPPFLAGS+= -DINET6 -I${.CURDIR}/../route6d - -.include diff --git a/usr.sbin/rip6query/rip6query.8 b/usr.sbin/rip6query/rip6query.8 deleted file mode 100644 index 2df17b6fa29..00000000000 --- a/usr.sbin/rip6query/rip6query.8 +++ /dev/null @@ -1,66 +0,0 @@ -.\" $OpenBSD: rip6query.8,v 1.9 2007/05/31 19:20:28 jmc Exp $ -.\" $KAME: rip6query.8,v 1.6 2001/11/16 07:05:36 itojun Exp $ -.\" -.\" Copyright (C) 1998 and 1999 WIDE Project. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the project nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: May 31 2007 $ -.Dt RIP6QUERY 8 -.Os -.Sh NAME -.Nm rip6query -.Nd RIPng debugging tool -.\" -.Sh SYNOPSIS -.Nm -.Op Fl I Ar interface -.Op Fl w Ar time -.Ar destination -.\" -.Sh DESCRIPTION -.Nm -requests remote RIPng daemon on -.Ar destination -to dump RIPng routing information. -.Fl I -lets you specify outgoing -.Ar interface -for the query packet, -and is useful when link-local address is specified for -.Ar destination . -.Fl w -specifies the time in seconds to wait for the initial -response from a gateway. -The default value is 5 seconds. -.\" -.Sh SEE ALSO -.Xr route6d 8 -.\" -.Sh HISTORY -The -.Nm -command first appeared in WIDE Hydrangea IPv6 protocol stack kit. diff --git a/usr.sbin/rip6query/rip6query.c b/usr.sbin/rip6query/rip6query.c deleted file mode 100644 index d4414ba13ca..00000000000 --- a/usr.sbin/rip6query/rip6query.c +++ /dev/null @@ -1,217 +0,0 @@ -/* $OpenBSD: rip6query.c,v 1.16 2015/08/20 22:39:29 deraadt Exp $ */ -/* $KAME: rip6query.c,v 1.17 2002/09/08 01:35:17 itojun Exp $ */ - -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "route6d.h" - -#define DEFAULT_WAIT 5 - -int s; -int query_wait = DEFAULT_WAIT; -struct sockaddr_in6 sin6; -struct rip6 *ripbuf; - -#define RIPSIZE(n) (sizeof(struct rip6) + (n-1) * sizeof(struct netinfo6)) - -static void usage(void); -static void sigalrm_handler(int); -static const char *sa_n2a(struct sockaddr *); -static const char *inet6_n2a(struct in6_addr *); - -int -main(int argc, char *argv[]) -{ - struct netinfo6 *np; - struct sockaddr_in6 fsock; - int i, n, len; - socklen_t flen; - int c; - int ifidx = -1; - int error; - const char *errstr; - char pbuf[NI_MAXSERV]; - struct addrinfo hints, *res; - - while ((c = getopt(argc, argv, "I:w:")) != -1) { - switch (c) { - case 'I': - ifidx = if_nametoindex(optarg); - if (ifidx == 0) { - errx(1, "invalid interface %s", optarg); - /*NOTREACHED*/ - } - break; - case 'w': - query_wait = strtonum(optarg, 1, INT_MAX, &errstr); - if (errstr) - errx(1, "-w %s: %s", optarg, errstr); - break; - default: - usage(); - exit(1); - /*NOTREACHED*/ - } - } - argv += optind; - argc -= optind; - - if (argc != 1) { - usage(); - exit(1); - } - - if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { - err(1, "socket"); - /*NOTREACHED*/ - } - - /* getaddrinfo is preferred for addr%scope syntax */ - snprintf(pbuf, sizeof(pbuf), "%d", RIP6_PORT); - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_INET6; - hints.ai_socktype = SOCK_DGRAM; - error = getaddrinfo(argv[0], pbuf, &hints, &res); - if (error) { - errx(1, "%s: %s", argv[0], gai_strerror(error)); - /*NOTREACHED*/ - } - if (res->ai_next) { - errx(1, "%s: %s", argv[0], "resolved to multiple addrs"); - /*NOTREACHED*/ - } - if (sizeof(sin6) != res->ai_addrlen) { - errx(1, "%s: %s", argv[0], "invalid addrlen"); - /*NOTREACHED*/ - } - memcpy(&sin6, res->ai_addr, res->ai_addrlen); - if (ifidx >= 0) - sin6.sin6_scope_id = ifidx; - - if ((ripbuf = malloc(BUFSIZ)) == NULL) { - err(1, "malloc"); - /*NOTREACHED*/ - } - ripbuf->rip6_cmd = RIP6_REQUEST; - ripbuf->rip6_vers = RIP6_VERSION; - ripbuf->rip6_res1[0] = 0; - ripbuf->rip6_res1[1] = 0; - np = ripbuf->rip6_nets; - bzero(&np->rip6_dest, sizeof(struct in6_addr)); - np->rip6_tag = 0; - np->rip6_plen = 0; - np->rip6_metric = HOPCNT_INFINITY6; - if (sendto(s, ripbuf, RIPSIZE(1), 0, (struct sockaddr *)&sin6, - sizeof(struct sockaddr_in6)) < 0) { - err(1, "send"); - /*NOTREACHED*/ - } - signal(SIGALRM, sigalrm_handler); - for (;;) { - flen = sizeof(fsock); - alarm(query_wait); - if ((len = recvfrom(s, ripbuf, BUFSIZ, 0, - (struct sockaddr *)&fsock, &flen)) < 0) { - err(1, "recvfrom"); - /*NOTREACHED*/ - } - alarm(0); - printf("Response from %s len %d\n", - sa_n2a((struct sockaddr *)&fsock), len); - n = (len - sizeof(struct rip6) + sizeof(struct netinfo6)) / - sizeof(struct netinfo6); - np = ripbuf->rip6_nets; - for (i = 0; i < n; i++, np++) { - printf("\t%s/%d [%d]", inet6_n2a(&np->rip6_dest), - np->rip6_plen, np->rip6_metric); - if (np->rip6_tag) - printf(" tag=0x%x", ntohs(np->rip6_tag)); - printf("\n"); - } - } - - exit(0); -} - -static void -usage(void) -{ - fprintf(stderr, - "usage: rip6query [-I interface] [-w time] destination\n"); -} - -/* getnameinfo() is preferred as we may be able to show ifindex as ifname */ -static const char * -sa_n2a(struct sockaddr *sa) -{ - static char buf[NI_MAXHOST]; - - if (getnameinfo(sa, sa->sa_len, buf, sizeof(buf), - NULL, 0, NI_NUMERICHOST) != 0) { - snprintf(buf, sizeof(buf), "%s", "(invalid)"); - } - return buf; -} - -static const char * -inet6_n2a(struct in6_addr *addr) -{ - static char buf[NI_MAXHOST]; - - return inet_ntop(AF_INET6, addr, buf, sizeof(buf)); -} - -static void -sigalrm_handler(int sig) -{ - - _exit(0); -}