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