1177633Sdfr/*-
2177633Sdfr * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
3177633Sdfr * Authors: Doug Rabson <dfr@rabson.org>
4177633Sdfr * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
5177633Sdfr *
6177633Sdfr * Redistribution and use in source and binary forms, with or without
7177633Sdfr * modification, are permitted provided that the following conditions
8177633Sdfr * are met:
9177633Sdfr * 1. Redistributions of source code must retain the above copyright
10177633Sdfr *    notice, this list of conditions and the following disclaimer.
11177633Sdfr * 2. Redistributions in binary form must reproduce the above copyright
12177633Sdfr *    notice, this list of conditions and the following disclaimer in the
13177633Sdfr *    documentation and/or other materials provided with the distribution.
14177633Sdfr *
15177633Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16177633Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17177633Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18177633Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19177633Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20177633Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21177633Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22177633Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23177633Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24177633Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25177633Sdfr * SUCH DAMAGE.
26177633Sdfr */
27177633Sdfr
28177633Sdfr#include "opt_inet6.h"
29177633Sdfr
30177633Sdfr#include <sys/cdefs.h>
31177633Sdfr__FBSDID("$FreeBSD$");
32177633Sdfr
33177633Sdfr#include <sys/param.h>
34177633Sdfr#include <sys/malloc.h>
35177633Sdfr#include <sys/systm.h>
36177633Sdfr
37177633Sdfr#include <rpc/types.h>
38177633Sdfr
39177633Sdfr/*
40177633Sdfr * For in-kernel use, we use a simple compiled-in configuration.
41177633Sdfr */
42177633Sdfr
43177633Sdfrstatic struct netconfig netconfigs[] = {
44177633Sdfr#ifdef INET6
45177633Sdfr	{
46177633Sdfr		.nc_netid =	"udp6",
47177633Sdfr		.nc_semantics =	NC_TPI_CLTS,
48177633Sdfr		.nc_flag =	NC_VISIBLE,
49177633Sdfr		.nc_protofmly =	"inet6",
50177633Sdfr		.nc_proto =	"udp",
51177633Sdfr	},
52177633Sdfr	{
53177633Sdfr		.nc_netid =	"tcp6",
54177633Sdfr		.nc_semantics =	NC_TPI_COTS_ORD,
55177633Sdfr		.nc_flag =	NC_VISIBLE,
56177633Sdfr		.nc_protofmly =	"inet6",
57177633Sdfr		.nc_proto =	"tcp",
58177633Sdfr	},
59177633Sdfr#endif
60177633Sdfr	{
61177633Sdfr		.nc_netid =	"udp",
62177633Sdfr		.nc_semantics =	NC_TPI_CLTS,
63177633Sdfr		.nc_flag =	NC_VISIBLE,
64177633Sdfr		.nc_protofmly =	"inet",
65177633Sdfr		.nc_proto =	"udp",
66177633Sdfr	},
67177633Sdfr	{
68177633Sdfr		.nc_netid =	"tcp",
69177633Sdfr		.nc_semantics =	NC_TPI_COTS_ORD,
70177633Sdfr		.nc_flag =	NC_VISIBLE,
71177633Sdfr		.nc_protofmly =	"inet",
72177633Sdfr		.nc_proto =	"tcp",
73177633Sdfr	},
74177633Sdfr	{
75177633Sdfr		.nc_netid =	"local",
76177633Sdfr		.nc_semantics =	NC_TPI_COTS_ORD,
77177633Sdfr		.nc_flag =	0,
78177633Sdfr		.nc_protofmly =	"loopback",
79177633Sdfr		.nc_proto =	"",
80177633Sdfr	},
81177633Sdfr	{
82177633Sdfr		.nc_netid =	NULL,
83177633Sdfr	}
84177633Sdfr};
85177633Sdfr
86177633Sdfrvoid *
87177633Sdfrsetnetconfig(void)
88177633Sdfr{
89177633Sdfr	struct netconfig **nconfp;
90177633Sdfr
91177633Sdfr	nconfp = malloc(sizeof(struct netconfig *), M_RPC, M_WAITOK);
92177633Sdfr	*nconfp = netconfigs;
93177633Sdfr
94177633Sdfr	return ((void *) nconfp);
95177633Sdfr}
96177633Sdfr
97177633Sdfrstruct netconfig *
98177633Sdfrgetnetconfig(void *handle)
99177633Sdfr{
100177633Sdfr	struct netconfig **nconfp = (struct netconfig **) handle;
101177633Sdfr	struct netconfig *nconf;
102177633Sdfr
103177633Sdfr	nconf = *nconfp;
104177633Sdfr	if (nconf->nc_netid == NULL)
105177633Sdfr		return (NULL);
106177633Sdfr
107177633Sdfr	(*nconfp)++;
108177633Sdfr
109177633Sdfr	return (nconf);
110177633Sdfr}
111177633Sdfr
112177633Sdfrstruct netconfig *
113177633Sdfrgetnetconfigent(const char *netid)
114177633Sdfr{
115177633Sdfr	struct netconfig *nconf;
116177633Sdfr
117177633Sdfr	for (nconf = netconfigs; nconf->nc_netid; nconf++) {
118177633Sdfr		if (!strcmp(netid, nconf->nc_netid))
119177633Sdfr			return (nconf);
120177633Sdfr	}
121177633Sdfr
122177633Sdfr	return (NULL);
123177633Sdfr}
124177633Sdfr
125177633Sdfrvoid
126177633Sdfrfreenetconfigent(struct netconfig *nconf)
127177633Sdfr{
128177633Sdfr
129177633Sdfr}
130177633Sdfr
131177633Sdfrint
132177633Sdfrendnetconfig(void * handle)
133177633Sdfr{
134177633Sdfr	struct netconfig **nconfp = (struct netconfig **) handle;
135177633Sdfr
136177633Sdfr	free(nconfp, M_RPC);
137177633Sdfr	return (0);
138177633Sdfr}
139