Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src sbin/rtsol now shares source code with usr.sbin/rtsold.



details:   https://anonhg.NetBSD.org/src/rev/d6e614e5cdbe
branches:  trunk
changeset: 476013:d6e614e5cdbe
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri Sep 03 05:25:43 1999 +0000

description:
sbin/rtsol now shares source code with usr.sbin/rtsold.
sbin/rtsol is compiled separately for static linkage.

diffstat:

 sbin/rtsol/Makefile      |   12 +-
 sbin/rtsol/rtsol.8       |   96 ---------
 sbin/rtsol/rtsol.c       |  483 -----------------------------------------------
 usr.sbin/rtsold/Makefile |    3 +-
 4 files changed, 11 insertions(+), 583 deletions(-)

diffs (truncated from 626 to 300 lines):

diff -r c5091e801e1a -r d6e614e5cdbe sbin/rtsol/Makefile
--- a/sbin/rtsol/Makefile       Fri Sep 03 05:19:59 1999 +0000
+++ b/sbin/rtsol/Makefile       Fri Sep 03 05:25:43 1999 +0000
@@ -1,10 +1,16 @@
-# $NetBSD: Makefile,v 1.1 1999/07/02 08:28:04 itojun Exp $
+# $NetBSD: Makefile,v 1.2 1999/09/03 05:25:44 itojun Exp $
 
 PROG=  rtsol
+SRCS=  rtsold.c rtsol.c if.c probe.c
 
-CPPFLAGS+=-DADVAPI=1
 CPPFLAGS+=-DINET6
 
-MAN=   rtsol.8
+LDADD+=        -lkvm
+DPADD+=        ${LIBKVM}
+
+#MAN=  rtsold.8
+NOMAN= yes
+
+.PATH: ${.CURDIR}/../../usr.sbin/rtsold
 
 .include <bsd.prog.mk>
