sockmod_sctp.c revision d496d3f8834a66aac9da86c94e941d41fdeff23b
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * CDDL HEADER START
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * The contents of this file are subject to the terms of the
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Common Development and Distribution License (the "License").
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * You may not use this file except in compliance with the License.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * See the License for the specific language governing permissions
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * and limitations under the License.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * When distributing Covered Code, include this CDDL HEADER in each
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * If applicable, add the following below this CDDL HEADER, with the
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * fields enclosed by brackets "[]" replaced with your own identifying
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * information: Portions Copyright [yyyy] [name of copyright owner]
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * CDDL HEADER END
d496d3f8834a66aac9da86c94e941d41fdeff23bErik Nordmark * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Use is subject to license terms.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangningstruct sonode *socksctp_create(struct sockparams *, int, int, int,
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning int, int, int *, cred_t *);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangningstatic int socksctp_constructor(void *, void *, int);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangningstatic void socksctp_destructor(void *, void *);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Module linkage information for the kernel.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning sosctp_sockcache = kmem_cache_create("sctpsock",
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning sizeof (struct sctp_sonode), 0, socksctp_constructor,
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning sosctp_assoccache = kmem_cache_create("sctp_assoc",
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning sizeof (struct sctp_soassoc), 0, NULL, NULL, NULL, NULL, NULL, 0);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangningsocksctp_constructor(void *buf, void *cdrarg, int kmflags)
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning return (sonode_constructor((void *)so, cdrarg, kmflags));
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Creates a sctp socket data structure.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning/* ARGSUSED */
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangningsocksctp_create(struct sockparams *sp, int family, int type, int protocol,
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning int version, int sflags, int *errorp, cred_t *cr)
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning int kmflags = (sflags & SOCKET_NOSLEEP) ? KM_NOSLEEP : KM_SLEEP;
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * We only support two types of SCTP socket. Let sotpi_create()
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * handle all other cases, such as raw socket.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning if (!(family == AF_INET || family == AF_INET6) ||
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning !(type == SOCK_STREAM || type == SOCK_SEQPACKET)) {
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning ss = kmem_cache_alloc(sosctp_sockcache, kmflags);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning dprint(2, ("sosctp_create: %p domain %d type %d\n", (void *)so, family,
d496d3f8834a66aac9da86c94e941d41fdeff23bErik Nordmark * set the default values to be INFPSZ
d496d3f8834a66aac9da86c94e941d41fdeff23bErik Nordmark * if a protocol desires it can change the value later
d496d3f8834a66aac9da86c94e941d41fdeff23bErik Nordmark so->so_proto_props.sopp_rxhiwat = SOCKET_RECVHIWATER;
d496d3f8834a66aac9da86c94e941d41fdeff23bErik Nordmark so->so_proto_props.sopp_rxlowat = SOCKET_RECVLOWATER;
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Free SCTP socket data structure.