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