Use cloning bpf.
This commit is contained in:
parent
fb5ec6aa33
commit
c438716d36
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: pf.c,v 1.9 2004/04/10 17:53:05 darrenr Exp $ */
|
/* $NetBSD: pf.c,v 1.10 2004/12/01 23:15:08 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
|
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
|
||||||
|
@ -35,11 +35,12 @@
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
__RCSID("$NetBSD: pf.c,v 1.9 2004/04/10 17:53:05 darrenr Exp $");
|
__RCSID("$NetBSD: pf.c,v 1.10 2004/12/01 23:15:08 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
|
#include <paths.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <net/bpf.h>
|
#include <net/bpf.h>
|
||||||
|
|
||||||
|
@ -77,12 +78,11 @@ pfInit(interface, mode, protocol, typ)
|
||||||
int typ, mode;
|
int typ, mode;
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int n = 0;
|
|
||||||
char device[sizeof "/dev/bpf000"];
|
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
u_int dlt;
|
u_int dlt;
|
||||||
int immediate;
|
int immediate;
|
||||||
u_int bufsize;
|
u_int bufsize;
|
||||||
|
const char *device = _PATH_BPF;
|
||||||
|
|
||||||
static struct bpf_insn insns[] = {
|
static struct bpf_insn insns[] = {
|
||||||
BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12),
|
BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12),
|
||||||
|
@ -99,12 +99,7 @@ pfInit(interface, mode, protocol, typ)
|
||||||
insns
|
insns
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Go through all the minors and find one that isn't in use. */
|
fd = open(device, mode);
|
||||||
do {
|
|
||||||
(void) snprintf(device, sizeof(device), "/dev/bpf%d", n++);
|
|
||||||
fd = open(device, mode);
|
|
||||||
} while (fd < 0 && errno == EBUSY);
|
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
mopLogWarn("pfInit: open %s", device);
|
mopLogWarn("pfInit: open %s", device);
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
Loading…
Reference in New Issue