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