#include <sys/sysmacros.h>
#include <sys/strsubr.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/modctl.h>
#include <sys/cmn_err.h>
#include <sys/vfs.h>
#include <inet/sdp_itf.h>
#include <fs/sockfs/sockcommon.h>
#include "socksdp.h"
struct sonode *socksdp_create(struct sockparams *, int, int, int,
int, int, int *, cred_t *);
static void socksdp_destroy(struct sonode *);
static __smod_priv_t sosdp_priv = {
socksdp_create,
socksdp_destroy,
NULL
};
static smod_reg_t sinfo = {
SOCKMOD_VERSION,
"socksdp",
SOCK_UC_VERSION,
SOCK_DC_VERSION,
NULL,
&sosdp_priv
};
static struct modlsockmod modlsockmod = {
&mod_sockmodops, "SDP socket module", &sinfo
};
static struct modlinkage modlinkage = {
MODREV_1,
&modlsockmod,
NULL
};
struct sonode *
socksdp_create(struct sockparams *sp, int family, int type, int protocol,
int version, int sflags, int *errorp, cred_t *cr)
{
struct sonode *so;
int kmflags = (sflags & SOCKET_NOSLEEP) ? KM_NOSLEEP : KM_SLEEP;
dprint(4, ("Inside sosdp_create: domain:%d proto:%d type:%d",
family, protocol, type));
*errorp = 0;
if (is_system_labeled()) {
*errorp = EOPNOTSUPP;
return (NULL);
}
if (version == SOV_STREAM) {
*errorp = EINVAL;
return (NULL);
}
if (!(family == AF_INET || family == AF_INET6) ||
!(type == SOCK_STREAM)) {
*errorp = EINVAL;
return (NULL);
}
so = kmem_cache_alloc(socket_cache, kmflags);
if (so == NULL) {
*errorp = ENOMEM;
return (NULL);
}
sonode_init(so, sp, family, type, protocol, &sosdp_sonodeops);
so->so_pollev |= SO_POLLEV_ALWAYS;
dprint(2, ("sosdp_create: %p domain %d type %d\n", (void *)so, family,
type));
if (version == SOV_DEFAULT) {
version = so_default_version;
}
so->so_version = (short)version;
so->so_proto_props.sopp_rxhiwat = SOCKET_RECVHIWATER;
so->so_proto_props.sopp_rxlowat = SOCKET_RECVLOWATER;
so->so_proto_props.sopp_maxpsz = INFPSZ;
so->so_proto_props.sopp_maxblk = INFPSZ;
return (so);
}
static void
socksdp_destroy(struct sonode *so)
{
ASSERT(so->so_ops == &sosdp_sonodeops);
sosdp_fini(so, CRED());
kmem_cache_free(socket_cache, so);
}
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
_fini(void)
{
return (mod_remove(&modlinkage));
}
int
_info(struct modinfo *modinfop)
{
return (mod_info(&modlinkage, modinfop));
}