xref: /titanic_41/usr/src/uts/common/ipp/ipp.h (revision 6185db853e024a486ff8837e6784dd290d866112)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2001-2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_IPP_IPP_H
28 #define	_IPP_IPP_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * IP Policy Framework (IPPF)
34  */
35 
36 #include <sys/types.h>
37 #include <sys/param.h>
38 #include <sys/nvpair.h>
39 #include <sys/stream.h>
40 #include <sys/kstat.h>
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 #ifdef	_KERNEL
47 
48 typedef struct ipp_mod		ipp_mod_t;
49 typedef int32_t			ipp_mod_id_t;
50 
51 #define	IPP_MOD_RESERVED	0	/* Upper limit of reserved values */
52 #define	IPP_MOD_INVAL		-1
53 
54 typedef	struct ipp_action	ipp_action_t;
55 typedef	int32_t			ipp_action_id_t;
56 
57 #define	IPP_ACTION_RESERVED	0	/* Upper limit of reserved values */
58 #define	IPP_ACTION_INVAL	-1
59 #define	IPP_ACTION_CONT		-2
60 #define	IPP_ACTION_DEFER	-3
61 #define	IPP_ACTION_DROP		-4
62 
63 #endif	/* _KERNEL */
64 
65 #define	IPP_ANAME_CONT		"ipp.continue"
66 #define	IPP_ANAME_DEFER		"ipp.defer"
67 #define	IPP_ANAME_DROP		"ipp.drop"
68 
69 typedef enum ipp_flags {
70 	IPP_DESTROY_REF = 0x00000001
71 } ipp_flags_t;
72 
73 #ifdef	_KERNEL
74 
75 typedef struct ipp_stat		ipp_stat_t;
76 
77 /*
78  * NOTE: Semi-opaque alias for struct ipp_stat_impl in common/ipp/ipp_impl.h
79  */
80 struct ipp_stat {
81 	void	*ipps_data;
82 };
83 
84 #define	IPP_STAT_TAG		0x80
85 
86 #define	IPP_STAT_INT32		(IPP_STAT_TAG | KSTAT_DATA_INT32)
87 #define	IPP_STAT_UINT32		(IPP_STAT_TAG | KSTAT_DATA_UINT32)
88 #define	IPP_STAT_INT64		(IPP_STAT_TAG | KSTAT_DATA_INT64)
89 #define	IPP_STAT_UINT64		(IPP_STAT_TAG | KSTAT_DATA_UINT64)
90 #define	IPP_STAT_STRING		(IPP_STAT_TAG | KSTAT_DATA_CHAR)
91 
92 #define	IPP_STAT_READ		KSTAT_READ
93 #define	IPP_STAT_WRITE		KSTAT_WRITE
94 
95 typedef kstat_named_t		ipp_named_t;
96 
97 typedef	struct ipp_class	ipp_class_t;
98 typedef	struct ipp_log		ipp_log_t;
99 
100 typedef struct ipp_packet	ipp_packet_t;
101 
102 #define	IPPO_REV_1	1
103 #define	IPPO_REV	IPPO_REV_1	/* interface version */
104 
105 typedef struct ipp_ops	ipp_ops_t;
106 
107 struct ipp_ops {
108 	int	ippo_rev;
109 	int	(*ippo_action_create)(ipp_action_id_t, nvlist_t **,
110 	    ipp_flags_t);
111 	int	(*ippo_action_modify)(ipp_action_id_t, nvlist_t **,
112 	    ipp_flags_t);
113 	int	(*ippo_action_destroy)(ipp_action_id_t, ipp_flags_t);
114 	int	(*ippo_action_info)(ipp_action_id_t, int (*)(nvlist_t *,
115 	    void *), void *, ipp_flags_t);
116 	int	(*ippo_action_invoke)(ipp_action_id_t, ipp_packet_t *);
117 };
118 
119 /*
120  * IPPF client interface
121  */
122 
123 extern int		ipp_list_mods(ipp_mod_id_t **, int *);
124 
125 extern ipp_mod_id_t	ipp_mod_lookup(const char *);
126 extern int		ipp_mod_name(ipp_mod_id_t, char **);
127 extern int		ipp_mod_register(const char *, ipp_ops_t *);
128 extern int		ipp_mod_unregister(ipp_mod_id_t);
129 extern int		ipp_mod_list_actions(ipp_mod_id_t, ipp_action_id_t **,
130     int *);
131 
132 extern ipp_action_id_t	ipp_action_lookup(const char *);
133 extern int		ipp_action_name(ipp_action_id_t, char **);
134 extern int		ipp_action_mod(ipp_action_id_t, ipp_mod_id_t *);
135 extern int		ipp_action_create(ipp_mod_id_t, const char *,
136     nvlist_t **, ipp_flags_t, ipp_action_id_t *);
137 extern int		ipp_action_modify(ipp_action_id_t, nvlist_t **,
138     ipp_flags_t);
139 extern int		ipp_action_destroy(ipp_action_id_t, ipp_flags_t);
140 extern int		ipp_action_info(ipp_action_id_t, int (*)(nvlist_t *,
141     void *), void *, ipp_flags_t);
142 extern void		ipp_action_set_ptr(ipp_action_id_t, void *);
143 extern void		*ipp_action_get_ptr(ipp_action_id_t);
144 extern int		ipp_action_ref(ipp_action_id_t,	ipp_action_id_t,
145     ipp_flags_t);
146 extern int		ipp_action_unref(ipp_action_id_t, ipp_action_id_t,
147     ipp_flags_t);
148 
149 extern int		ipp_packet_alloc(ipp_packet_t **, const char *,
150     ipp_action_id_t);
151 extern void		ipp_packet_free(ipp_packet_t *);
152 extern int		ipp_packet_add_class(ipp_packet_t *, const char *,
153     ipp_action_id_t);
154 extern int		ipp_packet_process(ipp_packet_t **);
155 extern int		ipp_packet_next(ipp_packet_t *, ipp_action_id_t);
156 extern void		ipp_packet_set_data(ipp_packet_t *, mblk_t *);
157 extern mblk_t		*ipp_packet_get_data(ipp_packet_t *);
158 extern void		ipp_packet_set_private(ipp_packet_t *, void *,
159     void (*)(void *));
160 extern void		*ipp_packet_get_private(ipp_packet_t *);
161 
162 extern int		ipp_stat_create(ipp_action_id_t, const char *, int,
163     int (*)(ipp_stat_t *, void *, int), void *, ipp_stat_t **);
164 extern void		ipp_stat_install(ipp_stat_t *);
165 extern void		ipp_stat_destroy(ipp_stat_t *);
166 extern int		ipp_stat_named_init(ipp_stat_t *, const char *,
167     uchar_t, ipp_named_t *);
168 extern int		ipp_stat_named_op(ipp_named_t *, void *, int);
169 
170 #endif	/* _KERNEL */
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 #endif /* _IPP_IPP_H */
177