summaryrefslogtreecommitdiff
path: root/sys/net/bpf.c
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 /sys/net/bpf.c
parent395de9a9a23845c5ed5e7bcba947082ba1c154fd (diff)
de-#ifdef-ize
Diffstat (limited to 'sys/net/bpf.c')
-rw-r--r--sys/net/bpf.c149
1 files changed, 6 insertions, 143 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