xref: /csrg-svn/sys/net/bpfdesc.h (revision 47639)
1*47639Smccanne /*
2*47639Smccanne  * Copyright (c) 1990 The Regents of the University of California.
3*47639Smccanne  * All rights reserved.
4*47639Smccanne  *
5*47639Smccanne  * Redistribution and use in source and binary forms, with or without
6*47639Smccanne  * modification, are permitted provided that: (1) source code distributions
7*47639Smccanne  * retain the above copyright notice and this paragraph in its entirety, (2)
8*47639Smccanne  * distributions including binary code include the above copyright notice and
9*47639Smccanne  * this paragraph in its entirety in the documentation or other materials
10*47639Smccanne  * provided with the distribution, and (3) all advertising materials mentioning
11*47639Smccanne  * features or use of this software display the following acknowledgement:
12*47639Smccanne  * ``This product includes software developed by the University of California,
13*47639Smccanne  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14*47639Smccanne  * the University nor the names of its contributors may be used to endorse
15*47639Smccanne  * or promote products derived from this software without specific prior
16*47639Smccanne  * written permission.
17*47639Smccanne  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18*47639Smccanne  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19*47639Smccanne  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20*47639Smccanne  *
21*47639Smccanne  * @(#) $Header: bpfdesc.h,v 1.7 90/12/04 01:05:01 mccanne Exp $ (LBL)
22*47639Smccanne  *
23*47639Smccanne  * This code is derived from the Stanford/CMU enet packet filter,
24*47639Smccanne  * (net/enetdefs.h) distributed in 4.3BSD Unix.
25*47639Smccanne  */
26*47639Smccanne 
27*47639Smccanne /*
28*47639Smccanne  * Descriptor associated with each open bpf file.
29*47639Smccanne  */
30*47639Smccanne struct bpf_d {
31*47639Smccanne 	struct bpf_d	*bd_next;	/* Linked list of descriptors */
32*47639Smccanne 	/*
33*47639Smccanne 	 * Buffer slots: two mbuf clusters buffer the incoming packets.
34*47639Smccanne 	 *   The model has three slots.  Sbuf is always occupied.
35*47639Smccanne 	 *   sbuf (store) - Receive interrupt puts packets here.
36*47639Smccanne 	 *   hbuf (hold) - When sbuf is full, put cluster here and
37*47639Smccanne 	 *                 wakeup read (replace sbuf with fbuf).
38*47639Smccanne 	 *   fbuf (free) - When read is done, put cluster here.
39*47639Smccanne 	 * On receiving, if sbuf is full and fbuf is 0, packet is dropped.
40*47639Smccanne 	 */
41*47639Smccanne 	struct mbuf *	bd_sbuf;	/* store slot */
42*47639Smccanne 	struct mbuf *	bd_hbuf;	/* hold slot */
43*47639Smccanne 	struct mbuf *	bd_fbuf;	/* free slot */
44*47639Smccanne 
45*47639Smccanne 	struct bpf_if *	bd_bif;		/* interface descriptor */
46*47639Smccanne 	u_long		bd_rtout;	/* Read timeout in 'ticks' */
47*47639Smccanne 	struct mbuf *	bd_filterm;	/* Packet filter mbuf */
48*47639Smccanne 	struct bpf_insn *bd_filter; 	/* precomputed pointer to fcode */
49*47639Smccanne 	u_long		bd_rcount;	/* number of packets received */
50*47639Smccanne 	u_long		bd_dcount;	/* number of packets dropped */
51*47639Smccanne 	struct proc *	bd_SelProc;	/* process that last selected us */
52*47639Smccanne 
53*47639Smccanne 	u_char		bd_promisc;	/* true if listening promiscuously */
54*47639Smccanne 	u_char		bd_state;	/* idle, waiting, or timed out */
55*47639Smccanne 	u_char		bd_SelColl;	/* true if selects collide */
56*47639Smccanne 	u_char		bd_immediate;	/* true to return on packet arrival */
57*47639Smccanne };
58*47639Smccanne 
59*47639Smccanne /*
60*47639Smccanne  * Descriptor associated with each attached hardware interface.
61*47639Smccanne  */
62*47639Smccanne struct bpf_if {
63*47639Smccanne 	/* List of descriptors listening on this interface. */
64*47639Smccanne 	struct bpf_d *bif_dlist;
65*47639Smccanne 
66*47639Smccanne 	/* Pointer to the device driver's softc bpf field. */
67*47639Smccanne 	struct bpf_if **bif_driverp;
68*47639Smccanne 
69*47639Smccanne 	/* Device parameters, see bpf.h. */
70*47639Smccanne 	struct bpf_devp bif_devp;
71*47639Smccanne 
72*47639Smccanne 	/* Length of bpf header (bpf_hdr + padding). */
73*47639Smccanne 	u_int bif_hdrlen;
74*47639Smccanne 
75*47639Smccanne 	/* 'ifnet' of associated interface. */
76*47639Smccanne 	struct ifnet *bif_ifp;
77*47639Smccanne };
78