1 /* $OpenBSD: bpfdesc.h,v 1.8 2001/06/09 06:16:37 angelos Exp $ */ 2 /* $NetBSD: bpfdesc.h,v 1.11 1995/09/27 18:30:42 thorpej Exp $ */ 3 4 /* 5 * Copyright (c) 1990, 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from the Stanford/CMU enet packet filter, 9 * (net/enet.c) distributed as part of 4.3BSD, and code contributed 10 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 11 * Berkeley Laboratory. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 3. All advertising materials mentioning features or use of this software 22 * must display the following acknowledgement: 23 * This product includes software developed by the University of 24 * California, Berkeley and its contributors. 25 * 4. Neither the name of the University nor the names of its contributors 26 * may be used to endorse or promote products derived from this software 27 * without specific prior written permission. 28 * 29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * @(#)bpfdesc.h 8.1 (Berkeley) 6/10/93 42 */ 43 44 #ifndef _NET_BPFDESC_H_ 45 #define _NET_BPFDESC_H_ 46 47 #include <sys/select.h> 48 49 /* 50 * Descriptor associated with each open bpf file. 51 */ 52 struct bpf_d { 53 struct bpf_d *bd_next; /* Linked list of descriptors */ 54 /* 55 * Buffer slots: two mbuf clusters buffer the incoming packets. 56 * The model has three slots. Sbuf is always occupied. 57 * sbuf (store) - Receive interrupt puts packets here. 58 * hbuf (hold) - When sbuf is full, put cluster here and 59 * wakeup read (replace sbuf with fbuf). 60 * fbuf (free) - When read is done, put cluster here. 61 * On receiving, if sbuf is full and fbuf is 0, packet is dropped. 62 */ 63 caddr_t bd_sbuf; /* store slot */ 64 caddr_t bd_hbuf; /* hold slot */ 65 caddr_t bd_fbuf; /* free slot */ 66 int bd_slen; /* current length of store buffer */ 67 int bd_hlen; /* current length of hold buffer */ 68 69 int bd_bufsize; /* absolute length of buffers */ 70 71 struct bpf_if * bd_bif; /* interface descriptor */ 72 u_long bd_rtout; /* Read timeout in 'ticks' */ 73 u_long bd_rdStart; /* when the read started */ 74 struct bpf_insn *bd_filter; /* filter code */ 75 u_long bd_rcount; /* number of packets received */ 76 u_long bd_dcount; /* number of packets dropped */ 77 78 u_char bd_promisc; /* true if listening promiscuously */ 79 u_char bd_state; /* idle, waiting, or timed out */ 80 u_char bd_immediate; /* true to return on packet arrival */ 81 int bd_hdrcmplt; /* false to fill in src lladdr automatically */ 82 int bd_async; /* non-zero if packet reception should generate signal */ 83 int bd_sig; /* signal to send upon packet reception */ 84 pid_t bd_pgid; /* process or group id for signal */ 85 uid_t bd_siguid; /* uid for process that set pgid */ 86 uid_t bd_sigeuid; /* euid for process that set pgid */ 87 u_char bd_pad; /* explicit alignment */ 88 struct selinfo bd_sel; /* bsd select info */ 89 }; 90 91 /* 92 * Descriptor associated with each attached hardware interface. 93 */ 94 struct bpf_if { 95 struct bpf_if *bif_next; /* list of all interfaces */ 96 struct bpf_d *bif_dlist; /* descriptor list */ 97 struct bpf_if **bif_driverp; /* pointer into softc */ 98 u_int bif_dlt; /* link layer type */ 99 u_int bif_hdrlen; /* length of header (with padding) */ 100 struct ifnet *bif_ifp; /* correspoding interface */ 101 }; 102 103 #ifdef _KERNEL 104 int bpf_setf __P((struct bpf_d *, struct bpf_program *)); 105 #endif /* _KERNEL */ 106 #endif /* _NET_BPFDESC_H_ */ 107