diff options
author | Julian Elischer <julian@FreeBSD.org> | 1995-12-08 11:19:42 +0000 |
---|---|---|
committer | Julian Elischer <julian@FreeBSD.org> | 1995-12-08 11:19:42 +0000 |
commit | 87f6c6625d5a4889540cb77c8296e456b7d1390b (patch) | |
tree | 5150d199464d64c1021f91b2c2f112d48546a8bf /sys/net | |
parent | 0b7a315970685222e8ccbcdf3d645d35650cd03e (diff) | |
download | src-test2-87f6c6625d5a4889540cb77c8296e456b7d1390b.tar.gz src-test2-87f6c6625d5a4889540cb77c8296e456b7d1390b.zip |
Notes
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/bpf.c | 59 | ||||
-rw-r--r-- | sys/net/if_tun.c | 91 |
2 files changed, 70 insertions, 80 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index db072c33a204..8a1840c8f337 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -37,7 +37,7 @@ * * @(#)bpf.c 8.2 (Berkeley) 3/28/94 * - * $Id: bpf.c,v 1.17 1995/12/02 19:37:19 bde Exp $ + * $Id: bpf.c,v 1.18 1995/12/06 23:51:53 bde Exp $ */ #include "bpfilter.h" @@ -80,14 +80,11 @@ #include <netinet/in.h> #include <netinet/if_ether.h> #include <sys/kernel.h> - -#ifdef JREMOD #include <sys/conf.h> #ifdef DEVFS #include <sys/devfsext.h> #endif /*DEVFS*/ -#define CDEV_MAJOR 23 -#endif /*JREMOD*/ + /* * Older BSDs don't have kernel malloc. @@ -145,6 +142,20 @@ static void catchpacket __P((struct bpf_d *, u_char *, u_int, u_int, void (*)(const void *, void *, u_int))); static void reset_d __P((struct bpf_d *)); +static d_open_t bpfopen; +static d_close_t bpfclose; +static d_read_t bpfread; +static d_write_t bpfwrite; +static d_ioctl_t bpfioctl; +static d_select_t bpfselect; + +#define CDEV_MAJOR 23 +struct cdevsw bpf_cdevsw = + { bpfopen, bpfclose, bpfread, bpfwrite, /*23*/ + bpfioctl, nostop, nullreset, nodevtotty,/* bpf */ + bpfselect, nommap, NULL, "bpf", NULL, -1 }; + + static int bpf_movein(uio, linktype, mp, sockp, datlen) register struct uio *uio; @@ -321,7 +332,7 @@ bpf_detachd(d) * EBUSY if file is open by another process. */ /* ARGSUSED */ -int +static int bpfopen(dev, flags, fmt, p) dev_t dev; int flags; @@ -353,7 +364,7 @@ bpfopen(dev, flags, fmt, p) * deallocating its buffers, and marking it free. */ /* ARGSUSED */ -int +static int bpfclose(dev, flags, fmt, p) dev_t dev; int flags; @@ -425,7 +436,7 @@ bpf_sleep(d) /* * bpfread - read next chunk of packets from buffers */ -int +static int bpfread(dev, uio, ioflag) dev_t dev; register struct uio *uio; @@ -540,7 +551,7 @@ bpf_wakeup(d) #endif } -int +static int bpfwrite(dev, uio, ioflag) dev_t dev; struct uio *uio; @@ -617,7 +628,7 @@ reset_d(d) * BIOCVERSION Get filter language version. */ /* ARGSUSED */ -int +static int bpfioctl(dev, cmd, addr, flags, p) dev_t dev; int cmd; @@ -1006,7 +1017,7 @@ bpf_ifname(ifp, ifr) #if BSD >= 199103 #define bpf_select bpfselect #else -int +static int bpfselect(dev, rw) register dev_t dev; int rw; @@ -1322,30 +1333,26 @@ bpfattach(driverp, ifp, dlt, hdrlen) printf("bpf: %s%d attached\n", ifp->if_name, ifp->if_unit); } - -#ifdef JREMOD -struct cdevsw bpf_cdevsw = - { bpfopen, bpfclose, bpfread, bpfwrite, /*23*/ - bpfioctl, nostop, nullreset, nodevtotty,/* bpf */ - bpfselect, nommap, NULL }; +static void *bpf_devfs_token[NBPFILTER]; static bpf_devsw_installed = 0; static void bpf_drvinit(void *unused) { dev_t dev; + int i; + char name[32]; if( ! bpf_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&bpf_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&bpf_cdevsw, NULL); bpf_devsw_installed = 1; #ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "bpf", major(dev), 0, DV_CHR, 0, 0, 0600); + for ( i = 0 ; i < NBPFILTER ; i++ ) { + sprintf(name,"bpf%d",i); + bpf_devfs_token[i] = + devfs_add_devsw( "/", name, + &bpf_cdevsw, i, DV_CHR, 0, 0, 0600); } #endif } @@ -1353,6 +1360,4 @@ static void bpf_drvinit(void *unused) SYSINIT(bpfdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,bpf_drvinit,NULL) -#endif /* JREMOD */ - #endif diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 12e3e1a42f6c..97678c5979c7 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -33,6 +33,9 @@ #ifdef __FreeBSD__ #include <sys/kernel.h> #endif +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <sys/conf.h> #include <machine/cpu.h> @@ -67,12 +70,6 @@ static void tunattach __P((void *)); PSEUDO_SET(tunattach, if_tun); #endif -#ifdef JREMOD -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 52 -#endif /*JREMOD*/ #define TUNDEBUG if (tundebug) printf int tundebug = 0; @@ -82,15 +79,27 @@ struct tun_softc tunctl[NTUN]; int tunoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *rt)); int tunifioctl __P((struct ifnet *, int, caddr_t)); +static int tuninit __P((int)); -static struct cdevsw tuncdevsw = { +static d_open_t tunopen; +static d_close_t tunclose; +static d_read_t tunread; +static d_write_t tunwrite; +static d_ioctl_t tunioctl; +static d_select_t tunselect; + +#define CDEV_MAJOR 52 +static struct cdevsw tun_cdevsw = { tunopen, tunclose, tunread, tunwrite, tunioctl, nullstop, noreset, nodevtotty, - tunselect, nommap, nostrategy + tunselect, nommap, nostrategy, "tun", NULL, -1 }; -extern dev_t tuncdev; -static int tuninit __P((int)); + +static tun_devsw_installed = 0; +#ifdef DEVFS +static void *tun_devfs_token[NTUN]; +#endif static void tunattach(dummy) @@ -98,13 +107,20 @@ tunattach(dummy) { register int i; struct ifnet *ifp; + dev_t dev; + char name[32]; - /* - * In case we are an LKM, set up device switch. - */ - cdevsw[major(tuncdev)] = tuncdevsw; - - for (i = 0; i < NTUN; i++) { + if( tun_devsw_installed ) return; + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&tun_cdevsw, NULL); + tun_devsw_installed = 1; + for ( i = 0; i < NTUN; i++ ) { +#ifdef DEVFS + sprintf(name, "tun%d", i ); + tun_devfs_token[i] = devfs_add_devsw( + "/", name, &tun_cdevsw , i, + DV_CHR, 0, 0, 0600); +#endif tunctl[i].tun_flags = TUN_INITED; ifp = &tunctl[i].tun_if; @@ -131,7 +147,7 @@ tunattach(dummy) * tunnel open - must be superuser & the device must be * configured in */ -int +static int tunopen(dev, flag, mode, p) dev_t dev; int flag, mode; @@ -159,7 +175,7 @@ tunopen(dev, flag, mode, p) * tunclose - close the device - mark i/f down & delete * routing info */ -int +static int tunclose(dev_t dev, int foo, int bar, struct proc *p) { register int unit = minor(dev), s; @@ -370,7 +386,7 @@ tunoutput(ifp, m0, dst, rt) /* * the cdevsw interface is now pretty minimal. */ -int +static int tunioctl(dev, cmd, data, flag, p) dev_t dev; int cmd; @@ -437,7 +453,7 @@ tunioctl(dev, cmd, data, flag, p) * The cdevsw read interface - reads a packet at a time, or at * least as much of a packet as can be read. */ -int +static int tunread(dev_t dev, struct uio *uio, int flag) { int unit = minor(dev); @@ -488,7 +504,7 @@ tunread(dev_t dev, struct uio *uio, int flag) /* * the cdevsw write interface - an atomic write is a packet - or else! */ -int +static int tunwrite(dev_t dev, struct uio *uio, int flag) { int unit = minor (dev); @@ -576,7 +592,7 @@ tunwrite(dev_t dev, struct uio *uio, int flag) * really. The write detect always returns true, write never blocks * anyway, it either accepts the packet or drops it. */ -int +static int tunselect(dev_t dev, int rw, struct proc *p) { int unit = minor(dev), s; @@ -605,36 +621,5 @@ tunselect(dev_t dev, int rw, struct proc *p) return 0; } -#ifdef JREMOD -struct cdevsw tun_cdevsw = - { tunopen, tunclose, tunread, tunwrite, /*52*/ - tunioctl, nostop, nullreset, nodevtotty,/* tunnel */ - tunselect, nommap, NULL }; - -static tun_devsw_installed = 0; - -static void tun_drvinit(void *unused) -{ - dev_t dev; - - if( ! tun_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&tun_cdevsw,NULL); - tun_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "tun", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif - } -} - -SYSINIT(tundev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,tun_drvinit,NULL) - -#endif /* JREMOD */ #endif /* NTUN */ |