NET_HOOK_REGISTER(9F) Kernel Functions for Drivers NET_HOOK_REGISTER(9F)
net_hook_register - add a hook to be called in event processing
#include <sys/neti.h>
int net_hook_register(net_handle_t info, char *event, hook_t *hook);
illumos DDI specific (illumos DDI).
info
value returned from a successful call to
net_protocol_register().
name
unique name for this hook.
hook
pointer to a hook_t structure.
The net_hook_register() function uses hooks that allow callbacks to
be registered with events that belong to a network protocol. A
successful call to net_hook_register() requires that a valid handle
for a network protocol be provided (the info parameter), along with a
unique name and a hook description that includes a reference to an
available event. No two hooks on the same netstack may share a name.
While it is possible to use the same hook_t structure with multiple
calls to net_hook_register(), it is not encouraged.
The hook_t structure passed in with this function is described by
hook_t(9S). The following describes how this structure is used.
h_func
Must be non-NULL and represent a function that
fits the specified interface.
h_name
Gives the hook a name that represents its
owner. No duplication of h_name among the
hooks present for an event is allowed.
h_flags
Currently unused and must be set to 0.
h_hint, h_hintvalue
Specify a hint to net_hook_register() on how
to insert this hook. If the hint cannot be
specified, then an error is returned.
h_arg;
May take any value that the consumer wishes to
have passed back when the hook is activated.
If the net_hook_register() function succeeds, 0 is returned.
Otherwise, one of the following errors is returned:
ENOMEM
The system cannot allocate any more memory to support
registering this hook.
ENXIO
A hook cannot be found among the given family of events.
EEXIST
A hook with the given h_name already exists on that event.
ESRCH
A before or after dependency cannot be satisfied due to the
hook with
EBUSY
The h_hint field specifies a hint that cannot currently be
satisfied because it conflicts with another hook. An
example of this might be specifying HH_FIRST or HH_LAST
when another hook has already been registered with this
value.
ESHUTDOWN
The netstack corresponding to info is condemned or no
longer exists.
The net_hook_register() function may be called from user or kernel
context.
See attributes(7) for descriptions of the following attributes:
+--------------------+-----------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+--------------------+-----------------+
|Interface Stability | Committed |
+--------------------+-----------------+
net_hook_unregister(9F), hook_t(9S)
March 5, 2012 NET_HOOK_REGISTER(9F)
NAME
net_hook_register - add a hook to be called in event processing
SYNOPSIS
#include <sys/neti.h>
int net_hook_register(net_handle_t info, char *event, hook_t *hook);
INTERFACE LEVEL
illumos DDI specific (illumos DDI).
PARAMETERS
info
value returned from a successful call to
net_protocol_register().
name
unique name for this hook.
hook
pointer to a hook_t structure.
DESCRIPTION
The net_hook_register() function uses hooks that allow callbacks to
be registered with events that belong to a network protocol. A
successful call to net_hook_register() requires that a valid handle
for a network protocol be provided (the info parameter), along with a
unique name and a hook description that includes a reference to an
available event. No two hooks on the same netstack may share a name.
While it is possible to use the same hook_t structure with multiple
calls to net_hook_register(), it is not encouraged.
The hook_t structure passed in with this function is described by
hook_t(9S). The following describes how this structure is used.
h_func
Must be non-NULL and represent a function that
fits the specified interface.
h_name
Gives the hook a name that represents its
owner. No duplication of h_name among the
hooks present for an event is allowed.
h_flags
Currently unused and must be set to 0.
h_hint, h_hintvalue
Specify a hint to net_hook_register() on how
to insert this hook. If the hint cannot be
specified, then an error is returned.
h_arg;
May take any value that the consumer wishes to
have passed back when the hook is activated.
RETURN VALUES
If the net_hook_register() function succeeds, 0 is returned.
Otherwise, one of the following errors is returned:
ENOMEM
The system cannot allocate any more memory to support
registering this hook.
ENXIO
A hook cannot be found among the given family of events.
EEXIST
A hook with the given h_name already exists on that event.
ESRCH
A before or after dependency cannot be satisfied due to the
hook with
EBUSY
The h_hint field specifies a hint that cannot currently be
satisfied because it conflicts with another hook. An
example of this might be specifying HH_FIRST or HH_LAST
when another hook has already been registered with this
value.
ESHUTDOWN
The netstack corresponding to info is condemned or no
longer exists.
CONTEXT
The net_hook_register() function may be called from user or kernel
context.
ATTRIBUTES
See attributes(7) for descriptions of the following attributes:
+--------------------+-----------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+--------------------+-----------------+
|Interface Stability | Committed |
+--------------------+-----------------+
SEE ALSO
net_hook_unregister(9F), hook_t(9S)
March 5, 2012 NET_HOOK_REGISTER(9F)