Deleted Added
full compact
bpf.c (92260) bpf.c (92725)
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.4 (Berkeley) 1/9/95
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.4 (Berkeley) 1/9/95
39 *
40 * $FreeBSD: head/sys/net/bpf.c 92260 2002-03-14 04:47:08Z alfred $
40 * $FreeBSD: head/sys/net/bpf.c 92725 2002-03-19 21:54:18Z alfred $
41 */
42
43#include "opt_bpf.h"
44#include "opt_netgraph.h"
45
46#include <sys/param.h>
47#include <sys/systm.h>
48#include <sys/conf.h>

--- 38 unchanged lines hidden (view full) ---

87 &bpf_maxbufsize, 0, "");
88
89/*
90 * bpf_iflist is the list of interfaces; each corresponds to an ifnet
91 */
92static struct bpf_if *bpf_iflist;
93static struct mtx bpf_mtx; /* bpf global lock */
94
41 */
42
43#include "opt_bpf.h"
44#include "opt_netgraph.h"
45
46#include <sys/param.h>
47#include <sys/systm.h>
48#include <sys/conf.h>

--- 38 unchanged lines hidden (view full) ---

87 &bpf_maxbufsize, 0, "");
88
89/*
90 * bpf_iflist is the list of interfaces; each corresponds to an ifnet
91 */
92static struct bpf_if *bpf_iflist;
93static struct mtx bpf_mtx; /* bpf global lock */
94
95static int bpf_allocbufs __P((struct bpf_d *));
96static void bpf_attachd __P((struct bpf_d *d, struct bpf_if *bp));
97static void bpf_detachd __P((struct bpf_d *d));
98static void bpf_freed __P((struct bpf_d *));
99static void bpf_mcopy __P((const void *, void *, size_t));
100static int bpf_movein __P((struct uio *, int,
101 struct mbuf **, struct sockaddr *, int *));
102static int bpf_setif __P((struct bpf_d *, struct ifreq *));
103static void bpf_timed_out __P((void *));
95static int bpf_allocbufs(struct bpf_d *);
96static void bpf_attachd(struct bpf_d *d, struct bpf_if *bp);
97static void bpf_detachd(struct bpf_d *d);
98static void bpf_freed(struct bpf_d *);
99static void bpf_mcopy(const void *, void *, size_t);
100static int bpf_movein(struct uio *, int,
101 struct mbuf **, struct sockaddr *, int *);
102static int bpf_setif(struct bpf_d *, struct ifreq *);
103static void bpf_timed_out(void *);
104static __inline void
104static __inline void
105 bpf_wakeup __P((struct bpf_d *));
106static void catchpacket __P((struct bpf_d *, u_char *, u_int,
107 u_int, void (*)(const void *, void *, size_t)));
108static void reset_d __P((struct bpf_d *));
109static int bpf_setf __P((struct bpf_d *, struct bpf_program *));
105 bpf_wakeup(struct bpf_d *);
106static void catchpacket(struct bpf_d *, u_char *, u_int,
107 u_int, void (*)(const void *, void *, size_t));
108static void reset_d(struct bpf_d *);
109static int bpf_setf(struct bpf_d *, struct bpf_program *);
110
111static d_open_t bpfopen;
112static d_close_t bpfclose;
113static d_read_t bpfread;
114static d_write_t bpfwrite;
115static d_ioctl_t bpfioctl;
116static d_poll_t bpfpoll;
117

--- 1017 unchanged lines hidden (view full) ---

1135 * bpf_mcopy is passed in to copy mbuf chains. In the latter case,
1136 * pkt is really an mbuf.
1137 */
1138static void
1139catchpacket(d, pkt, pktlen, snaplen, cpfn)
1140 register struct bpf_d *d;
1141 register u_char *pkt;
1142 register u_int pktlen, snaplen;
110
111static d_open_t bpfopen;
112static d_close_t bpfclose;
113static d_read_t bpfread;
114static d_write_t bpfwrite;
115static d_ioctl_t bpfioctl;
116static d_poll_t bpfpoll;
117

--- 1017 unchanged lines hidden (view full) ---

1135 * bpf_mcopy is passed in to copy mbuf chains. In the latter case,
1136 * pkt is really an mbuf.
1137 */
1138static void
1139catchpacket(d, pkt, pktlen, snaplen, cpfn)
1140 register struct bpf_d *d;
1141 register u_char *pkt;
1142 register u_int pktlen, snaplen;
1143 register void (*cpfn) __P((const void *, void *, size_t));
1143 register void (*cpfn)(const void *, void *, size_t);
1144{
1145 register struct bpf_hdr *hp;
1146 register int totlen, curlen;
1147 register int hdrlen = d->bd_bif->bif_hdrlen;
1148 /*
1149 * Figure out how many bytes to move. If the packet is
1150 * greater or equal to the snapshot length, transfer that
1151 * much. Otherwise, transfer the whole packet (unless

--- 177 unchanged lines hidden (view full) ---

1329 }
1330
1331 mtx_destroy(&bp->bif_mtx);
1332 free(bp, M_BPF);
1333
1334 mtx_unlock(&bpf_mtx);
1335}
1336
1144{
1145 register struct bpf_hdr *hp;
1146 register int totlen, curlen;
1147 register int hdrlen = d->bd_bif->bif_hdrlen;
1148 /*
1149 * Figure out how many bytes to move. If the packet is
1150 * greater or equal to the snapshot length, transfer that
1151 * much. Otherwise, transfer the whole packet (unless

--- 177 unchanged lines hidden (view full) ---

1329 }
1330
1331 mtx_destroy(&bp->bif_mtx);
1332 free(bp, M_BPF);
1333
1334 mtx_unlock(&bpf_mtx);
1335}
1336
1337static void bpf_drvinit __P((void *unused));
1337static void bpf_drvinit(void *unused);
1338
1338
1339static void bpf_clone __P((void *arg, char *name, int namelen, dev_t *dev));
1339static void bpf_clone(void *arg, char *name, int namelen, dev_t *dev);
1340
1341static void
1342bpf_clone(arg, name, namelen, dev)
1343 void *arg;
1344 char *name;
1345 int namelen;
1346 dev_t *dev;
1347{

--- 79 unchanged lines hidden ---
1340
1341static void
1342bpf_clone(arg, name, namelen, dev)
1343 void *arg;
1344 char *name;
1345 int namelen;
1346 dev_t *dev;
1347{

--- 79 unchanged lines hidden ---