diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/bpf.c | 85 | ||||
-rw-r--r-- | sys/net/bpf.h | 12 |
2 files changed, 45 insertions, 52 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 0b2183f51b1..7a447e1f6ac 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,5 +1,5 @@ -/* $OpenBSD: bpf.c,v 1.8 1997/02/12 03:35:11 deraadt Exp $ */ -/* $NetBSD: bpf.c,v 1.27 1996/05/07 05:26:02 thorpej Exp $ */ +/* $OpenBSD: bpf.c,v 1.9 1997/03/17 16:29:37 niklas Exp $ */ +/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* * Copyright (c) 1990, 1991, 1993 @@ -63,24 +63,24 @@ #include <sys/protosw.h> #include <sys/socket.h> +#include <sys/errno.h> +#include <sys/kernel.h> + #include <net/if.h> #include <net/bpf.h> #include <net/bpfdesc.h> -#include <sys/errno.h> - #include <netinet/in.h> #include <netinet/if_arc.h> #include <netinet/if_ether.h> -#include <sys/kernel.h> /* * Older BSDs don't have kernel malloc. */ #if BSD < 199103 extern bcopy(); -static caddr_t bpf_alloc(); +caddr_t bpf_alloc(); #include <net/bpf_compat.h> #define BPF_BUFSIZE (MCLBYTES-8) #define UIOMOVE(cp, len, code, uio) uiomove(cp, len, code, uio) @@ -103,29 +103,23 @@ int bpf_bufsize = BPF_BUFSIZE; struct bpf_if *bpf_iflist; struct bpf_d bpf_dtab[NBPFILTER]; -static int bpf_allocbufs __P((struct bpf_d *)); -static int bpf_allocbufs __P((struct bpf_d *)); -static void bpf_freed __P((struct bpf_d *)); -static void bpf_freed __P((struct bpf_d *)); -static void bpf_ifname __P((struct ifnet *, struct ifreq *)); -static void bpf_ifname __P((struct ifnet *, struct ifreq *)); -static void bpf_mcopy __P((const void *, void *, size_t)); -static int bpf_movein __P((struct uio *, int, - struct mbuf **, struct sockaddr *)); -static void bpf_attachd __P((struct bpf_d *, struct bpf_if *)); -static void bpf_detachd __P((struct bpf_d *)); -static int bpf_setif __P((struct bpf_d *, struct ifreq *)); -static int bpf_setif __P((struct bpf_d *, struct ifreq *)); +int bpf_allocbufs __P((struct bpf_d *)); +void bpf_freed __P((struct bpf_d *)); +void bpf_ifname __P((struct ifnet *, struct ifreq *)); +void bpf_mcopy __P((const void *, void *, size_t)); +int bpf_movein __P((struct uio *, int, struct mbuf **, struct sockaddr *)); +void bpf_attachd __P((struct bpf_d *, struct bpf_if *)); +void bpf_detachd __P((struct bpf_d *)); +int bpf_setif __P((struct bpf_d *, struct ifreq *)); #if BSD >= 199103 -int bpfselect __P((dev_t, int, struct proc *)); +int bpfselect __P((dev_t, int, struct proc *)); #endif -static __inline void - bpf_wakeup __P((struct bpf_d *)); -static void catchpacket __P((struct bpf_d *, u_char *, size_t, size_t, - void (*)(const void *, void *, size_t))); -static void reset_d __P((struct bpf_d *)); +static __inline void bpf_wakeup __P((struct bpf_d *)); +void bpf_catchpacket __P((struct bpf_d *, u_char *, size_t, size_t, + void (*)(const void *, void *, size_t))); +void bpf_reset_d __P((struct bpf_d *)); -static int +int bpf_movein(uio, linktype, mp, sockp) register struct uio *uio; int linktype; @@ -234,7 +228,7 @@ bpf_movein(uio, linktype, mp, sockp) * Attach file to the bpf interface, i.e. make d listen on bp. * Must be called at splimp. */ -static void +void bpf_attachd(d, bp) struct bpf_d *d; struct bpf_if *bp; @@ -254,7 +248,7 @@ bpf_attachd(d, bp) /* * Detach a file from its interface. */ -static void +void bpf_detachd(d) struct bpf_d *d; { @@ -386,7 +380,7 @@ bpfclose(dev, flag, mode, p) * Support for SunOS, which does not have tsleep. */ #if BSD < 199103 -static +int bpf_timeout(arg) caddr_t arg; { @@ -596,8 +590,8 @@ bpfwrite(dev, uio, ioflag) * Reset a descriptor by flushing its packet buffer and clearing the * receive and drop counts. Should be called at splimp. */ -static void -reset_d(d) +void +bpf_reset_d(d) struct bpf_d *d; { if (d->bd_hbuf) { @@ -701,7 +695,7 @@ bpfioctl(dev, cmd, addr, flag, p) */ case BIOCFLUSH: s = splimp(); - reset_d(d); + bpf_reset_d(d); splx(s); break; @@ -872,7 +866,7 @@ bpf_setf(d, fp) return (EINVAL); s = splimp(); d->bd_filter = 0; - reset_d(d); + bpf_reset_d(d); splx(s); if (old != 0) free((caddr_t)old, M_DEVBUF); @@ -888,7 +882,7 @@ bpf_setf(d, fp) bpf_validate(fcode, (int)flen)) { s = splimp(); d->bd_filter = fcode; - reset_d(d); + bpf_reset_d(d); splx(s); if (old != 0) free((caddr_t)old, M_DEVBUF); @@ -904,7 +898,7 @@ bpf_setf(d, fp) * to the interface indicated by the name stored in ifr. * Return an errno or 0. */ -static int +int bpf_setif(d, ifr) struct bpf_d *d; struct ifreq *ifr; @@ -970,7 +964,7 @@ bpf_setif(d, ifr) bpf_attachd(d, bp); } - reset_d(d); + bpf_reset_d(d); splx(s); return (0); } @@ -981,12 +975,11 @@ bpf_setif(d, ifr) /* * Copy the interface name to the ifreq. */ -static void +void bpf_ifname(ifp, ifr) struct ifnet *ifp; struct ifreq *ifr; { - bcopy(ifp->if_xname, ifr->ifr_name, IFNAMSIZ); } @@ -1080,7 +1073,7 @@ bpf_tap(arg, pkt, pktlen) ++d->bd_rcount; slen = bpf_filter(d->bd_filter, pkt, pktlen, pktlen); if (slen != 0) - catchpacket(d, pkt, pktlen, slen, bcopy); + bpf_catchpacket(d, pkt, pktlen, slen, bcopy); } } @@ -1088,7 +1081,7 @@ bpf_tap(arg, pkt, pktlen) * Copy data from an mbuf chain into a buffer. This code is derived * from m_copydata in sys/uipc_mbuf.c. */ -static void +void bpf_mcopy(src_arg, dst_arg, len) const void *src_arg; void *dst_arg; @@ -1132,7 +1125,7 @@ bpf_mtap(arg, m) ++d->bd_rcount; slen = bpf_filter(d->bd_filter, (u_char *)m, pktlen, 0); if (slen != 0) - catchpacket(d, (u_char *)m, pktlen, slen, bpf_mcopy); + bpf_catchpacket(d, (u_char *)m, pktlen, slen, bpf_mcopy); } } @@ -1144,8 +1137,8 @@ bpf_mtap(arg, m) * bpf_mcopy is passed in to copy mbuf chains. In the latter case, * pkt is really an mbuf. */ -static void -catchpacket(d, pkt, pktlen, snaplen, cpfn) +void +bpf_catchpacket(d, pkt, pktlen, snaplen, cpfn) register struct bpf_d *d; register u_char *pkt; register size_t pktlen, snaplen; @@ -1216,7 +1209,7 @@ catchpacket(d, pkt, pktlen, snaplen, cpfn) /* * Initialize all nonzero fields of a descriptor. */ -static int +int bpf_allocbufs(d) register struct bpf_d *d; { @@ -1238,7 +1231,7 @@ bpf_allocbufs(d) * Free buffers currently in use by a descriptor. * Called on close. */ -static void +void bpf_freed(d) register struct bpf_d *d; { @@ -1355,7 +1348,7 @@ ifpromisc(ifp, pswitch) * is admittedly a hack. * If resources unavaiable, return 0. */ -static caddr_t +caddr_t bpf_alloc(size, canwait) register int size; register int canwait; diff --git a/sys/net/bpf.h b/sys/net/bpf.h index 1c3417212ec..12b5e3281b6 100644 --- a/sys/net/bpf.h +++ b/sys/net/bpf.h @@ -1,5 +1,5 @@ -/* $OpenBSD: bpf.h,v 1.4 1996/07/12 07:57:41 mickey Exp $ */ -/* $NetBSD: bpf.h,v 1.14 1996/05/02 00:57:28 cgd Exp $ */ +/* $OpenBSD: bpf.h,v 1.5 1997/03/17 16:29:37 niklas Exp $ */ +/* $NetBSD: bpf.h,v 1.15 1996/12/13 07:57:33 mikel Exp $ */ /* * Copyright (c) 1990, 1991, 1993 @@ -50,11 +50,11 @@ typedef int32_t bpf_int32; typedef u_int32_t bpf_u_int32; /* - * Alignment macros. BPF_WORDALIGN rounds up to the next - * even multiple of BPF_ALIGNMENT. + * Alignment macros. BPF_WORDALIGN rounds up to the next even multiple of + * BPF_ALIGNMENT (which is at least as much as what a timeval needs). */ -#define BPF_ALIGNMENT sizeof(u_int32_t) -#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1)) +#define BPF_ALIGNMENT sizeof(long) +#define BPF_WORDALIGN(x) (((x) + (BPF_ALIGNMENT - 1)) & ~(BPF_ALIGNMENT - 1)) #define BPF_MAXINSNS 512 #define BPF_MAXBUFSIZE 0x8000 |