bpf.c (64880) | bpf.c (65374) |
---|---|
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 * $FreeBSD: head/sys/net/bpf.c 64880 2000-08-20 21:34:39Z phk $ | 40 * $FreeBSD: head/sys/net/bpf.c 65374 2000-09-02 19:17:34Z phk $ |
41 */ 42 43#include "bpf.h" | 41 */ 42 43#include "bpf.h" |
44#include "opt_devfs.h" | |
45 46#ifndef __GNUC__ 47#define inline 48#else 49#define inline __inline 50#endif 51 52#include <sys/param.h> --- 21 unchanged lines hidden (view full) --- 74#include <net/bpf.h> 75#include <net/bpfdesc.h> 76 77#include <netinet/in.h> 78#include <netinet/if_ether.h> 79#include <sys/kernel.h> 80#include <sys/sysctl.h> 81 | 44 45#ifndef __GNUC__ 46#define inline 47#else 48#define inline __inline 49#endif 50 51#include <sys/param.h> --- 21 unchanged lines hidden (view full) --- 73#include <net/bpf.h> 74#include <net/bpfdesc.h> 75 76#include <netinet/in.h> 77#include <netinet/if_ether.h> 78#include <sys/kernel.h> 79#include <sys/sysctl.h> 80 |
82#ifdef DEVFS 83#include <sys/eventhandler.h> 84#include <fs/devfs/devfs.h> 85#endif 86 | |
87MALLOC_DEFINE(M_BPF, "BPF", "BPF data"); 88 89#if NBPF > 0 90 91/* 92 * Older BSDs don't have kernel malloc. 93 */ 94#if BSD < 199103 --- 1263 unchanged lines hidden (view full) --- 1358 1359 free(bp, M_BPF); 1360 1361 splx(s); 1362} 1363 1364static void bpf_drvinit __P((void *unused)); 1365 | 81MALLOC_DEFINE(M_BPF, "BPF", "BPF data"); 82 83#if NBPF > 0 84 85/* 86 * Older BSDs don't have kernel malloc. 87 */ 88#if BSD < 199103 --- 1263 unchanged lines hidden (view full) --- 1352 1353 free(bp, M_BPF); 1354 1355 splx(s); 1356} 1357 1358static void bpf_drvinit __P((void *unused)); 1359 |
1366#ifdef DEVFS | |
1367static void bpf_clone __P((void *arg, char *name, int namelen, dev_t *dev)); 1368 1369static void 1370bpf_clone(arg, name, namelen, dev) 1371 void *arg; 1372 char *name; 1373 int namelen; 1374 dev_t *dev; 1375{ 1376 int u; 1377 1378 if (*dev != NODEV) 1379 return; | 1360static void bpf_clone __P((void *arg, char *name, int namelen, dev_t *dev)); 1361 1362static void 1363bpf_clone(arg, name, namelen, dev) 1364 void *arg; 1365 char *name; 1366 int namelen; 1367 dev_t *dev; 1368{ 1369 int u; 1370 1371 if (*dev != NODEV) 1372 return; |
1380 if (devfs_stdclone(name, NULL, "bpf", &u) != 1) | 1373 if (dev_stdclone(name, NULL, "bpf", &u) != 1) |
1381 return; 1382 /* XXX: minor encoding if u > 255 */ 1383 *dev = make_dev(&bpf_cdevsw, u, 0, 0, 0600, "bpf%d", u); 1384 return; 1385} | 1374 return; 1375 /* XXX: minor encoding if u > 255 */ 1376 *dev = make_dev(&bpf_cdevsw, u, 0, 0, 0600, "bpf%d", u); 1377 return; 1378} |
1386#endif | |
1387 1388static void 1389bpf_drvinit(unused) 1390 void *unused; 1391{ 1392 | 1379 1380static void 1381bpf_drvinit(unused) 1382 void *unused; 1383{ 1384 |
1393#ifdef DEVFS 1394 EVENTHANDLER_REGISTER(devfs_clone, bpf_clone, 0, 1000); 1395#else | 1385 EVENTHANDLER_REGISTER(dev_clone, bpf_clone, 0, 1000); |
1396 cdevsw_add(&bpf_cdevsw); | 1386 cdevsw_add(&bpf_cdevsw); |
1397#endif | |
1398} 1399 1400SYSINIT(bpfdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,bpf_drvinit,NULL) 1401 1402#else /* !BPF */ 1403/* 1404 * NOP stubs to allow bpf-using drivers to load and function. 1405 * --- 43 unchanged lines hidden --- | 1387} 1388 1389SYSINIT(bpfdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,bpf_drvinit,NULL) 1390 1391#else /* !BPF */ 1392/* 1393 * NOP stubs to allow bpf-using drivers to load and function. 1394 * --- 43 unchanged lines hidden --- |