Merge commit 'ea01a15a654b9e1c7b37d958f4d1911882ed7781'
[unleashed.git] / kernel / net / sockmods / sdp / sockmod_sdp.c
blobb4c653001012abf0c800d1edd09da2aeaf23da18
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
26 #include <sys/sysmacros.h>
27 #include <sys/strsubr.h>
28 #include <sys/socket.h>
29 #include <sys/socketvar.h>
30 #include <sys/modctl.h>
31 #include <sys/cmn_err.h>
32 #include <sys/vfs.h>
33 #include <inet/sdp_itf.h>
34 #include <../../../../kernel/fs/sockfs/sockcommon.h>
35 #include "socksdp.h"
37 struct sonode *socksdp_create(struct sockparams *, int, int, int,
38 int, int *, cred_t *);
39 static void socksdp_destroy(struct sonode *);
41 static __smod_priv_t sosdp_priv = {
42 socksdp_create,
43 socksdp_destroy,
44 NULL
47 static smod_reg_t sinfo = {
48 SOCKMOD_VERSION,
49 "socksdp",
50 SOCK_UC_VERSION,
51 SOCK_DC_VERSION,
52 NULL,
53 &sosdp_priv
57 * Module linkage information for the kernel
59 static struct modlsockmod modlsockmod = {
60 &mod_sockmodops, "SDP socket module", &sinfo
63 static struct modlinkage modlinkage = {
64 MODREV_1,
65 &modlsockmod,
66 NULL
70 * Creates a sdp socket data structure.
72 /* ARGSUSED */
73 struct sonode *
74 socksdp_create(struct sockparams *sp, int family, int type, int protocol, int
75 sflags, int *errorp, cred_t *cr)
77 struct sonode *so;
78 int kmflags = (sflags & SOCKET_NOSLEEP) ? KM_NOSLEEP : KM_SLEEP;
80 dprint(4, ("Inside sosdp_create: domain:%d proto:%d type:%d",
81 family, protocol, type));
83 *errorp = 0;
86 * We only support one type of SDP socket. Let sotpi_create()
87 * handle all other cases, such as raw socket.
89 if (!(family == AF_INET || family == AF_INET6) ||
90 !(type == SOCK_STREAM)) {
91 *errorp = EINVAL;
92 return (NULL);
95 so = kmem_cache_alloc(socket_cache, kmflags);
96 if (so == NULL) {
97 *errorp = ENOMEM;
98 return (NULL);
101 sonode_init(so, sp, family, type, protocol, &sosdp_sonodeops);
102 so->so_pollev |= SO_POLLEV_ALWAYS;
104 dprint(2, ("sosdp_create: %p domain %d type %d\n", (void *)so, family,
105 type));
107 so->so_is_stream = false;
110 * set the default values to be INFPSZ
111 * if a protocol desires it can change the value later
113 so->so_proto_props.sopp_rxhiwat = SOCKET_RECVHIWATER;
114 so->so_proto_props.sopp_rxlowat = SOCKET_RECVLOWATER;
115 so->so_proto_props.sopp_maxpsz = INFPSZ;
116 so->so_proto_props.sopp_maxblk = INFPSZ;
118 return (so);
121 static void
122 socksdp_destroy(struct sonode *so)
124 ASSERT(so->so_ops == &sosdp_sonodeops);
126 sosdp_fini(so, CRED());
128 kmem_cache_free(socket_cache, so);
132 _init(void)
134 return (mod_install(&modlinkage));
138 _fini(void)
140 return (mod_remove(&modlinkage));
144 _info(struct modinfo *modinfop)
146 return (mod_info(&modlinkage, modinfop));