xref: /csrg-svn/sys/net/bpfdesc.h (revision 49199)
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 	 */
4148933Smccanne 	caddr_t		bd_sbuf;	/* store slot */
4248933Smccanne 	caddr_t		bd_hbuf;	/* hold slot */
4348933Smccanne 	caddr_t		bd_fbuf;	/* free slot */
4448933Smccanne 	int 		bd_slen;	/* current length of store buffer */
4548933Smccanne 	int 		bd_hlen;	/* current length of hold buffer */
4647639Smccanne 
4748933Smccanne 	int		bd_bufsize;	/* absolute length of buffers */
4848933Smccanne 
4947639Smccanne 	struct bpf_if *	bd_bif;		/* interface descriptor */
5047639Smccanne 	u_long		bd_rtout;	/* Read timeout in 'ticks' */
5148933Smccanne 	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 */
5448933Smccanne 	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 */
5848933Smccanne 	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 {
66*49199Smccanne 	struct bpf_if *bif_next;	/* list of all interfaces */
67*49199Smccanne 	struct bpf_d *bif_dlist;	/* descriptor list */
68*49199Smccanne 	struct bpf_if **bif_driverp;	/* pointer into softc */
69*49199Smccanne 	u_int bif_dlt;			/* link layer type */
70*49199Smccanne 	u_int bif_hdrlen;		/* length of header (with padding) */
71*49199Smccanne 	struct ifnet *bif_ifp;		/* correspoding interface */
7247639Smccanne };
73