Source-Changes-HG archive

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

[src/trunk]: src/sbin/route IPv6-ready route command (-inet6 and -prefixlen a...



details:   https://anonhg.NetBSD.org/src/rev/e59ccde1f10d
branches:  trunk
changeset: 474270:e59ccde1f10d
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri Jul 02 15:29:02 1999 +0000

description:
IPv6-ready route command (-inet6 and -prefixlen are added)

diffstat:

 sbin/route/Makefile    |    4 +-
 sbin/route/keywords.c  |    4 +-
 sbin/route/keywords.h  |   56 +++++++++++----------
 sbin/route/keywords.sh |    4 +-
 sbin/route/route.8     |   20 ++++++-
 sbin/route/route.c     |  129 ++++++++++++++++++++++++++++++++++++++++++++++--
 sbin/route/show.c      |   24 ++++++++-
 7 files changed, 200 insertions(+), 41 deletions(-)

diffs (truncated from 502 to 300 lines):

diff -r ea3b0d207e75 -r e59ccde1f10d sbin/route/Makefile
--- a/sbin/route/Makefile       Fri Jul 02 15:28:49 1999 +0000
+++ b/sbin/route/Makefile       Fri Jul 02 15:29:02 1999 +0000
@@ -1,10 +1,12 @@
-#      $NetBSD: Makefile,v 1.18 1997/10/10 19:52:22 christos Exp $
+#      $NetBSD: Makefile,v 1.19 1999/07/02 15:29:02 itojun Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/5/93
 
 PROG=  route
 MAN=   route.8
 SRCS=  route.c show.c keywords.c ccitt_addr.c
 
+CFLAGS+=-DINET6
+
 # The Makefile over in ../../distrib/utils/x_route
 # would like keywords.[ch] to always exist here, so
 # they are now checked in as sources.
diff -r ea3b0d207e75 -r e59ccde1f10d sbin/route/keywords.c
--- a/sbin/route/keywords.c     Fri Jul 02 15:28:49 1999 +0000
+++ b/sbin/route/keywords.c     Fri Jul 02 15:29:02 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: keywords.c,v 1.2 1997/04/03 02:35:48 christos Exp $ */
+/* $NetBSD: keywords.c,v 1.3 1999/07/02 15:29:03 itojun Exp $ */
 
 /* WARNING!  This file was generated by keywords.sh  */
 
@@ -25,6 +25,7 @@
        {"ifa", K_IFA},
        {"ifp", K_IFP},
        {"inet", K_INET},
+       {"inet6", K_INET6},
        {"iso", K_ISO},
        {"link", K_LINK},
        {"llinfo", K_LLINFO},
@@ -37,6 +38,7 @@
        {"netmask", K_NETMASK},
        {"nostatic", K_NOSTATIC},
        {"osi", K_OSI},
+       {"prefixlen", K_PREFIXLEN},
        {"proto1", K_PROTO1},
        {"proto2", K_PROTO2},
        {"recvpipe", K_RECVPIPE},
diff -r ea3b0d207e75 -r e59ccde1f10d sbin/route/keywords.h
--- a/sbin/route/keywords.h     Fri Jul 02 15:28:49 1999 +0000
+++ b/sbin/route/keywords.h     Fri Jul 02 15:29:02 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: keywords.h,v 1.4 1997/04/03 02:35:49 christos Exp $ */
+/* $NetBSD: keywords.h,v 1.5 1999/07/02 15:29:03 itojun Exp $ */
 
 /* WARNING!  This file was generated by keywords.sh  */
 
@@ -27,29 +27,31 @@
 #define        K_IFA   17
 #define        K_IFP   18
 #define        K_INET  19
-#define        K_ISO   20
-#define        K_LINK  21
-#define        K_LLINFO        22
-#define        K_LOCK  23
-#define        K_LOCKREST      24
-#define        K_MASK  25
-#define        K_MONITOR       26
-#define        K_MTU   27
-#define        K_NET   28
-#define        K_NETMASK       29
-#define        K_NOSTATIC      30
-#define        K_OSI   31
-#define        K_PROTO1        32
-#define        K_PROTO2        33
-#define        K_RECVPIPE      34
-#define        K_REJECT        35
-#define        K_RTT   36
-#define        K_RTTVAR        37
-#define        K_SA    38
-#define        K_SENDPIPE      39
-#define        K_SHOW  40
-#define        K_SSTHRESH      41
-#define        K_STATIC        42
-#define        K_X25   43
-#define        K_XNS   44
-#define        K_XRESOLVE      45
+#define        K_INET6 20
+#define        K_ISO   21
+#define        K_LINK  22
+#define        K_LLINFO        23
+#define        K_LOCK  24
+#define        K_LOCKREST      25
+#define        K_MASK  26
+#define        K_MONITOR       27
+#define        K_MTU   28
+#define        K_NET   29
+#define        K_NETMASK       30
+#define        K_NOSTATIC      31
+#define        K_OSI   32
+#define        K_PREFIXLEN     33
+#define        K_PROTO1        34
+#define        K_PROTO2        35
+#define        K_RECVPIPE      36
+#define        K_REJECT        37
+#define        K_RTT   38
+#define        K_RTTVAR        39
+#define        K_SA    40
+#define        K_SENDPIPE      41
+#define        K_SHOW  42
+#define        K_SSTHRESH      43
+#define        K_STATIC        44
+#define        K_X25   45
+#define        K_XNS   46
+#define        K_XRESOLVE      47
diff -r ea3b0d207e75 -r e59ccde1f10d sbin/route/keywords.sh
--- a/sbin/route/keywords.sh    Fri Jul 02 15:28:49 1999 +0000
+++ b/sbin/route/keywords.sh    Fri Jul 02 15:29:02 1999 +0000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: keywords.sh,v 1.4 1997/04/03 02:35:49 christos Exp $
+# $NetBSD: keywords.sh,v 1.5 1999/07/02 15:29:03 itojun Exp $
 # @(#)keywords 8.2 (Berkeley) 3/19/94
 #
 # WARNING!  If you change this file, re-run it!
@@ -27,6 +27,7 @@
 ifa
 ifp
 inet
+inet6
 iso
 link
 llinfo
@@ -39,6 +40,7 @@
 netmask
 nostatic
 osi
+prefixlen
 proto1
 proto2
 recvpipe
diff -r ea3b0d207e75 -r e59ccde1f10d sbin/route/route.8
--- a/sbin/route/route.8        Fri Jul 02 15:28:49 1999 +0000
+++ b/sbin/route/route.8        Fri Jul 02 15:29:02 1999 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: route.8,v 1.17 1999/03/24 06:29:21 mycroft Exp $
+.\"    $NetBSD: route.8,v 1.18 1999/07/02 15:29:03 itojun Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -137,8 +137,9 @@
 .Fl osi ,
 .Fl xns ,
 .Fl atalk ,
+.Fl inet ,
 or
-.Fl inet
+.Fl inet6
 modifiers, only routes having destinations with addresses in the
 delineated family will be deleted.
 .Pp
@@ -230,6 +231,8 @@
 .Dv AF_INET
 case
 can be overridden by making sure this option follows the destination parameter.
+.Fl prefixlen
+is also available for similar purpose, in IPv6 case.
 .Pp
 Routes have associated flags which influence operation of the protocols
 when sending to destinations matched by the routes.
@@ -351,3 +354,16 @@
 The first paragraph may have slightly exaggerated
 .Xr routed 8 Ns 's
 abilities.
+.Pp
+Some uses of the
+.Fl ifa
+or
+.Fl ifp
+modifiers with the add command will incorrectly fail with a
+.Dq Network is unreachable
+message if there is no default route.
+See case
+.Dv RTM_ADD
+in
+.Pa sys/net/rtsock.c:route_output
+for details.
diff -r ea3b0d207e75 -r e59ccde1f10d sbin/route/route.c
--- a/sbin/route/route.c        Fri Jul 02 15:28:49 1999 +0000
+++ b/sbin/route/route.c        Fri Jul 02 15:29:02 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.c,v 1.30 1998/10/23 05:36:42 lukem Exp $ */
+/*     $NetBSD: route.c,v 1.31 1999/07/02 15:29:03 itojun Exp $        */
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)route.c    8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.30 1998/10/23 05:36:42 lukem Exp $");
+__RCSID("$NetBSD: route.c,v 1.31 1999/07/02 15:29:03 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -89,6 +89,9 @@
 static int getaddr __P((int, char *, struct hostent **));
 static void flushroutes __P((int, char *[]));
 #ifndef SMALL
+#ifdef INET6
+static int prefixlen __P((char *));
+#endif
 static int x25_makemask __P((void));
 static void interfaces __P((void));
 static void monitor __P((void));
@@ -108,6 +111,9 @@
 union  sockunion {
        struct  sockaddr sa;
        struct  sockaddr_in sin;
+#ifdef INET6
+       struct  sockaddr_in6 sin6;
+#endif
        struct  sockaddr_at sat;
        struct  sockaddr_dl sdl;
 #ifndef SMALL
@@ -124,6 +130,9 @@
 int    locking, lockrest, debugonly;
 struct rt_metrics rt_metrics;
 u_int32_t  rtm_inits;
+#ifdef INET6
+char ntop_buf[INET6_ADDRSTRLEN];       /*for inet_ntop()*/
+#endif
 
 static void
 usage(cp)
@@ -253,6 +262,11 @@
                        case K_INET:
                                af = AF_INET;
                                break;
+#ifdef INET6
+                       case K_INET6:
+                               af = AF_INET6;
+                               break;
+#endif
                        case K_ATALK:
                                af = AF_APPLETALK;
                                break;
@@ -413,6 +427,19 @@
                return (link_ntoa((struct sockaddr_dl *)sa));
 
 #ifndef SMALL
+#ifdef INET6
+       case AF_INET6:
+           {   struct in6_addr in6;
+               int gap;
+
+               in6 = ((struct sockaddr_in6 *)sa)->sin6_addr;
+               gap = 24 - sa->sa_len;
+               if (gap > 0)
+                       bzero((char *)(&in6 + 1) - gap, gap);
+               return ((char *)inet_ntop(AF_INET6, &in6, ntop_buf, sizeof(ntop_buf)));
+           }
+#endif
+
        case AF_NS:
                return (ns_print((struct sockaddr_ns *)sa));
 
@@ -515,6 +542,19 @@
                return (link_ntoa((struct sockaddr_dl *)sa));
 
 #ifndef SMALL
+#ifdef INET6
+       case AF_INET6:
+           {   struct in6_addr in6;
+               int gap;
+
+               in6 = ((struct sockaddr_in6 *)sa)->sin6_addr;
+               gap = 24 - sa->sa_len;
+               if (gap > 0)
+                       bzero((char *)(&in6 + 1) - gap, gap);
+               return ((char *)inet_ntop(AF_INET6, &in6, ntop_buf, sizeof(ntop_buf)));
+           }
+#endif
+
        case AF_NS:
                return (ns_print((struct sockaddr_ns *)sa));
 
@@ -599,6 +639,20 @@
                                aflen = sizeof(struct sockaddr_in);
                                break;
 
+#ifdef INET6
+                       case K_INET6:
+                               af = AF_INET6;
+                               aflen = sizeof(struct sockaddr_in6);
+                               if (prefixlen("64") != 64) {
+                                       fprintf(stderr, "internal error:"
+                                               "setting prefixlen=64\n");
+                                       exit(1);
+                               }
+                               forcenet = 0;
+                               ishost = 1;
+                               break;
+#endif
+
                        case K_LINK:



Home | Main Index | Thread Index | Old Index