bpf.c (12678) | bpf.c (12820) |
---|---|
1/* 2 * Copyright (c) 1990, 1991, 1993 3 * The Regents of the University of California. 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 and Van Jacobson both of Lawrence 8 * Berkeley Laboratory. --- 23 unchanged lines hidden (view full) --- 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)bpf.c 8.2 (Berkeley) 3/28/94 39 * | 1/* 2 * Copyright (c) 1990, 1991, 1993 3 * The Regents of the University of California. 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 and Van Jacobson both of Lawrence 8 * Berkeley Laboratory. --- 23 unchanged lines hidden (view full) --- 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)bpf.c 8.2 (Berkeley) 3/28/94 39 * |
40 * $Id: bpf.c,v 1.19 1995/12/08 11:18:01 julian Exp $ | 40 * $Id: bpf.c,v 1.20 1995/12/08 23:21:46 phk Exp $ |
41 */ 42 43#include "bpfilter.h" 44 45#if NBPFILTER > 0 46 47#ifndef __GNUC__ 48#define inline --- 26 unchanged lines hidden (view full) --- 75#include <net/bpf.h> 76#include <net/bpfdesc.h> 77 78#include <sys/errno.h> 79 80#include <netinet/in.h> 81#include <netinet/if_ether.h> 82#include <sys/kernel.h> | 41 */ 42 43#include "bpfilter.h" 44 45#if NBPFILTER > 0 46 47#ifndef __GNUC__ 48#define inline --- 26 unchanged lines hidden (view full) --- 75#include <net/bpf.h> 76#include <net/bpfdesc.h> 77 78#include <sys/errno.h> 79 80#include <netinet/in.h> 81#include <netinet/if_ether.h> 82#include <sys/kernel.h> |
83#include <sys/sysctl.h> |
|
83#include <sys/conf.h> 84#ifdef DEVFS 85#include <sys/devfsext.h> 86#endif /*DEVFS*/ 87 88 89/* 90 * Older BSDs don't have kernel malloc. --- 9 unchanged lines hidden (view full) --- 100#define UIOMOVE(cp, len, code, uio) uiomove(cp, len, uio) 101#endif 102 103#define PRINET 26 /* interruptible */ 104 105/* 106 * The default read buffer size is patchable. 107 */ | 84#include <sys/conf.h> 85#ifdef DEVFS 86#include <sys/devfsext.h> 87#endif /*DEVFS*/ 88 89 90/* 91 * Older BSDs don't have kernel malloc. --- 9 unchanged lines hidden (view full) --- 101#define UIOMOVE(cp, len, code, uio) uiomove(cp, len, uio) 102#endif 103 104#define PRINET 26 /* interruptible */ 105 106/* 107 * The default read buffer size is patchable. 108 */ |
108int bpf_bufsize = BPF_BUFSIZE; | 109static int bpf_bufsize = BPF_BUFSIZE; 110SYSCTL_INT(_debug, OID_AUTO, bpf_bufsize, CTLFLAG_RW, 111 &bpf_bufsize, 0, ""); |
109 110/* 111 * bpf_iflist is the list of interfaces; each corresponds to an ifnet 112 * bpf_dtab holds the descriptors, indexed by minor device # 113 */ | 112 113/* 114 * bpf_iflist is the list of interfaces; each corresponds to an ifnet 115 * bpf_dtab holds the descriptors, indexed by minor device # 116 */ |
114struct bpf_if *bpf_iflist; 115struct bpf_d bpf_dtab[NBPFILTER]; | 117static struct bpf_if *bpf_iflist; 118static struct bpf_d bpf_dtab[NBPFILTER]; |
116 | 119 |
117#if BSD >= 199207 118/* 119 * bpfilterattach() is called at boot time in new systems. We do 120 * nothing here since old systems will not call this. 121 */ 122/* ARGSUSED */ 123void 124bpfilterattach(n) 125 int n; 126{ 127} 128#endif 129 | |
130static int bpf_allocbufs __P((struct bpf_d *)); 131static void bpf_attachd __P((struct bpf_d *d, struct bpf_if *bp)); 132static void bpf_detachd __P((struct bpf_d *d)); 133static void bpf_freed __P((struct bpf_d *)); 134static void bpf_ifname __P((struct ifnet *, struct ifreq *)); 135static void bpf_mcopy __P((const void *, void *, u_int)); 136static int bpf_movein __P((struct uio *, int, 137 struct mbuf **, struct sockaddr *, int *)); 138static int bpf_setif __P((struct bpf_d *, struct ifreq *)); 139static inline void 140 bpf_wakeup __P((struct bpf_d *)); 141static void catchpacket __P((struct bpf_d *, u_char *, u_int, 142 u_int, void (*)(const void *, void *, u_int))); 143static void reset_d __P((struct bpf_d *)); | 120static int bpf_allocbufs __P((struct bpf_d *)); 121static void bpf_attachd __P((struct bpf_d *d, struct bpf_if *bp)); 122static void bpf_detachd __P((struct bpf_d *d)); 123static void bpf_freed __P((struct bpf_d *)); 124static void bpf_ifname __P((struct ifnet *, struct ifreq *)); 125static void bpf_mcopy __P((const void *, void *, u_int)); 126static int bpf_movein __P((struct uio *, int, 127 struct mbuf **, struct sockaddr *, int *)); 128static int bpf_setif __P((struct bpf_d *, struct ifreq *)); 129static inline void 130 bpf_wakeup __P((struct bpf_d *)); 131static void catchpacket __P((struct bpf_d *, u_char *, u_int, 132 u_int, void (*)(const void *, void *, u_int))); 133static void reset_d __P((struct bpf_d *)); |
134static int bpf_setf __P((struct bpf_d *, struct bpf_program *)); |
|
144 145static d_open_t bpfopen; 146static d_close_t bpfclose; 147static d_read_t bpfread; 148static d_write_t bpfwrite; 149static d_ioctl_t bpfioctl; 150static d_select_t bpfselect; 151 --- 718 unchanged lines hidden (view full) --- 870 } 871 return (error); 872} 873 874/* 875 * Set d's packet filter program to fp. If this file already has a filter, 876 * free it and replace it. Returns EINVAL for bogus requests. 877 */ | 135 136static d_open_t bpfopen; 137static d_close_t bpfclose; 138static d_read_t bpfread; 139static d_write_t bpfwrite; 140static d_ioctl_t bpfioctl; 141static d_select_t bpfselect; 142 --- 718 unchanged lines hidden (view full) --- 861 } 862 return (error); 863} 864 865/* 866 * Set d's packet filter program to fp. If this file already has a filter, 867 * free it and replace it. Returns EINVAL for bogus requests. 868 */ |
878int | 869static int |
879bpf_setf(d, fp) 880 struct bpf_d *d; 881 struct bpf_program *fp; 882{ 883 struct bpf_insn *fcode, *old; 884 u_int flen, size; 885 int s; 886 --- 477 unchanged lines hidden --- | 870bpf_setf(d, fp) 871 struct bpf_d *d; 872 struct bpf_program *fp; 873{ 874 struct bpf_insn *fcode, *old; 875 u_int flen, size; 876 int s; 877 --- 477 unchanged lines hidden --- |