summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/hook_impl.h
diff options
context:
space:
mode:
authordr146992 <none@none>2006-10-20 16:37:58 -0700
committerdr146992 <none@none>2006-10-20 16:37:58 -0700
commit381a2a9a387f449fab7d0c7e97c4184c26963abf (patch)
tree9beb8c59e549aba6f888d2adc733dae7e248d9e2 /usr/src/uts/common/sys/hook_impl.h
parentf273041ff6419d6156c10c02bb1a527bfcfdc457 (diff)
downloadillumos-gate-381a2a9a387f449fab7d0c7e97c4184c26963abf.tar.gz
PSARC/2005/334 Packet Filtering Hooks
PSARC/2006/321 ARP packet filtering Hooks 6401219 use of pullupmsg() considered destructive - clears h/w checksum flags 6418698 PSARC/2005/334 - Packet Filtering Hooks API 6449290 package prototype files in usr/src/pkgdefs/SUNWipfr missing CDDL 6449292 package prototype files in usr/src/pkgdefs/SUNWipfu missing CDDL 6449296 Makefiles for ipf kernel module building missing CDDL 6473996 "fastroute" + "nat" packets cause memory leaks in ipfilter --HG-- rename : usr/src/cmd/ipf/etc/pfil.ap.sh => deleted_files/usr/src/cmd/ipf/etc/pfil.ap.sh rename : usr/src/cmd/ipf/pfild/Makefile => deleted_files/usr/src/cmd/ipf/pfild/Makefile rename : usr/src/cmd/ipf/pfild/pfild.c => deleted_files/usr/src/cmd/ipf/pfild/pfild.c rename : usr/src/cmd/ipf/pfild/vas.c => deleted_files/usr/src/cmd/ipf/pfild/vas.c rename : usr/src/cmd/ipf/svc/pfil => deleted_files/usr/src/cmd/ipf/svc/pfil rename : usr/src/cmd/ipf/svc/pfil.xml => deleted_files/usr/src/cmd/ipf/svc/pfil.xml rename : usr/src/uts/common/inet/pfil/compat.h => deleted_files/usr/src/uts/common/inet/pfil/compat.h rename : usr/src/uts/common/inet/pfil/ndd.c => deleted_files/usr/src/uts/common/inet/pfil/ndd.c rename : usr/src/uts/common/inet/pfil/os.h => deleted_files/usr/src/uts/common/inet/pfil/os.h rename : usr/src/uts/common/inet/pfil/pfil.c => deleted_files/usr/src/uts/common/inet/pfil/pfil.c rename : usr/src/uts/common/inet/pfil/pfil.conf => deleted_files/usr/src/uts/common/inet/pfil/pfil.conf rename : usr/src/uts/common/inet/pfil/pfil.h => deleted_files/usr/src/uts/common/inet/pfil/pfil.h rename : usr/src/uts/common/inet/pfil/pfild.h => deleted_files/usr/src/uts/common/inet/pfil/pfild.h rename : usr/src/uts/common/inet/pfil/pfildrv.c => deleted_files/usr/src/uts/common/inet/pfil/pfildrv.c rename : usr/src/uts/common/inet/pfil/pfilstream.c => deleted_files/usr/src/uts/common/inet/pfil/pfilstream.c rename : usr/src/uts/common/inet/pfil/pkt.c => deleted_files/usr/src/uts/common/inet/pfil/pkt.c rename : usr/src/uts/common/inet/pfil/qif.c => deleted_files/usr/src/uts/common/inet/pfil/qif.c rename : usr/src/uts/common/inet/pfil/qif.h => deleted_files/usr/src/uts/common/inet/pfil/qif.h rename : usr/src/uts/intel/pfil/Makefile => deleted_files/usr/src/uts/intel/pfil/Makefile rename : usr/src/uts/sparc/pfil/Makefile => deleted_files/usr/src/uts/sparc/pfil/Makefile rename : usr/src/uts/common/inet/pfil/misc.c => usr/src/uts/common/inet/ipf/misc.c
Diffstat (limited to 'usr/src/uts/common/sys/hook_impl.h')
-rw-r--r--usr/src/uts/common/sys/hook_impl.h136
1 files changed, 136 insertions, 0 deletions
diff --git a/usr/src/uts/common/sys/hook_impl.h b/usr/src/uts/common/sys/hook_impl.h
new file mode 100644
index 0000000000..d8e169b2ae
--- /dev/null
+++ b/usr/src/uts/common/sys/hook_impl.h
@@ -0,0 +1,136 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * This file include internal used definition and data structure of hooks
+ */
+
+#ifndef _SYS_HOOK_IMPL_H
+#define _SYS_HOOK_IMPL_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/hook.h>
+#include <sys/condvar_impl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * The following diagram describes the linking together of data structures
+ * used in this implementation of callback hooks. The start of it all is
+ * the "familylist" variable in hook.c. The relationships between data
+ * structures is:
+ * - there is a list of hook families;
+ * - each hook family can have a list of hook events;
+ * - each hook_event_t must be uniquely associated with one family and event;
+ * - each hook event can have a list of registered hooks to call.
+ *
+ * familylist +--------------+
+ * | | hook_event_t |<--\
+ * | +--------------+ |
+ * V |
+ * +-------------------+ ->+------------------+ | ->+--------------+
+ * | hook_family_int_t | / | hook_event_int_t | | / | hook_int_t |
+ * | +---------------+ | / | | / / | +----------+ |
+ * | | hook_family_t | | / | hei_event---------/ / | | hook_t | |
+ * | +---------------+ | / | | / | +----------+ |
+ * | | / | | / | |
+ * | hfi_head------------/ | hei_head-----------/ | hi_entry--\ |
+ * | hfi_entry--\ | | hei_entry--\ | +-----------|--+
+ * +------------|------+ +------------|-----+ |
+ * | | |
+ * V V V
+ * +-------------------+ +------------------+ +--------------+
+ * | hook_family_int_t | | hook_event_int_t | | hook_int_t |
+ * ...
+ */
+
+/*
+ * hook_int: internal storage of hook
+ */
+typedef struct hook_int {
+ TAILQ_ENTRY(hook_int) hi_entry;
+ hook_t hi_hook;
+} hook_int_t;
+
+/*
+ * Hook_int_head: tail queue of hook_int
+ */
+TAILQ_HEAD(hook_int_head, hook_int);
+typedef struct hook_int_head hook_int_head_t;
+
+/*
+ * hook_event_int: internal storage of hook_event
+ */
+typedef struct hook_event_int {
+ cvwaitlock_t hei_lock;
+ SLIST_ENTRY(hook_event_int) hei_entry;
+ hook_event_t *hei_event;
+ hook_int_head_t hei_head;
+} hook_event_int_t;
+
+/*
+ * hook_event_int_head: singly-linked list of hook_event_int
+ */
+SLIST_HEAD(hook_event_int_head, hook_event_int);
+typedef struct hook_event_int_head hook_event_int_head_t;
+
+/*
+ * hook_family_int: internal storage of hook_family
+ */
+typedef struct hook_family_int {
+ SLIST_ENTRY(hook_family_int) hfi_entry;
+ hook_event_int_head_t hfi_head;
+ hook_family_t hfi_family;
+} hook_family_int_t;
+
+/*
+ * hook_family_int_head: singly-linked list of hook_family
+ */
+SLIST_HEAD(hook_family_int_head, hook_family_int);
+typedef struct hook_family_int_head hook_family_int_head_t;
+
+/*
+ * Names of hooks families currently defined by Solaris
+ */
+#define Hn_ARP "arp"
+#define Hn_IPV4 "inet"
+#define Hn_IPV6 "inet6"
+
+extern hook_family_int_t *hook_family_add(hook_family_t *);
+extern int hook_family_remove(hook_family_int_t *);
+extern hook_event_int_t *hook_event_add(hook_family_int_t *, hook_event_t *);
+extern int hook_event_remove(hook_family_int_t *, hook_event_t *);
+extern int hook_register(hook_family_int_t *, char *, hook_t *);
+extern int hook_unregister(hook_family_int_t *, char *, hook_t *);
+extern int hook_run(hook_event_token_t, hook_data_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_HOOK_IMPL_H */