ethfoo(4) is no more. You'll find everything under sys/net/if_tap.[ch]

and sys/lkm/net/tap/if_tap_lkm.c.
This commit is contained in:
cube 2005-01-19 11:12:11 +00:00
parent fead024e60
commit daeec6c990
8 changed files with 0 additions and 1679 deletions

View File

@ -1,6 +0,0 @@
# $NetBSD: Makefile,v 1.1 2003/11/24 21:58:45 cube Exp $
SUBDIR= ethfoo
SUBDIR+= setaddr
.include <bsd.subdir.mk>

View File

@ -1,42 +0,0 @@
$NetBSD: README,v 1.1 2003/11/24 21:58:45 cube Exp $
ethfoo is meant to be an example of a few features of the NetBSD kernel.
The module, once loaded, emulates one or several Ethernet devices, each
one having its own Ethernet address. You can do most of what can be
done with a real Ethernet device, but no packet can be received.
On the network layer, ethfoo is a convenient skeleton for an Ethernet
device driver, and demonstrates how an interface should be attached and
manipulated inside the kernel. It also implements a cloning interface,
making it possible for the administrator to create and destroy ethfoo
interfaces at will, using the 'create' keyword of ifconfig:
# ifconfig ethfoo15 create
# ifconfig ethfoo15 inet 192.168.23.45
# ifconfig ethfoo15 destroy
ethfoo is also a demonstration of what can be done with autoconf(9) from
a Loadable Kernel Module. It uses Jason R. Thorpe's idea of adding a
pseudo-device to the autoconf tables to avoid any attachment troubles,
as seen in sys/dev/ata/ata_raid.c.
A cfdriver structure and a cfdata structure are registered to the system
at load time, making it possible to creates instances of the pseudo-
device when the administrator uses the ifconfig create command. When a
new ethfoo device is attached, the usual standard autoconf routines are
called: match() and attach(). Since we registered the cf structures,
we don't have to care about allocating structures such as the softc, it
has already been done by the kernel.
At that point it would even be possible to pass more parameters to the
new device, using the custom argument through a ethfoo_attach_args
structure. It could be useful to pass an Ethernet address, for example.
ethfoo is not supposed to be anything more than an example of how to
write a simple but complete LKM, though it can be good to have a fake
Ethernet device when using software such as FlexLM.
It would be a good idea to pull up parts of ethfoo into tun(4), to make
it possible to read and write packets through a character device. It is
also possible to extend ethfoo in that direction using MOD_DEV instead
of MOD_MISC.

View File

@ -1,12 +0,0 @@
# $NetBSD: Makefile,v 1.3 2004/12/12 21:46:58 cube Exp $
SRCS= ethfoo_lkm.c
KMOD= ethfoo
MAN= #
WARNS= 3
INCSDIR= /usr/include/net
INCS= ethfoo.h
.include <bsd.kinc.mk>
.include <bsd.kmod.mk>

View File

@ -1,2 +0,0 @@
o hunt a bug in kqueue code that makes ethfoo crash under heavy load
o add comments for all the device-related functions

View File

@ -1,39 +0,0 @@
/* $NetBSD: ethfoo.h,v 1.1 2004/12/12 21:46:58 cube Exp $ */
/*
* Copyright (c) 2003, 2004 The NetBSD Foundation.
* All rights reserved.
*
* This code is derived from software contributed to the NetBSD Foundation
* by Quentin Garnier.
*
* 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.
*/
#define ETHFOO_GETMINOR _IOR('e', 0, int)

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
# $NetBSD: Makefile,v 1.1 2003/11/24 21:58:45 cube Exp $
PROG= setaddr
MAN= #
.include <bsd.prog.mk>

View File

@ -1,76 +0,0 @@
/* $NetBSD: setaddr.c,v 1.1 2003/11/24 21:58:45 cube Exp $ */
/*
* Copyright (c) 2003, Quentin Garnier. 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.
*
* 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.
*/
#include <sys/types.h>
#include <sys/sockio.h>
#include <net/if.h>
#include <net/if_ether.h>
#include <stdio.h>
void
usage()
{
(void)fprintf(stderr, "usage: %s interface address\n", getprogname());
(void)fprintf(stderr, "example: %s ethfoo2 01:23:45:67:89:ab\n", getprogname());
exit(1);
}
int
main(int argc, char *argv[])
{
int s;
struct ifaliasreq ifra;
struct sockaddr *sa;
setprogname(argv[0]);
/* Usage: setaddr <iface> <ethaddr> */
if (argc != 3)
usage();
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
err(1, "opening socket");
strlcpy(ifra.ifra_name, argv[1], IFNAMSIZ-1);
ifra.ifra_name[IFNAMSIZ-1] = 0;
sa = (void *)&ifra.ifra_addr;
sa->sa_family = AF_LINK;
sa->sa_len = sizeof(struct sockaddr);
memcpy(&sa->sa_data, ether_aton(argv[2]), ETHER_ADDR_LEN);
if (ioctl(s, SIOCSIFPHYADDR, &ifra) < 0)
err(1, "SIOCSIFPHYADDR");
close(s);
exit(0);
}