neti.c revision f4b3ec61df05330d25f55a36b975b4d7519fdeb1
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
static void net_init();
static void net_fini();
/*
* Module linkage information for the kernel.
*/
&mod_miscops, /* drv_modops */
"netinfo module 1.0", /* drv_linkinfo */
};
static struct modlinkage modlinkage = {
MODREV_1, /* ml_rev */
&modlmisc, /* ml_linkage */
};
/*
* Module entry points.
*/
int
_init(void)
{
int error;
net_init();
if (error != 0)
net_fini();
return (error);
}
int
_fini(void)
{
int error;
if (error == 0)
net_fini();
return (error);
}
int
{
}
static void
net_init()
{
/*
* We want to be informed each time a stack is created or
* destroyed in the kernel.
*/
}
static void
net_fini()
{
}
/*
* Initialize the neti stack instance.
*/
/*ARGSUSED*/
static void *
{
#ifdef NS_DEBUG
#endif
return (nts);
}
/*
* Free the neti stack instance.
*/
/*ARGSUSED*/
static void
{
#ifdef NS_DEBUG
#endif
}
static net_data_t
{
struct net_data *n;
break;
}
}
return (n);
}
{
netstack_t *ns;
return (nd);
}
{
struct neti_stack *nts;
new->netd_refcnt = 0;
if (n != NULL) {
return (NULL);
}
else
return (new);
}
int
{
struct neti_stack *nts;
if (info->netd_refcnt != 0) {
return (EBUSY);
}
return (0);
}
{
netstack_t *ns;
return (nd);
}
{
struct net_data *n;
struct neti_stack *nts;
if (n != NULL)
return (n);
}
/*
* Note: the man page specifies "returns -1 if the value passed in is unknown
* to this framework". We are not doing a lookup in this function, just a
* simply add to the netd_refcnt of the net_data_t passed in, so -1 is never a
* return value.
*/
int
{
struct neti_stack *nts;
/* net_release has been called too many times */
if (info->netd_refcnt < 0) {
return (1);
}
return (0);
}
{
netstack_t *ns;
return (nd);
}
{
struct neti_stack *nts;
if (found)
break;
if (n == info)
}
}
if (n != NULL)
return (n);
}
/*
* Public accessor functions
*/
int
{
info->netd_netstack));
}
int
{
info->netd_netstack));
}
int
{
}
int
{
}
{
info->netd_netstack));
}
{
}
{
info->netd_netstack));
}
int
{
info->netd_netstack));
}
{
}
int
{
}
int
{
}
/*
* Hooks related functions
*/
/*
* Function: net_register_family
* Returns: int - 0 = Succ, Else = Fail
* Parameters: info(I) - protocol
* hf(I) - family pointer
*
* Call hook_family_add to register family
*/
int
{
return (EEXIST);
return (EEXIST);
return (0);
}
/*
* Function: net_unregister_family
* Returns: int - transparent value, explained by caller
* Parameters: info(I) - protocol
* hf(I) - family pointer
*
* Call hook_family_remove to unregister family
*/
int
{
int ret;
return (ENXIO);
return (EINVAL);
if (ret == 0)
return (ret);
}
/*
* Function: net_register_event
* Returns: internal event pointer - NULL = Fail
* Parameters: info(I) - protocol
* he(I) - event pointer
*
* Call hook_event_add to register event on specific family
* Internal event pointer is returned so caller can get
* handle to run hooks
*/
{
return (NULL);
return ((hook_event_token_t)hei);
}
/*
* Function: net_unregister_event
* Returns: int - transparent value, explained by caller
* Parameters: info(I) - protocol
* he(I) - event pointer
*
* Call hook_event_remove to unregister event on specific family
*/
int
{
return (ENXIO);
}
/*
* Function: net_register_hook
* Returns: int - transparent value, explained by caller
* Parameters: info(I) - protocol
* event(I) - event name
* h(I) - hook pointer
*
*/
int
{
return (ENXIO);
}
/*
* Function: net_unregister_hook
* Returns: int - transparent value, explained by caller
* Parameters: info(I) - protocol
* event(I) - event name
* h(I) - hook pointer
*
*/
int
{
return (ENXIO);
}