|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: ! 25: /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ ! 26: /* ! 27: * Copyright (c) 1990, 1991, 1993 ! 28: * The Regents of the University of California. All rights reserved. ! 29: * ! 30: * This code is derived from the Stanford/CMU enet packet filter, ! 31: * (net/enet.c) distributed as part of 4.3BSD, and code contributed ! 32: * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence ! 33: * Berkeley Laboratory. ! 34: * ! 35: * Redistribution and use in source and binary forms, with or without ! 36: * modification, are permitted provided that the following conditions ! 37: * are met: ! 38: * 1. Redistributions of source code must retain the above copyright ! 39: * notice, this list of conditions and the following disclaimer. ! 40: * 2. Redistributions in binary form must reproduce the above copyright ! 41: * notice, this list of conditions and the following disclaimer in the ! 42: * documentation and/or other materials provided with the distribution. ! 43: * 3. All advertising materials mentioning features or use of this software ! 44: * must display the following acknowledgement: ! 45: * This product includes software developed by the University of ! 46: * California, Berkeley and its contributors. ! 47: * 4. Neither the name of the University nor the names of its contributors ! 48: * may be used to endorse or promote products derived from this software ! 49: * without specific prior written permission. ! 50: * ! 51: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ! 52: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! 53: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ! 54: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ! 55: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ! 56: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ! 57: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! 58: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ! 59: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ! 60: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! 61: * SUCH DAMAGE. ! 62: * ! 63: * @(#)bpfdesc.h 8.1 (Berkeley) 6/10/93 ! 64: * ! 65: */ ! 66: ! 67: #include <sys/select.h> ! 68: ! 69: /* ! 70: * Descriptor associated with each open bpf file. ! 71: */ ! 72: struct bpf_d { ! 73: struct bpf_d *bd_next; /* Linked list of descriptors */ ! 74: /* ! 75: * Buffer slots: two mbuf clusters buffer the incoming packets. ! 76: * The model has three slots. Sbuf is always occupied. ! 77: * sbuf (store) - Receive interrupt puts packets here. ! 78: * hbuf (hold) - When sbuf is full, put cluster here and ! 79: * wakeup read (replace sbuf with fbuf). ! 80: * fbuf (free) - When read is done, put cluster here. ! 81: * On receiving, if sbuf is full and fbuf is 0, packet is dropped. ! 82: */ ! 83: caddr_t bd_sbuf; /* store slot */ ! 84: caddr_t bd_hbuf; /* hold slot */ ! 85: caddr_t bd_fbuf; /* free slot */ ! 86: int bd_slen; /* current length of store buffer */ ! 87: int bd_hlen; /* current length of hold buffer */ ! 88: ! 89: int bd_bufsize; /* absolute length of buffers */ ! 90: ! 91: struct bpf_if * bd_bif; /* interface descriptor */ ! 92: u_long bd_rtout; /* Read timeout in 'ticks' */ ! 93: struct bpf_insn *bd_filter; /* filter code */ ! 94: u_long bd_rcount; /* number of packets received */ ! 95: u_long bd_dcount; /* number of packets dropped */ ! 96: ! 97: u_char bd_promisc; /* true if listening promiscuously */ ! 98: u_char bd_state; /* idle, waiting, or timed out */ ! 99: u_char bd_immediate; /* true to return on packet arrival */ ! 100: #if BSD < 199103 ! 101: u_char bd_selcoll; /* true if selects collide */ ! 102: int bd_timedout; ! 103: struct proc * bd_selproc; /* process that last selected us */ ! 104: #else ! 105: u_char bd_pad; /* explicit alignment */ ! 106: struct selinfo bd_sel; /* bsd select info */ ! 107: #endif ! 108: }; ! 109: ! 110: /* ! 111: * Mark a descriptor free by making it point to itself. ! 112: * This is probably cheaper than marking with a constant since ! 113: * the address should be in a register anyway. ! 114: */ ! 115: #define D_ISFREE(d) ((d) == (d)->bd_next) ! 116: #define D_MARKFREE(d) ((d)->bd_next = (d)) ! 117: #define D_MARKUSED(d) ((d)->bd_next = 0) ! 118: ! 119: /* ! 120: * Descriptor associated with each attached hardware interface. ! 121: */ ! 122: struct bpf_if { ! 123: struct bpf_if *bif_next; /* list of all interfaces */ ! 124: struct bpf_d *bif_dlist; /* descriptor list */ ! 125: struct bpf_if **bif_driverp; /* pointer into softc */ ! 126: u_int bif_dlt; /* link layer type */ ! 127: u_int bif_hdrlen; /* length of header (with padding) */ ! 128: struct ifnet *bif_ifp; /* correspoding interface */ ! 129: }; ! 130: ! 131: #ifdef _KERNEL ! 132: int bpf_setf __P((struct bpf_d *, struct bpf_program *)); ! 133: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.