4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * This file includes definitions of kernel hook framework components
33 #include <sys/queue.h>
34 #include <sys/netstack.h>
41 * Definition exposed to hook provider and consumer
44 #define HOOK_VERSION 1
46 typedef uintptr_t hook_data_t
;
48 struct hook_event_int
;
49 typedef struct hook_event_int
*hook_event_token_t
;
51 typedef struct hook_int
*hook_token_t
;
53 typedef int (* hook_func_t
)(hook_event_token_t
, hook_data_t
, void *);
56 * A hook_notify_cmd_t is given as an argument to functions called as part of
57 * the notify callbacks that have been registered firing.
59 typedef enum hook_notify_cmd_e
{
68 typedef enum hook_hint_e
{
79 typedef struct hook_s
{
81 hook_func_t h_func
; /* callback func */
82 char *h_name
; /* name of this hook */
83 uint_t h_flags
; /* extra hook properties */
84 hook_hint_t h_hint
; /* What type of hint is hintvalue */
85 uintptr_t h_hintvalue
;
86 void *h_arg
; /* value to pass back into the hook */
89 #define HOOK_INIT(x, fn, r, a) \
91 (x) = hook_alloc(HOOK_VERSION); \
95 (x)->h_hint = HH_NONE; \
96 (x)->h_hintvalue = 0; \
104 typedef struct hook_family_s
{
105 int hf_version
; /* version number */
106 char *hf_name
; /* family name */
109 #define HOOK_FAMILY_INIT(x, y) \
111 (x)->hf_version = HOOK_VERSION; \
112 (x)->hf_name = (y); \
119 typedef struct hook_event_s
{
121 char *he_name
; /* name of this hook list */
122 int he_flags
; /* 1 = multiple entries allowed */
123 boolean_t he_interested
; /* true if callback exist */
126 #define HOOK_RDONLY 0x1 /* Callbacks must not change data */
127 /* Multiple callbacks are allowed */
129 #define HOOK_EVENT_INIT(x, y) \
131 (x)->he_version = HOOK_VERSION; \
132 (x)->he_name = (y); \
134 (x)->he_interested = B_FALSE; \
138 typedef int (* hook_notify_fn_t
)(hook_notify_cmd_t
, void *, const char *,
139 const char *, const char *);
141 extern hook_t
*hook_alloc(const int version
);
142 extern void hook_free(hook_t
*);
148 #endif /* _SYS_HOOK_H */