/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2008 Isilon Inc http://www.isilon.com/4* Authors: Doug Rabson <[email protected]>5* Developed with Red Inc: Alfred Perlstein <[email protected]>6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#include "opt_inet6.h"3031#include <sys/param.h>32#include <sys/malloc.h>33#include <sys/systm.h>3435#include <rpc/types.h>3637/*38* For in-kernel use, we use a simple compiled-in configuration.39*/4041static struct netconfig netconfigs[] = {42#ifdef INET643{44.nc_netid = "udp6",45.nc_semantics = NC_TPI_CLTS,46.nc_flag = NC_VISIBLE,47.nc_protofmly = "inet6",48.nc_proto = "udp",49},50{51.nc_netid = "tcp6",52.nc_semantics = NC_TPI_COTS_ORD,53.nc_flag = NC_VISIBLE,54.nc_protofmly = "inet6",55.nc_proto = "tcp",56},57#endif58{59.nc_netid = "udp",60.nc_semantics = NC_TPI_CLTS,61.nc_flag = NC_VISIBLE,62.nc_protofmly = "inet",63.nc_proto = "udp",64},65{66.nc_netid = "tcp",67.nc_semantics = NC_TPI_COTS_ORD,68.nc_flag = NC_VISIBLE,69.nc_protofmly = "inet",70.nc_proto = "tcp",71},72{73.nc_netid = "local",74.nc_semantics = NC_TPI_COTS_ORD,75.nc_flag = 0,76.nc_protofmly = "loopback",77.nc_proto = "",78},79{80.nc_netid = NULL,81}82};8384void *85setnetconfig(void)86{87struct netconfig **nconfp;8889nconfp = malloc(sizeof(struct netconfig *), M_RPC, M_WAITOK);90*nconfp = netconfigs;9192return ((void *) nconfp);93}9495struct netconfig *96getnetconfig(void *handle)97{98struct netconfig **nconfp = (struct netconfig **) handle;99struct netconfig *nconf;100101nconf = *nconfp;102if (nconf->nc_netid == NULL)103return (NULL);104105(*nconfp)++;106107return (nconf);108}109110struct netconfig *111getnetconfigent(const char *netid)112{113struct netconfig *nconf;114115for (nconf = netconfigs; nconf->nc_netid; nconf++) {116if (!strcmp(netid, nconf->nc_netid))117return (nconf);118}119120return (NULL);121}122123void124freenetconfigent(struct netconfig *nconf)125{126127}128129int130endnetconfig(void * handle)131{132struct netconfig **nconfp = (struct netconfig **) handle;133134free(nconfp, M_RPC);135return (0);136}137138139