Source-Changes-HG archive

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

[src/trunk]: src/sbin/rtsol sync with recent KAME.



details:   https://anonhg.NetBSD.org/src/rev/7ae6c732b22d
branches:  trunk
changeset: 475011:7ae6c732b22d
user:      itojun <itojun%NetBSD.org@localhost>
date:      Thu Jul 29 09:57:58 1999 +0000

description:
sync with recent KAME.
- warn if net.inet6.ip6.accept_rtadv=0 (the command has no use in this case)
- conformance to RFC2461: obey declared timing constants more strictly

diffstat:

 sbin/rtsol/rtsol.c |  31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)

diffs (97 lines):

diff -r 362895a23615 -r 7ae6c732b22d sbin/rtsol/rtsol.c
--- a/sbin/rtsol/rtsol.c        Thu Jul 29 09:09:18 1999 +0000
+++ b/sbin/rtsol/rtsol.c        Thu Jul 29 09:57:58 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsol.c,v 1.2 1999/07/04 02:43:39 itojun Exp $ */
+/*     $NetBSD: rtsol.c,v 1.3 1999/07/29 09:57:58 itojun Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -64,7 +64,7 @@
 int interface_down __P((char *));
 int interface_up __P((char *));
 static int getifflag6 __P((char *, int *));
-static int getdadcount __P((void));
+static int getinet6sysctl __P((int));
 
 static int trick = 1;
 static int verbose = 0;
@@ -88,6 +88,9 @@
        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) {
@@ -115,6 +118,9 @@
                /*NOTREACHED*/
        }
 
+       if (!getinet6sysctl(IPV6CTL_ACCEPT_RTADV))
+               warnx("kernel is configured not to accept RAs");
+
        if (trick) {
                /*
                 * Notebook hack:
@@ -172,8 +178,15 @@
        vmsg((stderr, "sending RS for %d time%s:\n",
                rtsol_retry, (1 < rtsol_retry) ? "s" : ""));
 
+       rdelay = random() % ((long)MAX_RTR_SOLICITATION_DELAY * 1000);
+       vmsg((stderr, "sleep %ldmsec before sending the first one\n", rdelay));
+       if (rdelay / 1000 > 0)
+               sleep(rdelay / 1000);
+       usleep(rdelay % 1000);
+
 retry:
-       vmsg((stderr, "%d \r", rtsol_retry));
+       vmsg((stderr, "%d, interval=%dsec\r", rtsol_retry,
+               RTR_SOLICITATION_INTERVAL));
 
        i = sendit(s, (char *)outpack, cc, &to, index);
        if (i < 0) {
@@ -185,13 +198,13 @@
        }
        FD_ZERO(&fdset);
        FD_SET(s, &fdset);
-       timeout.tv_sec = 1;
+       timeout.tv_sec = RTR_SOLICITATION_INTERVAL;
        timeout.tv_usec = 0;
        if (select(s + 1, &fdset, NULL, NULL, &timeout) < 1) {
                if (0 < --rtsol_retry)
                        goto retry;
        } else {
-               vmsg((stderr, "got a RA packet\n"));
+               vmsg((stderr, "\ngot a RA packet\n"));
        }
 
        close(s);
@@ -303,7 +316,7 @@
        }
        close(s);
 
-       retry = getdadcount();
+       retry = getinet6sysctl(IPV6CTL_DAD_COUNT);
        if (retry < 0) {
                retry = 10;
                vmsg((stderr, "invalid dad count; setting retry to %d\n",
@@ -454,12 +467,14 @@
 }
 
 static int
-getdadcount()
+getinet6sysctl(code)
+       int code;
 {
-       int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_DAD_COUNT };
+       int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, 0 };
        int value;
        size_t size;
 
+       mib[3] = code;
        size = sizeof(value);
        if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &value, &size, NULL, 0) < 0)
                return -1;



Home | Main Index | Thread Index | Old Index