147639Smccanne /* 247639Smccanne * Copyright (c) 1990 The Regents of the University of California. 347639Smccanne * All rights reserved. 447639Smccanne * 547639Smccanne * Redistribution and use in source and binary forms, with or without 647639Smccanne * modification, are permitted provided that: (1) source code distributions 747639Smccanne * retain the above copyright notice and this paragraph in its entirety, (2) 847639Smccanne * distributions including binary code include the above copyright notice and 947639Smccanne * this paragraph in its entirety in the documentation or other materials 1047639Smccanne * provided with the distribution, and (3) all advertising materials mentioning 1147639Smccanne * features or use of this software display the following acknowledgement: 1247639Smccanne * ``This product includes software developed by the University of California, 1347639Smccanne * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 1447639Smccanne * the University nor the names of its contributors may be used to endorse 1547639Smccanne * or promote products derived from this software without specific prior 1647639Smccanne * written permission. 1747639Smccanne * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 1847639Smccanne * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 1947639Smccanne * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 2047639Smccanne * 2147639Smccanne * @(#) $Header: bpfdesc.h,v 1.7 90/12/04 01:05:01 mccanne Exp $ (LBL) 2247639Smccanne * 2347639Smccanne * This code is derived from the Stanford/CMU enet packet filter, 2447639Smccanne * (net/enetdefs.h) distributed in 4.3BSD Unix. 2547639Smccanne */ 2647639Smccanne 2747639Smccanne /* 2847639Smccanne * Descriptor associated with each open bpf file. 2947639Smccanne */ 3047639Smccanne struct bpf_d { 3147639Smccanne struct bpf_d *bd_next; /* Linked list of descriptors */ 3247639Smccanne /* 3347639Smccanne * Buffer slots: two mbuf clusters buffer the incoming packets. 3447639Smccanne * The model has three slots. Sbuf is always occupied. 3547639Smccanne * sbuf (store) - Receive interrupt puts packets here. 3647639Smccanne * hbuf (hold) - When sbuf is full, put cluster here and 3747639Smccanne * wakeup read (replace sbuf with fbuf). 3847639Smccanne * fbuf (free) - When read is done, put cluster here. 3947639Smccanne * On receiving, if sbuf is full and fbuf is 0, packet is dropped. 4047639Smccanne */ 41*48933Smccanne caddr_t bd_sbuf; /* store slot */ 42*48933Smccanne caddr_t bd_hbuf; /* hold slot */ 43*48933Smccanne caddr_t bd_fbuf; /* free slot */ 44*48933Smccanne int bd_slen; /* current length of store buffer */ 45*48933Smccanne int bd_hlen; /* current length of hold buffer */ 4647639Smccanne 47*48933Smccanne int bd_bufsize; /* absolute length of buffers */ 48*48933Smccanne 4947639Smccanne struct bpf_if * bd_bif; /* interface descriptor */ 5047639Smccanne u_long bd_rtout; /* Read timeout in 'ticks' */ 51*48933Smccanne struct bpf_insn *bd_filter; /* filter code */ 5247639Smccanne u_long bd_rcount; /* number of packets received */ 5347639Smccanne u_long bd_dcount; /* number of packets dropped */ 54*48933Smccanne struct proc * bd_selproc; /* process that last selected us */ 5547639Smccanne 5647639Smccanne u_char bd_promisc; /* true if listening promiscuously */ 5747639Smccanne u_char bd_state; /* idle, waiting, or timed out */ 58*48933Smccanne u_char bd_selcoll; /* true if selects collide */ 5947639Smccanne u_char bd_immediate; /* true to return on packet arrival */ 6047639Smccanne }; 6147639Smccanne 6247639Smccanne /* 6347639Smccanne * Descriptor associated with each attached hardware interface. 6447639Smccanne */ 6547639Smccanne struct bpf_if { 6647639Smccanne /* List of descriptors listening on this interface. */ 6747639Smccanne struct bpf_d *bif_dlist; 6847639Smccanne 6947639Smccanne /* Pointer to the device driver's softc bpf field. */ 7047639Smccanne struct bpf_if **bif_driverp; 7147639Smccanne 7247639Smccanne /* Device parameters, see bpf.h. */ 7347639Smccanne struct bpf_devp bif_devp; 7447639Smccanne 7547639Smccanne /* Length of bpf header (bpf_hdr + padding). */ 7647639Smccanne u_int bif_hdrlen; 7747639Smccanne 7847639Smccanne /* 'ifnet' of associated interface. */ 7947639Smccanne struct ifnet *bif_ifp; 8047639Smccanne }; 81