1*e9a684c4Soster /* $NetBSD: net_inet6_nd_90.c,v 1.2 2023/12/09 20:31:57 oster Exp $ */
24be362dbSpgoyette
3*e9a684c4Soster /* $NetBSD: net_inet6_nd_90.c,v 1.2 2023/12/09 20:31:57 oster Exp $ */
44be362dbSpgoyette /* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */
54be362dbSpgoyette
64be362dbSpgoyette /*
74be362dbSpgoyette * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
84be362dbSpgoyette * All rights reserved.
94be362dbSpgoyette *
104be362dbSpgoyette * Redistribution and use in source and binary forms, with or without
114be362dbSpgoyette * modification, are permitted provided that the following conditions
124be362dbSpgoyette * are met:
134be362dbSpgoyette * 1. Redistributions of source code must retain the above copyright
144be362dbSpgoyette * notice, this list of conditions and the following disclaimer.
154be362dbSpgoyette * 2. Redistributions in binary form must reproduce the above copyright
164be362dbSpgoyette * notice, this list of conditions and the following disclaimer in the
174be362dbSpgoyette * documentation and/or other materials provided with the distribution.
184be362dbSpgoyette * 3. Neither the name of the project nor the names of its contributors
194be362dbSpgoyette * may be used to endorse or promote products derived from this software
204be362dbSpgoyette * without specific prior written permission.
214be362dbSpgoyette *
224be362dbSpgoyette * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
234be362dbSpgoyette * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
244be362dbSpgoyette * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
254be362dbSpgoyette * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
264be362dbSpgoyette * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
274be362dbSpgoyette * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
284be362dbSpgoyette * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
294be362dbSpgoyette * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
304be362dbSpgoyette * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
314be362dbSpgoyette * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
324be362dbSpgoyette * SUCH DAMAGE.
334be362dbSpgoyette */
344be362dbSpgoyette
354be362dbSpgoyette #include <sys/cdefs.h>
36*e9a684c4Soster __KERNEL_RCSID(0, "$NetBSD: net_inet6_nd_90.c,v 1.2 2023/12/09 20:31:57 oster Exp $");
374be362dbSpgoyette
384be362dbSpgoyette #if defined(_KERNEL_OPT)
394be362dbSpgoyette #include "opt_compat_netbsd.h"
404be362dbSpgoyette #endif
414be362dbSpgoyette
424be362dbSpgoyette #include <sys/param.h>
434be362dbSpgoyette #include <sys/systm.h>
444be362dbSpgoyette #include <sys/namei.h>
454be362dbSpgoyette #include <sys/filedesc.h>
464be362dbSpgoyette #include <sys/kernel.h>
474be362dbSpgoyette #include <sys/sysctl.h>
484be362dbSpgoyette
494be362dbSpgoyette #include <net/if.h>
504be362dbSpgoyette
514be362dbSpgoyette #include <netinet/in.h>
524be362dbSpgoyette
534be362dbSpgoyette #include <netinet/icmp6.h>
544be362dbSpgoyette #include <netinet/ip6.h>
554be362dbSpgoyette
564be362dbSpgoyette #include <netinet6/in6_var.h>
574be362dbSpgoyette #include <netinet6/nd6.h>
584be362dbSpgoyette
594be362dbSpgoyette #include <sys/compat_stub.h>
604be362dbSpgoyette
614be362dbSpgoyette #include <compat/common/compat_mod.h>
624be362dbSpgoyette
63*e9a684c4Soster #ifdef INET6
64*e9a684c4Soster
654be362dbSpgoyette static struct sysctllog *nd6_clog;
664be362dbSpgoyette
674be362dbSpgoyette /*
684be362dbSpgoyette * sysctl helper routine for the net.inet6.icmp6.nd6 nodes. silly?
694be362dbSpgoyette */
704be362dbSpgoyette static int
sysctl_net_inet6_icmp6_nd6(SYSCTLFN_ARGS)714be362dbSpgoyette sysctl_net_inet6_icmp6_nd6(SYSCTLFN_ARGS)
724be362dbSpgoyette {
734be362dbSpgoyette (void)&name;
744be362dbSpgoyette (void)&l;
754be362dbSpgoyette (void)&oname;
764be362dbSpgoyette
774be362dbSpgoyette if (namelen != 0)
784be362dbSpgoyette return (EINVAL);
794be362dbSpgoyette
804be362dbSpgoyette return (nd6_sysctl(rnode->sysctl_num, oldp, oldlenp,
814be362dbSpgoyette /*XXXUNCONST*/
824be362dbSpgoyette __UNCONST(newp), newlen));
834be362dbSpgoyette }
844be362dbSpgoyette int real_net_inet6_nd_90(int);
854be362dbSpgoyette
864be362dbSpgoyette /*
874be362dbSpgoyette * the hook is only called for valid codes, so the mere presence
884be362dbSpgoyette * of the hook means success.
894be362dbSpgoyette */
904be362dbSpgoyette /* ARGSUSED */
914be362dbSpgoyette int
real_net_inet6_nd_90(int name)924be362dbSpgoyette real_net_inet6_nd_90(int name)
934be362dbSpgoyette {
944be362dbSpgoyette
954be362dbSpgoyette return 0;
964be362dbSpgoyette }
974be362dbSpgoyette
984be362dbSpgoyette int
net_inet6_nd_90_init(void)994be362dbSpgoyette net_inet6_nd_90_init(void)
1004be362dbSpgoyette {
1014be362dbSpgoyette int error;
1024be362dbSpgoyette
1034be362dbSpgoyette error = sysctl_createv(&nd6_clog, 0, NULL, NULL,
1044be362dbSpgoyette CTLFLAG_PERMANENT,
1054be362dbSpgoyette CTLTYPE_STRUCT, "nd6_drlist",
1064be362dbSpgoyette SYSCTL_DESCR("Default router list"),
1074be362dbSpgoyette sysctl_net_inet6_icmp6_nd6, 0, NULL, 0,
1084be362dbSpgoyette CTL_NET, PF_INET6, IPPROTO_ICMPV6,
1094be362dbSpgoyette OICMPV6CTL_ND6_DRLIST, CTL_EOL);
1104be362dbSpgoyette if (error != 0)
1114be362dbSpgoyette return error;
1124be362dbSpgoyette
1134be362dbSpgoyette error = sysctl_createv(&nd6_clog, 0, NULL, NULL,
1144be362dbSpgoyette CTLFLAG_PERMANENT,
1154be362dbSpgoyette CTLTYPE_STRUCT, "nd6_prlist",
1164be362dbSpgoyette SYSCTL_DESCR("Prefix list"),
1174be362dbSpgoyette sysctl_net_inet6_icmp6_nd6, 0, NULL, 0,
1184be362dbSpgoyette CTL_NET, PF_INET6, IPPROTO_ICMPV6,
1194be362dbSpgoyette OICMPV6CTL_ND6_PRLIST, CTL_EOL);
1204be362dbSpgoyette
1214be362dbSpgoyette MODULE_HOOK_SET(net_inet6_nd_90_hook, real_net_inet6_nd_90);
1224be362dbSpgoyette return error;
1234be362dbSpgoyette }
1244be362dbSpgoyette
1254be362dbSpgoyette int
net_inet6_nd_90_fini(void)1264be362dbSpgoyette net_inet6_nd_90_fini(void)
1274be362dbSpgoyette {
1284be362dbSpgoyette
1294be362dbSpgoyette sysctl_teardown(&nd6_clog);
1304be362dbSpgoyette MODULE_HOOK_UNSET(net_inet6_nd_90_hook);
1314be362dbSpgoyette return 0;
1324be362dbSpgoyette }
133*e9a684c4Soster
134*e9a684c4Soster #endif /* INET6 */
135*e9a684c4Soster
136