xref: /csrg-svn/sys/net/bpfdesc.h (revision 51426)
149284Sbostic /*-
249284Sbostic  * Copyright (c) 1991 The Regents of the University of California.
347639Smccanne  * All rights reserved.
447639Smccanne  *
549284Sbostic  * This code is derived from the Stanford/CMU enet packet filter,
649284Sbostic  * (net/enet.c) distributed as part of 4.3BSD, and code contributed
7*51426Smccanne  * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
8*51426Smccanne  * Berkeley Laboratory.
947639Smccanne  *
10*51426Smccanne  * Redistribution and use in source and binary forms, with or without
11*51426Smccanne  * modification, are permitted provided that the following conditions
12*51426Smccanne  * are met:
13*51426Smccanne  * 1. Redistributions of source code must retain the above copyright
14*51426Smccanne  *    notice, this list of conditions and the following disclaimer.
15*51426Smccanne  * 2. Redistributions in binary form must reproduce the above copyright
16*51426Smccanne  *    notice, this list of conditions and the following disclaimer in the
17*51426Smccanne  *    documentation and/or other materials provided with the distribution.
18*51426Smccanne  * 3. All advertising materials mentioning features or use of this software
19*51426Smccanne  *    must display the following acknowledgement:
20*51426Smccanne  *	This product includes software developed by the University of
21*51426Smccanne  *	California, Berkeley and its contributors.
22*51426Smccanne  * 4. Neither the name of the University nor the names of its contributors
23*51426Smccanne  *    may be used to endorse or promote products derived from this software
24*51426Smccanne  *    without specific prior written permission.
2549284Sbostic  *
26*51426Smccanne  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27*51426Smccanne  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28*51426Smccanne  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29*51426Smccanne  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30*51426Smccanne  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31*51426Smccanne  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32*51426Smccanne  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33*51426Smccanne  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34*51426Smccanne  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35*51426Smccanne  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36*51426Smccanne  * SUCH DAMAGE.
3749284Sbostic  *
38*51426Smccanne  *	@(#)bpfdesc.h	7.1 (Berkeley) 5/7/91
39*51426Smccanne  *
40*51426Smccanne  * @(#) $Header: bpfdesc.h,v 1.9 91/10/27 21:22:38 mccanne Exp $ (LBL)
4147639Smccanne  */
4247639Smccanne 
4347639Smccanne /*
4447639Smccanne  * Descriptor associated with each open bpf file.
4547639Smccanne  */
4647639Smccanne struct bpf_d {
4747639Smccanne 	struct bpf_d	*bd_next;	/* Linked list of descriptors */
4847639Smccanne 	/*
4947639Smccanne 	 * Buffer slots: two mbuf clusters buffer the incoming packets.
5047639Smccanne 	 *   The model has three slots.  Sbuf is always occupied.
5147639Smccanne 	 *   sbuf (store) - Receive interrupt puts packets here.
5247639Smccanne 	 *   hbuf (hold) - When sbuf is full, put cluster here and
5347639Smccanne 	 *                 wakeup read (replace sbuf with fbuf).
5447639Smccanne 	 *   fbuf (free) - When read is done, put cluster here.
5547639Smccanne 	 * On receiving, if sbuf is full and fbuf is 0, packet is dropped.
5647639Smccanne 	 */
5748933Smccanne 	caddr_t		bd_sbuf;	/* store slot */
5848933Smccanne 	caddr_t		bd_hbuf;	/* hold slot */
5948933Smccanne 	caddr_t		bd_fbuf;	/* free slot */
6048933Smccanne 	int 		bd_slen;	/* current length of store buffer */
6148933Smccanne 	int 		bd_hlen;	/* current length of hold buffer */
6247639Smccanne 
6348933Smccanne 	int		bd_bufsize;	/* absolute length of buffers */
6448933Smccanne 
6547639Smccanne 	struct bpf_if *	bd_bif;		/* interface descriptor */
6647639Smccanne 	u_long		bd_rtout;	/* Read timeout in 'ticks' */
6748933Smccanne 	struct bpf_insn *bd_filter; 	/* filter code */
6847639Smccanne 	u_long		bd_rcount;	/* number of packets received */
6947639Smccanne 	u_long		bd_dcount;	/* number of packets dropped */
7048933Smccanne 	struct proc *	bd_selproc;	/* process that last selected us */
7147639Smccanne 
7247639Smccanne 	u_char		bd_promisc;	/* true if listening promiscuously */
7347639Smccanne 	u_char		bd_state;	/* idle, waiting, or timed out */
7448933Smccanne 	u_char		bd_selcoll;	/* true if selects collide */
7547639Smccanne 	u_char		bd_immediate;	/* true to return on packet arrival */
76*51426Smccanne #if BSD < 199103
77*51426Smccanne 	int		bd_timedout;
78*51426Smccanne #endif
7947639Smccanne };
8047639Smccanne 
8147639Smccanne /*
8247639Smccanne  * Descriptor associated with each attached hardware interface.
8347639Smccanne  */
8447639Smccanne struct bpf_if {
8549199Smccanne 	struct bpf_if *bif_next;	/* list of all interfaces */
8649199Smccanne 	struct bpf_d *bif_dlist;	/* descriptor list */
8749199Smccanne 	struct bpf_if **bif_driverp;	/* pointer into softc */
8849199Smccanne 	u_int bif_dlt;			/* link layer type */
8949199Smccanne 	u_int bif_hdrlen;		/* length of header (with padding) */
9049199Smccanne 	struct ifnet *bif_ifp;		/* correspoding interface */
9147639Smccanne };
92