diff options
Diffstat (limited to 'sys/net/bpf.c')
| -rw-r--r-- | sys/net/bpf.c | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index f2e09c84d78..7e42edc8e62 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.37 2003/07/29 23:02:52 itojun Exp $ */ +/* $OpenBSD: bpf.c,v 1.38 2003/09/23 16:51:13 millert Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -48,6 +48,7 @@ #include <sys/vnode.h> #include <sys/file.h> #include <sys/socket.h> +#include <sys/poll.h> #include <sys/kernel.h> #include <net/if.h> @@ -83,7 +84,7 @@ int bpf_movein(struct uio *, int, struct mbuf **, struct sockaddr *); void bpf_attachd(struct bpf_d *, struct bpf_if *); void bpf_detachd(struct bpf_d *); int bpf_setif(struct bpf_d *, struct ifreq *); -int bpfselect(dev_t, int, struct proc *); +int bpfpoll(dev_t, int, struct proc *); int bpfkqfilter(dev_t, struct knote *); static __inline void bpf_wakeup(struct bpf_d *); void bpf_catchpacket(struct bpf_d *, u_char *, size_t, size_t, @@ -928,46 +929,37 @@ bpf_ifname(ifp, ifr) } /* - * 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. + * Support for poll() system call */ int -bpfselect(dev, rw, p) +bpfpoll(dev, events, p) register dev_t dev; - int rw; + int events; struct proc *p; { register struct bpf_d *d; - register int s; + register int s, revents; + + revents = events & (POLLIN | POLLRDNORM); + if (revents == 0) + return (0); /* only support reading */ - if (rw != FREAD) - return (0); /* * An imitation of the FIONREAD ioctl code. */ d = &bpf_dtab[minor(dev)]; - s = splimp(); - if (d->bd_hlen != 0 || (d->bd_immediate && d->bd_slen != 0)) { + if (d->bd_hlen == 0 && (!d->bd_immediate || d->bd_slen == 0)) { + revents = 0; /* no data waiting */ /* - * There is data waiting. + * if there's a timeout, mark the time we started waiting. */ - splx(s); - return (1); + if (d->bd_rtout != -1 && d->bd_rdStart == 0) + d->bd_rdStart = ticks; + selrecord(p, &d->bd_sel); } - - /* - * if there isn't data waiting, and there's a timeout, - * mark the time we started waiting. - */ - if (d->bd_rtout != -1 && d->bd_rdStart == 0) - d->bd_rdStart = ticks; - - selrecord(p, &d->bd_sel); splx(s); - return (0); + return (revents); } struct filterops bpfread_filtops = |
