Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/lkm/net/ethfoo ethfoo(4) is no more. You'll find everyt...
details: https://anonhg.NetBSD.org/src/rev/b5b067a194dd
branches: trunk
changeset: 573088:b5b067a194dd
user: cube <cube%NetBSD.org@localhost>
date: Wed Jan 19 11:12:11 2005 +0000
description:
ethfoo(4) is no more. You'll find everything under sys/net/if_tap.[ch]
and sys/lkm/net/tap/if_tap_lkm.c.
diffstat:
sys/lkm/net/ethfoo/Makefile | 6 -
sys/lkm/net/ethfoo/README | 42 -
sys/lkm/net/ethfoo/ethfoo/Makefile | 12 -
sys/lkm/net/ethfoo/ethfoo/TODO | 2 -
sys/lkm/net/ethfoo/ethfoo/ethfoo.h | 39 -
sys/lkm/net/ethfoo/ethfoo/ethfoo_lkm.c | 1496 --------------------------------
sys/lkm/net/ethfoo/setaddr/Makefile | 6 -
sys/lkm/net/ethfoo/setaddr/setaddr.c | 76 -
8 files changed, 0 insertions(+), 1679 deletions(-)
diffs (truncated from 1711 to 300 lines):
diff -r d016d65e5083 -r b5b067a194dd sys/lkm/net/ethfoo/Makefile
--- a/sys/lkm/net/ethfoo/Makefile Wed Jan 19 11:09:05 2005 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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>
diff -r d016d65e5083 -r b5b067a194dd sys/lkm/net/ethfoo/README
--- a/sys/lkm/net/ethfoo/README Wed Jan 19 11:09:05 2005 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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.
diff -r d016d65e5083 -r b5b067a194dd sys/lkm/net/ethfoo/ethfoo/Makefile
--- a/sys/lkm/net/ethfoo/ethfoo/Makefile Wed Jan 19 11:09:05 2005 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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>
diff -r d016d65e5083 -r b5b067a194dd sys/lkm/net/ethfoo/ethfoo/TODO
--- a/sys/lkm/net/ethfoo/ethfoo/TODO Wed Jan 19 11:09:05 2005 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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
diff -r d016d65e5083 -r b5b067a194dd sys/lkm/net/ethfoo/ethfoo/ethfoo.h
--- a/sys/lkm/net/ethfoo/ethfoo/ethfoo.h Wed Jan 19 11:09:05 2005 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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)
diff -r d016d65e5083 -r b5b067a194dd sys/lkm/net/ethfoo/ethfoo/ethfoo_lkm.c
--- a/sys/lkm/net/ethfoo/ethfoo/ethfoo_lkm.c Wed Jan 19 11:09:05 2005 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1496 +0,0 @@
-/* $NetBSD: ethfoo_lkm.c,v 1.15 2004/12/17 12:17:09 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.
- */
-
-/*
- * ethfoo is a NetBSD Loadable Kernel Module that demonstrates the use of
- * several kernel mechanisms, mostly in the networking subsytem.
- *
- * 1. it is example LKM, with the standard LKM management routines and
- * 2. example Ethernet driver.
- * 3. example of use of autoconf stuff inside a LKM.
- * 4. example clonable network interface.
- * 5. example sysctl interface use from a LKM.
- * 6. example LKM character device, with read, write, ioctl, poll
- * and kqueue available.
- * 7. example cloning device, using the MOVEFD semantics.
- *
- * XXX Hacks
- * 1. NetBSD doesn't offer a way to change an Ethernet address, so I chose
- * to use the SIOCSIFPHYADDR ioctl() normally used by gif(4).
- */
-
-#include <sys/cdefs.h>
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/conf.h>
-#include <sys/device.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/ksyms.h>
-#include <sys/lkm.h>
-#include <sys/poll.h>
-#include <sys/select.h>
-#include <sys/sockio.h>
-#include <sys/sysctl.h>
-
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_ether.h>
-#include <net/if_media.h>
-
-#include "ethfoo.h"
-
-/* autoconf(9) structures */
-
-CFDRIVER_DECL(ethfoo, DV_DULL, NULL);
-
-/*
- * sysctl node management
- *
- * It's not really possible to use a SYSCTL_SETUP block with
- * current LKM implementation, so it is easier to just define
- * our own function.
- *
- * The handler function is a "helper" in Andrew Brown's sysctl
- * framework terminology. It is used as a gateway for sysctl
- * requests over the nodes.
- *
- * ethfoo_log allows the module to log creations of nodes and
- * destroy them all at once using sysctl_teardown.
- */
-static int ethfoo_node;
-static struct sysctllog *ethfoo_log;
-static int ethfoo_sysctl_setup(void);
-static int ethfoo_sysctl_handler(SYSCTLFN_PROTO);
-
-/*
- * Since we're an Ethernet device, we need the 3 following
- * components: a leading struct device, a struct ethercom,
- * and also a struct ifmedia since we don't attach a PHY to
- * ourselves. We could emulate one, but there's no real
- * point.
- *
- * sc_bpf_mtap is here to optionnally depend on BPF, to make
- * our faked interface available to BPF listeners. Here, ksyms
- * is used to check if BPF was compiled in, so it is only
- * available in -current.
- */
-
-struct ethfoo_softc {
- struct device sc_dev;
- struct ifmedia sc_im;
- struct ethercom sc_ec;
- void (*sc_bpf_mtap)(caddr_t, struct mbuf *);
- int sc_flags;
-#define ETHFOO_INUSE 0x00000001 /* ethfoo device can only be opened once */
-#define ETHFOO_ASYNCIO 0x00000002 /* user is using async I/O (SIGIO) on the device */
-#define ETHFOO_NBIO 0x00000004 /* user wants calls to avoid blocking */
-#define ETHFOO_GOING 0x00000008 /* interface is being destroyed */
- struct selinfo sc_rsel;
- pid_t sc_pgid; /* For async. IO */
- struct lock sc_rdlock;
- struct simplelock sc_kqlock;
-};
-
-/* LKM management routines */
-
-int ethfoo_lkmentry(struct lkm_table *, int, int);
-static int ethfoo_lkmload(struct lkm_table *, int);
-static int ethfoo_lkmunload(struct lkm_table *, int);
-
-/* autoconf(9) glue */
-
-static int ethfoo_match(struct device *, struct cfdata *, void *);
-static void ethfoo_attach(struct device *, struct device *, void *);
-static int ethfoo_detach(struct device*, int);
-
-/* Ethernet address helper functions */
-
-static char *ethfoo_ether_sprintf(char *, const u_char *);
-static int ethfoo_ether_aton(u_char *, char *);
-
-CFATTACH_DECL(ethfoo, sizeof(struct ethfoo_softc),
- ethfoo_match, ethfoo_attach, ethfoo_detach, NULL);
-
-/* Real device access routines */
-static int ethfoo_dev_close(struct ethfoo_softc *);
-static int ethfoo_dev_read(int, struct uio *, int);
-static int ethfoo_dev_write(int, struct uio *, int);
-static int ethfoo_dev_ioctl(int, u_long, caddr_t, struct proc *);
-static int ethfoo_dev_poll(int, int, struct proc *);
-static int ethfoo_dev_kqfilter(int, struct knote *);
-
-/* Fileops access routines */
-static int ethfoo_fops_close(struct file *, struct proc *);
-static int ethfoo_fops_read(struct file *, off_t *, struct uio *,
- struct ucred *, int);
-static int ethfoo_fops_write(struct file *, off_t *, struct uio *,
- struct ucred *, int);
-static int ethfoo_fops_ioctl(struct file *, u_long, void *,
- struct proc *);
-static int ethfoo_fops_poll(struct file *, int, struct proc *);
-static int ethfoo_fops_kqfilter(struct file *, struct knote *);
-
-static const struct fileops ethfoo_fileops = {
- ethfoo_fops_read,
- ethfoo_fops_write,
- ethfoo_fops_ioctl,
Home |
Main Index |
Thread Index |
Old Index