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