Deleted Added
full compact
bpf.c (46130) bpf.c (46155)
1/*
2 * Copyright (c) 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from the Stanford/CMU enet packet filter,
6 * (net/enet.c) distributed as part of 4.3BSD, and code contributed
7 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
8 * Berkeley Laboratory.

--- 23 unchanged lines hidden (view full) ---

32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)bpf.c 8.2 (Berkeley) 3/28/94
39 *
1/*
2 * Copyright (c) 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from the Stanford/CMU enet packet filter,
6 * (net/enet.c) distributed as part of 4.3BSD, and code contributed
7 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
8 * Berkeley Laboratory.

--- 23 unchanged lines hidden (view full) ---

32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)bpf.c 8.2 (Berkeley) 3/28/94
39 *
40 * $Id: bpf.c,v 1.47 1999/01/27 22:42:13 dillon Exp $
40 * $Id: bpf.c,v 1.48 1999/04/28 01:18:13 msmith Exp $
41 */
42
43#include "bpfilter.h"
44
45#ifndef __GNUC__
46#define inline
47#else
48#define inline __inline

--- 292 unchanged lines hidden (view full) ---

341bpfopen(dev, flags, fmt, p)
342 dev_t dev;
343 int flags;
344 int fmt;
345 struct proc *p;
346{
347 register struct bpf_d *d;
348
41 */
42
43#include "bpfilter.h"
44
45#ifndef __GNUC__
46#define inline
47#else
48#define inline __inline

--- 292 unchanged lines hidden (view full) ---

341bpfopen(dev, flags, fmt, p)
342 dev_t dev;
343 int flags;
344 int fmt;
345 struct proc *p;
346{
347 register struct bpf_d *d;
348
349 if (p->p_prison)
350 return (EPERM);
351
349 if (minor(dev) >= NBPFILTER)
350 return (ENXIO);
351 /*
352 * Each minor can be opened by only one process. If the requested
353 * minor is in use, return EBUSY.
354 */
355 d = &bpf_dtab[minor(dev)];
356 if (!D_ISFREE(d))

--- 652 unchanged lines hidden (view full) ---

1009 int revents = 0;
1010
1011 /*
1012 * An imitation of the FIONREAD ioctl code.
1013 */
1014 d = &bpf_dtab[minor(dev)];
1015
1016 s = splimp();
352 if (minor(dev) >= NBPFILTER)
353 return (ENXIO);
354 /*
355 * Each minor can be opened by only one process. If the requested
356 * minor is in use, return EBUSY.
357 */
358 d = &bpf_dtab[minor(dev)];
359 if (!D_ISFREE(d))

--- 652 unchanged lines hidden (view full) ---

1012 int revents = 0;
1013
1014 /*
1015 * An imitation of the FIONREAD ioctl code.
1016 */
1017 d = &bpf_dtab[minor(dev)];
1018
1019 s = splimp();
1017 if (events & (POLLIN | POLLRDNORM))
1020 if (events & (POLLIN | POLLRDNORM)) {
1018 if (d->bd_hlen != 0 || (d->bd_immediate && d->bd_slen != 0))
1019 revents |= events & (POLLIN | POLLRDNORM);
1020 else
1021 selrecord(p, &d->bd_sel);
1021 if (d->bd_hlen != 0 || (d->bd_immediate && d->bd_slen != 0))
1022 revents |= events & (POLLIN | POLLRDNORM);
1023 else
1024 selrecord(p, &d->bd_sel);
1022
1025 }
1023 splx(s);
1024 return (revents);
1025}
1026
1027/*
1028 * Incoming linkage from device drivers. Process the packet pkt, of length
1029 * pktlen, which is stored in a contiguous buffer. The packet is parsed
1030 * by each process' filter, and if accepted, stashed into the corresponding

--- 321 unchanged lines hidden ---
1026 splx(s);
1027 return (revents);
1028}
1029
1030/*
1031 * Incoming linkage from device drivers. Process the packet pkt, of length
1032 * pktlen, which is stored in a contiguous buffer. The packet is parsed
1033 * by each process' filter, and if accepted, stashed into the corresponding

--- 321 unchanged lines hidden ---