net_inet6_nd_90.c revision 1.1 1 1.1 pgoyette /* $NetBSD: net_inet6_nd_90.c,v 1.1 2023/12/09 15:21:01 pgoyette Exp $ */
2 1.1 pgoyette
3 1.1 pgoyette /* $NetBSD: net_inet6_nd_90.c,v 1.1 2023/12/09 15:21:01 pgoyette Exp $ */
4 1.1 pgoyette /* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */
5 1.1 pgoyette
6 1.1 pgoyette /*
7 1.1 pgoyette * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
8 1.1 pgoyette * All rights reserved.
9 1.1 pgoyette *
10 1.1 pgoyette * Redistribution and use in source and binary forms, with or without
11 1.1 pgoyette * modification, are permitted provided that the following conditions
12 1.1 pgoyette * are met:
13 1.1 pgoyette * 1. Redistributions of source code must retain the above copyright
14 1.1 pgoyette * notice, this list of conditions and the following disclaimer.
15 1.1 pgoyette * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 pgoyette * notice, this list of conditions and the following disclaimer in the
17 1.1 pgoyette * documentation and/or other materials provided with the distribution.
18 1.1 pgoyette * 3. Neither the name of the project nor the names of its contributors
19 1.1 pgoyette * may be used to endorse or promote products derived from this software
20 1.1 pgoyette * without specific prior written permission.
21 1.1 pgoyette *
22 1.1 pgoyette * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
23 1.1 pgoyette * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.1 pgoyette * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.1 pgoyette * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
26 1.1 pgoyette * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.1 pgoyette * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.1 pgoyette * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 pgoyette * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.1 pgoyette * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.1 pgoyette * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 pgoyette * SUCH DAMAGE.
33 1.1 pgoyette */
34 1.1 pgoyette
35 1.1 pgoyette #include <sys/cdefs.h>
36 1.1 pgoyette __KERNEL_RCSID(0, "$NetBSD: net_inet6_nd_90.c,v 1.1 2023/12/09 15:21:01 pgoyette Exp $");
37 1.1 pgoyette
38 1.1 pgoyette #if defined(_KERNEL_OPT)
39 1.1 pgoyette #include "opt_compat_netbsd.h"
40 1.1 pgoyette #endif
41 1.1 pgoyette
42 1.1 pgoyette #include <sys/param.h>
43 1.1 pgoyette #include <sys/systm.h>
44 1.1 pgoyette #include <sys/namei.h>
45 1.1 pgoyette #include <sys/filedesc.h>
46 1.1 pgoyette #include <sys/kernel.h>
47 1.1 pgoyette #include <sys/sysctl.h>
48 1.1 pgoyette
49 1.1 pgoyette #include <net/if.h>
50 1.1 pgoyette
51 1.1 pgoyette #include <netinet/in.h>
52 1.1 pgoyette
53 1.1 pgoyette #include <netinet/icmp6.h>
54 1.1 pgoyette #include <netinet/ip6.h>
55 1.1 pgoyette
56 1.1 pgoyette #include <netinet6/in6_var.h>
57 1.1 pgoyette #include <netinet6/nd6.h>
58 1.1 pgoyette
59 1.1 pgoyette #include <sys/compat_stub.h>
60 1.1 pgoyette
61 1.1 pgoyette #include <compat/common/compat_mod.h>
62 1.1 pgoyette
63 1.1 pgoyette static struct sysctllog *nd6_clog;
64 1.1 pgoyette
65 1.1 pgoyette /*
66 1.1 pgoyette * sysctl helper routine for the net.inet6.icmp6.nd6 nodes. silly?
67 1.1 pgoyette */
68 1.1 pgoyette static int
69 1.1 pgoyette sysctl_net_inet6_icmp6_nd6(SYSCTLFN_ARGS)
70 1.1 pgoyette {
71 1.1 pgoyette (void)&name;
72 1.1 pgoyette (void)&l;
73 1.1 pgoyette (void)&oname;
74 1.1 pgoyette
75 1.1 pgoyette if (namelen != 0)
76 1.1 pgoyette return (EINVAL);
77 1.1 pgoyette
78 1.1 pgoyette return (nd6_sysctl(rnode->sysctl_num, oldp, oldlenp,
79 1.1 pgoyette /*XXXUNCONST*/
80 1.1 pgoyette __UNCONST(newp), newlen));
81 1.1 pgoyette }
82 1.1 pgoyette int real_net_inet6_nd_90(int);
83 1.1 pgoyette
84 1.1 pgoyette /*
85 1.1 pgoyette * the hook is only called for valid codes, so the mere presence
86 1.1 pgoyette * of the hook means success.
87 1.1 pgoyette */
88 1.1 pgoyette /* ARGSUSED */
89 1.1 pgoyette int
90 1.1 pgoyette real_net_inet6_nd_90(int name)
91 1.1 pgoyette {
92 1.1 pgoyette
93 1.1 pgoyette return 0;
94 1.1 pgoyette }
95 1.1 pgoyette
96 1.1 pgoyette int
97 1.1 pgoyette net_inet6_nd_90_init(void)
98 1.1 pgoyette {
99 1.1 pgoyette int error;
100 1.1 pgoyette
101 1.1 pgoyette error = sysctl_createv(&nd6_clog, 0, NULL, NULL,
102 1.1 pgoyette CTLFLAG_PERMANENT,
103 1.1 pgoyette CTLTYPE_STRUCT, "nd6_drlist",
104 1.1 pgoyette SYSCTL_DESCR("Default router list"),
105 1.1 pgoyette sysctl_net_inet6_icmp6_nd6, 0, NULL, 0,
106 1.1 pgoyette CTL_NET, PF_INET6, IPPROTO_ICMPV6,
107 1.1 pgoyette OICMPV6CTL_ND6_DRLIST, CTL_EOL);
108 1.1 pgoyette if (error != 0)
109 1.1 pgoyette return error;
110 1.1 pgoyette
111 1.1 pgoyette error = sysctl_createv(&nd6_clog, 0, NULL, NULL,
112 1.1 pgoyette CTLFLAG_PERMANENT,
113 1.1 pgoyette CTLTYPE_STRUCT, "nd6_prlist",
114 1.1 pgoyette SYSCTL_DESCR("Prefix list"),
115 1.1 pgoyette sysctl_net_inet6_icmp6_nd6, 0, NULL, 0,
116 1.1 pgoyette CTL_NET, PF_INET6, IPPROTO_ICMPV6,
117 1.1 pgoyette OICMPV6CTL_ND6_PRLIST, CTL_EOL);
118 1.1 pgoyette
119 1.1 pgoyette MODULE_HOOK_SET(net_inet6_nd_90_hook, real_net_inet6_nd_90);
120 1.1 pgoyette return error;
121 1.1 pgoyette }
122 1.1 pgoyette
123 1.1 pgoyette int
124 1.1 pgoyette net_inet6_nd_90_fini(void)
125 1.1 pgoyette {
126 1.1 pgoyette
127 1.1 pgoyette sysctl_teardown(&nd6_clog);
128 1.1 pgoyette MODULE_HOOK_UNSET(net_inet6_nd_90_hook);
129 1.1 pgoyette return 0;
130 1.1 pgoyette }
131