'\" te .\" Copyright (C) 2008, Sun Microsystems, Inc. All Rights Reserved. .\" Copyright (C) 2012, Joyent, Inc. All Rights Reserved. .\" 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 or http://www.opensolaris.org/os/licensing. 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] .TH NET_HOOK_REGISTER 9F "Mar 5, 2012" .SH NAME net_hook_register \- add a hook to be called in event processing .SH SYNOPSIS .nf #include \fBint\fR \fBnet_hook_register\fR(\fBnet_handle_t\fR \fIinfo\fR, \fBchar\fR *\fIevent\fR, \fBhook_t\fR *\fIhook\fR); .fi .SH INTERFACE LEVEL illumos DDI specific (illumos DDI). .SH PARAMETERS .ne 2 .na \fB\fIinfo\fR\fR .ad .RS 8n value returned from a successful call to \fBnet_protocol_register()\fR. .RE .sp .ne 2 .na \fB\fIname\fR\fR .ad .RS 8n unique name for this hook. .RE .sp .ne 2 .na \fB\fIhook\fR\fR .ad .RS 8n pointer to a \fBhook_t\fR structure. .RE .SH DESCRIPTION The \fBnet_hook_register()\fR function uses hooks that allow callbacks to be registered with events that belong to a network protocol. A successful call to \fBnet_hook_register()\fR requires that a valid handle for a network protocol be provided (the \fIinfo\fR 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. .sp .LP While it is possible to use the same \fBhook_t\fR structure with multiple calls to \fBnet_hook_register()\fR, it is not encouraged. .sp .LP The \fBhook_t\fR structure passed in with this function is described by \fBhook_t\fR(9S). The following describes how this structure is used. .sp .ne 2 .na \fB\fBh_func\fR\fR .ad .RS 23n Must be non-NULL and represent a function that fits the specified interface. .RE .sp .ne 2 .na \fB\fBh_name\fR\fR .ad .RS 23n Gives the hook a name that represents its owner. No duplication of \fBh_name\fR among the hooks present for an event is allowed. .RE .sp .ne 2 .na \fB\fBh_flags\fR\fR .ad .RS 23n Currently unused and must be set to 0. .RE .sp .ne 2 .na \fB\fBh_hint, h_hintvalue\fR\fR .ad .RS 23n Specify a hint to \fBnet_hook_register()\fR on how to insert this hook. If the hint cannot be specified, then an error is returned. .RE .sp .ne 2 .na \fB\fBh_arg;\fR\fR .ad .RS 23n May take any value that the consumer wishes to have passed back when the hook is activated. .RE .SH RETURN VALUES If the \fBnet_hook_register()\fR function succeeds, 0 is returned. Otherwise, one of the following errors is returned: .sp .ne 2 .na \fBENOMEM\fR .ad .RS 10n The system cannot allocate any more memory to support registering this hook. .RE .sp .ne 2 .na \fBENXIO\fR .ad .RS 10n A hook cannot be found among the given family of events. .RE .sp .ne 2 .na \fBEEXIST\fR .ad .RS 10n A hook with the given \fBh_name\fR already exists on that event. .RE .sp .ne 2 .na \fBESRCH\fR .ad .RS 10n A before or after dependency cannot be satisfied due to the hook with .RE .sp .ne 2 .na \fBEBUSY\fR .ad .RS 10n The \fBh_hint\fR field specifies a hint that cannot currently be satisfied because it conflicts with another hook. An example of this might be specifying \fBHH_FIRST\fR or \fBHH_LAST\fR when another hook has already been registered with this value. .RE .sp .ne 2 .na \fBESHUTDOWN\fR .ad .RS 10n The netstack corresponding to \fIinfo\fR is condemned or no longer exists. .SH CONTEXT The \fBnet_hook_register()\fR function may be called from user or kernel context. .SH ATTRIBUTES See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Committed .TE .SH SEE ALSO \fBnet_hook_unregister\fR(9F), \fBhook_t\fR(9S)