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
3e95bd4ab92abca814bd28e854607d1975c7dc88Anders Persson * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning mutex_init(&smod_list_lock, NULL, MUTEX_DEFAULT, NULL);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning for (smodp = list_head(&smod_list); smodp != NULL;
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Register the socket module.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Make sure the socket module does not depend on capabilities
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * not available on the system.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning "Failed to register socket module %s: version mismatch",
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning if ((smodp = smod_find(reg->smod_name)) != NULL) {
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning if (strcmp(smodp->smod_name, SOTPI_SMOD_NAME) == 0 ||
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning (reg->__smod_priv->smodp_sock_create_func != NULL ||
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning reg->__smod_priv->smodp_sock_destroy_func != NULL))) {
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning smodp->smod_proto_create_func = reg->smod_proto_create_func;
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning smodp->smod_sock_create_func = sock_comm_create_function;
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning smodp->smod_sock_destroy_func = sock_comm_destroy_function;
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Unregister the socket module
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Delete the entry from the socket module list.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Initialize the socket module entry.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning smodp = kmem_zalloc(sizeof (*smodp), KM_SLEEP);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Clean up the socket module part of the sockparams entry.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning ASSERT(strcmp(smodp->smod_name, "socktpi") != 0);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning kmem_free(smodp->smod_name, strlen(smodp->smod_name) + 1);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Add an entry at the front of the socket module list.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Lookup the socket module table by the socket module name.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * If there is an existing entry, then increase the reference count.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Otherwise we load the module and in the module register function create
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * a new entry and add it to the end of the socket module table.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * If find an entry, increase the reference count and
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * return the entry pointer.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * We have a sockmod, and it is not loaded.
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * Load the module into the kernel, modload() will
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning * take care of the multiple threads.