1*58bf2198Sozaki-r /* $NetBSD: altq_component.c,v 1.1 2021/07/14 03:19:24 ozaki-r Exp $ */
2*58bf2198Sozaki-r
3*58bf2198Sozaki-r /*
4*58bf2198Sozaki-r * Copyright (c) 2019 Internet Initiative Japan Inc.
5*58bf2198Sozaki-r * All rights reserved.
6*58bf2198Sozaki-r *
7*58bf2198Sozaki-r * Redistribution and use in source and binary forms, with or without
8*58bf2198Sozaki-r * modification, are permitted provided that the following conditions
9*58bf2198Sozaki-r * are met:
10*58bf2198Sozaki-r * 1. Redistributions of source code must retain the above copyright
11*58bf2198Sozaki-r * notice, this list of conditions and the following disclaimer.
12*58bf2198Sozaki-r * 2. Redistributions in binary form must reproduce the above copyright
13*58bf2198Sozaki-r * notice, this list of conditions and the following disclaimer in the
14*58bf2198Sozaki-r * documentation and/or other materials provided with the distribution.
15*58bf2198Sozaki-r *
16*58bf2198Sozaki-r * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
17*58bf2198Sozaki-r * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18*58bf2198Sozaki-r * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19*58bf2198Sozaki-r * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20*58bf2198Sozaki-r * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21*58bf2198Sozaki-r * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22*58bf2198Sozaki-r * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23*58bf2198Sozaki-r * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24*58bf2198Sozaki-r * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*58bf2198Sozaki-r * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*58bf2198Sozaki-r * SUCH DAMAGE.
27*58bf2198Sozaki-r */
28*58bf2198Sozaki-r
29*58bf2198Sozaki-r #include <sys/cdefs.h>
30*58bf2198Sozaki-r __KERNEL_RCSID(0, "$NetBSD: altq_component.c,v 1.1 2021/07/14 03:19:24 ozaki-r Exp $");
31*58bf2198Sozaki-r
32*58bf2198Sozaki-r #include <sys/param.h>
33*58bf2198Sozaki-r #include <sys/stat.h>
34*58bf2198Sozaki-r #include <sys/filedesc.h>
35*58bf2198Sozaki-r
36*58bf2198Sozaki-r #include <sys/vfs_syscalls.h>
37*58bf2198Sozaki-r
38*58bf2198Sozaki-r #include <net/if.h>
39*58bf2198Sozaki-r
40*58bf2198Sozaki-r #include <altq/altq.h>
41*58bf2198Sozaki-r
42*58bf2198Sozaki-r #include <rump-sys/kern.h>
43*58bf2198Sozaki-r #include <rump-sys/vfs.h>
44*58bf2198Sozaki-r
45*58bf2198Sozaki-r static void
create_altq_devs(void)46*58bf2198Sozaki-r create_altq_devs(void)
47*58bf2198Sozaki-r {
48*58bf2198Sozaki-r extern const struct cdevsw altq_cdevsw;
49*58bf2198Sozaki-r devmajor_t bmajor = NODEVMAJOR, cmajor = NODEVMAJOR;
50*58bf2198Sozaki-r int error;
51*58bf2198Sozaki-r
52*58bf2198Sozaki-r error = devsw_attach("altq", NULL, &bmajor,
53*58bf2198Sozaki-r &altq_cdevsw, &cmajor);
54*58bf2198Sozaki-r if (error != 0)
55*58bf2198Sozaki-r panic("altq devsw attach failed: %d", error);
56*58bf2198Sozaki-r
57*58bf2198Sozaki-r do_sys_mkdir("/dev/altq", 0755, UIO_SYSSPACE);
58*58bf2198Sozaki-r
59*58bf2198Sozaki-r error = rump_vfs_makeonedevnode(S_IFCHR, "/dev/altq/altq", cmajor, 0);
60*58bf2198Sozaki-r if (error != 0)
61*58bf2198Sozaki-r panic("cannot create altq device node: %d", error);
62*58bf2198Sozaki-r
63*58bf2198Sozaki-r error = rump_vfs_makeonedevnode(S_IFCHR, "/dev/altq/cbq", cmajor, ALTQT_CBQ);
64*58bf2198Sozaki-r if (error != 0)
65*58bf2198Sozaki-r panic("cannot create altq/cbq device node: %d", error);
66*58bf2198Sozaki-r }
67*58bf2198Sozaki-r
RUMP_COMPONENT(RUMP_COMPONENT_NET_IF)68*58bf2198Sozaki-r RUMP_COMPONENT(RUMP_COMPONENT_NET_IF)
69*58bf2198Sozaki-r {
70*58bf2198Sozaki-r
71*58bf2198Sozaki-r create_altq_devs();
72*58bf2198Sozaki-r }
73