Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin gifconfig, which configures gif IPv[46]-over-IPv[46...



details:   https://anonhg.NetBSD.org/src/rev/d67bd4798c3d
branches:  trunk
changeset: 474216:d67bd4798c3d
user:      itojun <itojun%NetBSD.org@localhost>
date:      Thu Jul 01 19:41:56 1999 +0000

description:
gifconfig, which configures gif IPv[46]-over-IPv[46] pseudo interface.
add gifconfig to SUBDIR.

diffstat:

 usr.sbin/Makefile              |    5 +-
 usr.sbin/gifconfig/Makefile    |    7 +
 usr.sbin/gifconfig/gifconfig.8 |  138 ++++++
 usr.sbin/gifconfig/gifconfig.c |  831 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 980 insertions(+), 1 deletions(-)

diffs (truncated from 1007 to 300 lines):

diff -r ab480273d358 -r d67bd4798c3d usr.sbin/Makefile
--- a/usr.sbin/Makefile Thu Jul 01 19:18:47 1999 +0000
+++ b/usr.sbin/Makefile Thu Jul 01 19:41:56 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.109 1999/06/30 06:49:28 augustss Exp $
+#      $NetBSD: Makefile,v 1.110 1999/07/01 19:41:56 itojun Exp $
 #      from: @(#)Makefile      5.20 (Berkeley) 6/12/93
 
 # XXX Temporary for NO_SENDMAIL and BUILD_POSTFIX
@@ -21,6 +21,9 @@
        ypbind yppoll ypserv ypset \
        zdump zic
 
+# IPv6
+SUBDIR+=gifconfig
+
 .if !defined(NO_SENDMAIL)
 SUBDIR+=       sendmail
 .endif
diff -r ab480273d358 -r d67bd4798c3d usr.sbin/gifconfig/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/gifconfig/Makefile       Thu Jul 01 19:41:56 1999 +0000
@@ -0,0 +1,7 @@
+# $NetBSD: Makefile,v 1.1 1999/07/01 19:41:57 itojun Exp $
+
+PROG=  gifconfig
+CFLAGS+=-DINET6
+MAN=   gifconfig.8
+
+.include <bsd.prog.mk>
diff -r ab480273d358 -r d67bd4798c3d usr.sbin/gifconfig/gifconfig.8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/gifconfig/gifconfig.8    Thu Jul 01 19:41:56 1999 +0000
@@ -0,0 +1,138 @@
+.\" 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.
+.\"
+.\"     $Id: gifconfig.8,v 1.1 1999/07/01 19:41:58 itojun Exp $
+.\"
+.Dd May 17, 1998
+.Dt GIFCONFIG 8
+.Os KAME
+.\"
+.Sh NAME
+.Nm gifconfig
+.Nd configure generic IP tunnel
+.\"
+.Sh SYNOPSIS
+.Nm
+.Ar interface
+.Op Ar af
+.Op Ar physsrc physdest
+.Nm gifconfig
+.Fl a
+.\"
+.Sh DESCRIPTION
+.Nm
+configures the physical address for the generic IP tunnel 
+inteface, such as "gif0".
+Argument
+.Ar physsrc
+and
+.Ar physdest
+are interpreted as the outer source/destination address for 
+encapsulating IPv4/v6 header.
+Argument
+.Ar af
+specifies the address family for
+.Ar physsrc
+and
+.Ar physdest .
+.Ar Af
+can be
+.Li inet
+or 
+.Li inet6 ,
+and will be treated as
+.Li inet
+if ommitted.
+.Pp
+.Nm
+takes the following optional argument:
+.Bl -tag -width Ds
+.It Fl a
+Display information associated all generic IP tunnel interfaces.
+.El
+.Pp
+Please note that it is very easy to create infinite routing loop,
+when you configure tunnel over same address family
+.Po
+e.g. IPv4-over-IPv4
+.Pc .
+.\"
+.Sh EXAMPLES
+If you would like to configure IPv6 over IPv4(aka IPv6 in IPv4) 
+tunnel between
+.Li 10.1.1.1
+and
+.Li 10.2.3.4 ,
+you should perform the following command:
+.Bd -literal -offset
+# gifconfig gif0 inet 10.1.1.1 10.2.3.4
+.Ed
+.Pp
+To use the
+.Li 0.0.0.0
+feature to establish a tunnel from host1 to host3
+which will encapsulate and carry packets from host2, on host1 do:
+.Bd -literal -offset
+# ifconfig gif0 inet host1  127.0.0.2  # assign an address to gif0
+# gifconfig gif0 inet host1 0.0.0.0    # assign encapsulation addresses
+# route add host2 host3 -ifp gif0:     # encap host2 packets, send to host3
+.Ed
+.Pp
+Note: the
+.Fl ifp
+option to route does not work as documented in
+most versions of FreeBSD.
+.Pp
+On host3 do:
+.Bd -literal -offset
+# ifconfig gif0 inet host3  127.0.0.2  # assign an address to gif0
+# gifconfig gif0 inet host3 0.0.0.0    # assign encapsulation addresses
+.Ed
+.Pp
+Now if you ping host2 from host1, the packets should be encapsulated
+with outer source address = host1 and outer destination address = host3,
+and delivered to host3.
+host3 will decapsulate the packet and deliver it normally to host2.
+.Pp
+This is also possible with IPv6 outer proto, by replacing
+.Li inet
+to
+.Li inet6 ,
+and IPv4 addresses to some appropriate IPv6 addresses in above example.
+.\"
+.Sh RETURN VALUES
+The command exits with exit status of 1 on errors, 0 on success.
+.\"
+.Sh SEE ALSO
+.Xr gif 4 ,
+.Xr ifconfig 8
+.Sh HISTORY
+The
+.Nm
+command first appeared in WIDE Hydrangea IPv6 protocol stack kit.
+.\" .Sh BUGS
+.\" (to be written)
diff -r ab480273d358 -r d67bd4798c3d usr.sbin/gifconfig/gifconfig.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/gifconfig/gifconfig.c    Thu Jul 01 19:41:56 1999 +0000
@@ -0,0 +1,831 @@
+/*
+ * Copyright (c) 1983, 1993
+ *     The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+/*
+ * gifconfig, derived from ifconfig
+ *
+ * @(#) Copyright (c) 1983, 1993\n\
+ *     The Regents of the University of California.  All rights reserved.\n
+ *
+ * @(#)ifconfig.c      8.2 (Berkeley) 2/16/94
+ */
+
+/*
+ *  951109 - Andrew%pubnix.net@localhost - Changed to iterative buffer growing mechanism
+ *                              for ifconfig -a so all interfaces are queried.
+ *
+ *  960101 - peter%freebsd.org@localhost - Blow away the SIOCGIFCONF code and use
+ *                              sysctl() to get the structured interface conf
+ *                              and parse the messages in there. REALLY UGLY!
+ */
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/sysctl.h>
+
+#include <net/if.h>
+#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#include <net/if_var.h>
+#endif /* __FreeBSD__ >= 3 */
+#include <net/if_dl.h>
+#include <net/if_types.h>
+#include <net/route.h>
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+
+#include <sys/protosw.h>
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <nlist.h>
+#include <kvm.h>
+#include <fcntl.h>
+
+struct ifreq           ifr;
+struct ifaliasreq      addreq;
+#ifdef INET6
+struct in6_ifreq       in6_ifr;
+struct in6_aliasreq    in6_addreq;
+#endif
+
+char   name[32];
+int    flags;
+int    metric;
+int    mtu;
+int    setpsrc = 0;
+int    s;
+kvm_t  *kvmd;
+extern int errno;
+
+#ifdef INET6
+char ntop_buf[INET6_ADDRSTRLEN];       /*inet_ntop()*/
+#endif
+
+void setifpsrc __P((char *, int));
+void setifpdst __P((char *, int));
+void setifflags __P((char *, int));
+
+
+#define        NEXTARG         0xffffff
+
+struct cmd {
+       char    *c_name;
+       int     c_parameter;            /* NEXTARG means next argv */
+       void    (*c_func) __P((char *, int));
+} cmds[] = {
+       { "up",         IFF_UP,         setifflags } ,
+       { "down",       -IFF_UP,        setifflags },
+       { 0,            0,              setifpsrc },
+       { 0,            0,              setifpdst },
+};
+
+/*
+ * XNS support liberally adapted from code written at the University of
+ * Maryland principally by James O'Toole and Chris Torek.
+ */
+int main __P((int, char *[]));



Home | Main Index | Thread Index | Old Index