12958Sdr146992 /* 22958Sdr146992 * CDDL HEADER START 32958Sdr146992 * 42958Sdr146992 * The contents of this file are subject to the terms of the 52958Sdr146992 * Common Development and Distribution License (the "License"). 62958Sdr146992 * You may not use this file except in compliance with the License. 72958Sdr146992 * 82958Sdr146992 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 92958Sdr146992 * or http://www.opensolaris.org/os/licensing. 102958Sdr146992 * See the License for the specific language governing permissions 112958Sdr146992 * and limitations under the License. 122958Sdr146992 * 132958Sdr146992 * When distributing Covered Code, include this CDDL HEADER in each 142958Sdr146992 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 152958Sdr146992 * If applicable, add the following below this CDDL HEADER, with the 162958Sdr146992 * fields enclosed by brackets "[]" replaced with your own identifying 172958Sdr146992 * information: Portions Copyright [yyyy] [name of copyright owner] 182958Sdr146992 * 192958Sdr146992 * CDDL HEADER END 202958Sdr146992 */ 212958Sdr146992 /* 22*3448Sdh155122 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 232958Sdr146992 * Use is subject to license terms. 242958Sdr146992 */ 252958Sdr146992 262958Sdr146992 /* 272958Sdr146992 * This file includes definitions of kernel hook framework components 282958Sdr146992 */ 292958Sdr146992 302958Sdr146992 #ifndef _SYS_HOOK_H 312958Sdr146992 #define _SYS_HOOK_H 322958Sdr146992 332958Sdr146992 #pragma ident "%Z%%M% %I% %E% SMI" 342958Sdr146992 352958Sdr146992 #include <sys/queue.h> 36*3448Sdh155122 #include <sys/netstack.h> 372958Sdr146992 382958Sdr146992 #ifdef __cplusplus 392958Sdr146992 extern "C" { 402958Sdr146992 #endif 412958Sdr146992 422958Sdr146992 /* 432958Sdr146992 * Definition exposed to hook provider and consumer 442958Sdr146992 */ 452958Sdr146992 462958Sdr146992 #define HOOK_VERSION 1 472958Sdr146992 482958Sdr146992 typedef uintptr_t hook_data_t; 492958Sdr146992 502958Sdr146992 struct hook_event_int; 512958Sdr146992 typedef struct hook_event_int *hook_event_token_t; 522958Sdr146992 53*3448Sdh155122 typedef int (* hook_func_t)(hook_event_token_t, hook_data_t, netstack_t *); 542958Sdr146992 552958Sdr146992 /* 562958Sdr146992 * Hook 572958Sdr146992 */ 582958Sdr146992 typedef struct hook { 592958Sdr146992 int32_t h_version; /* version number */ 602958Sdr146992 hook_func_t h_func; /* callback func */ 612958Sdr146992 char *h_name; /* name of this hook */ 622958Sdr146992 int h_flags; /* extra hook properties */ 632958Sdr146992 } hook_t; 642958Sdr146992 652958Sdr146992 #define HOOK_INIT(x, fn, r) \ 662958Sdr146992 do { \ 672958Sdr146992 (x)->h_version = HOOK_VERSION; \ 682958Sdr146992 (x)->h_func = (fn); \ 692958Sdr146992 (x)->h_name = (r); \ 702958Sdr146992 (x)->h_flags = 0; \ 712958Sdr146992 _NOTE(CONSTCOND) \ 722958Sdr146992 } while (0) 732958Sdr146992 742958Sdr146992 /* 752958Sdr146992 * Family 762958Sdr146992 */ 772958Sdr146992 typedef struct hook_family { 782958Sdr146992 int32_t hf_version; /* version number */ 792958Sdr146992 char *hf_name; /* family name */ 802958Sdr146992 } hook_family_t; 812958Sdr146992 822958Sdr146992 #define HOOK_FAMILY_INIT(x, y) \ 832958Sdr146992 do { \ 842958Sdr146992 (x)->hf_version = HOOK_VERSION; \ 852958Sdr146992 (x)->hf_name = (y); \ 862958Sdr146992 _NOTE(CONSTCOND) \ 872958Sdr146992 } while (0) 882958Sdr146992 892958Sdr146992 /* 902958Sdr146992 * Event 912958Sdr146992 */ 922958Sdr146992 typedef struct hook_event { 932958Sdr146992 int32_t he_version; /* version number */ 942958Sdr146992 char *he_name; /* name of this hook list */ 952958Sdr146992 int he_flags; /* 1 = multiple entries allowed */ 962958Sdr146992 boolean_t he_interested; /* true if callback exist */ 972958Sdr146992 } hook_event_t; 982958Sdr146992 992958Sdr146992 #define HOOK_RDONLY 0x1 /* Callbacks must not change data */ 1002958Sdr146992 /* Multiple callbacks are allowed */ 1012958Sdr146992 1022958Sdr146992 #define HOOK_EVENT_INIT(x, y) \ 1032958Sdr146992 do { \ 1042958Sdr146992 (x)->he_version = HOOK_VERSION; \ 1052958Sdr146992 (x)->he_name = (y); \ 1062958Sdr146992 (x)->he_flags = 0; \ 1072958Sdr146992 (x)->he_interested = B_FALSE; \ 1082958Sdr146992 _NOTE(CONSTCOND) \ 1092958Sdr146992 } while (0) 1102958Sdr146992 1112958Sdr146992 #ifdef __cplusplus 1122958Sdr146992 } 1132958Sdr146992 #endif 1142958Sdr146992 1152958Sdr146992 #endif /* _SYS_HOOK_H */ 116