retire greconfig(8) - you can use ifconfig(8) for everything it can do.

This commit is contained in:
itojun 2002-06-09 19:31:43 +00:00
parent 4cfae24f91
commit f79eb4420d
9 changed files with 9 additions and 422 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.330 2002/06/06 23:05:34 thorpej Exp $
# $NetBSD: mi,v 1.331 2002/06/09 19:31:43 itojun Exp $
. base-sys-root
./altroot base-sys-root
./bin base-sys-root
@ -634,7 +634,6 @@
./usr/sbin/fixmount base-nfsclient-bin
./usr/sbin/fsinfo base-sysutil-bin
./usr/sbin/getencstat base-sysutil-bin
./usr/sbin/greconfig base-netutil-bin
./usr/sbin/group base-sysutil-bin
./usr/sbin/groupadd base-sysutil-bin
./usr/sbin/groupdel base-sysutil-bin

View File

@ -1,4 +1,4 @@
# $NetBSD: obsolete.mi,v 1.46 2002/06/06 23:05:36 thorpej Exp $
# $NetBSD: obsolete.mi,v 1.47 2002/06/09 19:31:44 itojun Exp $
/bin/rcorder
/dev/i4b
/dev/i4bctl
@ -200,3 +200,4 @@
/var/named/var
/var/named/var/run
/var/named/var/tmp
/usr/sbin/greconfig

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.487 2002/06/06 23:05:37 thorpej Exp $
# $NetBSD: mi,v 1.488 2002/06/09 19:31:44 itojun Exp $
./usr/share/info/am-utils.info man-amd-info
./usr/share/info/as.info man-computil-info
./usr/share/info/awk.info man-util-info
@ -1353,7 +1353,6 @@
./usr/share/man/cat8/getNAME.0 man-man-catman
./usr/share/man/cat8/getencstat.0 man-sysutil-catman
./usr/share/man/cat8/getty.0 man-sysutil-catman
./usr/share/man/cat8/greconfig.0 man-netutil-catman
./usr/share/man/cat8/grfconfig.0 man-sysutil-catman
./usr/share/man/cat8/group.0 man-sysutil-catman
./usr/share/man/cat8/groupadd.0 man-sysutil-catman
@ -3072,7 +3071,6 @@
./usr/share/man/man8/getNAME.8 man-man-man
./usr/share/man/man8/getencstat.8 man-sysutil-man
./usr/share/man/man8/getty.8 man-sysutil-man
./usr/share/man/man8/greconfig.8 man-netutil-man
./usr/share/man/man8/grfconfig.8 man-sysutil-man
./usr/share/man/man8/group.8 man-sysutil-man
./usr/share/man/man8/groupadd.8 man-sysutil-man

View File

@ -1,4 +1,4 @@
# $NetBSD: obsolete.mi,v 1.47 2002/06/06 23:05:38 thorpej Exp $
# $NetBSD: obsolete.mi,v 1.48 2002/06/09 19:31:44 itojun Exp $
/usr/share/man/cat1/amq.0
/usr/share/man/cat1/g711conv.0
/usr/share/man/cat1/i386
@ -98,6 +98,7 @@
/usr/share/man/cat8/arm32/MAKEDEV.0
/usr/share/man/cat8/arm32/makedev.0
/usr/share/man/cat8/gettable.0
/usr/share/man/cat8/greconfig.0
/usr/share/man/cat8/htable.0
/usr/share/man/cat8/i386/apmd.0
/usr/share/man/cat8/i386/bad144.0
@ -224,6 +225,7 @@
/usr/share/man/man8/arm32/MAKEDEV.8
/usr/share/man/man8/arm32/makedev.8
/usr/share/man/man8/gettable.8
/usr/share/man/man8/greconfig.8
/usr/share/man/man8/htable.8
/usr/share/man/man8/i386/apmd.8
/usr/share/man/man8/i386/bad144.8

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.173 2002/05/29 19:40:52 drochner Exp $
# $NetBSD: Makefile,v 1.174 2002/06/09 19:31:45 itojun Exp $
# from: @(#)Makefile 5.20 (Berkeley) 6/12/93
.include <bsd.own.mk>
@ -6,7 +6,7 @@
SUBDIR= ac accton altq amd apm apmd arp bad144 bind bootp catman \
chown chroot chrtbl cnwctl config cron dev_mkdb \
dhcp diskpart dumpfs dumplfs edquota eeprom \
envstat eshconfig etcupdate greconfig grfconfig \
envstat eshconfig etcupdate grfconfig \
grfinfo gspa hilinfo ifwatchd inetd installboot \
iopctl iostat ipf irdaattach isdn iteconfig \
kgmon kvm_mkdb lastlogin link lpr mailwrapper makefs map-mbone \

