1 1.2 oster /* $NetBSD: net_inet6_nd_90.c,v 1.2 2023/12/09 20:31:57 oster Exp $ */ 2 1.1 pgoyette 3 1.2 oster /* $NetBSD: net_inet6_nd_90.c,v 1.2 2023/12/09 20:31:57 oster 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.2 oster __KERNEL_RCSID(0, "$NetBSD: net_inet6_nd_90.c,v 1.2 2023/12/09 20:31:57 oster 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.2 oster #ifdef INET6 64 1.2 oster 65 1.1 pgoyette static struct sysctllog *nd6_clog; 66 1.1 pgoyette 67 1.1 pgoyette /* 68 1.1 pgoyette * sysctl helper routine for the net.inet6.icmp6.nd6 nodes. silly? 69 1.1 pgoyette */ 70 1.1 pgoyette static int 71 1.1 pgoyette sysctl_net_inet6_icmp6_nd6(SYSCTLFN_ARGS) 72 1.1 pgoyette { 73 1.1 pgoyette (void)&name; 74 1.1 pgoyette (void)&l; 75 1.1 pgoyette (void)&oname; 76 1.1 pgoyette 77 1.1 pgoyette if (namelen != 0) 78 1.1 pgoyette return (EINVAL); 79 1.1 pgoyette 80 1.1 pgoyette return (nd6_sysctl(rnode->sysctl_num, oldp, oldlenp, 81 1.1 pgoyette /*XXXUNCONST*/ 82 1.1 pgoyette __UNCONST(newp), newlen)); 83 1.1 pgoyette } 84 1.1 pgoyette int real_net_inet6_nd_90(int); 85 1.1 pgoyette 86 1.1 pgoyette /* 87 1.1 pgoyette * the hook is only called for valid codes, so the mere presence 88 1.1 pgoyette * of the hook means success. 89 1.1 pgoyette */ 90 1.1 pgoyette /* ARGSUSED */ 91 1.1 pgoyette int 92 1.1 pgoyette real_net_inet6_nd_90(int name) 93 1.1 pgoyette { 94 1.1 pgoyette 95 1.1 pgoyette return 0; 96 1.1 pgoyette } 97 1.1 pgoyette 98 1.1 pgoyette int 99 1.1 pgoyette net_inet6_nd_90_init(void) 100 1.1 pgoyette { 101 1.1 pgoyette int error; 102 1.1 pgoyette 103 1.1 pgoyette error = sysctl_createv(&nd6_clog, 0, NULL, NULL, 104 1.1 pgoyette CTLFLAG_PERMANENT, 105 1.1 pgoyette CTLTYPE_STRUCT, "nd6_drlist", 106 1.1 pgoyette SYSCTL_DESCR("Default router list"), 107 1.1 pgoyette sysctl_net_inet6_icmp6_nd6, 0, NULL, 0, 108 1.1 pgoyette CTL_NET, PF_INET6, IPPROTO_ICMPV6, 109 1.1 pgoyette OICMPV6CTL_ND6_DRLIST, CTL_EOL); 110 1.1 pgoyette if (error != 0) 111 1.1 pgoyette return error; 112 1.1 pgoyette 113 1.1 pgoyette error = sysctl_createv(&nd6_clog, 0, NULL, NULL, 114 1.1 pgoyette CTLFLAG_PERMANENT, 115 1.1 pgoyette CTLTYPE_STRUCT, "nd6_prlist", 116 1.1 pgoyette SYSCTL_DESCR("Prefix list"), 117 1.1 pgoyette sysctl_net_inet6_icmp6_nd6, 0, NULL, 0, 118 1.1 pgoyette CTL_NET, PF_INET6, IPPROTO_ICMPV6, 119 1.1 pgoyette OICMPV6CTL_ND6_PRLIST, CTL_EOL); 120 1.1 pgoyette 121 1.1 pgoyette MODULE_HOOK_SET(net_inet6_nd_90_hook, real_net_inet6_nd_90); 122 1.1 pgoyette return error; 123 1.1 pgoyette } 124 1.1 pgoyette 125 1.1 pgoyette int 126 1.1 pgoyette net_inet6_nd_90_fini(void) 127 1.1 pgoyette { 128 1.1 pgoyette 129 1.1 pgoyette sysctl_teardown(&nd6_clog); 130 1.1 pgoyette MODULE_HOOK_UNSET(net_inet6_nd_90_hook); 131 1.1 pgoyette return 0; 132 1.1 pgoyette } 133 1.2 oster 134 1.2 oster #endif /* INET6 */ 135 1.2 oster 136