summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>2000-06-19 03:00:55 +0000
committerJason Wright <jason@cvs.openbsd.org>2000-06-19 03:00:55 +0000
commit23d8ca243cd22afdff431c98ab9fd51073379a4c (patch)
tree465041965ce525810ad8df19c019b5a81f26dcb3
parent395de9a9a23845c5ed5e7bcba947082ba1c154fd (diff)
de-#ifdef-ize
-rw-r--r--sys/net/bpf.c149
-rw-r--r--sys/net/bpf.h24
-rw-r--r--sys/net/bpf_filter.c11
-rw-r--r--sys/net/bpfdesc.h8
4 files changed, 10 insertions, 182 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index f6f12efabda..dd09ae44a7e 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.21 2000/06/08 22:25:24 niklas Exp $ */
+/* $OpenBSD: bpf.c,v 1.22 2000/06/19 03:00:51 jason Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -56,9 +56,6 @@
#include <sys/vnode.h>
#include <sys/file.h>
-#if defined(sparc) && BSD < 199103
-#include <sys/stream.h>
-#endif
#include <sys/tty.h>
#include <sys/uio.h>
@@ -76,19 +73,7 @@
#include <netinet/if_arc.h>
#include <netinet/if_ether.h>
-/*
- * Older BSDs don't have kernel malloc.
- */
-#if BSD < 199103
-extern bcopy();
-caddr_t bpf_alloc();
-#include <net/bpf_compat.h>
-#define BPF_BUFSIZE (MCLBYTES-8)
-#define UIOMOVE(cp, len, code, uio) uiomove(cp, len, code, uio)
-#else
#define BPF_BUFSIZE 8192 /* 4096 too small for FDDI frames */
-#define UIOMOVE(cp, len, code, uio) uiomove(cp, len, uio)
-#endif
#define PRINET 6 /* interruptible */
@@ -112,9 +97,7 @@ int bpf_movein __P((struct uio *, int, struct mbuf **, struct sockaddr *));
void bpf_attachd __P((struct bpf_d *, struct bpf_if *));
void bpf_detachd __P((struct bpf_d *));
int bpf_setif __P((struct bpf_d *, struct ifreq *));
-#if BSD >= 199103
int bpfselect __P((dev_t, int, struct proc *));
-#endif
static __inline void bpf_wakeup __P((struct bpf_d *));
void bpf_catchpacket __P((struct bpf_d *, u_char *, size_t, size_t,
void (*)(const void *, void *, size_t)));
@@ -191,13 +174,8 @@ bpf_movein(uio, linktype, mp, sockp)
m->m_pkthdr.len = len - hlen;
if (len > MHLEN) {
-#if BSD >= 199103
MCLGET(m, M_WAIT);
if ((m->m_flags & M_EXT) == 0) {
-#else
- MCLGET(m);
- if (m->m_len != MCLBYTES) {
-#endif
error = ENOBUFS;
goto bad;
}
@@ -209,16 +187,12 @@ bpf_movein(uio, linktype, mp, sockp)
*/
if (hlen != 0) {
m->m_len -= hlen;
-#if BSD >= 199103
m->m_data += hlen; /* XXX */
-#else
- m->m_off += hlen;
-#endif
- error = UIOMOVE((caddr_t)sockp->sa_data, hlen, UIO_WRITE, uio);
+ error = uiomove((caddr_t)sockp->sa_data, hlen, uio);
if (error)
goto bad;
}
- error = UIOMOVE(mtod(m, caddr_t), len - hlen, UIO_WRITE, uio);
+ error = uiomove(mtod(m, caddr_t), len - hlen, uio);
if (!error)
return (0);
bad:
@@ -301,7 +275,6 @@ bpf_detachd(d)
#define D_MARKFREE(d) ((d)->bd_next = (d))
#define D_MARKUSED(d) ((d)->bd_next = 0)
-#if BSD >= 199207 || NetBSD0_9 >= 2
/*
* bpfilterattach() is called at boot time in new systems. We do
* nothing here since old systems will not call this.
@@ -320,7 +293,6 @@ bpfilterattach(n)
for (i = 0; i < NBPFILTER; ++i)
D_MARKFREE(&bpf_dtab[i]);
}
-#endif
/*
* Open ethernet device. Returns ENXIO for illegal minor device number,
@@ -484,7 +456,7 @@ bpfread(dev, uio, ioflag)
* We know the entire buffer is transferred since
* we checked above that the read buffer is bpf_bufsize bytes.
*/
- error = UIOMOVE(d->bd_hbuf, d->bd_hlen, UIO_READ, uio);
+ error = uiomove(d->bd_hbuf, d->bd_hlen, uio);
s = splimp();
d->bd_fbuf = d->bd_hbuf;
@@ -508,17 +480,9 @@ bpf_wakeup(d)
csignal(d->bd_pgid, d->bd_sig,
d->bd_siguid, d->bd_sigeuid);
-#if BSD >= 199103
selwakeup(&d->bd_sel);
/* XXX */
d->bd_sel.si_selpid = 0;
-#else
- if (d->bd_selproc) {
- selwakeup(d->bd_selproc, (int)d->bd_selcoll);
- d->bd_selcoll = 0;
- d->bd_selproc = 0;
- }
-#endif
}
int
@@ -551,11 +515,7 @@ bpfwrite(dev, uio, ioflag)
}
s = splsoftnet();
-#if BSD >= 199103
error = (*ifp->if_output)(ifp, m, &dst, (struct rtentry *)0);
-#else
- error = (*ifp->if_output)(ifp, m, &dst);
-#endif
splx(s);
/*
* The driver frees the mbuf.
@@ -643,9 +603,6 @@ bpfioctl(dev, cmd, addr, flag, p)
* Set buffer length.
*/
case BIOCSBLEN:
-#if BSD < 199103
- error = EINVAL;
-#else
if (d->bd_bif != 0)
error = EINVAL;
else {
@@ -657,7 +614,6 @@ bpfioctl(dev, cmd, addr, flag, p)
*(u_int *)addr = size = BPF_MINBUFSIZE;
d->bd_bufsize = size;
}
-#endif
break;
/*
@@ -963,36 +919,13 @@ bpf_ifname(ifp, ifr)
}
/*
- * The new select interface passes down the proc pointer; the old select
- * stubs had to grab it out of the user struct. This glue allows either case.
- */
-#if BSD >= 199103
-#define bpf_select bpfselect
-#else
-int
-bpfselect(dev, rw)
- register dev_t dev;
- int rw;
-{
- /*
- * if there isn't data waiting, and there's a timeout,
- * mark the time we started waiting.
- */
- if (b->db_rtout != -1 && (d->bd_rdStart == 0))
- d->bd_rdStart = ticks;
-
- return (bpf_select(dev, rw, u.u_procp));
-}
-#endif
-
-/*
* Support for select() system call
*
* Return true iff the specific operation will not block indefinitely.
* Otherwise, return false but make a note that a selwakeup() must be done.
*/
int
-bpf_select(dev, rw, p)
+bpfselect(dev, rw, p)
register dev_t dev;
int rw;
struct proc *p;
@@ -1023,21 +956,7 @@ bpf_select(dev, rw, p)
if (d->bd_rtout != -1 && d->bd_rdStart == 0)
d->bd_rdStart = ticks;
-#if BSD >= 199103
selrecord(p, &d->bd_sel);
-#else
- /*
- * No data ready. If there's already a select() waiting on this
- * minor device then this is a collision. This shouldn't happen
- * because minors really should not be shared, but if a process
- * forks while one of these is open, it is possible that both
- * processes could select on the same descriptor.
- */
- if (d->bd_selproc && d->bd_selproc->p_wchan == (caddr_t)&selwait)
- d->bd_selcoll = 1;
- else
- d->bd_selproc = p;
-#endif
splx(s);
return (0);
}
@@ -1188,13 +1107,7 @@ bpf_catchpacket(d, pkt, pktlen, snaplen, cpfn)
* Append the bpf header.
*/
hp = (struct bpf_hdr *)(d->bd_sbuf + curlen);
-#if BSD >= 199103
microtime(&hp->bh_tstamp);
-#elif defined(sun)
- uniqtime(&hp->bh_tstamp);
-#else
- hp->bh_tstamp = time;
-#endif
hp->bh_datalen = pktlen;
hp->bh_hdrlen = hdrlen;
/*
@@ -1277,14 +1190,8 @@ bpfattach(driverp, ifp, dlt, hdrlen)
u_int dlt, hdrlen;
{
struct bpf_if *bp;
-#if BSD < 199103
- static struct bpf_if bpf_ifs[NBPFILTER];
- static int bpfifno;
-
- bp = (bpfifno < NBPFILTER) ? &bpf_ifs[bpfifno++] : 0;
-#else
bp = (struct bpf_if *)malloc(sizeof(*bp), M_DEVBUF, M_DONTWAIT);
-#endif
+
if (bp == 0)
panic("bpfattach");
@@ -1305,10 +1212,6 @@ bpfattach(driverp, ifp, dlt, hdrlen)
* performance reasons and to alleviate alignment restrictions).
*/
bp->bif_hdrlen = BPF_WORDALIGN(hdrlen + SIZEOF_BPF_HDR) - hdrlen;
-
-#if 0
- printf("bpf: %s attached\n", ifp->if_xname);
-#endif
}
/* Detach an interface from its attached bpf device. */
@@ -1341,21 +1244,13 @@ bpfdetach(ifp)
break;
}
-#if BSD < 199103
- if (bp == &bpf_ifs[bpfifno - 1])
- bpfifno--;
- else
- printf("bpfdetach: leaked one bpf\n");
-#else
free(bp, M_DEVBUF);
-#endif
}
pbp = &bp->bif_next;
}
ifp->if_bpf = NULL;
}
-#if BSD >= 199103
/* XXX This routine belongs in net/if.c. */
/*
* Set/clear promiscuous mode on interface ifp based on the truth value
@@ -1396,35 +1291,3 @@ ifpromisc(ifp, pswitch)
ifr.ifr_flags = ifp->if_flags;
return ((*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr));
}
-#endif
-
-#if BSD < 199103
-/*
- * Allocate some memory for bpf. This is temporary SunOS support, and
- * is admittedly a hack.
- * If resources unavaiable, return 0.
- */
-caddr_t
-bpf_alloc(size, canwait)
- register int size;
- register int canwait;
-{
- register struct mbuf *m;
-
- if ((unsigned)size > (MCLBYTES-8))
- return 0;
-
- MGET(m, canwait, MT_DATA);
- if (m == 0)
- return 0;
- if ((unsigned)size > (MLEN-8)) {
- MCLGET(m);
- if (m->m_len != MCLBYTES) {
- m_freem(m);
- return 0;
- }
- }
- *mtod(m, struct mbuf **) = m;
- return mtod(m, caddr_t) + 8;
-}
-#endif
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index 9717881967a..37503941651 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.h,v 1.12 1999/08/08 00:43:00 niklas Exp $ */
+/* $OpenBSD: bpf.h,v 1.13 2000/06/19 03:00:54 jason Exp $ */
/* $NetBSD: bpf.h,v 1.15 1996/12/13 07:57:33 mikel Exp $ */
/*
@@ -97,28 +97,7 @@ struct bpf_version {
/*
* BPF ioctls
- *
- * The first set is for compatibility with Sun's pcc style
- * header files. If you're using gcc, we assume that you
- * have run fixincludes so the latter set should work.
*/
-#if (defined(sun) || defined(ibm032)) && !defined(__GNUC__)
-#define BIOCGBLEN _IOR(B,102, u_int)
-#define BIOCSBLEN _IOWR(B,102, u_int)
-#define BIOCSETF _IOW(B,103, struct bpf_program)
-#define BIOCFLUSH _IO(B,104)
-#define BIOCPROMISC _IO(B,105)
-#define BIOCGDLT _IOR(B,106, u_int)
-#define BIOCGETIF _IOR(B,107, struct ifreq)
-#define BIOCSETIF _IOW(B,108, struct ifreq)
-#define BIOCSRTIMEOUT _IOW(B,109, struct timeval)
-#define BIOCGRTIMEOUT _IOR(B,110, struct timeval)
-#define BIOCGSTATS _IOR(B,111, struct bpf_stat)
-#define BIOCIMMEDIATE _IOW(B,112, u_int)
-#define BIOCVERSION _IOR(B,113, struct bpf_version)
-#define BIOCSRSIG _IOW(B,114, u_int)
-#define BIOCGRSIG _IOR(B,115, u_int)
-#else
#define BIOCGBLEN _IOR('B',102, u_int)
#define BIOCSBLEN _IOWR('B',102, u_int)
#define BIOCSETF _IOW('B',103, struct bpf_program)
@@ -134,7 +113,6 @@ struct bpf_version {
#define BIOCVERSION _IOR('B',113, struct bpf_version)
#define BIOCSRSIG _IOW('B',114, u_int)
#define BIOCGRSIG _IOR('B',115, u_int)
-#endif
/*
* Structure prepended to each packet.
diff --git a/sys/net/bpf_filter.c b/sys/net/bpf_filter.c
index b65d8ef6705..095ac146037 100644
--- a/sys/net/bpf_filter.c
+++ b/sys/net/bpf_filter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf_filter.c,v 1.6 1999/09/13 22:35:44 niklas Exp $ */
+/* $OpenBSD: bpf_filter.c,v 1.7 2000/06/19 03:00:54 jason Exp $ */
/* $NetBSD: bpf_filter.c,v 1.12 1996/02/13 22:00:00 christos Exp $ */
/*
@@ -45,14 +45,7 @@
#include <sys/types.h>
#include <sys/time.h>
-#ifdef sun
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#endif
-
-#if defined(sparc) || defined(__mips__) || defined(ibm032) || \
- ((defined(__NetBSD__) || defined(__OpenBSD__)) && !defined(UNALIGNED_ACCESS))
+#ifndef UNALIGNED_ACCESS
#define BPF_ALIGN
#endif
diff --git a/sys/net/bpfdesc.h b/sys/net/bpfdesc.h
index 577158c592f..f3440b636c4 100644
--- a/sys/net/bpfdesc.h
+++ b/sys/net/bpfdesc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpfdesc.h,v 1.5 1999/08/08 00:43:00 niklas Exp $ */
+/* $OpenBSD: bpfdesc.h,v 1.6 2000/06/19 03:00:54 jason Exp $ */
/* $NetBSD: bpfdesc.h,v 1.11 1995/09/27 18:30:42 thorpej Exp $ */
/*
@@ -80,14 +80,8 @@ struct bpf_d {
pid_t bd_pgid; /* process or group id for signal */
uid_t bd_siguid; /* uid for process that set pgid */
uid_t bd_sigeuid; /* euid for process that set pgid */
-#if BSD < 199103
- u_char bd_selcoll; /* true if selects collide */
- int bd_timedout;
- struct proc * bd_selproc; /* process that last selected us */
-#else
u_char bd_pad; /* explicit alignment */
struct selinfo bd_sel; /* bsd select info */
-#endif
};
/*