xref: /original-bsd/sys/net/bpfdesc.h (revision c3e32dec)
1 /*
2  * Copyright (c) 1990, 1991 Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from the Stanford/CMU enet packet filter,
6  * (net/enet.c) distributed as part of 4.3BSD, and code contributed
7  * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
8  * Berkeley Laboratory.
9  *
10  * %sccs.include.redist.c%
11  *
12  *      @(#)bpfdesc.h	7.6 (Berkeley) 06/04/93
13  *
14  * @(#) $Header: bpfdesc.h,v 1.9 91/10/27 21:22:38 mccanne Exp $ (LBL)
15  */
16 
17 /*
18  * Descriptor associated with each open bpf file.
19  */
20 struct bpf_d {
21 	struct bpf_d	*bd_next;	/* Linked list of descriptors */
22 	/*
23 	 * Buffer slots: two mbuf clusters buffer the incoming packets.
24 	 *   The model has three slots.  Sbuf is always occupied.
25 	 *   sbuf (store) - Receive interrupt puts packets here.
26 	 *   hbuf (hold) - When sbuf is full, put cluster here and
27 	 *                 wakeup read (replace sbuf with fbuf).
28 	 *   fbuf (free) - When read is done, put cluster here.
29 	 * On receiving, if sbuf is full and fbuf is 0, packet is dropped.
30 	 */
31 	caddr_t		bd_sbuf;	/* store slot */
32 	caddr_t		bd_hbuf;	/* hold slot */
33 	caddr_t		bd_fbuf;	/* free slot */
34 	int 		bd_slen;	/* current length of store buffer */
35 	int 		bd_hlen;	/* current length of hold buffer */
36 
37 	int		bd_bufsize;	/* absolute length of buffers */
38 
39 	struct bpf_if *	bd_bif;		/* interface descriptor */
40 	u_long		bd_rtout;	/* Read timeout in 'ticks' */
41 	struct bpf_insn *bd_filter; 	/* filter code */
42 	u_long		bd_rcount;	/* number of packets received */
43 	u_long		bd_dcount;	/* number of packets dropped */
44 
45 	u_char		bd_promisc;	/* true if listening promiscuously */
46 	u_char		bd_state;	/* idle, waiting, or timed out */
47 	u_char		bd_immediate;	/* true to return on packet arrival */
48 #if BSD < 199103
49 	u_char		bd_selcoll;	/* true if selects collide */
50 	int		bd_timedout;
51 	struct proc *	bd_selproc;	/* process that last selected us */
52 #else
53 	u_char		bd_pad;		/* explicit alignment */
54 	struct selinfo	bd_sel;		/* bsd select info */
55 #endif
56 };
57 
58 /*
59  * Descriptor associated with each attached hardware interface.
60  */
61 struct bpf_if {
62 	struct bpf_if *bif_next;	/* list of all interfaces */
63 	struct bpf_d *bif_dlist;	/* descriptor list */
64 	struct bpf_if **bif_driverp;	/* pointer into softc */
65 	u_int bif_dlt;			/* link layer type */
66 	u_int bif_hdrlen;		/* length of header (with padding) */
67 	struct ifnet *bif_ifp;		/* correspoding interface */
68 };
69 
70 #ifdef KERNEL
71 int	 bpf_setf __P((struct bpf_d *, struct bpf_program *));
72 #endif
73