xref: /illumos-gate/usr/src/uts/common/ipp/ipp.h (revision d48be21240dfd051b689384ce2b23479d757f2d8)
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 /*
31  * IP Policy Framework (IPPF)
32  */
33 
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <sys/nvpair.h>
37 #include <sys/stream.h>
38 #include <sys/kstat.h>
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 #ifdef	_KERNEL
45 
46 typedef struct ipp_mod		ipp_mod_t;
47 typedef int32_t			ipp_mod_id_t;
48 
49 #define	IPP_MOD_RESERVED	0	/* Upper limit of reserved values */
50 #define	IPP_MOD_INVAL		-1
51 
52 typedef	struct ipp_action	ipp_action_t;
53 typedef	int32_t			ipp_action_id_t;
54 
55 #define	IPP_ACTION_RESERVED	0	/* Upper limit of reserved values */
56 #define	IPP_ACTION_INVAL	-1
57 #define	IPP_ACTION_CONT		-2
58 #define	IPP_ACTION_DEFER	-3
59 #define	IPP_ACTION_DROP		-4
60 
61 #endif	/* _KERNEL */
62 
63 #define	IPP_ANAME_CONT		"ipp.continue"
64 #define	IPP_ANAME_DEFER		"ipp.defer"
65 #define	IPP_ANAME_DROP		"ipp.drop"
66 
67 typedef enum ipp_flags {
68 	IPP_DESTROY_REF = 0x00000001
69 } ipp_flags_t;
70 
71 #ifdef	_KERNEL
72 
73 typedef struct ipp_stat		ipp_stat_t;
74 
75 /*
76  * NOTE: Semi-opaque alias for struct ipp_stat_impl in common/ipp/ipp_impl.h
77  */
78 struct ipp_stat {
79 	void	*ipps_data;
80 };
81 
82 #define	IPP_STAT_TAG		0x80
83 
84 #define	IPP_STAT_INT32		(IPP_STAT_TAG | KSTAT_DATA_INT32)
85 #define	IPP_STAT_UINT32		(IPP_STAT_TAG | KSTAT_DATA_UINT32)
86 #define	IPP_STAT_INT64		(IPP_STAT_TAG | KSTAT_DATA_INT64)
87 #define	IPP_STAT_UINT64		(IPP_STAT_TAG | KSTAT_DATA_UINT64)
88 #define	IPP_STAT_STRING		(IPP_STAT_TAG | KSTAT_DATA_CHAR)
89 
90 #define	IPP_STAT_READ		KSTAT_READ
91 #define	IPP_STAT_WRITE		KSTAT_WRITE
92 
93 typedef kstat_named_t		ipp_named_t;
94 
95 typedef	struct ipp_class	ipp_class_t;
96 typedef	struct ipp_log		ipp_log_t;
97 
98 typedef struct ipp_packet	ipp_packet_t;
99 
100 #define	IPPO_REV_1	1
101 #define	IPPO_REV	IPPO_REV_1	/* interface version */
102 
103 typedef struct ipp_ops	ipp_ops_t;
104 
105 struct ipp_ops {
106 	int	ippo_rev;
107 	int	(*ippo_action_create)(ipp_action_id_t, nvlist_t **,
108 	    ipp_flags_t);
109 	int	(*ippo_action_modify)(ipp_action_id_t, nvlist_t **,
110 	    ipp_flags_t);
111 	int	(*ippo_action_destroy)(ipp_action_id_t, ipp_flags_t);
112 	int	(*ippo_action_info)(ipp_action_id_t, int (*)(nvlist_t *,
113 	    void *), void *, ipp_flags_t);
114 	int	(*ippo_action_invoke)(ipp_action_id_t, ipp_packet_t *);
115 };
116 
117 /*
118  * IPPF client interface
119  */
120 
121 extern int		ipp_list_mods(ipp_mod_id_t **, int *);
122 
123 extern ipp_mod_id_t	ipp_mod_lookup(const char *);
124 extern int		ipp_mod_name(ipp_mod_id_t, char **);
125 extern int		ipp_mod_register(const char *, ipp_ops_t *);
126 extern int		ipp_mod_unregister(ipp_mod_id_t);
127 extern int		ipp_mod_list_actions(ipp_mod_id_t, ipp_action_id_t **,
128     int *);
129 
130 extern ipp_action_id_t	ipp_action_lookup(const char *);
131 extern int		ipp_action_name(ipp_action_id_t, char **);
132 extern int		ipp_action_mod(ipp_action_id_t, ipp_mod_id_t *);
133 extern int		ipp_action_create(ipp_mod_id_t, const char *,
134     nvlist_t **, ipp_flags_t, ipp_action_id_t *);
135 extern int		ipp_action_modify(ipp_action_id_t, nvlist_t **,
136     ipp_flags_t);
137 extern int		ipp_action_destroy(ipp_action_id_t, ipp_flags_t);
138 extern int		ipp_action_info(ipp_action_id_t, int (*)(nvlist_t *,
139     void *), void *, ipp_flags_t);
140 extern void		ipp_action_set_ptr(ipp_action_id_t, void *);
141 extern void		*ipp_action_get_ptr(ipp_action_id_t);
142 extern int		ipp_action_ref(ipp_action_id_t,	ipp_action_id_t,
143     ipp_flags_t);
144 extern int		ipp_action_unref(ipp_action_id_t, ipp_action_id_t,
145     ipp_flags_t);
146 
147 extern int		ipp_packet_alloc(ipp_packet_t **, const char *,
148     ipp_action_id_t);
149 extern void		ipp_packet_free(ipp_packet_t *);
150 extern int		ipp_packet_add_class(ipp_packet_t *, const char *,
151     ipp_action_id_t);
152 extern int		ipp_packet_process(ipp_packet_t **);
153 extern int		ipp_packet_next(ipp_packet_t *, ipp_action_id_t);
154 extern void		ipp_packet_set_data(ipp_packet_t *, mblk_t *);
155 extern mblk_t		*ipp_packet_get_data(ipp_packet_t *);
156 extern void		ipp_packet_set_private(ipp_packet_t *, void *,
157     void (*)(void *));
158 extern void		*ipp_packet_get_private(ipp_packet_t *);
159 
160 extern int		ipp_stat_create(ipp_action_id_t, const char *, int,
161     int (*)(ipp_stat_t *, void *, int), void *, ipp_stat_t **);
162 extern void		ipp_stat_install(ipp_stat_t *);
163 extern void		ipp_stat_destroy(ipp_stat_t *);
164 extern int		ipp_stat_named_init(ipp_stat_t *, const char *,
165     uchar_t, ipp_named_t *);
166 extern int		ipp_stat_named_op(ipp_named_t *, void *, int);
167 
168 #endif	/* _KERNEL */
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 
174 #endif /* _IPP_IPP_H */
175