xref: /csrg-svn/sys/net/bpfdesc.h (revision 49284)
1*49284Sbostic /*-
2*49284Sbostic  * Copyright (c) 1991 The Regents of the University of California.
347639Smccanne  * All rights reserved.
447639Smccanne  *
5*49284Sbostic  * This code is derived from the Stanford/CMU enet packet filter,
6*49284Sbostic  * (net/enet.c) distributed as part of 4.3BSD, and code contributed
7*49284Sbostic  * to Berkeley by Steven McCanne of Lawrence Berkeley Laboratory.
847639Smccanne  *
9*49284Sbostic  * %sccs.include.redist.c%
10*49284Sbostic  *
11*49284Sbostic  *	@(#)bpfdesc.h	7.1 (Berkeley) 05/07/91
12*49284Sbostic  *
1347639Smccanne  * @(#) $Header: bpfdesc.h,v 1.7 90/12/04 01:05:01 mccanne Exp $ (LBL)
1447639Smccanne  */
1547639Smccanne 
1647639Smccanne /*
1747639Smccanne  * Descriptor associated with each open bpf file.
1847639Smccanne  */
1947639Smccanne struct bpf_d {
2047639Smccanne 	struct bpf_d	*bd_next;	/* Linked list of descriptors */
2147639Smccanne 	/*
2247639Smccanne 	 * Buffer slots: two mbuf clusters buffer the incoming packets.
2347639Smccanne 	 *   The model has three slots.  Sbuf is always occupied.
2447639Smccanne 	 *   sbuf (store) - Receive interrupt puts packets here.
2547639Smccanne 	 *   hbuf (hold) - When sbuf is full, put cluster here and
2647639Smccanne 	 *                 wakeup read (replace sbuf with fbuf).
2747639Smccanne 	 *   fbuf (free) - When read is done, put cluster here.
2847639Smccanne 	 * On receiving, if sbuf is full and fbuf is 0, packet is dropped.
2947639Smccanne 	 */
3048933Smccanne 	caddr_t		bd_sbuf;	/* store slot */
3148933Smccanne 	caddr_t		bd_hbuf;	/* hold slot */
3248933Smccanne 	caddr_t		bd_fbuf;	/* free slot */
3348933Smccanne 	int 		bd_slen;	/* current length of store buffer */
3448933Smccanne 	int 		bd_hlen;	/* current length of hold buffer */
3547639Smccanne 
3648933Smccanne 	int		bd_bufsize;	/* absolute length of buffers */
3748933Smccanne 
3847639Smccanne 	struct bpf_if *	bd_bif;		/* interface descriptor */
3947639Smccanne 	u_long		bd_rtout;	/* Read timeout in 'ticks' */
4048933Smccanne 	struct bpf_insn *bd_filter; 	/* filter code */
4147639Smccanne 	u_long		bd_rcount;	/* number of packets received */
4247639Smccanne 	u_long		bd_dcount;	/* number of packets dropped */
4348933Smccanne 	struct proc *	bd_selproc;	/* process that last selected us */
4447639Smccanne 
4547639Smccanne 	u_char		bd_promisc;	/* true if listening promiscuously */
4647639Smccanne 	u_char		bd_state;	/* idle, waiting, or timed out */
4748933Smccanne 	u_char		bd_selcoll;	/* true if selects collide */
4847639Smccanne 	u_char		bd_immediate;	/* true to return on packet arrival */
4947639Smccanne };
5047639Smccanne 
5147639Smccanne /*
5247639Smccanne  * Descriptor associated with each attached hardware interface.
5347639Smccanne  */
5447639Smccanne struct bpf_if {
5549199Smccanne 	struct bpf_if *bif_next;	/* list of all interfaces */
5649199Smccanne 	struct bpf_d *bif_dlist;	/* descriptor list */
5749199Smccanne 	struct bpf_if **bif_driverp;	/* pointer into softc */
5849199Smccanne 	u_int bif_dlt;			/* link layer type */
5949199Smccanne 	u_int bif_hdrlen;		/* length of header (with padding) */
6049199Smccanne 	struct ifnet *bif_ifp;		/* correspoding interface */
6147639Smccanne };
62