neti_impl.c revision 1a5e258f5471356ca102c7176637cdce45bac147
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A * If they're trying to find a protocol that is being 2N/A * shutdown, just ignore it.. 2N/A * Note: the man page specifies "returns -1 if the value passed in is unknown 2N/A * to this framework". We are not doing a lookup in this function, just a 2N/A * simply add to the netd_refcnt of the net_handle_t passed in, so -1 is never a 2N/A * Is this safe? No hold on nts_lock? Consider that if the caller 2N/A * of net_protocol_release() is going to free this structure then 2N/A * it is now the only owner (refcnt==1) and it will have been 2N/A * removed from the nts_netd_head list on the neti_stack_t from a 2N/A * call to net_protocol_unregister already, so it is thus an orphan. 2N/A * We are only interested in finding protocols that 2N/A * are not in some sort of shutdown state. There is 2N/A * no need to check for netd_stack==NULL because 2N/A * that implies it is no longer on this list. 2N/A * Public accessor functions * Hooks related functions * Function: net_family_register * Returns: int - 0 = Succ, Else = Fail * Parameters: info(I) - protocol * Call hook_family_add to register family * There is no need to bump netd_refcnt in the two functions * net_family_register and net_family_unregister because the caller of these * two functions is assumed to "own" a reference on 'info' via an earlier * call to net_protocol_register(). Thus the owner is expected to do a * call to net_protocol_unregister() after having done a * net_family_unregister() to make sure things are properly cleaned up. * Passing a pointer to info->netd_hooks into hook_family_add is required * so that this can be set before the notify functions are called. If this * does not happen, the notify function may do something that seems fine, * like add a notify function to the family but cause a panic because * netd_hooks is NULL when we get to hook_family_notify_register. * Function: net_family_unregister * Returns: int - transparent value, explained by caller * Parameters: info(I) - protocol * Call hook_family_remove to unregister family * Function: net_event_register * Returns: internal event pointer - NULL = Fail * Parameters: info(I) - protocol * Call hook_event_add to register event on specific family * Internal event pointer is returned so caller can get * Function: net_event_unregister * Returns: int - transparent value, explained by caller * Parameters: info(I) - protocol * Call hook_event_remove to unregister event on specific family * Function: net_hook_register * Returns: int - transparent value, explained by caller * Parameters: info(I) - protocol * Call hook_register to add hook on specific family/event * Function: net_hook_unregister * Returns: int - transparent value, explained by caller * Parameters: info(I) - protocol * Call hook_unregister to remove hook on specific family/event