diff -r c5091e801e1a -r d6e614e5cdbe sbin/rtsol/rtsol.8
--- a/sbin/rtsol/rtsol.8        Fri Sep 03 05:19:59 1999 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-.\" 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.
-.\"
-.\"     $NetBSD: rtsol.8,v 1.2 1999/07/04 02:43:39 itojun Exp $
-.\"     KAME Id: rtsol.8,v 1.1.2.5.2.2.4.2 1999/05/02 13:18:43 itojun Exp
-.\"
-.Dd May 17, 1998
-.Dt RTSOL 8
-.Os
-.\"
-.Sh NAME
-.Nm rtsol
-.Nd send router solicitation
-.\"
-.Sh SYNOPSIS
-.Nm
-.Op Fl nv
-.Ar interface
-.\"
-.Sh DESCRIPTION
-.Nm Rtsol
-sends router solicitation packet to the specified
-.Ar interface .
-If there is any router on the network, the router may respond by
-router advertisement packet.
-Router advertisement packet contains information about the network,
-the link-local address of the router, and so forth.
-The kernel will install the new routing information and address prefix
-for the
-.Ar interface ,
-according to the information.
-.Pp
-.Nm
-implements some quickhack code for notebook computers.
-.Fl n
-disables the behavior
-.Pq the flag stands for no tricks .
-.Pp
-If
-.Fl v 
-is specified,
-.Nm
-will generate more messages.
-This is mostly for debugging.
-.Pp
-Router advertisement packet will be processed only if the
-node is configured as a host, not a router.
-To accept router advertisement packet,
-.Xr sysctl 8
-variables must be set as follows:
-.Bd -literal -offset
-# sysctl -w net.inet6.ip6.forwarding=0
-# sysctl -w net.inet6.ip6.accept_rtadv=1
-.Ed
-.Pp
-Typically this is done in system startup scripts, such as
-.Xr rc 8 .
-.\"
-.Sh RETURN VALUES
-The program exits with 0 on success, non-zero on failures.
-.\"
-.Sh SEE ALSO
-.Xr rtadvd 8 ,
-.Xr rtsold 8 ,
-.Xr sysctl 8
-.\"
-.Sh HISTORY
-The
-.Nm
-command first appeared in WIDE Hydrangea IPv6 protocol stack kit.
-.\" .Sh BUGS
-.\" (to be written)
diff -r c5091e801e1a -r d6e614e5cdbe sbin/rtsol/rtsol.c
--- a/sbin/rtsol/rtsol.c        Fri Sep 03 05:19:59 1999 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,483 +0,0 @@
-/*     $NetBSD: rtsol.c,v 1.3 1999/07/29 09:57:58 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 <sys/param.h>
-#include <sys/socket.h>
-#ifdef ADVAPI
-#include <sys/uio.h>
-#endif
-#include <sys/ioctl.h>
-
-#include <net/if.h>
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
-#include <net/if_var.h>
-#endif /* __FreeBSD__ >= 3 */
-#include <netinet/in.h>
-#include <netinet/ip6.h>
-#include <netinet/icmp6.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <err.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <sys/sysctl.h>
-#include <netdb.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
-#include <netinet6/nd6.h>
-
-#define ALLROUTER      "ff02::2"
-
-int main __P((int, char **));
-void usage __P((void));
-int sendit __P((int, char *, int, struct sockaddr_in6 *, int));
-int interface_down __P((char *));
-int interface_up __P((char *));
-static int getifflag6 __P((char *, int *));
-static int getinet6sysctl __P((int));
-
-static int trick = 1;
-static int verbose = 0;
-#define vmsg(x)                { if (verbose) fprintf x; }
-
-extern char *optarg;
-extern int optind;
-
-int
-main(argc, argv)
-       int argc;
-       char *argv[];
-{
-       struct sockaddr_in6 to;
-       struct icmp6_hdr *icp;
-       u_int hlim = 255;
-       u_char outpack[sizeof(struct icmp6_hdr)];
-       u_short index;
-       int s, i, cc = sizeof(struct icmp6_hdr);
-       int opt;
-       fd_set fdset;
-       struct timeval timeout;
-       int rtsol_retry = MAX_RTR_SOLICITATIONS;
-       long rdelay;
-
-       srandom((unsigned)time(NULL));
-       
-       while ((opt = getopt(argc, argv, "nv")) != EOF) {
-               switch (opt) {
-               case 'n':
-                       trick = 0;
-                       break;
-               case 'v':
-                       verbose++;
-                       break;
-               default:
-                       usage();
-                       /*NOTREACHED*/
-               }
-       }
-       argc -= optind;
-       argv += optind;
-       if (argc != 1) {
-               usage();
-               /*NOTREACHED*/
-       }
-
-       index = (u_short)if_nametoindex(argv[0]);
-       if (index == 0) {
-               errx(1, "invalid interface %s", argv[0]);
-               /*NOTREACHED*/
-       }
-
-       if (!getinet6sysctl(IPV6CTL_ACCEPT_RTADV))
-               warnx("kernel is configured not to accept RAs");
-
-       if (trick) {
-               /*
-                * Notebook hack:
-                * It looks that, most of the pccard drivers do not reset
-                * multicast packet filter properly on suspend/resume session.
-                * bring interface down, then up, to initialize it properly.
-                */
-               if (interface_down(argv[0]) < 0)
-                       err(1, "interface state could not be changed");
-               vmsg((stderr, "a bit of delay...\n"));
-               usleep(500 * 1000);     /* 0.5s */
-       }
-
-       if (interface_up(argv[0]) < 0)
-               err(1, "interface not ready");
-
-    {
-       struct addrinfo hints, *res;
-       int error;
-
-       memset(&hints, 0, sizeof(hints));
-       hints.ai_family = AF_INET6;
-       error = getaddrinfo(ALLROUTER, NULL, &hints, &res);
-       if (error) {
-               errx(1, "getaddrinfo: %s", gai_strerror(error));
-               /*NOTREACHED*/
-       }
-       memcpy(&to, res->ai_addr, res->ai_addrlen);
-    }
-       
-       if ((s = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0)
-               err(1, "socket");
-
-       if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &hlim,
-                       sizeof(hlim)) == -1)
-               err(1, "setsockopt(IPV6_MULTICAST_HOPS)");
-#ifdef ICMP6_FILTER
-    {
-       struct icmp6_filter filt;
-       ICMP6_FILTER_SETBLOCKALL(&filt);
-       ICMP6_FILTER_SETPASS(ND_ROUTER_ADVERT, &filt);
-       if (setsockopt(s, IPPROTO_ICMPV6, ICMP6_FILTER, &filt,
-                       sizeof(filt)) == -1)
-               err(1, "setsockopt(ICMP6_FILTER)");
-    }
-#endif
-       
-       /* fill ICMP header */
-       icp = (struct icmp6_hdr *)outpack;
-       icp->icmp6_type = ND_ROUTER_SOLICIT;



Home | Main Index | Thread Index | Old Index