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 */ 30 struct 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 */ 41 struct mbuf * bd_sbuf; /* store slot */ 42 struct mbuf * bd_hbuf; /* hold slot */ 43 struct mbuf * bd_fbuf; /* free slot */ 44 45 struct bpf_if * bd_bif; /* interface descriptor */ 46 u_long bd_rtout; /* Read timeout in 'ticks' */ 47 struct mbuf * bd_filterm; /* Packet filter mbuf */ 48 struct bpf_insn *bd_filter; /* precomputed pointer to fcode */ 49 u_long bd_rcount; /* number of packets received */ 50 u_long bd_dcount; /* number of packets dropped */ 51 struct proc * bd_SelProc; /* process that last selected us */ 52 53 u_char bd_promisc; /* true if listening promiscuously */ 54 u_char bd_state; /* idle, waiting, or timed out */ 55 u_char bd_SelColl; /* true if selects collide */ 56 u_char bd_immediate; /* true to return on packet arrival */ 57 }; 58 59 /* 60 * Descriptor associated with each attached hardware interface. 61 */ 62 struct bpf_if { 63 /* List of descriptors listening on this interface. */ 64 struct bpf_d *bif_dlist; 65 66 /* Pointer to the device driver's softc bpf field. */ 67 struct bpf_if **bif_driverp; 68 69 /* Device parameters, see bpf.h. */ 70 struct bpf_devp bif_devp; 71 72 /* Length of bpf header (bpf_hdr + padding). */ 73 u_int bif_hdrlen; 74 75 /* 'ifnet' of associated interface. */ 76 struct ifnet *bif_ifp; 77 }; 78