| 1 | /*- |
| 2 | * Copyright (c) 1991 The 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 of Lawrence Berkeley Laboratory. |
| 8 | * |
| 9 | * %sccs.include.redist.c% |
| 10 | * |
| 11 | * @(#)bpfdesc.h 7.1 (Berkeley) %G% |
| 12 | * |
| 13 | * @(#) $Header: bpfdesc.h,v 1.7 90/12/04 01:05:01 mccanne Exp $ (LBL) |
| 14 | */ |
| 15 | |
| 16 | /* |
| 17 | * Descriptor associated with each open bpf file. |
| 18 | */ |
| 19 | struct bpf_d { |
| 20 | struct bpf_d *bd_next; /* Linked list of descriptors */ |
| 21 | /* |
| 22 | * Buffer slots: two mbuf clusters buffer the incoming packets. |
| 23 | * The model has three slots. Sbuf is always occupied. |
| 24 | * sbuf (store) - Receive interrupt puts packets here. |
| 25 | * hbuf (hold) - When sbuf is full, put cluster here and |
| 26 | * wakeup read (replace sbuf with fbuf). |
| 27 | * fbuf (free) - When read is done, put cluster here. |
| 28 | * On receiving, if sbuf is full and fbuf is 0, packet is dropped. |
| 29 | */ |
| 30 | caddr_t bd_sbuf; /* store slot */ |
| 31 | caddr_t bd_hbuf; /* hold slot */ |
| 32 | caddr_t bd_fbuf; /* free slot */ |
| 33 | int bd_slen; /* current length of store buffer */ |
| 34 | int bd_hlen; /* current length of hold buffer */ |
| 35 | |
| 36 | int bd_bufsize; /* absolute length of buffers */ |
| 37 | |
| 38 | struct bpf_if * bd_bif; /* interface descriptor */ |
| 39 | u_long bd_rtout; /* Read timeout in 'ticks' */ |
| 40 | struct bpf_insn *bd_filter; /* filter code */ |
| 41 | u_long bd_rcount; /* number of packets received */ |
| 42 | u_long bd_dcount; /* number of packets dropped */ |
| 43 | struct proc * bd_selproc; /* process that last selected us */ |
| 44 | |
| 45 | u_char bd_promisc; /* true if listening promiscuously */ |
| 46 | u_char bd_state; /* idle, waiting, or timed out */ |
| 47 | u_char bd_selcoll; /* true if selects collide */ |
| 48 | u_char bd_immediate; /* true to return on packet arrival */ |
| 49 | }; |
| 50 | |
| 51 | /* |
| 52 | * Descriptor associated with each attached hardware interface. |
| 53 | */ |
| 54 | struct bpf_if { |
| 55 | struct bpf_if *bif_next; /* list of all interfaces */ |
| 56 | struct bpf_d *bif_dlist; /* descriptor list */ |
| 57 | struct bpf_if **bif_driverp; /* pointer into softc */ |
| 58 | u_int bif_dlt; /* link layer type */ |
| 59 | u_int bif_hdrlen; /* length of header (with padding) */ |
| 60 | struct ifnet *bif_ifp; /* correspoding interface */ |
| 61 | }; |