xref: /csrg-svn/sys/net/bpfdesc.h (revision 63211)
151441Smccanne /*
2*63211Sbostic  * Copyright (c) 1990, 1991, 1993
3*63211Sbostic  *	The Regents of the University of California.  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
751441Smccanne  * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
851426Smccanne  * Berkeley Laboratory.
947639Smccanne  *
1051441Smccanne  * %sccs.include.redist.c%
1149284Sbostic  *
12*63211Sbostic  *      @(#)bpfdesc.h	8.1 (Berkeley) 06/10/93
1349284Sbostic  *
1451426Smccanne  * @(#) $Header: bpfdesc.h,v 1.9 91/10/27 21:22:38 mccanne Exp $ (LBL)
1547639Smccanne  */
1647639Smccanne 
1747639Smccanne /*
1847639Smccanne  * Descriptor associated with each open bpf file.
1947639Smccanne  */
2047639Smccanne struct bpf_d {
2147639Smccanne 	struct bpf_d	*bd_next;	/* Linked list of descriptors */
2247639Smccanne 	/*
2347639Smccanne 	 * Buffer slots: two mbuf clusters buffer the incoming packets.
2447639Smccanne 	 *   The model has three slots.  Sbuf is always occupied.
2547639Smccanne 	 *   sbuf (store) - Receive interrupt puts packets here.
2647639Smccanne 	 *   hbuf (hold) - When sbuf is full, put cluster here and
2747639Smccanne 	 *                 wakeup read (replace sbuf with fbuf).
2847639Smccanne 	 *   fbuf (free) - When read is done, put cluster here.
2947639Smccanne 	 * On receiving, if sbuf is full and fbuf is 0, packet is dropped.
3047639Smccanne 	 */
3148933Smccanne 	caddr_t		bd_sbuf;	/* store slot */
3248933Smccanne 	caddr_t		bd_hbuf;	/* hold slot */
3348933Smccanne 	caddr_t		bd_fbuf;	/* free slot */
3448933Smccanne 	int 		bd_slen;	/* current length of store buffer */
3548933Smccanne 	int 		bd_hlen;	/* current length of hold buffer */
3647639Smccanne 
3748933Smccanne 	int		bd_bufsize;	/* absolute length of buffers */
3848933Smccanne 
3947639Smccanne 	struct bpf_if *	bd_bif;		/* interface descriptor */
4047639Smccanne 	u_long		bd_rtout;	/* Read timeout in 'ticks' */
4148933Smccanne 	struct bpf_insn *bd_filter; 	/* filter code */
4247639Smccanne 	u_long		bd_rcount;	/* number of packets received */
4347639Smccanne 	u_long		bd_dcount;	/* number of packets dropped */
4447639Smccanne 
4547639Smccanne 	u_char		bd_promisc;	/* true if listening promiscuously */
4647639Smccanne 	u_char		bd_state;	/* idle, waiting, or timed out */
4747639Smccanne 	u_char		bd_immediate;	/* true to return on packet arrival */
4851426Smccanne #if BSD < 199103
4953949Smccanne 	u_char		bd_selcoll;	/* true if selects collide */
5051426Smccanne 	int		bd_timedout;
5153949Smccanne 	struct proc *	bd_selproc;	/* process that last selected us */
5253949Smccanne #else
5353949Smccanne 	u_char		bd_pad;		/* explicit alignment */
5453949Smccanne 	struct selinfo	bd_sel;		/* bsd select info */
5551426Smccanne #endif
5647639Smccanne };
5747639Smccanne 
5847639Smccanne /*
5947639Smccanne  * Descriptor associated with each attached hardware interface.
6047639Smccanne  */
6147639Smccanne struct bpf_if {
6249199Smccanne 	struct bpf_if *bif_next;	/* list of all interfaces */
6349199Smccanne 	struct bpf_d *bif_dlist;	/* descriptor list */
6449199Smccanne 	struct bpf_if **bif_driverp;	/* pointer into softc */
6549199Smccanne 	u_int bif_dlt;			/* link layer type */
6649199Smccanne 	u_int bif_hdrlen;		/* length of header (with padding) */
6749199Smccanne 	struct ifnet *bif_ifp;		/* correspoding interface */
6847639Smccanne };
6961364Sbostic 
7061364Sbostic #ifdef KERNEL
7161364Sbostic int	 bpf_setf __P((struct bpf_d *, struct bpf_program *));
7261364Sbostic #endif
73