#include "opt_inet6.h"
#include <sys/param.h>
#include <sys/malloc.h>
#include <sys/systm.h>
#include <rpc/types.h>
static struct netconfig netconfigs[] = {
#ifdef INET6
{
.nc_netid = "udp6",
.nc_semantics = NC_TPI_CLTS,
.nc_flag = NC_VISIBLE,
.nc_protofmly = "inet6",
.nc_proto = "udp",
},
{
.nc_netid = "tcp6",
.nc_semantics = NC_TPI_COTS_ORD,
.nc_flag = NC_VISIBLE,
.nc_protofmly = "inet6",
.nc_proto = "tcp",
},
#endif
{
.nc_netid = "udp",
.nc_semantics = NC_TPI_CLTS,
.nc_flag = NC_VISIBLE,
.nc_protofmly = "inet",
.nc_proto = "udp",
},
{
.nc_netid = "tcp",
.nc_semantics = NC_TPI_COTS_ORD,
.nc_flag = NC_VISIBLE,
.nc_protofmly = "inet",
.nc_proto = "tcp",
},
{
.nc_netid = "local",
.nc_semantics = NC_TPI_COTS_ORD,
.nc_flag = 0,
.nc_protofmly = "loopback",
.nc_proto = "",
},
{
.nc_netid = NULL,
}
};
void *
setnetconfig(void)
{
struct netconfig **nconfp;
nconfp = malloc(sizeof(struct netconfig *), M_RPC, M_WAITOK);
*nconfp = netconfigs;
return ((void *) nconfp);
}
struct netconfig *
getnetconfig(void *handle)
{
struct netconfig **nconfp = (struct netconfig **) handle;
struct netconfig *nconf;
nconf = *nconfp;
if (nconf->nc_netid == NULL)
return (NULL);
(*nconfp)++;
return (nconf);
}
struct netconfig *
getnetconfigent(const char *netid)
{
struct netconfig *nconf;
for (nconf = netconfigs; nconf->nc_netid; nconf++) {
if (!strcmp(netid, nconf->nc_netid))
return (nconf);
}
return (NULL);
}
void
freenetconfigent(struct netconfig *nconf)
{
}
int
endnetconfig(void * handle)
{
struct netconfig **nconfp = (struct netconfig **) handle;
free(nconfp, M_RPC);
return (0);
}