1*e7bed289Sriastradh /* $NetBSD: bpf_component.c,v 1.4 2022/03/28 12:33:22 riastradh Exp $ */
2fba5e42dSpooka
3fba5e42dSpooka /*
4fba5e42dSpooka * Copyright (c) 2010 Antti Kantee. All Rights Reserved.
5fba5e42dSpooka *
6fba5e42dSpooka * Redistribution and use in source and binary forms, with or without
7fba5e42dSpooka * modification, are permitted provided that the following conditions
8fba5e42dSpooka * are met:
9fba5e42dSpooka * 1. Redistributions of source code must retain the above copyright
10fba5e42dSpooka * notice, this list of conditions and the following disclaimer.
11fba5e42dSpooka * 2. Redistributions in binary form must reproduce the above copyright
12fba5e42dSpooka * notice, this list of conditions and the following disclaimer in the
13fba5e42dSpooka * documentation and/or other materials provided with the distribution.
14fba5e42dSpooka *
15fba5e42dSpooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16fba5e42dSpooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17fba5e42dSpooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18fba5e42dSpooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19fba5e42dSpooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20fba5e42dSpooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21fba5e42dSpooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22fba5e42dSpooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23fba5e42dSpooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24fba5e42dSpooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25fba5e42dSpooka * SUCH DAMAGE.
26fba5e42dSpooka */
27fba5e42dSpooka
28fba5e42dSpooka #include <sys/cdefs.h>
29*e7bed289Sriastradh __KERNEL_RCSID(0, "$NetBSD: bpf_component.c,v 1.4 2022/03/28 12:33:22 riastradh Exp $");
30fba5e42dSpooka
31fba5e42dSpooka #include <sys/param.h>
32fba5e42dSpooka #include <sys/conf.h>
33fba5e42dSpooka #include <sys/device.h>
34fba5e42dSpooka #include <sys/mbuf.h>
35fba5e42dSpooka #include <sys/stat.h>
36fba5e42dSpooka
37fba5e42dSpooka #include <net/bpf.h>
38fba5e42dSpooka
396bb51422Spooka #include <rump-sys/kern.h>
406bb51422Spooka #include <rump-sys/vfs.h>
41fba5e42dSpooka
RUMP_COMPONENT(RUMP_COMPONENT_NET)42fba5e42dSpooka RUMP_COMPONENT(RUMP_COMPONENT_NET)
43fba5e42dSpooka {
44fba5e42dSpooka extern const struct cdevsw bpf_cdevsw;
45fba5e42dSpooka devmajor_t bmaj, cmaj;
46fba5e42dSpooka int error;
47fba5e42dSpooka
48fba5e42dSpooka bmaj = cmaj = NODEVMAJOR;
49fba5e42dSpooka if ((error = devsw_attach("bpf", NULL, &bmaj, &bpf_cdevsw, &cmaj)) != 0)
50fba5e42dSpooka panic("bpf devsw attach failed: %d", error);
51fba5e42dSpooka if ((error = rump_vfs_makeonedevnode(S_IFCHR, "/dev/bpf", cmaj, 0)) !=0)
52fba5e42dSpooka panic("cannot create bpf device nodes: %d", error);
53*e7bed289Sriastradh devsw_detach(NULL, &bpf_cdevsw);
54fba5e42dSpooka }
55