View File

@ -1,6 +0,0 @@
# $NetBSD: Makefile,v 1.1 1998/09/13 20:50:55 hwr Exp $
#
PROG= greconfig
MAN= greconfig.8
.include <bsd.prog.mk>

View File

@ -1,69 +0,0 @@
$Id: README.gre,v 1.4 1999/01/26 21:32:39 hwr Exp $
---------------------------------------------------------------------------
A GRE Tunnel for NetBSD
Heiko W.Rupp
<hwr@pilhuhn.de>
This is a very alpha implementation of GRE packet encapsulation.
Generic Route Encapsulation (GRE) is described in RFC 1701 and 1702.
The interface also supports MOBILE (protocol 55) as of RFC 2004 but
default is GRE mode.
Basically GRE allows to tunnel not only IP over IP, but also provides
for other protocols like Appletalk etc. Cisco routers do their multicast
tunnels over GRE (1). The hope is, that with GRE encapsulation, a method
is found to encapsulate all other protocols with one mechanism and reduce
the need for own tunneling in ip_mroute etc.
This implementation is (as said) still alpha, but works for me.
Successful testing has been done for GRE encapsulation with Cisco routers
and NetBSD boxes as remote.
The files:
net/if_gre.[ch] : output interface, encapsulates packets.
netinet/ip_gre.[ch]: input part, deencapsulates packets. Is IP only
at the moment and only supports GRE without options.
netinet/in.h : Addition of IPPROTO_GRE
netinet/in_proto.c : Addition of protocol switch for GRE
conf/files : mention new files for GRE
greconfig.c : Utility to set/display tunnel endpoints / mode.
greconfig.8 : Manpage for greconfig.
gre.4 : Documentation of driver plus example.
Installation:
On NetBSD: add "pseudo-device gre <n>"
to your kernel config file with <n> being the number of tunnel interfaces
you want. Then recompile and install the new kernel.
Also compile greconfig.c: cc -o greconfig greconfig.c
Grectl is used to set/display tunnel endpoints. In case when IP is
encapsulated, this is not needed, but e.g. in the AppleTalk over IP
case.
Todos/Bugs:
Support other protocols for encapsulation
The compute_route() code in if_gre.c toggles the last bit of the
IP-address to provoke the search for a less specific route than the
one directly over the tunnel to prevent loops. This is possibly not
the best solution.
GRE RFC not yet fully implemented (no GRE options), no other protocols
yet than IP over IP.
Code quality is surely not best and possibly not near anything like KNF
Traceroute does not work yet over the tunnel :(
BPF does probably not yet work (it might, but last time I looked,
it bombed, so I #if 0'd it out). And also only in outgoing
direction.
---------------------------------------------------------------------------
(1) tunnels that end on a mrouted have tunnel mode DVMRP set

View File

@ -1,114 +0,0 @@
.\" $NetBSD: greconfig.8,v 1.10 2002/03/04 14:45:48 wiz Exp $
.\"
.\" Copyright 1998 (c) The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Heiko W.Rupp <hwr@pilhuhn.de>
.\"
.\" 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 NetBSD
.\" Foundation, Inc. and its contributors.
.\" 4. Neither the name of the The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
.\"
.Dd August 14, 1998
.Dt GRECONFIG 8
.Os
.Sh NAME
.Nm greconfig
.Nd set characteristics of the
.Xr gre 4
pseudo device
.Sh SYNOPSIS
.Nm
.Fl i Ar unit
.Op Fl v
.Nm ""
.Fl i Ar unit
.Op Fl d Ar dst
.Op Fl s Ar src
.Op Fl p Ar proto
.Op Fl v
.Sh DESCRIPTION
.Nm
is used to manipulate or display the characteristics of the
.Xr gre 4
tunnel device. The first form shown above displays the current
parameters, while the second one sets parameters to new values.
.Pp
The options have the following meanings:
.Bl -tag -width flag
.It Fl i Ar unit
Denotes the interface that is to be set/displayed. Unit is in the form
.Dq greN
where N is an integer from zero to the maximum numbers of
units. This option is always required.
.It Fl d Ar dst
Sets the IP address of the remote tunnel end. This may be the same as the
tunnel destination set with
.Xr ifconfig 8
when IP packets are to be encapsulated.
.It Fl s Ar src
Sets the IP address of the local tunnel end. This may be the same as
the tunnel gateway set with
.Xr ifconfig 8
when IP packets are to be encapsulated.
.It Fl p Ar proto
Sets the way how packets are encapsulated. Currently supported values are:
.Bl -tag -width aaa
.It 47 GRE encapsulation as described in RFC 1701,1702
.It 55 MOBILE encapsulation as described in RFC 2004
.El
.It Fl v
Give a little more verbose output when running
.Nm Ns .
.El
.Pp
Note that the values for
.Ar src ,
.Ar dst ,
.Ar proto
must be coordinated with the remote end of the tunnel.
.Pp
For tunnels that run IP as encapsulated protocol, the tunnel endpoints
can be set with the normal
.Xr ifconfig 8 .
In this case, the encapsulation protocol can be chosen by giving
.Dq -link0
for GRE encapsulation
as argument to
.Xr ifconfig 8 .
.Sh SEE ALSO
.Xr gre 4 ,
.Xr netintro 4 ,
.Xr protocols 5 ,
.Xr ifconfig 8
.Pp
A description of GRE encapsulation can be found in RFC 1701, RFC 1702.
.Pp
A description of MOBILE encapsulation can be found in RFC 2004.
.Sh AUTHORS
.An Heiko W.Rupp Aq hwr@pilhuhn.de

View File

@ -1,224 +0,0 @@
/*
* (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Heiko W.Rupp <hwr@pilhuhn.de>
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* greconfig - frontend to set/query tunnel endpoints
*
* $NetBSD: greconfig.c,v 1.7 2002/06/09 09:05:51 martin Exp $
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <err.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/sockio.h>
#include <netdb.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
/* from sys/sockio.h */
#define GRESADDRS _IOW('i', 101, struct ifreq)
#define GRESADDRD _IOW('i', 102, struct ifreq)
#define GREGADDRS _IOWR('i', 103, struct ifreq)
#define GREGADDRD _IOWR('i', 104, struct ifreq)
#define GRESPROTO _IOW('i' , 105, struct ifreq)
#define GREGPROTO _IOWR('i', 106, struct ifreq)
void usage(void);
void name2sa(char *name,struct sockaddr **sa);
char *sa2name(struct sockaddr *sa);
int verbose;
int
main(int argc, char **argv)
{
int i, s, err;
char *dst, *src, *inf;
struct ifreq ifr;
struct sockaddr *sa;
int pflag=0;
u_char proto = 47;
dst = src = inf = NULL;
verbose = 0;
while ((i = getopt(argc, argv, "d:i:p:s:v")) != -1)
switch(i) {
case 'd':
dst = optarg;
break;
case 'i':
inf = optarg;
break;
case 'p':
proto = atoi(optarg);
pflag++;
break;
case 's':
src = optarg;
break;
case 'v':
verbose++;
break;
default:
usage();
exit(EXIT_FAILURE);
}
if (inf == NULL) {
usage();
exit(EXIT_FAILURE);
}
if (strncmp("gre", inf, 3) != 0) {
usage();
exit(EXIT_FAILURE);
}
if ((proto != 47) && (proto != 55)) {
usage();
exit(EXIT_FAILURE);
}
s = socket(PF_INET, SOCK_DGRAM, 0);
if (s < 0) {
perror("socket() failed:");
exit(EXIT_FAILURE);
}
if (pflag) { /* IPPROTO_GRE is default in kernel */
strncpy(ifr.ifr_name, inf, sizeof(ifr.ifr_name));
ifr.ifr_flags = proto;
if (verbose)
printf("Setting tunnel protocol to proto %d\n", proto);
err = ioctl(s, GRESPROTO, (caddr_t)&ifr);
if (err < 0)
perror("GRESPROTO");
}
if (src != NULL) {
strncpy(ifr.ifr_name, inf, sizeof(ifr.ifr_name));
name2sa(src, &sa);
ifr.ifr_addr = *sa;
if (verbose)
printf("Setting source address to %s...\n",
sa2name(sa));
err = ioctl(s, GRESADDRS, (caddr_t)&ifr);
if (err < 0)
perror("GRESADDRS");
}
if (dst != NULL) {
strncpy(ifr.ifr_name, inf, sizeof(ifr.ifr_name));
name2sa(dst, &sa);
ifr.ifr_addr = *sa;
if (verbose)
printf("Setting destination address to %s...\n",
sa2name(sa));
err = ioctl(s, GRESADDRD, (caddr_t)&ifr);
if (err < 0)
perror("GRESADDRD");
}
if (src == NULL && dst == NULL && !pflag) {
strncpy(ifr.ifr_name, inf, sizeof(ifr.ifr_name));
err = ioctl(s, GREGADDRS, (caddr_t)&ifr);
if (err < 0)
perror("GREGADDRS");
else
printf("%s -> ", sa2name(&ifr.ifr_addr));
strncpy(ifr.ifr_name, inf, sizeof(ifr.ifr_name));
err = ioctl(s, GREGADDRD, (caddr_t)&ifr);
if (err < 0)
perror("GREGADDRD");
else
printf("%s, ", sa2name(&ifr.ifr_addr));
err = ioctl(s, GREGPROTO, (caddr_t)&ifr);
if (err < 0)
perror("GREGPROTO");
else
printf("running IP-Proto %d\n", ifr.ifr_flags);
}
close(s);
exit(EXIT_SUCCESS);
}
void
usage(void)
{
fprintf(stderr,
"greconfig -i unit [-d dst] [-s src] [-p proto] [-v]\n");
fprintf(stderr, "unit is gre<n>, proto either 47 or 55\n");
}
void
name2sa(char *name, struct sockaddr **sa)
{
struct hostent *hp;
struct sockaddr_in *si;
static struct sockaddr_in s;
hp = gethostbyname(name);
if (hp == NULL)
errx(EXIT_FAILURE, "Host \"%s\" not found\n", name);
bzero(&s, sizeof(struct sockaddr_in));
s.sin_family = hp->h_addrtype;
if (hp->h_addrtype != AF_INET)
errx(EXIT_FAILURE, "Only internet addresses allowed, not %s\n", name);
bcopy(hp->h_addr, &s.sin_addr, hp->h_length);
si = &s;
*sa = (struct sockaddr *)si;
}
char *
sa2name(struct sockaddr *sa)
{
struct sockaddr_in *si;
si = ((struct sockaddr_in *)(sa));
return (inet_ntoa(si->sin_addr));
}