bpf.c (9819) | bpf.c (10624) |
---|---|
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.9 1995/07/16 10:13:08 bde Exp $ | 40 * $Id: bpf.c,v 1.10 1995/07/31 10:35:36 peter Exp $ |
41 */ 42 43#include "bpfilter.h" 44 45#if NBPFILTER > 0 46 47#ifndef __GNUC__ 48#define inline --- 254 unchanged lines hidden (view full) --- 303#define D_MARKUSED(d) ((d)->bd_next = 0) 304 305/* 306 * Open ethernet device. Returns ENXIO for illegal minor device number, 307 * EBUSY if file is open by another process. 308 */ 309/* ARGSUSED */ 310int | 41 */ 42 43#include "bpfilter.h" 44 45#if NBPFILTER > 0 46 47#ifndef __GNUC__ 48#define inline --- 254 unchanged lines hidden (view full) --- 303#define D_MARKUSED(d) ((d)->bd_next = 0) 304 305/* 306 * Open ethernet device. Returns ENXIO for illegal minor device number, 307 * EBUSY if file is open by another process. 308 */ 309/* ARGSUSED */ 310int |
311bpfopen(dev, flag) | 311bpfopen(dev, flags, fmt, p) |
312 dev_t dev; | 312 dev_t dev; |
313 int flag; | 313 int flags; 314 int fmt; 315 struct proc *p; |
314{ 315 register struct bpf_d *d; 316 317 if (minor(dev) >= NBPFILTER) 318 return (ENXIO); 319 /* 320 * Each minor can be opened by only one process. If the requested 321 * minor is in use, return EBUSY. --- 11 unchanged lines hidden (view full) --- 333} 334 335/* 336 * Close the descriptor by detaching it from its interface, 337 * deallocating its buffers, and marking it free. 338 */ 339/* ARGSUSED */ 340int | 316{ 317 register struct bpf_d *d; 318 319 if (minor(dev) >= NBPFILTER) 320 return (ENXIO); 321 /* 322 * Each minor can be opened by only one process. If the requested 323 * minor is in use, return EBUSY. --- 11 unchanged lines hidden (view full) --- 335} 336 337/* 338 * Close the descriptor by detaching it from its interface, 339 * deallocating its buffers, and marking it free. 340 */ 341/* ARGSUSED */ 342int |
341bpfclose(dev, flag) | 343bpfclose(dev, flags, fmt, p) |
342 dev_t dev; | 344 dev_t dev; |
343 int flag; | 345 int flags; 346 int fmt; 347 struct proc *p; |
344{ 345 register struct bpf_d *d = &bpf_dtab[minor(dev)]; 346 register int s; 347 348 s = splimp(); 349 if (d->bd_bif) 350 bpf_detachd(d); 351 splx(s); --- 51 unchanged lines hidden (view full) --- 403 (d)->bd_hlen = (d)->bd_slen; \ 404 (d)->bd_sbuf = (d)->bd_fbuf; \ 405 (d)->bd_slen = 0; \ 406 (d)->bd_fbuf = 0; 407/* 408 * bpfread - read next chunk of packets from buffers 409 */ 410int | 348{ 349 register struct bpf_d *d = &bpf_dtab[minor(dev)]; 350 register int s; 351 352 s = splimp(); 353 if (d->bd_bif) 354 bpf_detachd(d); 355 splx(s); --- 51 unchanged lines hidden (view full) --- 407 (d)->bd_hlen = (d)->bd_slen; \ 408 (d)->bd_sbuf = (d)->bd_fbuf; \ 409 (d)->bd_slen = 0; \ 410 (d)->bd_fbuf = 0; 411/* 412 * bpfread - read next chunk of packets from buffers 413 */ 414int |
411bpfread(dev, uio) | 415bpfread(dev, uio, ioflag) |
412 dev_t dev; 413 register struct uio *uio; | 416 dev_t dev; 417 register struct uio *uio; |
418 int ioflag; |
|
414{ 415 register struct bpf_d *d = &bpf_dtab[minor(dev)]; 416 int error; 417 int s; 418 419 /* 420 * Restrict application to use a buffer the same size as 421 * as kernel buffers. --- 95 unchanged lines hidden (view full) --- 517 selwakeup(d->bd_selproc, (int)d->bd_selcoll); 518 d->bd_selcoll = 0; 519 d->bd_selproc = 0; 520 } 521#endif 522} 523 524int | 419{ 420 register struct bpf_d *d = &bpf_dtab[minor(dev)]; 421 int error; 422 int s; 423 424 /* 425 * Restrict application to use a buffer the same size as 426 * as kernel buffers. --- 95 unchanged lines hidden (view full) --- 522 selwakeup(d->bd_selproc, (int)d->bd_selcoll); 523 d->bd_selcoll = 0; 524 d->bd_selproc = 0; 525 } 526#endif 527} 528 529int |
525bpfwrite(dev, uio) | 530bpfwrite(dev, uio, ioflag) |
526 dev_t dev; 527 struct uio *uio; | 531 dev_t dev; 532 struct uio *uio; |
533 int ioflag; |
|
528{ 529 register struct bpf_d *d = &bpf_dtab[minor(dev)]; 530 struct ifnet *ifp; 531 struct mbuf *m; 532 int error, s; 533 static struct sockaddr dst; 534 int datlen; 535 --- 57 unchanged lines hidden (view full) --- 593 * BIOCSRTIMEOUT Set read timeout. 594 * BIOCGRTIMEOUT Get read timeout. 595 * BIOCGSTATS Get packet stats. 596 * BIOCIMMEDIATE Set immediate mode. 597 * BIOCVERSION Get filter language version. 598 */ 599/* ARGSUSED */ 600int | 534{ 535 register struct bpf_d *d = &bpf_dtab[minor(dev)]; 536 struct ifnet *ifp; 537 struct mbuf *m; 538 int error, s; 539 static struct sockaddr dst; 540 int datlen; 541 --- 57 unchanged lines hidden (view full) --- 599 * BIOCSRTIMEOUT Set read timeout. 600 * BIOCGRTIMEOUT Get read timeout. 601 * BIOCGSTATS Get packet stats. 602 * BIOCIMMEDIATE Set immediate mode. 603 * BIOCVERSION Get filter language version. 604 */ 605/* ARGSUSED */ 606int |
601bpfioctl(dev, cmd, addr, flag) | 607bpfioctl(dev, cmd, addr, flags, p) |
602 dev_t dev; 603 int cmd; 604 caddr_t addr; | 608 dev_t dev; 609 int cmd; 610 caddr_t addr; |
605 int flag; | 611 int flags; 612 struct proc *p; |
606{ 607 register struct bpf_d *d = &bpf_dtab[minor(dev)]; 608 int s, error = 0; 609 610 switch (cmd) { 611 612 default: 613 error = EINVAL; --- 755 unchanged lines hidden --- | 613{ 614 register struct bpf_d *d = &bpf_dtab[minor(dev)]; 615 int s, error = 0; 616 617 switch (cmd) { 618 619 default: 620 error = EINVAL; --- 755 unchanged lines hidden --- |