Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/rip6query sync with latest kame. terminate only if...



details:   https://anonhg.NetBSD.org/src/rev/44184a60d6d4
branches:  trunk
changeset: 517615:44184a60d6d4
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri Nov 16 07:09:36 2001 +0000

description:
sync with latest kame.  terminate only if ripng response is not received
for 5 seconds (or length specified by -w).

diffstat:

 usr.sbin/rip6query/rip6query.8 |  16 ++++++++++------
 usr.sbin/rip6query/rip6query.c |  37 +++++++++++++++++++++++++------------
 2 files changed, 35 insertions(+), 18 deletions(-)

diffs (178 lines):

diff -r 774cebf7030c -r 44184a60d6d4 usr.sbin/rip6query/rip6query.8
--- a/usr.sbin/rip6query/rip6query.8    Fri Nov 16 05:35:40 2001 +0000
+++ b/usr.sbin/rip6query/rip6query.8    Fri Nov 16 07:09:36 2001 +0000
@@ -1,7 +1,9 @@
 .\"
+.\"    $NetBSD: rip6query.8,v 1.3 2001/11/16 07:09:36 itojun 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:
@@ -13,7 +15,7 @@
 .\" 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
@@ -26,9 +28,6 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\"    $NetBSD: rip6query.8,v 1.2 2001/04/26 23:27:44 wiz Exp $
-.\"    KAME Id: rip6query.8,v 1.2 2000/01/19 06:24:55 itojun Exp
-.\"
 .Dd October 7, 1999
 .Dt RIP6QUERY 8
 .Os
@@ -39,12 +38,13 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl I Ar interface
+.Op Fl w Ar time
 .Ar destination
 .\"
 .Sh DESCRIPTION
 .Nm
 requests remote RIPng daemon on
-.Ar destionation
+.Ar destination
 to dump RIPng routing information.
 .Fl I
 lets you specify outgoing
@@ -52,6 +52,10 @@
 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
diff -r 774cebf7030c -r 44184a60d6d4 usr.sbin/rip6query/rip6query.c
--- a/usr.sbin/rip6query/rip6query.c    Fri Nov 16 05:35:40 2001 +0000
+++ b/usr.sbin/rip6query/rip6query.c    Fri Nov 16 07:09:36 2001 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: rip6query.c,v 1.6 2001/05/07 14:00:22 kleink Exp $     */
-/*     $KAME: rip6query.c,v 1.9 2000/12/19 23:54:01 itojun Exp $       */
+/*     $NetBSD: rip6query.c,v 1.7 2001/11/16 07:09:37 itojun Exp $     */
+/*     $KAME: rip6query.c,v 1.15 2001/11/16 07:01:21 itojun Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -55,12 +55,10 @@
 
 #include "route6d.h"
 
-/* wrapper for KAME-special getnameinfo() */
-#ifndef NI_WITHSCOPEID
-#define NI_WITHSCOPEID 0
-#endif
+#define        DEFAULT_WAIT    5
 
 int    s;
+int    query_wait = DEFAULT_WAIT;
 struct sockaddr_in6 sin6;
 struct rip6    *ripbuf;
 
@@ -68,6 +66,7 @@
 
 int main __P((int, char **));
 static void usage __P((void));
+static void sigalrm_handler __P((int));
 static const char *sa_n2a __P((struct sockaddr *));
 static const char *inet6_n2a __P((struct in6_addr *));
 
@@ -85,7 +84,7 @@
        char pbuf[10];
        struct addrinfo hints, *res;
 
-       while ((c = getopt(argc, argv, "I:")) != -1) {
+       while ((c = getopt(argc, argv, "I:w:")) != -1) {
                switch (c) {
                case 'I':
                        ifidx = if_nametoindex(optarg);
@@ -94,6 +93,9 @@
                                /*NOTREACHED*/
                        }
                        break;
+               case 'w':
+                       query_wait = atoi(optarg);
+                       break;
                default:
                        usage();
                        exit(1);
@@ -113,7 +115,7 @@
                /*NOTREACHED*/
        }
 
-       /* getaddrinfo is preferred for addr@ifname syntax */
+       /* getaddrinfo is preferred for addr%scope syntax */
        snprintf(pbuf, sizeof(pbuf), "%d", RIP6_PORT);
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = AF_INET6;
@@ -153,13 +155,16 @@
                err(1, "send");
                /*NOTREACHED*/
        }
-       do {
+       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)) /
@@ -172,7 +177,7 @@
                                printf(" tag=0x%x", ntohs(np->rip6_tag));
                        printf("\n");
                }
-       } while (len == RIPSIZE(24));
+       }
 
        exit(0);
 }
@@ -180,7 +185,7 @@
 static void
 usage()
 {
-       fprintf(stderr, "Usage: rip6query [-I iface] address\n");
+       fprintf(stderr, "Usage: rip6query [-I iface] [-w wait] address\n");
 }
 
 /* getnameinfo() is preferred as we may be able to show ifindex as ifname */
@@ -191,7 +196,7 @@
        static char buf[NI_MAXHOST];
 
        if (getnameinfo(sa, sa->sa_len, buf, sizeof(buf),
-                       NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID) != 0) {
+                       NULL, 0, NI_NUMERICHOST) != 0) {
                snprintf(buf, sizeof(buf), "%s", "(invalid)");
        }
        return buf;
@@ -205,3 +210,11 @@
 
        return inet_ntop(AF_INET6, addr, buf, sizeof(buf));
 }
+
+static void
+sigalrm_handler(sig)
+       int sig;
+{
+
+       exit(0);
+}



Home | Main Index | Thread Index | Old Index