xref: /illumos-gate/usr/src/man/man9s/hook_t.9s (revision 74079a53e205d2eeb75b215833ddc684a1db3088)
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]
HOOK_T 9S "Mar 5, 2012"
NAME
hook_t - callback structure for subscribing to netinfo events
SYNOPSIS
#include <sys/hook.h>
INTERFACE LEVEL
illumos DDI specific (illumos DDI).
DESCRIPTION
The hook_t data structure defines a callback that is to be inserted into a networking event. This data structure must be allocated with a call to hook_alloc() and released with a call to hook_free().
STRUCTURE MEMBERS
hook_func_t h_func; /* callback function to invoke */
char *h_name; /* unique name given to the hook */
int h_flags;
hook_hint_t h_hint; /* insertion hint type */
uintptr_t h_hintvalue; /* used with h_hint */
void *h_arg; /* value to pass into h_func */

typedef int (*hook_func_t)(net_event_t token, hook_data_t info,
 void *);
"CALLBACK RETURN VALUES"
The value returned by the hook_func_t function indicates whether or not the packet should still be considered valid. If the callback function has modified the packet in such a way that it should no longer be processed or considered valid, e.g. called freemsg(9F), then the callback should return 1. Otherwise it should return 0.
"HINT TYPES"
Hook hints are hints that are used at the time of insertion and are not rules that enforce where a hook lives for its entire lifetime on an event. The valid values for the h_hint field are: HH_NONE

Insert the hook wherever convenient.

HH_FIRST

Place the hook first on the list of hooks.

HH_LAST

Place the hook last on the list of hooks.

HH_BEFORE

Place the hook before another hook on the list of hooks. The value in h_hintvalue must be a pointer to the name of another hook.

HH_AFTER

Place the hook after another hook on the list of hooks. The value in h_hintvalue must be a pointer to the name of another hook.

ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Committed
SEE ALSO
netinfo(9F)