Source-Changes-HG archive

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

[src/trunk]: src/sbin/ifconfig Add `create' and `destroy' commands.



details:   https://anonhg.NetBSD.org/src/rev/edaf2f25c9e5
branches:  trunk
changeset: 494109:edaf2f25c9e5
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Jul 02 00:28:00 2000 +0000

description:
Add `create' and `destroy' commands.

diffstat:

 sbin/ifconfig/ifconfig.8 |   6 ++++-
 sbin/ifconfig/ifconfig.c |  55 ++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 56 insertions(+), 5 deletions(-)

diffs (124 lines):

diff -r 4cff29dedd5f -r edaf2f25c9e5 sbin/ifconfig/ifconfig.8
--- a/sbin/ifconfig/ifconfig.8  Sun Jul 02 00:21:42 2000 +0000
+++ b/sbin/ifconfig/ifconfig.8  Sun Jul 02 00:28:00 2000 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ifconfig.8,v 1.33 2000/06/30 17:45:11 thorpej Exp $
+.\"    $NetBSD: ifconfig.8,v 1.34 2000/07/02 00:28:00 thorpej Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -311,6 +311,10 @@
 Unconfigure the physical source and destination address for IP tunnel
 interfaces previously configured with
 .Cm tunnel .
+.It Cm create
+Create the specified network pseudo-device.
+.It Cm destroy
+Destroy the specified network pseudo-device.
 .It Cm pltime Ar n
 (inet6 only)
 Set preferred lifetime for the address.
diff -r 4cff29dedd5f -r edaf2f25c9e5 sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c  Sun Jul 02 00:21:42 2000 +0000
+++ b/sbin/ifconfig/ifconfig.c  Sun Jul 02 00:28:00 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ifconfig.c,v 1.80 2000/06/30 17:45:11 thorpej Exp $    */
+/*     $NetBSD: ifconfig.c,v 1.81 2000/07/02 00:28:01 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
 #if 0
 static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
 #else
-__RCSID("$NetBSD: ifconfig.c,v 1.80 2000/06/30 17:45:11 thorpej Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.81 2000/07/02 00:28:01 thorpej Exp $");
 #endif
 #endif /* not lint */
 
@@ -178,6 +178,8 @@
 void   setmediaopt __P((const char *, int));
 void   unsetmediaopt __P((const char *, int));
 void   setmediainst __P((const char *, int));
+void   clone_create __P((const char *, int));
+void   clone_destroy __P((const char *, int));
 void   fixnsel __P((struct sockaddr_iso *));
 int    main __P((int, char *[]));
 
@@ -250,6 +252,11 @@
        { "tunnel",     NEXTARG2,       0,              NULL,
                                                        settunnel } ,
        { "deletetunnel", 0,            0,              deletetunnel },
+#if 0
+       /* XXX `create' special-cased below */
+       { "create",     0,              0,              clone_create } ,
+#endif
+       { "destroy",    0,              0,              clone_destroy } ,
        { "link0",      IFF_LINK0,      0,              setifflags } ,
        { "-link0",     -IFF_LINK0,     0,              setifflags } ,
        { "link1",      IFF_LINK1,      0,              setifflags } ,
@@ -449,6 +456,17 @@
        (void) strncpy(name, argv[0], sizeof(name));
        argc--; argv++;
 
+       /*
+        * NOTE:  We must special-case the `create' command right
+        * here as we would otherwise fail in getinfo().
+        */
+       if (argc > 0 && strcmp(argv[0], "create") == 0) {
+               clone_create(argv[0], 0);
+               argc--, argv++;
+               if (argc == 0)
+                       exit(0);
+       }
+
        /* Check for address family. */
        afp = NULL;
        if (argc > 0) {
@@ -773,6 +791,33 @@
 #endif
 }
 
+/*ARGSUSED*/
+void
+clone_create(addr, param)
+       const char *addr;
+       int param;
+{
+
+       /* We're called early... */
+       getsock(AF_INET);
+
+       (void) strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       if (ioctl(s, SIOCIFCREATE, &ifr) < 0)
+               err(1, "SIOCIFCREATE");
+}
+
+/*ARGSUSED*/
+void
+clone_destroy(addr, param)
+       const char *addr;
+       int param;
+{
+
+       (void) strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       if (ioctl(s, SIOCIFDESTROY, &ifr) < 0)
+               err(1, "SIOCIFDESTROY");
+}
+
 #define RIDADDR 0
 #define ADDR   1
 #define MASK   2
@@ -2433,8 +2478,10 @@
                "\t[ instance minst ]\n"
                "\t[ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ]\n"
                "       %s -a [ -A ] [ -m ] [ -d ] [ -u ] [ af ]\n"
-               "       %s -l [ -d ] [ -u ]\n",
-               __progname, __progname, __progname);
+               "       %s -l [ -d ] [ -u ]\n"
+               "       %s interface create\n"
+               "       %s interface destroy\n",
+               __progname, __progname, __progname, __progname, __progname);
        exit(1);
 }
 



Home | Main Index | Thread Index | Old Index